From 9c00d1981632065de44be439bb845779831f582e Mon Sep 17 00:00:00 2001 From: David Perez Date: Tue, 28 Nov 2023 15:09:37 -0600 Subject: [PATCH] Minor updates to prepare for View Item screen (#289) --- .../ui/platform/base/util/IntentHandler.kt | 7 ++++++- .../ui/platform/components/BitwardenTextField.kt | 5 ++++- .../ui/platform/components/BitwardenWideSwitch.kt | 3 +++ .../com/x8bit/bitwarden/ui/platform/theme/Type.kt | 13 +++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/IntentHandler.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/IntentHandler.kt index 4c68956b34..50d48a1044 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/IntentHandler.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/IntentHandler.kt @@ -31,6 +31,11 @@ class IntentHandler(private val context: Context) { * Start an activity to view the given [uri] in an external browser. */ fun launchUri(uri: Uri) { - startActivity(Intent(Intent.ACTION_VIEW, uri)) + val newUri = if (uri.scheme == null) { + uri.buildUpon().scheme("https").build() + } else { + uri.normalizeScheme() + } + startActivity(Intent(Intent.ACTION_VIEW, newUri)) } } diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenTextField.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenTextField.kt index 59f5a6fb5e..39b2cfc6c1 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenTextField.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenTextField.kt @@ -19,6 +19,8 @@ import androidx.compose.ui.tooling.preview.Preview * @param placeholder the optional placeholder to be displayed when the text field is in focus and * the [value] is empty. * @param hint optional hint text that will appear below the text input. + * @param singleLine when `true`, this text field becomes a single line that horizontally scrolls + * instead of wrapping onto multiple lines. * @param readOnly `true` if the input should be read-only and not accept user interactions. * @param enabled Whether or not the text field is enabled. * @param keyboardType the preferred type of keyboard input. @@ -31,6 +33,7 @@ fun BitwardenTextField( modifier: Modifier = Modifier, placeholder: String? = null, hint: String? = null, + singleLine: Boolean = true, readOnly: Boolean = false, enabled: Boolean = true, keyboardType: KeyboardType = KeyboardType.Text, @@ -52,7 +55,7 @@ fun BitwardenTextField( } }, onValueChange = onValueChange, - singleLine = true, + singleLine = singleLine, readOnly = readOnly, keyboardOptions = KeyboardOptions.Default.copy(keyboardType = keyboardType), ) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenWideSwitch.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenWideSwitch.kt index 7a538dd204..d4ecd8e988 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenWideSwitch.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/components/BitwardenWideSwitch.kt @@ -35,6 +35,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme * @param modifier A [Modifier] that you can use to apply custom modifications to the composable. * @param description An optional description label to be displayed below the [label]. * @param contentDescription A description of the switch's UI for accessibility purposes. + * @param readOnly Disables the click functionality without modifying the other UI characteristics. */ @Composable fun BitwardenWideSwitch( @@ -44,6 +45,7 @@ fun BitwardenWideSwitch( modifier: Modifier = Modifier, description: String? = null, contentDescription: String? = null, + readOnly: Boolean = false, ) { Row( horizontalArrangement = Arrangement.SpaceBetween, @@ -54,6 +56,7 @@ fun BitwardenWideSwitch( interactionSource = remember { MutableInteractionSource() }, indication = rememberRipple(color = MaterialTheme.colorScheme.primary), onClick = { onCheckedChange?.invoke(!isChecked) }, + enabled = !readOnly, ) .semantics(mergeDescendants = true) { toggleableState = ToggleableState(isChecked) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/theme/Type.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/theme/Type.kt index cb8fb6a6e6..cc6203e884 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/theme/Type.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/theme/Type.kt @@ -206,6 +206,18 @@ val nonMaterialTypography: NonMaterialTypography = NonMaterialTypography( ), platformStyle = PlatformTextStyle(includeFontPadding = false), ), + labelMediumProminent = TextStyle( + fontSize = 12.sp, + lineHeight = 16.sp, + fontFamily = FontFamily(Font(R.font.roboto_regular)), + fontWeight = FontWeight.W600, + letterSpacing = 0.5.sp, + lineHeightStyle = LineHeightStyle( + alignment = LineHeightStyle.Alignment.Center, + trim = LineHeightStyle.Trim.None, + ), + platformStyle = PlatformTextStyle(includeFontPadding = false), + ), ) /** @@ -213,4 +225,5 @@ val nonMaterialTypography: NonMaterialTypography = NonMaterialTypography( */ data class NonMaterialTypography( val fingerprint: TextStyle, + val labelMediumProminent: TextStyle, )