Skip to content

Commit

Permalink
- Small refactorings
Browse files Browse the repository at this point in the history
- Bugfixes
  • Loading branch information
Gematik-Entwicklung committed Feb 27, 2023
1 parent 87ff7e6 commit 281e0f0
Show file tree
Hide file tree
Showing 129 changed files with 4,339 additions and 2,229 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.9.0
- Small refactorings
- Bugfixes

# Release 1.8.0
- Switched to new analytics tool
- Bugfixes
Expand Down
8 changes: 4 additions & 4 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ android {
pickFirsts += "win32-x86/attach_hotspot_windows.dll"
}
}

composeOptions {
kotlinCompilerExtensionVersion = "1.3.0"
}
}

compose.android.useAndroidX = true
Expand All @@ -201,6 +197,10 @@ dependencies {
implementation(kotlin("reflect"))
testImplementation(kotlin("test"))

implementation("com.tom-roush:pdfbox-android:2.0.27.0") {
exclude(group = "org.bouncycastle")
}

app {
dataMatrix {
implementation(mlkitBarcodeScanner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ data class DebugSettingsData(
) : Parcelable

enum class Environment {
PU, TU, RU, TR
PU, TU, RU, RUDEV, TR
}
99 changes: 99 additions & 0 deletions android/src/debug/java/de/gematik/ti/erp/app/debug/ui/DebugPKV.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (c) 2023 gematik GmbH
*
* Licensed under the EUPL, Version 1.2 or – as soon they will be approved by
* the European Commission - subsequent versions of the EUPL (the Licence);
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* https://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
*/

package de.gematik.ti.erp.app.debug.ui

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import de.gematik.ti.erp.app.theme.PaddingDefaults
import de.gematik.ti.erp.app.utils.compose.AnimatedElevationScaffold
import de.gematik.ti.erp.app.utils.compose.NavigationBarMode
import org.kodein.di.compose.rememberViewModel

@Composable
fun DebugScreenPKV(onBack: () -> Unit) {
val viewModel by rememberViewModel<DebugSettingsViewModel>()
val listState = rememberLazyListState()
val context = LocalContext.current

AnimatedElevationScaffold(
navigationMode = NavigationBarMode.Back,
listState = listState,
topBarTitle = "Debug PKV",
onBack = onBack
) { innerPadding ->
var invoiceBundle by remember { mutableStateOf("") }
var attachement by remember { mutableStateOf("") }

LazyColumn(
state = listState,
modifier = Modifier
.padding(innerPadding)
.navigationBarsPadding()
.imePadding(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(PaddingDefaults.Medium),
contentPadding = PaddingValues(PaddingDefaults.Medium)
) {
item {
DebugCard(
title = "Invoice Bundle"
) {
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
value = invoiceBundle,
label = { Text("Bundle") },
onValueChange = {
invoiceBundle = it
},
maxLines = 1
)
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
value = attachement,
label = { Text("Attachement") },
onValueChange = {
attachement = it
},
maxLines = 1
)
DebugLoadingButton(
onClick = { viewModel.shareInvoicePDF(context, invoiceBundle, attachement) },
text = "Share"
)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import androidx.compose.material.icons.rounded.Refresh
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
Expand All @@ -69,12 +68,9 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
Expand Down Expand Up @@ -108,7 +104,7 @@ import java.util.zip.ZipOutputStream
import kotlin.math.max

@Composable
private fun DebugCard(
fun DebugCard(
modifier: Modifier = Modifier,
title: String,
onReset: (() -> Unit)? = null,
Expand Down Expand Up @@ -283,6 +279,9 @@ fun DebugScreen(
},
onClickDirectRedemption = {
navController.navigate(DebugScreenNavigation.DebugRedeemWithoutFD.path())
},
onClickPKV = {
navController.navigate(DebugScreenNavigation.DebugPKV.path())
}
)
}
Expand All @@ -296,6 +295,15 @@ fun DebugScreen(
)
}
}
composable(DebugScreenNavigation.DebugPKV.route) {
NavigationAnimation(mode = navMode) {
DebugScreenPKV(
onBack = {
navController.popBackStack()
}
)
}
}
}
}
}
Expand Down Expand Up @@ -435,7 +443,8 @@ private fun RedeemButton(
@Composable
fun DebugScreenMain(
onBack: () -> Unit,
onClickDirectRedemption: () -> Unit
onClickDirectRedemption: () -> Unit,
onClickPKV: () -> Unit
) {
val viewModel by rememberViewModel<DebugSettingsViewModel>()
val listState = rememberLazyListState()
Expand Down Expand Up @@ -492,6 +501,12 @@ fun DebugScreenMain(
) {
Text(text = "Direct Redemption")
}
Button(
onClick = onClickPKV,
modifier = Modifier.fillMaxWidth()
) {
Text(text = "PKV")
}
Button(
onClick = { viewModel.refreshPrescriptions() },
modifier = Modifier.fillMaxWidth()
Expand Down Expand Up @@ -587,30 +602,14 @@ fun DebugScreenMain(
}
}

private const val maxNumberOfVisualLogs = 25

@Composable
private fun RotatingLog(modifier: Modifier = Modifier, viewModel: DebugSettingsViewModel) {
DebugCard(modifier, title = "Log") {
val logs by viewModel.rotatingLog.collectAsState(emptyList())
val joinedLog =
logs.subList(max(0, logs.size - maxNumberOfVisualLogs), logs.size).fold(AnnotatedString("")) { acc, log ->
acc + AnnotatedString("\n") + log
}

var text by remember(joinedLog) { mutableStateOf(TextFieldValue(joinedLog)) }

Row {
val clipboard = LocalClipboardManager.current
Button(onClick = { clipboard.setText(joinedLog) }) {
Text("Copy All")
}

Spacer(Modifier.weight(1f))

val context = LocalContext.current
val mailAddress = stringResource(R.string.settings_contact_mail_address)
Button(onClick = {
val context = LocalContext.current
val mailAddress = stringResource(R.string.settings_contact_mail_address)
Button(
modifier = Modifier.fillMaxWidth(),
onClick = {
val intent = Intent(Intent.ACTION_SENDTO)
intent.data = Uri.parse("mailto:")
intent.putExtra(Intent.EXTRA_EMAIL, arrayOf(mailAddress))
Expand All @@ -621,7 +620,7 @@ private fun RotatingLog(modifier: Modifier = Modifier, viewModel: DebugSettingsV
val e = ZipEntry("log.txt")
it.putNextEntry(e)

val data = joinedLog.text.toByteArray()
val data = viewModel.rotatingLog.value.joinToString("\n").toByteArray()
it.write(data, 0, data.size)
it.closeEntry()
}
Expand All @@ -631,21 +630,10 @@ private fun RotatingLog(modifier: Modifier = Modifier, viewModel: DebugSettingsV
if (intent.resolveActivity(context.packageManager) != null) {
context.startActivity(intent)
}
}) {
Text("Send Mail")
}
) {
Text("Send Mail")
}

OutlinedTextField(
modifier = Modifier
.heightIn(max = 400.dp)
.fillMaxWidth(),
value = text,
readOnly = true,
onValueChange = {
text = it
}
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ import de.gematik.ti.erp.app.Route
object DebugScreenNavigation {
object DebugMain : Route("DebugMain")
object DebugRedeemWithoutFD : Route("DebugRedeemWithoutFD")
object DebugPKV : Route("DebugPKV")
}
Loading

0 comments on commit 281e0f0

Please sign in to comment.