From f4f79e56df6cfbf829cc3aacb7c486d527502003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Wed, 20 Mar 2024 15:06:21 +0100 Subject: [PATCH 1/2] Hide the Reset button when already default --- .../mullvad/mullvadvpn/compose/dialog/MtuDialog.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 e4a790fdb44f..76b8359a082b 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 @@ -119,11 +119,13 @@ fun MtuDialog( } ) - PrimaryButton( - modifier = Modifier.fillMaxWidth(), - text = stringResource(R.string.reset_to_default_button), - onClick = onResetMtu - ) + if (mtuInitial != null) { + PrimaryButton( + modifier = Modifier.fillMaxWidth(), + text = stringResource(R.string.reset_to_default_button), + onClick = onResetMtu + ) + } PrimaryButton( modifier = Modifier.fillMaxWidth(), From 1738bd129dc482c6dbfedf5b5444aca311b441fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20G=C3=B6ransson?= Date: Wed, 20 Mar 2024 15:50:41 +0100 Subject: [PATCH 2/2] Make reset to default negative --- .../net/mullvad/mullvadvpn/compose/dialog/MtuDialogTest.kt | 1 + .../kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialog.kt | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialogTest.kt b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialogTest.kt index 26babe92454d..0641998f9bd1 100644 --- a/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialogTest.kt +++ b/android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/MtuDialogTest.kt @@ -125,6 +125,7 @@ class MtuDialogTest { val mockedClickHandler: () -> Unit = mockk(relaxed = true) setContentWithTheme { testMtuDialog( + mtuInitial = VALID_DUMMY_MTU_VALUE, onResetMtu = mockedClickHandler, ) } 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 76b8359a082b..4644a1aa952a 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 @@ -18,6 +18,7 @@ import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.navigation.EmptyDestinationsNavigator import com.ramcosta.composedestinations.spec.DestinationStyle import net.mullvad.mullvadvpn.R +import net.mullvad.mullvadvpn.compose.button.NegativeButton import net.mullvad.mullvadvpn.compose.button.PrimaryButton import net.mullvad.mullvadvpn.compose.textfield.MtuTextField import net.mullvad.mullvadvpn.compose.util.LaunchedEffectCollect @@ -120,7 +121,7 @@ fun MtuDialog( ) if (mtuInitial != null) { - PrimaryButton( + NegativeButton( modifier = Modifier.fillMaxWidth(), text = stringResource(R.string.reset_to_default_button), onClick = onResetMtu