diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/Navigation.kt b/app/src/main/java/dev/medzik/librepass/android/ui/Navigation.kt index 45d3198a..88fd821f 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/Navigation.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/Navigation.kt @@ -36,21 +36,21 @@ import dev.medzik.android.components.rememberMutableBoolean import dev.medzik.librepass.android.MainActivity import dev.medzik.librepass.android.R import dev.medzik.librepass.android.data.getRepository -import dev.medzik.librepass.android.ui.screens.PasswordGeneratorScreen import dev.medzik.librepass.android.ui.screens.WelcomeScreen -import dev.medzik.librepass.android.ui.screens.auth.AddCustomServer +import dev.medzik.librepass.android.ui.screens.auth.AddCustomServerScreen import dev.medzik.librepass.android.ui.screens.auth.LoginScreen import dev.medzik.librepass.android.ui.screens.auth.RegisterScreen import dev.medzik.librepass.android.ui.screens.auth.UnlockScreen -import dev.medzik.librepass.android.ui.screens.dashboard.CipherAddScreen -import dev.medzik.librepass.android.ui.screens.dashboard.CipherEditScreen -import dev.medzik.librepass.android.ui.screens.dashboard.CipherViewScreen -import dev.medzik.librepass.android.ui.screens.dashboard.SearchScreen -import dev.medzik.librepass.android.ui.screens.dashboard.VaultScreen import dev.medzik.librepass.android.ui.screens.settings.SettingsAccountScreen import dev.medzik.librepass.android.ui.screens.settings.SettingsAppearanceScreen import dev.medzik.librepass.android.ui.screens.settings.SettingsScreen import dev.medzik.librepass.android.ui.screens.settings.SettingsSecurityScreen +import dev.medzik.librepass.android.ui.screens.vault.CipherAddScreen +import dev.medzik.librepass.android.ui.screens.vault.CipherEditScreen +import dev.medzik.librepass.android.ui.screens.vault.CipherViewScreen +import dev.medzik.librepass.android.ui.screens.vault.PasswordGeneratorScreen +import dev.medzik.librepass.android.ui.screens.vault.SearchScreen +import dev.medzik.librepass.android.ui.screens.vault.VaultScreen import dev.medzik.librepass.android.utils.SecretStore import dev.medzik.librepass.android.utils.SecretStore.getUserSecrets import dev.medzik.librepass.android.utils.TopBar @@ -99,7 +99,7 @@ enum class Screen( navigationIcon = { TopBarBackIcon(it) } ) }, - composable = { AddCustomServer(it) } + composable = { AddCustomServerScreen(it) } ), // Vault diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/WelcomeScreen.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/Welcome.kt similarity index 100% rename from app/src/main/java/dev/medzik/librepass/android/ui/screens/WelcomeScreen.kt rename to app/src/main/java/dev/medzik/librepass/android/ui/screens/Welcome.kt diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/AddCustomServer.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/AddCustomServer.kt index 5d4aa4a5..9201d434 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/AddCustomServer.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/AddCustomServer.kt @@ -21,7 +21,7 @@ import dev.medzik.librepass.android.utils.StoreKey import dev.medzik.librepass.android.utils.TextInputField @Composable -fun AddCustomServer(navController: NavController) { +fun AddCustomServerScreen(navController: NavController) { val context = LocalContext.current var loading by rememberMutableBoolean() diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/LoginScreen.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/Login.kt similarity index 100% rename from app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/LoginScreen.kt rename to app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/Login.kt diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/RegisterScreen.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/Register.kt similarity index 100% rename from app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/RegisterScreen.kt rename to app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/Register.kt diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/UnlockScreen.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/Unlock.kt similarity index 100% rename from app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/UnlockScreen.kt rename to app/src/main/java/dev/medzik/librepass/android/ui/screens/auth/Unlock.kt diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/CipherAddScreen.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherAdd.kt similarity index 76% rename from app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/CipherAddScreen.kt rename to app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherAdd.kt index 88614ac9..be081809 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/CipherAddScreen.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherAdd.kt @@ -1,4 +1,4 @@ -package dev.medzik.librepass.android.ui.screens.dashboard +package dev.medzik.librepass.android.ui.screens.vault import androidx.compose.runtime.Composable import androidx.navigation.NavController diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/AddEditScreen.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherAddEdit.kt similarity index 99% rename from app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/AddEditScreen.kt rename to app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherAddEdit.kt index 33614769..68bbaa7d 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/AddEditScreen.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherAddEdit.kt @@ -1,4 +1,4 @@ -package dev.medzik.librepass.android.ui.screens.dashboard +package dev.medzik.librepass.android.ui.screens.vault import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/CipherEditScreen.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherEdit.kt similarity index 93% rename from app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/CipherEditScreen.kt rename to app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherEdit.kt index 3a12e90c..a10014ad 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/CipherEditScreen.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherEdit.kt @@ -1,4 +1,4 @@ -package dev.medzik.librepass.android.ui.screens.dashboard +package dev.medzik.librepass.android.ui.screens.vault import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/ViewScreen.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherView.kt similarity index 90% rename from app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/ViewScreen.kt rename to app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherView.kt index 3f2a8d34..a5d0b94c 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/ViewScreen.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/CipherView.kt @@ -1,4 +1,4 @@ -package dev.medzik.librepass.android.ui.screens.dashboard +package dev.medzik.librepass.android.ui.screens.vault import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.OpenInNew import androidx.compose.material.icons.filled.ContentCopy import androidx.compose.material.icons.filled.Edit import androidx.compose.material.icons.filled.History @@ -27,6 +28,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.unit.dp @@ -36,6 +38,7 @@ import dev.medzik.android.components.SecondaryText import dev.medzik.android.components.getString import dev.medzik.android.components.navigate import dev.medzik.android.components.rememberDialogState +import dev.medzik.android.utils.showToast import dev.medzik.librepass.android.R import dev.medzik.librepass.android.data.getRepository import dev.medzik.librepass.android.ui.Argument @@ -192,6 +195,8 @@ fun CipherViewScreen(navController: NavController) { CipherField( title = stringResource(R.string.CipherField_URL) + " ${index + 1}", value = it, + openUri = true, + uri = it, copy = true ) } @@ -221,11 +226,15 @@ fun CipherField( title: String, value: String?, hidden: Boolean = false, + openUri: Boolean = false, + uri: String? = null, copy: Boolean = false, customIcon: (@Composable () -> Unit)? = null ) { if (value.isNullOrEmpty()) return + val context = LocalContext.current + val uriHandler = LocalUriHandler.current val clipboardManager = LocalClipboardManager.current var hiddenState by remember { mutableStateOf(hidden) } @@ -268,6 +277,25 @@ fun CipherField( } } + if (openUri) { + IconButton(onClick = { + try { + var address = uri!! + if (!address.contains("http(s)?://".toRegex())) + address = "https://$uri" + + uriHandler.openUri(address) + } catch (e: Exception) { + context.showToast("No application found for URI: $uri") + } + }) { + Icon( + imageVector = Icons.AutoMirrored.Filled.OpenInNew, + contentDescription = null + ) + } + } + if (copy) { IconButton(onClick = { clipboardManager.setText(AnnotatedString(value)) }) { Icon( diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/PasswordGeneratorScreen.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/PasswordGenerator.kt similarity index 99% rename from app/src/main/java/dev/medzik/librepass/android/ui/screens/PasswordGeneratorScreen.kt rename to app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/PasswordGenerator.kt index 57a321cb..e0296a9d 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/screens/PasswordGeneratorScreen.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/PasswordGenerator.kt @@ -1,4 +1,4 @@ -package dev.medzik.librepass.android.ui.screens +package dev.medzik.librepass.android.ui.screens.vault import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/SearchScreen.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/Search.kt similarity index 98% rename from app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/SearchScreen.kt rename to app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/Search.kt index fb8616f8..443c22a6 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/SearchScreen.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/Search.kt @@ -1,4 +1,4 @@ -package dev.medzik.librepass.android.ui.screens.dashboard +package dev.medzik.librepass.android.ui.screens.vault import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth diff --git a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/VaultScreen.kt b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/Vault.kt similarity index 99% rename from app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/VaultScreen.kt rename to app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/Vault.kt index b53e128c..2af9d546 100644 --- a/app/src/main/java/dev/medzik/librepass/android/ui/screens/dashboard/VaultScreen.kt +++ b/app/src/main/java/dev/medzik/librepass/android/ui/screens/vault/Vault.kt @@ -1,4 +1,4 @@ -package dev.medzik.librepass.android.ui.screens.dashboard +package dev.medzik.librepass.android.ui.screens.vault import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize diff --git a/app/src/main/java/dev/medzik/librepass/android/utils/TextInputField.kt b/app/src/main/java/dev/medzik/librepass/android/utils/TextInputField.kt index 02031042..01ed6c62 100644 --- a/app/src/main/java/dev/medzik/librepass/android/utils/TextInputField.kt +++ b/app/src/main/java/dev/medzik/librepass/android/utils/TextInputField.kt @@ -55,21 +55,21 @@ fun TextInputField( maxLines = 1, singleLine = true, visualTransformation = ( - if (hidden && hiddenState.value) - PasswordVisualTransformation() - else - VisualTransformation.None - ), + if (hidden && hiddenState.value) + PasswordVisualTransformation() + else + VisualTransformation.None + ), trailingIcon = { if (hidden) { IconButton(onClick = { hiddenState.value = !hiddenState.value }) { Icon( imageVector = ( - if (hiddenState.value) - Icons.Filled.Visibility - else - Icons.Filled.VisibilityOff - ), + if (hiddenState.value) + Icons.Filled.Visibility + else + Icons.Filled.VisibilityOff + ), contentDescription = null ) } @@ -103,22 +103,22 @@ fun TextInputFieldBase( label = { Text(label) }, singleLine = singleLine, visualTransformation = ( - if (hidden && hiddenState.value) - PasswordVisualTransformation() - else - VisualTransformation.None - ), + if (hidden && hiddenState.value) + PasswordVisualTransformation() + else + VisualTransformation.None + ), trailingIcon = { Row { if (hidden) { IconButton(onClick = { hiddenState.value = !hiddenState.value }) { Icon( imageVector = ( - if (hiddenState.value) - Icons.Filled.Visibility - else - Icons.Filled.VisibilityOff - ), + if (hiddenState.value) + Icons.Filled.Visibility + else + Icons.Filled.VisibilityOff + ), contentDescription = null ) }