Skip to content

Commit c204bc9

Browse files
committed
Update dependencies and deprecated code
1 parent 7cc30b1 commit c204bc9

52 files changed

Lines changed: 405 additions & 406 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* License: LGPL 2.1
44
* © Estonian Information System Authority
55

6-
# RIA-DigiDoc-Android v3
6+
# RIA-DigiDoc-Android
77

88
Android application that allows signing containers with ID-card via USB reader, ID-card via NFC, Mobile-ID and Smart-ID.
99

app/build.gradle.kts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension
22
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
33

4-
val appAbiFilters = "arm64-v8a;armeabi-v7a;x86_64"
4+
val appAbiFilters = "arm64-v8a;armeabi-v7a;x86_64".split(';').map { it.trim() }
55

66
plugins {
77
jacoco
88
alias(libs.plugins.androidApplication)
9-
alias(libs.plugins.jetbrainsKotlinAndroid)
109
alias(libs.plugins.compose.compiler)
11-
kotlin("kapt")
10+
alias(libs.plugins.ksp)
1211
id("com.google.dagger.hilt.android")
1312
alias(libs.plugins.google.services)
1413
alias(libs.plugins.google.firebase.crashlytics)
@@ -20,6 +19,8 @@ tasks.register<JacocoReport>("jacocoFilteredReport") {
2019
group = "Reporting"
2120
description = "Generates filtered JaCoCo report excluding UI package and other noise"
2221

22+
val buildDir = layout.buildDirectory.get().asFile
23+
2324
val coverageFiles =
2425
fileTree("$buildDir/outputs/code_coverage/debugAndroidTest/connected") {
2526
include("**/coverage.ec")
@@ -85,7 +86,7 @@ android {
8586

8687
ndk {
8788
abiFilters.clear()
88-
abiFilters.addAll(appAbiFilters.split(';').map { it.trim() })
89+
abiFilters.addAll(appAbiFilters)
8990
}
9091
}
9192

@@ -113,8 +114,8 @@ android {
113114
nativeSymbolUploadEnabled = true
114115
mappingFileUploadEnabled = true
115116
}
116-
enableUnitTestCoverage = true
117-
enableAndroidTestCoverage = true
117+
enableUnitTestCoverage = project.hasProperty("coverageEnabled")
118+
enableAndroidTestCoverage = project.hasProperty("coverageEnabled")
118119
}
119120

120121
release {
@@ -132,14 +133,8 @@ android {
132133
}
133134
}
134135
compileOptions {
135-
sourceCompatibility = JavaVersion.VERSION_17
136-
targetCompatibility = JavaVersion.VERSION_17
137-
}
138-
139-
kotlin {
140-
compilerOptions {
141-
jvmTarget.set(JvmTarget.JVM_17)
142-
}
136+
sourceCompatibility = JavaVersion.VERSION_21
137+
targetCompatibility = JavaVersion.VERSION_21
143138
}
144139

145140
buildFeatures {
@@ -157,6 +152,12 @@ android {
157152
}
158153
}
159154

155+
kotlin {
156+
compilerOptions {
157+
jvmTarget.set(JvmTarget.JVM_21)
158+
}
159+
}
160+
160161
dependencies {
161162

162163
implementation(libs.androidx.core.ktx)
@@ -166,6 +167,7 @@ dependencies {
166167
implementation(libs.androidx.lifecycle.runtime.ktx)
167168
implementation(libs.androidx.activity.compose)
168169
implementation(platform(libs.androidx.compose.bom))
170+
implementation(libs.androidx.material.icons.core)
169171
implementation(libs.androidx.ui)
170172
implementation(libs.androidx.ui.graphics)
171173
implementation(libs.androidx.ui.tooling.preview)
@@ -179,7 +181,7 @@ dependencies {
179181
implementation(libs.androidx.core.ktx)
180182
implementation(libs.google.dagger.hilt.android)
181183
implementation(libs.firebase.crashlytics.ktx)
182-
kapt(libs.google.dagger.hilt.android.compile)
184+
ksp(libs.google.dagger.hilt.android.compile)
183185
implementation(libs.androidx.hilt)
184186
implementation(libs.kotlinx.coroutines.rx3)
185187

app/src/androidTest/kotlin/ee/ria/DigiDoc/viewmodel/DiagnosticsViewModelTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ class DiagnosticsViewModelTest {
332332
fun diagnosticsViewModel_saveFile_success() {
333333
val file = createTempFileWithStringContent("test", "Test content")
334334
val intent = Intent()
335-
intent.data = Uri.fromFile(file)
335+
val uri = Uri.fromFile(file)
336+
intent.data = uri
336337
val activityResult = ActivityResult(-1, intent)
337338
viewModel.saveFile(file, activityResult)
338339
}

app/src/androidTest/kotlin/ee/ria/DigiDoc/viewmodel/shared/SharedContainerViewModelTest.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ import org.mockito.Mockito.mock
6868
import org.mockito.Mockito.`when`
6969
import org.mockito.MockitoAnnotations
7070
import org.mockito.junit.MockitoJUnitRunner
71+
import org.mockito.kotlin.whenever
72+
import java.io.ByteArrayOutputStream
7173
import java.io.File
7274
import java.io.FileNotFoundException
7375
import java.nio.charset.Charset
@@ -127,7 +129,9 @@ class SharedContainerViewModelTest {
127129
fun sharedContainerViewModel_saveContainerFile_success() {
128130
val file = createTempFileWithStringContent("test", "Test content")
129131
val intent = Intent()
130-
intent.data = Uri.fromFile(file)
132+
val uri = Uri.fromFile(file)
133+
intent.data = uri
134+
whenever(contentResolver.openOutputStream(uri)).thenReturn(ByteArrayOutputStream())
131135
val activityResult = ActivityResult(-1, intent)
132136
viewModel.saveContainerFile(file, activityResult)
133137
}

app/src/main/kotlin/ee/ria/DigiDoc/domain/repository/fileopening/FileOpeningRepositoryImpl.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ class FileOpeningRepositoryImpl
200200
override fun isFileAlreadyInContainer(
201201
file: File,
202202
container: CryptoContainer,
203-
): Boolean =
204-
container.dataFiles?.any { it?.name == file.name }
205-
?: false
203+
): Boolean = container.dataFiles.any { it.name == file.name }
206204

207205
override fun isSivaConfirmationNeeded(
208206
context: Context,
@@ -272,10 +270,8 @@ class FileOpeningRepositoryImpl
272270
val dataFiles =
273271
cryptoContainer.dataFiles
274272

275-
if (dataFiles != null) {
276-
for (i in dataFiles.indices) {
277-
dataFiles[i]?.name?.let { containerFileNames.add(it) }
278-
}
273+
for (i in dataFiles.indices) {
274+
dataFiles[i].name.let { containerFileNames.add(it) }
279275
}
280276

281277
return containerFileNames

app/src/main/kotlin/ee/ria/DigiDoc/domain/service/fileopening/FileOpeningServiceImpl.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ class FileOpeningServiceImpl : FileOpeningService {
7474
displayName = it
7575
.getString(0)
7676
?.let { name ->
77-
sanitizeString(name, "")?.trim()?.let {
78-
if (it.isEmpty() || it.startsWith(".")) {
79-
"$DEFAULT_FILENAME$it"
80-
} else if (it.endsWith(".")) {
77+
sanitizeString(name, "").trim().let { sanitizedString ->
78+
if (sanitizedString.isEmpty() || sanitizedString.startsWith(".")) {
79+
"$DEFAULT_FILENAME$sanitizedString"
80+
} else if (sanitizedString.endsWith(".")) {
8181
DEFAULT_FILENAME
8282
} else {
83-
it
83+
sanitizedString
8484
}
8585
}
8686
}?.let { sanitized ->

app/src/main/kotlin/ee/ria/DigiDoc/fragment/screen/ProxyServicesSettingsScreen.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ fun ProxyServicesSettingsScreen(
275275
.clickable {
276276
settingsProxyChoice.value = ProxySetting.NO_PROXY.name
277277
setProxySetting(ProxySetting.NO_PROXY)
278+
sharedSettingsViewModel.saveProxySettings(true, ManualProxy("", 80, "", ""))
278279
},
279280
verticalAlignment = Alignment.CenterVertically,
280281
) {
@@ -295,6 +296,7 @@ fun ProxyServicesSettingsScreen(
295296
onClick = {
296297
settingsProxyChoice.value = ProxySetting.NO_PROXY.name
297298
setProxySetting(ProxySetting.NO_PROXY)
299+
sharedSettingsViewModel.saveProxySettings(true, ManualProxy("", 80, "", ""))
298300
},
299301
)
300302
}
@@ -321,6 +323,7 @@ fun ProxyServicesSettingsScreen(
321323
.clickable {
322324
settingsProxyChoice.value = ProxySetting.SYSTEM_PROXY.name
323325
setProxySetting(ProxySetting.SYSTEM_PROXY)
326+
sharedSettingsViewModel.saveProxySettings(true, ManualProxy("", 80, "", ""))
324327
},
325328
verticalAlignment = Alignment.CenterVertically,
326329
) {
@@ -341,6 +344,7 @@ fun ProxyServicesSettingsScreen(
341344
onClick = {
342345
settingsProxyChoice.value = ProxySetting.SYSTEM_PROXY.name
343346
setProxySetting(ProxySetting.SYSTEM_PROXY)
347+
sharedSettingsViewModel.saveProxySettings(true, ManualProxy("", 80, "", ""))
344348
},
345349
)
346350
}
@@ -365,8 +369,18 @@ fun ProxyServicesSettingsScreen(
365369
.fillMaxWidth()
366370
.padding(SPadding)
367371
.clickable {
372+
val proxyPortValue = proxyPort.text.toIntOrNull() ?: 80
368373
settingsProxyChoice.value = ProxySetting.MANUAL_PROXY.name
369374
setProxySetting(ProxySetting.MANUAL_PROXY)
375+
sharedSettingsViewModel.saveProxySettings(
376+
false,
377+
ManualProxy(
378+
host = proxyHost.text,
379+
port = proxyPortValue,
380+
username = proxyUsername.text,
381+
password = proxyPassword.text,
382+
),
383+
)
370384
},
371385
verticalAlignment = Alignment.CenterVertically,
372386
) {
@@ -386,8 +400,18 @@ fun ProxyServicesSettingsScreen(
386400
},
387401
selected = settingsProxyChoice.value == ProxySetting.MANUAL_PROXY.name,
388402
onClick = {
403+
val proxyPortValue = proxyPort.text.toIntOrNull() ?: 80
389404
settingsProxyChoice.value = ProxySetting.MANUAL_PROXY.name
390405
setProxySetting(ProxySetting.MANUAL_PROXY)
406+
sharedSettingsViewModel.saveProxySettings(
407+
false,
408+
ManualProxy(
409+
host = proxyHost.text,
410+
port = proxyPortValue,
411+
username = proxyUsername.text,
412+
password = proxyPassword.text,
413+
),
414+
)
391415
},
392416
)
393417
}

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/crypto/EncryptNavigation.kt

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,15 @@ fun EncryptNavigation(
415415
}
416416
}
417417

418-
val actionFile by remember { mutableStateOf<File?>(null) }
419-
420418
var isSaved by remember { mutableStateOf(false) }
421419

420+
val fileToSave = remember { mutableStateOf<File?>(null) }
421+
422+
val saveFile: (File, String?, ActivityResultLauncher<Intent>) -> Unit = { file, mimetype, launcher ->
423+
fileToSave.value = file
424+
launchSaveFileChooser(file, mimetype, launcher)
425+
}
426+
422427
val selectedCryptoContainerTabIndex = rememberSaveable { mutableIntStateOf(0) }
423428

424429
val snackBarHostState = remember { SnackbarHostState() }
@@ -430,23 +435,16 @@ fun EncryptNavigation(
430435
rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
431436
if (result.resultCode == Activity.RESULT_OK) {
432437
try {
433-
actionFile?.let { file ->
434-
sharedContainerViewModel
435-
.getCryptoContainerDataFile(cryptoContainer, file)
436-
?.let { sharedContainerViewModel.saveContainerFile(it, result) }
438+
fileToSave.value?.let { file ->
439+
sharedContainerViewModel.saveContainerFile(file, result)
437440
showMessage(context, R.string.file_saved)
438441
isSaved = true
439-
} ?: run {
440-
cryptoContainer?.file?.let {
441-
sharedContainerViewModel.saveContainerFile(it, result)
442-
showMessage(context, R.string.file_saved)
443-
isSaved = true
444-
} ?: showMessage(context, R.string.file_saved_error)
445-
}
442+
} ?: showMessage(context, R.string.file_saved_error)
446443
} catch (_: Exception) {
447444
showMessage(context, R.string.file_saved_error)
448445
}
449446
}
447+
fileToSave.value = null
450448
}
451449

452450
BackHandler {
@@ -1089,7 +1087,7 @@ fun EncryptNavigation(
10891087
handleSivaConfirmation = handleSivaConfirmation,
10901088
context = context,
10911089
saveFileLauncher = saveFileLauncher,
1092-
saveFile = ::saveFile,
1090+
saveFile = saveFile,
10931091
openRemoveFileDialog = openRemoveFileDialog,
10941092
onBackButtonClick = {
10951093
handleBackButtonClick(
@@ -1119,7 +1117,7 @@ fun EncryptNavigation(
11191117
cryptoContainer = cryptoContainer,
11201118
onSignClick = onSignActionClick,
11211119
saveFileLauncher = saveFileLauncher,
1122-
saveFile = ::saveFile,
1120+
saveFile = saveFile,
11231121
)
11241122

11251123
RecipientBottomSheet(
@@ -1207,7 +1205,7 @@ private fun handleBackButtonClick(
12071205
}
12081206
}
12091207

1210-
private fun saveFile(
1208+
private fun launchSaveFileChooser(
12111209
file: File,
12121210
mimetype: String?,
12131211
saveFileLauncher: ActivityResultLauncher<Intent>,

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/menu/LanguageChoiceButtonItem.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@
2222
package ee.ria.DigiDoc.ui.component.menu
2323

2424
import androidx.annotation.StringRes
25-
import androidx.compose.material.icons.Icons
26-
import androidx.compose.material.icons.filled.Home
2725
import androidx.compose.runtime.Composable
28-
import androidx.compose.ui.graphics.vector.ImageVector
2926
import androidx.compose.ui.res.stringResource
3027
import ee.ria.DigiDoc.R
3128
import ee.ria.DigiDoc.utils.Language
3229

3330
data class LanguageChoiceButtonItem(
3431
@param:StringRes val label: Int = 0,
35-
val icon: ImageVector = Icons.Filled.Home,
3632
val locale: String = "",
3733
val contentDescription: String = "",
3834
val testTag: String = "",

app/src/main/kotlin/ee/ria/DigiDoc/ui/component/myeid/pinandcertificate/MyEidPinScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ fun MyEidPinScreen(
774774
} else {
775775
focusManager.clearFocus()
776776
}
777-
}
777+
},
778778
)
779779
if (isTalkBackEnabled(context) && newPinState.value.isNotEmpty()) {
780780
IconButton(

0 commit comments

Comments
 (0)