diff options
| author | David Göransson <david.goransson@mullvad.net> | 2025-08-04 09:04:19 +0200 |
|---|---|---|
| committer | David Göransson <david.goransson@mullvad.net> | 2025-08-04 09:04:19 +0200 |
| commit | 3e0e65110b66d6f3ea7192a0d45ec8380df8ff0e (patch) | |
| tree | 5e5f88d7848aafca395290b92f6beabc568d659d /android/app/src | |
| parent | a7b8f9e34cb4135dea66289ee2e5ffc1ec4d8382 (diff) | |
| parent | 6e5856d0795ba6fe74d6d369d993c4cf37a2ff55 (diff) | |
| download | mullvadvpn-3e0e65110b66d6f3ea7192a0d45ec8380df8ff0e.tar.xz mullvadvpn-3e0e65110b66d6f3ea7192a0d45ec8380df8ff0e.zip | |
Merge branch 'bump-agp-droid-2098'
Diffstat (limited to 'android/app/src')
25 files changed, 132 insertions, 129 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/MullvadButton.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/MullvadButton.kt index 8aa7d762b5..2d9d2c47b5 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/MullvadButton.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/MullvadButton.kt @@ -109,6 +109,7 @@ fun NegativeButton( ) } +@Suppress("ComposableLambdaParameterNaming") @Composable fun VariantButton( onClick: () -> Unit, @@ -251,6 +252,7 @@ fun NegativeOutlinedButton( } } +@Suppress("ComposableLambdaParameterNaming") @Composable private fun BaseButton( onClick: () -> Unit, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/IconCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/IconCell.kt index 1a5f4e1030..bb2f5df14d 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/IconCell.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/IconCell.kt @@ -42,10 +42,10 @@ private fun PreviewIconCell() { } } +@Suppress("ComposableLambdaParameterNaming") @Composable fun IconCell( imageVector: ImageVector?, - endIcon: @Composable ColumnScope.() -> Unit = {}, title: String, modifier: Modifier = Modifier, contentDescription: String? = null, @@ -53,6 +53,7 @@ fun IconCell( titleColor: Color = MaterialTheme.colorScheme.onPrimary, onClick: () -> Unit = {}, enabled: Boolean = true, + endIcon: @Composable ColumnScope.() -> Unit = {}, ) { // Using a transparent background to avoid using the default background from BaseCell val background: Color = Color.Transparent diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt index 25dda7d3d0..408820091a 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt @@ -29,6 +29,8 @@ private fun PreviewNavigationCell() { AppTheme { NavigationComposeCell( title = "Navigation sample", + showWarning = true, + onClick = {}, bodyView = { NavigationCellBody( contentBodyDescription = "", @@ -36,8 +38,6 @@ private fun PreviewNavigationCell() { contentColor = MaterialTheme.colorScheme.onPrimary, ) }, - onClick = {}, - showWarning = true, ) } } @@ -48,6 +48,7 @@ private fun PreviewExternalLinkComposeCell() { AppTheme { NavigationComposeCell( title = "External link sample", + onClick = {}, bodyView = { NavigationCellBody( contentBodyDescription = "content body", @@ -56,12 +57,11 @@ private fun PreviewExternalLinkComposeCell() { isExternalLink = true, ) }, - onClick = {}, - showWarning = false, ) } } +@Suppress("ComposableLambdaParameterNaming") @Composable fun NavigationComposeCell( title: String, @@ -69,12 +69,12 @@ fun NavigationComposeCell( showWarning: Boolean = false, textColor: Color = MaterialTheme.colorScheme.onPrimary, textStyle: TextStyle = MaterialTheme.typography.titleMedium, - bodyView: @Composable () -> Unit = { - Icon(Icons.Default.ChevronRight, contentDescription = title, tint = textColor) - }, isRowEnabled: Boolean = true, onClick: () -> Unit, testTag: String = "", + bodyView: @Composable () -> Unit = { + Icon(Icons.Default.ChevronRight, contentDescription = title, tint = textColor) + }, ) { BaseCell( modifier = modifier, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SelectableCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SelectableCell.kt index b5da9c9ad6..ce512e251f 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SelectableCell.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SelectableCell.kt @@ -36,6 +36,7 @@ private fun PreviewSelectableCell() { } } +@Suppress("ComposableLambdaParameterNaming") @Composable fun SelectableCell( title: String, @@ -43,13 +44,6 @@ fun SelectableCell( modifier: Modifier = Modifier, isEnabled: Boolean = true, iconContentDescription: String? = null, - selectedIcon: @Composable RowScope.() -> Unit = { - SelectableIcon( - iconContentDescription = iconContentDescription, - isSelected = isSelected, - isEnabled = isEnabled, - ) - }, titleStyle: TextStyle = MaterialTheme.typography.bodyLarge, startPadding: Dp = Dimens.cellStartPadding, selectedColor: Color = MaterialTheme.colorScheme.selected, @@ -58,6 +52,13 @@ fun SelectableCell( onBackgroundColor: Color = MaterialTheme.colorScheme.onSurface, onCellClicked: () -> Unit = {}, testTag: String = "", + selectedIcon: @Composable RowScope.() -> Unit = { + SelectableIcon( + iconContentDescription = iconContentDescription, + isSelected = isSelected, + isEnabled = isEnabled, + ) + }, ) { BaseCell( modifier = modifier.semantics { selected = isSelected }, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SwitchComposeCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SwitchComposeCell.kt index db845fe1ea..3fc6eba0bf 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SwitchComposeCell.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SwitchComposeCell.kt @@ -63,14 +63,6 @@ fun NormalSwitchComposeCell( onInfoClicked: (() -> Unit)? = null, ) { SwitchComposeCell( - titleView = { - BaseCellTitle( - title = title, - style = MaterialTheme.typography.bodyLarge, - modifier = Modifier.weight(1f, true), - textColor = if (isEnabled) onBackground else onBackground.copy(AlphaDisabled), - ) - }, isToggled = isToggled, startPadding = startPadding, isEnabled = isEnabled, @@ -79,6 +71,14 @@ fun NormalSwitchComposeCell( onCellClicked = onCellClicked, onInfoClicked = onInfoClicked, modifier = modifier, + content = { + BaseCellTitle( + title = title, + style = MaterialTheme.typography.bodyLarge, + modifier = Modifier.weight(1f, true), + textColor = if (isEnabled) onBackground else onBackground.copy(AlphaDisabled), + ) + }, ) } @@ -95,14 +95,6 @@ fun HeaderSwitchComposeCell( onInfoClicked: (() -> Unit)? = null, ) { SwitchComposeCell( - titleView = { - BaseCellTitle( - title = title, - style = MaterialTheme.typography.titleMedium, - modifier = Modifier.weight(1f, fill = true), - textColor = onBackground, - ) - }, isToggled = isToggled, startPadding = startPadding, isEnabled = isEnabled, @@ -111,12 +103,20 @@ fun HeaderSwitchComposeCell( onCellClicked = onCellClicked, onInfoClicked = onInfoClicked, modifier, + content = { + BaseCellTitle( + title = title, + style = MaterialTheme.typography.titleMedium, + modifier = Modifier.weight(1f, fill = true), + textColor = onBackground, + ) + }, ) } +@Suppress("ComposableLambdaParameterNaming") @Composable private fun SwitchComposeCell( - titleView: @Composable RowScope.() -> Unit, isToggled: Boolean, startPadding: Dp, isEnabled: Boolean, @@ -125,10 +125,11 @@ private fun SwitchComposeCell( onCellClicked: (Boolean) -> Unit, onInfoClicked: (() -> Unit)?, modifier: Modifier = Modifier, + content: @Composable RowScope.() -> Unit, ) { BaseCell( modifier = modifier.focusProperties { canFocus = false }, - headlineContent = titleView, + headlineContent = content, isRowEnabled = isEnabled, bodyView = { SwitchCellView( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/AddTimeBottomSheet.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/AddTimeBottomSheet.kt index af2dea81cd..fed7e9f995 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/AddTimeBottomSheet.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/AddTimeBottomSheet.kt @@ -454,11 +454,11 @@ private fun Products( IconCell( imageVector = Icons.Outlined.Sell, title = stringResource(id = R.string.buy_credit), - onClick = { onSitePaymentClick() }, titleColor = onBackgroundColor.copy( alpha = if (internetBlocked) AlphaDisabled else AlphaVisible ), + onClick = { onSitePaymentClick() }, enabled = !internetBlocked, endIcon = { Icon( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/MullvadModalBottomSheet.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/MullvadModalBottomSheet.kt index c7b5e0c582..eb185c13a5 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/MullvadModalBottomSheet.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/MullvadModalBottomSheet.kt @@ -29,7 +29,7 @@ import net.mullvad.mullvadvpn.lib.theme.Dimens private fun PreviewMullvadModalBottomSheet() { AppTheme { MullvadModalBottomSheet( - sheetContent = { + content = { HeaderCell(text = "Title") HorizontalDivider() IconCell(imageVector = null, title = "Select") @@ -40,6 +40,7 @@ private fun PreviewMullvadModalBottomSheet() { } @OptIn(ExperimentalMaterial3Api::class) +@Suppress("ComposableLambdaParameterNaming") @Composable fun MullvadModalBottomSheet( modifier: Modifier = Modifier, @@ -47,7 +48,7 @@ fun MullvadModalBottomSheet( backgroundColor: Color = MaterialTheme.colorScheme.surfaceContainer, onBackgroundColor: Color = MaterialTheme.colorScheme.onSurface, onDismissRequest: () -> Unit, - sheetContent: @Composable ColumnScope.() -> Unit, + content: @Composable ColumnScope.() -> Unit, ) { // This is to avoid weird colors in the status bar and the navigation bar val paddingValues = BottomSheetDefaults.windowInsets.asPaddingValues() @@ -59,7 +60,7 @@ fun MullvadModalBottomSheet( contentWindowInsets = { WindowInsets(0, 0, 0, 0) }, // No insets dragHandle = { BottomSheetDefaults.DragHandle(color = onBackgroundColor) }, ) { - sheetContent() + content() Spacer(modifier = Modifier.height(Dimens.smallPadding)) Spacer(modifier = Modifier.height(paddingValues.calculateBottomPadding())) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/PlayPayment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/PlayPayment.kt index ac7eb140fc..ec27c6456c 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/PlayPayment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/PlayPayment.kt @@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Info import androidx.compose.material.icons.outlined.Info import androidx.compose.material.icons.outlined.Sell import androidx.compose.material3.HorizontalDivider @@ -162,12 +161,6 @@ private fun PaymentAvailable( Column { billingPaymentState.products.forEach { product -> IconCell( - titleColor = - if (enabled) { - MaterialTheme.colorScheme.onSurface - } else { - MaterialTheme.colorScheme.onSurface.copy(alpha = AlphaDisabled) - }, imageVector = Icons.Outlined.Sell, title = when (product.productId.value) { @@ -186,6 +179,12 @@ private fun PaymentAvailable( error("ProductId ${product.productId.value} is not supported") } }, + titleColor = + if (enabled) { + MaterialTheme.colorScheme.onSurface + } else { + MaterialTheme.colorScheme.onSurface.copy(alpha = AlphaDisabled) + }, onClick = { onPurchaseBillingProductClick(product.productId) }, enabled = enabled, ) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialog.kt index 41b3574d0d..d45aef007e 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialog.kt @@ -111,8 +111,10 @@ fun CreateCustomListDialog( InputDialog( title = stringResource(id = R.string.create_new_list), - confirmButtonText = stringResource(id = R.string.create), confirmButtonEnabled = isValidName, + confirmButtonText = stringResource(id = R.string.create), + onBack = onDismiss, + onConfirm = { createCustomList(name.value) }, input = { CustomListNameTextField( name = name.value, @@ -126,8 +128,6 @@ fun CreateCustomListDialog( modifier = Modifier.testTag(CREATE_CUSTOM_LIST_DIALOG_INPUT_TEST_TAG), ) }, - onBack = onDismiss, - onConfirm = { createCustomList(name.value) }, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomPortDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomPortDialog.kt index 35a98e061e..d8465325f0 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomPortDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomPortDialog.kt @@ -52,16 +52,6 @@ fun CustomPortDialog( ) { InputDialog( title = title, - input = { - CustomPortTextField( - value = portInput, - onValueChanged = onInputChanged, - onSubmit = onSavePort, - isValidValue = isValidInput, - maxCharLength = 5, - modifier = Modifier.testTag(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG).fillMaxWidth(), - ) - }, message = stringResource( id = R.string.custom_port_dialog_valid_ranges, @@ -71,7 +61,17 @@ fun CustomPortDialog( confirmButtonText = stringResource(id = R.string.custom_port_dialog_submit), onResetButtonText = stringResource(R.string.custom_port_dialog_remove), onBack = onDismiss, - onReset = if (showResetToDefault) onResetPort else null, onConfirm = { onSavePort(portInput) }, + onReset = if (showResetToDefault) onResetPort else null, + input = { + CustomPortTextField( + value = portInput, + onValueChanged = onInputChanged, + onSubmit = onSavePort, + isValidValue = isValidInput, + maxCharLength = 5, + modifier = Modifier.testTag(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG).fillMaxWidth(), + ) + }, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt index bf8a8b0989..6b3596f62b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DnsDialog.kt @@ -114,6 +114,12 @@ fun DnsDialog( } else { stringResource(R.string.update_dns_server_dialog_title) }, + confirmButtonEnabled = state.isValid(), + onResetButtonText = stringResource(id = R.string.remove_button), + messageTextColor = MaterialTheme.colorScheme.error, + onBack = onDismiss, + onConfirm = onSaveDnsClick, + onReset = state.index?.let { { onRemoveDnsClick(state.index) } }, input = { DnsTextField( value = state.input, @@ -137,11 +143,5 @@ fun DnsDialog( modifier = Modifier.fillMaxWidth(), ) }, - onResetButtonText = stringResource(id = R.string.remove_button), - confirmButtonEnabled = state.isValid(), - messageTextColor = MaterialTheme.colorScheme.error, - onReset = state.index?.let { { onRemoveDnsClick(state.index) } }, - onBack = onDismiss, - onConfirm = onSaveDnsClick, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialog.kt index 897106e3bf..996459403b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/EditCustomListNameDialog.kt @@ -82,8 +82,10 @@ fun EditCustomListNameDialog( ) { InputDialog( title = stringResource(id = R.string.update_list_name), - confirmButtonText = stringResource(id = R.string.save), confirmButtonEnabled = state.isValidName, + confirmButtonText = stringResource(id = R.string.save), + onBack = onDismiss, + onConfirm = { updateName(state.name) }, input = { CustomListNameTextField( name = state.name, @@ -94,8 +96,6 @@ fun EditCustomListNameDialog( modifier = Modifier.testTag(EDIT_CUSTOM_LIST_DIALOG_INPUT_TEST_TAG), ) }, - onBack = onDismiss, - onConfirm = { updateName(state.name) }, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/InputDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/InputDialog.kt index 8919ad69db..bc4f0ceed9 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/InputDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/InputDialog.kt @@ -28,6 +28,9 @@ private fun PreviewInputDialog() { InputDialog( title = "Input here", message = "Lorem ipsum", + onBack = {}, + onConfirm = {}, + onReset = {}, input = { CustomTextField( value = "input", @@ -39,18 +42,15 @@ private fun PreviewInputDialog() { isDigitsOnlyAllowed = false, ) }, - onReset = {}, - onBack = {}, - onConfirm = {}, ) } } +@Suppress("ComposableLambdaParameterNaming") @Composable fun InputDialog( title: String, message: String? = null, - input: @Composable ColumnScope.() -> Unit, confirmButtonEnabled: Boolean = true, confirmButtonText: String = stringResource(R.string.submit_button), onResetButtonText: String = stringResource(R.string.reset_to_default_button), @@ -58,6 +58,7 @@ fun InputDialog( onBack: () -> Unit, onConfirm: () -> Unit, onReset: (() -> Unit)? = null, + input: @Composable ColumnScope.() -> Unit, ) { AlertDialog( onDismissRequest = onBack, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt index e1ee0a0faf..4c6490e87b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt @@ -73,6 +73,15 @@ fun MtuDialog( InputDialog( title = stringResource(id = R.string.wireguard_mtu), message = stringResource(id = R.string.wireguard_mtu_footer, MTU_MIN_VALUE, MTU_MAX_VALUE), + confirmButtonEnabled = state.isValidInput, + onBack = onDismiss, + onConfirm = { onSaveMtu(state.mtuInput) }, + onReset = + if (state.showResetToDefault) { + onResetMtu + } else { + null + }, input = { MtuTextField( value = state.mtuInput, @@ -85,14 +94,5 @@ fun MtuDialog( modifier = Modifier.fillMaxWidth(), ) }, - confirmButtonEnabled = state.isValidInput, - onReset = - if (state.showResetToDefault) { - onResetMtu - } else { - null - }, - onBack = onDismiss, - onConfirm = { onSaveMtu(state.mtuInput) }, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/RedeemVoucherDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/RedeemVoucherDialog.kt index cd7d21b95f..62b9cf57c4 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/RedeemVoucherDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/RedeemVoucherDialog.kt @@ -236,20 +236,20 @@ private fun EnterVoucherBody( ) { CustomTextField( value = state.voucherInput, + keyboardType = KeyboardType.Password, + modifier = Modifier.testTag(VOUCHER_INPUT_TEST_TAG), + onValueChanged = { input -> onVoucherInputChange(input) }, onSubmit = { input -> if (state.voucherInput.length == VOUCHER_LENGTH) { onRedeem(input) } }, - onValueChanged = { input -> onVoucherInputChange(input) }, + placeholderText = stringResource(id = R.string.voucher_hint), isValidValue = state.voucherInput.isEmpty() || state.voucherInput.length == MAX_VOUCHER_LENGTH, - keyboardType = KeyboardType.Password, - placeholderText = stringResource(id = R.string.voucher_hint), + isDigitsOnlyAllowed = false, visualTransformation = vouchersVisualTransformation(), textStyle = MaterialTheme.typography.titleMedium, - isDigitsOnlyAllowed = false, - modifier = Modifier.testTag(VOUCHER_INPUT_TEST_TAG), ) Spacer(modifier = Modifier.height(Dimens.smallPadding)) Row( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt index 4707902ff0..f67a9e365a 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListsScreen.kt @@ -176,8 +176,8 @@ private fun LazyListScope.content( ) { customList -> NavigationComposeCell( title = customList.name.value, - onClick = { openCustomList(customList) }, textStyle = MaterialTheme.typography.bodyLarge, + onClick = { openCustomList(customList) }, ) } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreen.kt index b88aeb450c..28a2d64463 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/FilterScreen.kt @@ -176,9 +176,8 @@ private fun LazyItemScope.AnyOwnership(state: RelayFilterUiState, onSelectedOwne SelectableCell( title = stringResource(id = R.string.any), isSelected = state.selectedOwnership is Constraint.Any, - onCellClicked = { onSelectedOwnership() }, modifier = Modifier.animateItem(), - backgroundColor = MaterialTheme.colorScheme.surfaceContainerHighest, + onCellClicked = { onSelectedOwnership() }, ) } @@ -191,9 +190,8 @@ private fun LazyItemScope.Ownership( SelectableCell( title = stringResource(id = ownership.stringResource()), isSelected = ownership == state.selectedOwnership.getOrNull(), - onCellClicked = { onSelectedOwnership(ownership) }, modifier = Modifier.animateItem(), - backgroundColor = MaterialTheme.colorScheme.surfaceContainerHighest, + onCellClicked = { onSelectedOwnership(ownership) }, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ServerIpOverridesScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ServerIpOverridesScreen.kt index 90bedbeb18..bbfc028917 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ServerIpOverridesScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ServerIpOverridesScreen.kt @@ -280,20 +280,20 @@ private fun ImportOverridesByBottomSheet( IconCell( imageVector = Icons.Default.UploadFile, title = stringResource(id = R.string.server_ip_overrides_import_by_file), + modifier = Modifier.testTag(SERVER_IP_OVERRIDES_IMPORT_BY_FILE_TEST_TAG), onClick = { onImportByFile() onCloseSheet() }, - modifier = Modifier.testTag(SERVER_IP_OVERRIDES_IMPORT_BY_FILE_TEST_TAG), ) IconCell( imageVector = Icons.Default.TextFields, title = stringResource(id = R.string.server_ip_overrides_import_by_text), + modifier = Modifier.testTag(SERVER_IP_OVERRIDES_IMPORT_BY_TEXT_TEST_TAG), onClick = { onImportByText() onCloseSheet() }, - modifier = Modifier.testTag(SERVER_IP_OVERRIDES_IMPORT_BY_TEXT_TEST_TAG), ) if (overridesActive) { HorizontalDivider(color = onBackgroundColor) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt index c6cd4205cf..f70148a48c 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt @@ -242,13 +242,13 @@ private fun FaqAndGuides() { NavigationComposeCell( title = faqGuideLabel, + onClick = openFaqAndGuides, bodyView = { DefaultExternalLinkView( chevronContentDescription = faqGuideLabel, tint = MaterialTheme.colorScheme.onPrimary, ) }, - onClick = openFaqAndGuides, ) } @@ -263,13 +263,13 @@ private fun PrivacyPolicy(state: SettingsUiState) { NavigationComposeCell( title = privacyPolicyLabel, + onClick = openPrivacyPolicy, bodyView = { DefaultExternalLinkView( chevronContentDescription = privacyPolicyLabel, tint = MaterialTheme.colorScheme.onPrimary, ) }, - onClick = openPrivacyPolicy, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt index 427d035c87..7d26ad25ee 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/VpnSettingsScreen.kt @@ -513,8 +513,8 @@ fun VpnSettingsContent( VpnSettingItem.AutoConnectAndLockdownMode -> item(key = it::class.simpleName) { NavigationComposeCell( - modifier = Modifier.animateItem(), title = stringResource(id = R.string.auto_connect_and_lockdown_mode), + modifier = Modifier.animateItem(), onClick = { navigateToAutoConnectScreen() }, ) } @@ -629,7 +629,6 @@ fun VpnSettingsContent( is VpnSettingItem.DeviceIpVersionItem -> item(key = it::class.simpleName + it.constraint.getOrNull().toString()) { SelectableCell( - modifier = Modifier.animateItem(), title = when (it.constraint) { Constraint.Any -> stringResource(id = R.string.automatic) @@ -642,6 +641,7 @@ fun VpnSettingsContent( } }, isSelected = it.selected, + modifier = Modifier.animateItem(), onCellClicked = { onSelectDeviceIpVersion(it.constraint) }, ) } @@ -814,8 +814,8 @@ fun VpnSettingsContent( SelectableCell( title = stringResource(id = R.string.automatic), isSelected = it.selected, - onCellClicked = { onSelectObfuscationMode(ObfuscationMode.Auto) }, modifier = Modifier.animateItem(), + onCellClicked = { onSelectObfuscationMode(ObfuscationMode.Auto) }, ) } @@ -824,9 +824,9 @@ fun VpnSettingsContent( SelectableCell( title = stringResource(id = R.string.off), isSelected = it.selected, + modifier = Modifier.animateItem(), onCellClicked = { onSelectObfuscationMode(ObfuscationMode.Off) }, testTag = WIREGUARD_OBFUSCATION_OFF_CELL_TEST_TAG, - modifier = Modifier.animateItem(), ) } @@ -924,6 +924,10 @@ fun VpnSettingsContent( is Constraint.Any -> stringResource(id = R.string.automatic) }, + isSelected = it.selected, + modifier = Modifier.animateItem(), + isEnabled = it.enabled, + onCellClicked = { onWireguardPortSelected(it.constraint) }, testTag = when (it.constraint) { is Constraint.Only -> @@ -935,10 +939,6 @@ fun VpnSettingsContent( is Constraint.Any -> "" }, - isSelected = it.selected, - onCellClicked = { onWireguardPortSelected(it.constraint) }, - isEnabled = it.enabled, - modifier = Modifier.animateItem(), ) } @@ -986,8 +986,8 @@ fun VpnSettingsContent( @Composable private fun ServerIpOverrides(onServerIpOverridesClick: () -> Unit, modifier: Modifier = Modifier) { NavigationComposeCell( - modifier = modifier, title = stringResource(id = R.string.server_ip_override), + modifier = modifier, onClick = onServerIpOverridesClick, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/ApiAccessMethodTextField.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/ApiAccessMethodTextField.kt index b473dcbdb5..ea555784a5 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/ApiAccessMethodTextField.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/ApiAccessMethodTextField.kt @@ -29,23 +29,22 @@ fun ApiAccessMethodTextField( CustomTextField( value = value, keyboardType = keyboardType, + modifier = + modifier + .defaultMinSize(minHeight = Dimens.formTextFieldMinHeight) + .padding(vertical = Dimens.miniPadding), onValueChanged = onValueChanged, onSubmit = { if (imeAction == ImeAction.Done) { focusManager.clearFocus() } }, - labelText = labelText, placeholderText = null, + labelText = labelText, + maxCharLength = maxCharLength, isValidValue = isValidValue, isDigitsOnlyAllowed = isDigitsOnlyAllowed, - maxCharLength = maxCharLength, - supportingText = errorText?.let { { ErrorSupportingText(errorText) } }, colors = apiAccessTextFieldColors(), - modifier = - modifier - .defaultMinSize(minHeight = Dimens.formTextFieldMinHeight) - .padding(vertical = Dimens.miniPadding), keyboardOptions = KeyboardOptions( capitalization = capitalization, @@ -53,5 +52,6 @@ fun ApiAccessMethodTextField( keyboardType = keyboardType, imeAction = imeAction, ), + supportingText = errorText?.let { { ErrorSupportingText(errorText) } }, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomListNameTextField.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomListNameTextField.kt index 8e483e9153..9cb65ae4e4 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomListNameTextField.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomListNameTextField.kt @@ -27,17 +27,25 @@ fun CustomListNameTextField( val keyboardController = LocalSoftwareKeyboardController.current CustomTextField( value = name, + keyboardType = KeyboardType.Text, + modifier = + modifier.focusRequester(focusRequester).onFocusChanged { focusState -> + if (focusState.hasFocus) { + keyboardController?.show() + } + }, onValueChanged = onValueChanged, onSubmit = { if (isValidName) { onSubmit(it) } }, - keyboardType = KeyboardType.Text, placeholderText = null, + maxCharLength = CustomListName.MAX_LENGTH, isValidValue = error == null, isDigitsOnlyAllowed = false, - maxCharLength = CustomListName.MAX_LENGTH, + textStyle = MaterialTheme.typography.titleMedium, + capitalization = KeyboardCapitalization.Words, supportingText = error?.let { { @@ -48,14 +56,6 @@ fun CustomListNameTextField( ) } }, - capitalization = KeyboardCapitalization.Words, - textStyle = MaterialTheme.typography.titleMedium, - modifier = - modifier.focusRequester(focusRequester).onFocusChanged { focusState -> - if (focusState.hasFocus) { - keyboardController?.show() - } - }, ) LaunchedEffect(Unit) { focusRequester.requestFocus() } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomPortTextField.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomPortTextField.kt index cd4b67b4d2..81e40059d0 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomPortTextField.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomPortTextField.kt @@ -20,13 +20,12 @@ fun CustomPortTextField( value = value, keyboardType = KeyboardType.Number, modifier = modifier, - placeholderText = stringResource(id = R.string.custom_port_dialog_placeholder), onValueChanged = onValueChanged, onSubmit = onSubmit, - isDigitsOnlyAllowed = true, - isEnabled = true, - isValidValue = isValidValue, + placeholderText = stringResource(id = R.string.custom_port_dialog_placeholder), maxCharLength = maxCharLength, + isValidValue = isValidValue, + isDigitsOnlyAllowed = true, textStyle = MaterialTheme.typography.titleMedium, ) } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomTextField.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomTextField.kt index 783948978d..4f165a5303 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomTextField.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/CustomTextField.kt @@ -34,6 +34,7 @@ import net.mullvad.mullvadvpn.constant.EMPTY_STRING import net.mullvad.mullvadvpn.constant.NEWLINE_STRING import net.mullvad.mullvadvpn.lib.theme.Dimens +@Suppress("ComposableLambdaParameterNaming") @Composable fun CustomTextField( value: String, @@ -44,11 +45,10 @@ fun CustomTextField( isEnabled: Boolean = true, placeholderText: String?, labelText: String? = null, - maxCharLength: Int = Int.MAX_VALUE, + maxCharLength: Int = Int.Companion.MAX_VALUE, isValidValue: Boolean, isDigitsOnlyAllowed: Boolean, visualTransformation: VisualTransformation = VisualTransformation.None, - supportingText: @Composable (() -> Unit)? = null, colors: TextFieldColors = mullvadDarkTextFieldColors(), textStyle: TextStyle = LocalTextStyle.current, capitalization: KeyboardCapitalization = KeyboardCapitalization.None, @@ -59,6 +59,7 @@ fun CustomTextField( keyboardType = keyboardType, imeAction = ImeAction.Done, ), + supportingText: @Composable (() -> Unit)? = null, ) { // This is the same implementation as in BasicTextField.kt but with initial selection set at the // end of the text rather than in the beginning. diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/DnsTextField.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/DnsTextField.kt index f89d4c9627..a7aecddb67 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/DnsTextField.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/textfield/DnsTextField.kt @@ -1,7 +1,6 @@ package net.mullvad.mullvadvpn.compose.textfield import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.text.input.KeyboardType @@ -25,10 +24,10 @@ fun DnsTextField( onSubmit = { onSubmit() }, isEnabled = isEnabled, placeholderText = placeholderText, - supportingText = errorText?.let { { ErrorSupportingText(errorText) } }, maxCharLength = Int.MAX_VALUE, - isDigitsOnlyAllowed = false, isValidValue = isValidValue, + isDigitsOnlyAllowed = false, textStyle = MaterialTheme.typography.titleMedium, + supportingText = errorText?.let { { ErrorSupportingText(errorText) } }, ) } |
