Skip to content

Commit

Permalink
Release 1.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Gematik-Entwicklung committed Jun 28, 2023
1 parent af2ac5f commit 23971a4
Show file tree
Hide file tree
Showing 99 changed files with 21,427 additions and 1,338 deletions.
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Release 1.12.1
- Redeem prescriptions directly without being authenticated with TI
- Bugfixes (lots)

# Release 1.11.0-RC5
- Direct redemption of prescription without TI
- Bugfixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ fun DebugScreenMain(
.weight(1f)
)
Switch(
modifier = Modifier.testTag(TestTag.DebugMenu.FakeNFCCapabilities),
checked = viewModel.debugSettingsData.fakeNFCCapabilities,
onCheckedChange = { viewModel.allowNfc(it) }
)
Expand Down
47 changes: 15 additions & 32 deletions android/src/main/java/de/gematik/ti/erp/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.core.content.edit
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.lifecycle.lifecycleScope
Expand All @@ -71,11 +70,9 @@ import de.gematik.ti.erp.app.cardwall.mini.ui.rememberAuthenticator
import de.gematik.ti.erp.app.core.IntentHandler
import de.gematik.ti.erp.app.core.LocalAnalytics
import de.gematik.ti.erp.app.core.LocalIntentHandler
import de.gematik.ti.erp.app.mainscreen.ui.rememberMainScreenController
import de.gematik.ti.erp.app.prescription.detail.ui.SharePrescriptionHandler
import de.gematik.ti.erp.app.profiles.ui.LocalProfileHandler
import de.gematik.ti.erp.app.profiles.ui.rememberProfileHandler
import de.gematik.ti.erp.app.profiles.ui.rememberProfilesController
import de.gematik.ti.erp.app.userauthentication.ui.AuthenticationModeAndMethod
import de.gematik.ti.erp.app.userauthentication.ui.AuthenticationUseCase
import de.gematik.ti.erp.app.userauthentication.ui.UserAuthenticationScreen
Expand Down Expand Up @@ -120,6 +117,18 @@ class MainActivity : AppCompatActivity(), DIAware {

private val appPrefs: SharedPreferences by instance(ApplicationPreferencesTag)

private val appPrefsListener: SharedPreferences.OnSharedPreferenceChangeListener =
SharedPreferences.OnSharedPreferenceChangeListener { sharedPrefs, key ->
if (key == ScreenshotsAllowed) {
// `gemSpec_eRp_FdV A_20203` default settings are not allow screenshots
if (sharedPrefs.getBoolean(ScreenshotsAllowed, false)) {
this.window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
} else {
this.window?.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
}
}
}

private val intentHandler = IntentHandler(this)

private val _nfcTag = MutableSharedFlow<Tag>()
Expand Down Expand Up @@ -163,18 +172,7 @@ class MainActivity : AppCompatActivity(), DIAware {
installMessageConversionExceptionHandler()
}

if (BuildKonfig.INTERNAL) {
appPrefs.edit {
putBoolean(ScreenshotsAllowed, true)
}
}

switchScreenshotMode()
appPrefs.registerOnSharedPreferenceChangeListener { _, key ->
if (key == ScreenshotsAllowed) {
switchScreenshotMode()
}
}
appPrefs.registerOnSharedPreferenceChangeListener(appPrefsListener)

WindowCompat.setDecorFitsSystemWindows(window, false)

Expand All @@ -193,7 +191,7 @@ class MainActivity : AppCompatActivity(), DIAware {
) {
val authenticator = LocalAuthenticator.current

MainContent { settingsController ->
MainContent { settingscontroller ->
val auth by produceState<AuthenticationModeAndMethod?>(null) {
launch {
authenticationModeAndMethod.distinctUntilChangedBy { it::class }
Expand Down Expand Up @@ -236,17 +234,11 @@ class MainActivity : AppCompatActivity(), DIAware {
authenticator = authenticator.authenticatorSecureElement
)

val mainScreenController = rememberMainScreenController()
val profilesController = rememberProfilesController()

CompositionLocalProvider(
LocalProfileHandler provides rememberProfileHandler()
) {
MainScreen(
navController = navController,
settingsController = settingsController,
mainScreenController = mainScreenController,
profilesController = profilesController
navController = navController
)

SharePrescriptionHandler(authenticationModeAndMethod)
Expand Down Expand Up @@ -340,13 +332,4 @@ class MainActivity : AppCompatActivity(), DIAware {

NfcAdapter.getDefaultAdapter(applicationContext)?.disableReaderMode(this)
}

private fun switchScreenshotMode() {
// `gemSpec_eRp_FdV A_20203` default settings are not allow screenshots
if (appPrefs.getBoolean(ScreenshotsAllowed, false)) {
this.window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
} else {
this.window?.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
}
}
}
10 changes: 10 additions & 0 deletions android/src/main/java/de/gematik/ti/erp/app/TestTags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ object TestTag {
}

object DebugMenu {
val FakeNFCCapabilities by tagName()
val DebugMenuScreen by tagName()
val DebugMenuContent by tagName()
val CertificateField by tagName()
Expand Down Expand Up @@ -408,12 +409,21 @@ object TestTag {
val LoginScreen by tagName()
}

object Intro {
val IntroScreen by tagName()
val OrderEgkButton by tagName()
}

object CAN {
val CANScreen by tagName()
val CANField by tagName()
val OrderEgkButton by tagName()
}

object PIN {
val PinScreen by tagName()
val PINField by tagName()
val OrderEgkButton by tagName()
}

object StoreCredentials {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.systemBarsPadding
import de.gematik.ti.erp.app.R
import de.gematik.ti.erp.app.core.IntentHandler
import de.gematik.ti.erp.app.mainscreen.ui.ExternalAuthenticationDialog
import de.gematik.ti.erp.app.profiles.repository.ProfileIdentifier
import de.gematik.ti.erp.app.profiles.usecase.model.ProfilesUseCaseData
import de.gematik.ti.erp.app.theme.AppTheme
Expand All @@ -60,12 +61,10 @@ import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
import java.net.URI

@Stable
class ExternalPromptAuthenticator(
Expand Down Expand Up @@ -110,7 +109,7 @@ class ExternalPromptAuthenticator(
}

is Request.InsuranceSelected -> {
Napier.d("doExternalAuthentication for $authFor")
Napier.d("Fasttrack: doExternalAuthentication for $authFor")

bridge.doExternalAuthentication(
profileId = profileId,
Expand All @@ -126,23 +125,7 @@ class ExternalPromptAuthenticator(
cancel()
}

Napier.d("wait for instant of $authFor")

val uri = intentHandler.extAuthIntent.first()

Napier.d("doExternalAuthorization for $uri")

bridge.doExternalAuthorization(URI(uri))
.onSuccess {
send(PromptAuthenticator.AuthResult.Authenticated)
cancel()
}
.onFailure {
Napier.e("doExternalAuthorization failed", it)
// TODO error handling
send(PromptAuthenticator.AuthResult.Cancelled)
cancel()
}
Napier.d("Fasttrack: wait for instant of $authFor")
}
}
}
Expand Down Expand Up @@ -238,6 +221,7 @@ fun ExternalAuthPrompt(
}
}
}
ExternalAuthenticationDialog()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fun CardAccessNumber(
val lazyListState = rememberLazyListState()

CardHandlingScaffold(
modifier = Modifier.testTag("cardWall/cardAccessNumber"),
modifier = Modifier.testTag(TestTag.CardWall.CAN.CANScreen),
backMode = NavigationBarMode.Back,
title = screenTitle,
nextEnabled = can.length == EXPECTED_CAN_LENGTH,
Expand Down Expand Up @@ -154,6 +154,7 @@ fun CanDescription(onClickLearnMore: () -> Unit) {
onClick = { onClickLearnMore() },
style = AppTheme.typography.body2,
modifier = Modifier.align(Alignment.End)
.testTag(TestTag.CardWall.CAN.OrderEgkButton)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fun CardWallIntroScaffold(
val scrollState = rememberScrollState()

AnimatedElevationScaffold(
modifier = Modifier.testTag(TestTag.CardWall.Login.LoginScreen)
modifier = Modifier.testTag(TestTag.CardWall.Intro.IntroScreen)
.systemBarsPadding(),
topBarTitle = "",
elevated = scrollState.value > 0,
Expand Down Expand Up @@ -227,7 +227,7 @@ fun AddCardContent(
HintTextActionButton(
text = stringResource(R.string.cdw_intro_order_now),
align = Alignment.End,
modifier = Modifier.align(Alignment.End)
modifier = Modifier.align(Alignment.End).testTag(TestTag.CardWall.Intro.OrderEgkButton)
) {
onClickOrderNow()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fun CardWallSecretScreen(
) {
val lazyListState = rememberLazyListState()
CardHandlingScaffold(
modifier = Modifier.testTag("cardWall/secretScreen"),
modifier = Modifier.testTag(TestTag.CardWall.PIN.PinScreen),
backMode = when (navMode) {
NavigationMode.Forward,
NavigationMode.Back,
Expand Down Expand Up @@ -130,6 +130,7 @@ fun CardWallSecretScreen(
}
item {
ClickableTaggedText(
modifier = Modifier.testTag(TestTag.CardWall.PIN.OrderEgkButton),
text = annotatedLinkStringLight(
uri = "",
text = stringResource(R.string.cdw_no_pin_received)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ val networkModule = DI.Module("Network Module") {
.addInterceptor(loggingInterceptor)

if (BuildKonfig.INTERNAL) {
clientBuilder.addInterceptor(PharmacyRedeemInterceptor(instance()))
clientBuilder.addInterceptor(PharmacyRedeemInterceptor())
}

Retrofit.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import kotlinx.coroutines.flow.map
private val Context.dataStore by preferencesDataStore("featureToggles")

enum class Features(val featureName: String) {
REDEEM_WITHOUT_TI("RedeemWithoutTI"),
// REDEEM_WITHOUT_TI("RedeemWithoutTI"),
}

class FeatureToggleManager(val context: Context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class PharmacySearchInterceptor(private val endpointHelper: EndpointHelper) : In
}
}

class PharmacyRedeemInterceptor(private val endpointHelper: EndpointHelper) : Interceptor {
class PharmacyRedeemInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val original: Request = chain.request()
val request: Request = original.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.runtime.remember
import androidx.compose.ui.res.stringResource
import de.gematik.ti.erp.app.R
import de.gematik.ti.erp.app.core.LocalAuthenticator
import de.gematik.ti.erp.app.core.LocalIntentHandler
import de.gematik.ti.erp.app.idp.usecase.IdpUseCase
import de.gematik.ti.erp.app.utils.compose.AcceptDialog
Expand Down Expand Up @@ -61,15 +60,13 @@ class FastTrackHandler(
@Composable
fun ExternalAuthenticationDialog() {
var showAuthenticationError by remember { mutableStateOf(false) }

val intentHandler = LocalIntentHandler.current
val authenticator = LocalAuthenticator.current
val idpUseCase = rememberInstance<IdpUseCase>()
val fastTrackHandler = remember { FastTrackHandler(idpUseCase) }

LaunchedEffect(Unit) {
intentHandler.extAuthIntent.collect {
if (!authenticator.authenticatorExternal.isInProgress && !fastTrackHandler.handle(it)) {
if (!fastTrackHandler.handle(it)) {
showAuthenticationError = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import de.gematik.ti.erp.app.R
import de.gematik.ti.erp.app.settings.ui.SettingsController
import de.gematik.ti.erp.app.settings.ui.rememberSettingsController
import de.gematik.ti.erp.app.theme.AppTheme
import de.gematik.ti.erp.app.theme.PaddingDefaults
import de.gematik.ti.erp.app.utils.compose.AnimatedElevationScaffold
Expand All @@ -70,19 +69,20 @@ import java.util.Locale

@Composable
fun InsecureDeviceScreen(
navController: NavController,
settingsController: SettingsController,
headline: String,
icon: Painter,
headlineBody: String,
infoText: String,
toggleDescription: String,
pinUseCase: Boolean = true
pinUseCase: Boolean = true,
onBack: () -> Unit
) {
var checked by rememberSaveable { mutableStateOf(false) }
val scrollState = rememberScrollState()
val scope = rememberCoroutineScope()

val settingsController = rememberSettingsController()

AnimatedElevationScaffold(
elevated = scrollState.value > 0,
navigationMode = NavigationBarMode.Close,
Expand All @@ -91,12 +91,12 @@ fun InsecureDeviceScreen(
Spacer(modifier = Modifier.weight(1f))
Button(
onClick = {
if (checked && pinUseCase) {
if (checked) {
scope.launch {
settingsController.onAcceptInsecureDevice()
}
}
navController.popBackStack()
onBack()
},
shape = RoundedCornerShape(PaddingDefaults.Small),
enabled = if (pinUseCase) true else checked
Expand All @@ -112,7 +112,7 @@ fun InsecureDeviceScreen(
},
actions = {},
topBarTitle = headline,
onBack = { navController.popBackStack() }
onBack = onBack
) { innerPadding ->
Column(
modifier = Modifier
Expand Down
Loading

0 comments on commit 23971a4

Please sign in to comment.