From 335a6c3cc20fbac95133b9a8776dd0f5f7d35aea Mon Sep 17 00:00:00 2001 From: Jonatan Rhodin Date: Tue, 12 Mar 2024 11:39:21 +0100 Subject: [PATCH 1/2] Restore legacy auto-connect for non-TV devices --- .../mullvadvpn/compose/cell/BaseCell.kt | 6 +++ .../compose/cell/SwitchComposeCell.kt | 6 +++ .../compose/screen/VpnSettingsScreen.kt | 52 +++++++++++++------ .../resource/src/main/res/values/strings.xml | 2 + gui/locales/messages.pot | 6 +++ 5 files changed, 57 insertions(+), 15 deletions(-) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/BaseCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/BaseCell.kt index 13aaea433474..15f6e4d11179 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/BaseCell.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/BaseCell.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.testTag +import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow @@ -109,6 +110,11 @@ internal fun BaseCellTitle( @Composable fun BaseSubtitleCell(text: String, modifier: Modifier = Modifier) { + BaseSubtitleCell(text = AnnotatedString(text), modifier = modifier) +} + +@Composable +fun BaseSubtitleCell(text: AnnotatedString, modifier: Modifier = Modifier) { Text( text = text, style = MaterialTheme.typography.labelMedium, 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 e7d6e7f1c3b8..6aeea8897ddb 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 @@ -15,6 +15,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.focus.focusProperties import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp @@ -193,3 +194,8 @@ fun CustomDnsCellSubtitle(isCellClickable: Boolean, modifier: Modifier) { fun SwitchComposeSubtitleCell(text: String, modifier: Modifier = Modifier) { BaseSubtitleCell(text = text, modifier = modifier) } + +@Composable +fun SwitchComposeSubtitleCell(text: AnnotatedString, modifier: Modifier = Modifier) { + BaseSubtitleCell(text = text, modifier = modifier) +} 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 0530cfb4ae4d..403b1bb57e48 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 @@ -22,8 +22,10 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.core.text.HtmlCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.compose.collectAsStateWithLifecycle @@ -49,6 +51,7 @@ import net.mullvad.mullvadvpn.compose.cell.SelectableCell import net.mullvad.mullvadvpn.compose.cell.SwitchComposeSubtitleCell import net.mullvad.mullvadvpn.compose.component.NavigateBackIconButton import net.mullvad.mullvadvpn.compose.component.ScaffoldWithMediumTopBar +import net.mullvad.mullvadvpn.compose.component.textResource import net.mullvad.mullvadvpn.compose.destinations.AutoConnectAndLockdownModeDestination import net.mullvad.mullvadvpn.compose.destinations.ContentBlockersInfoDialogDestination import net.mullvad.mullvadvpn.compose.destinations.CustomDnsInfoDialogDestination @@ -65,6 +68,7 @@ import net.mullvad.mullvadvpn.compose.dialog.WireguardCustomPortNavArgs import net.mullvad.mullvadvpn.compose.dialog.WireguardPortInfoDialogArgument import net.mullvad.mullvadvpn.compose.extensions.itemWithDivider import net.mullvad.mullvadvpn.compose.extensions.itemsIndexedWithDivider +import net.mullvad.mullvadvpn.compose.extensions.toAnnotatedString import net.mullvad.mullvadvpn.compose.state.VpnSettingsUiState import net.mullvad.mullvadvpn.compose.test.LAZY_LIST_LAST_ITEM_TEST_TAG import net.mullvad.mullvadvpn.compose.test.LAZY_LIST_QUANTUM_ITEM_OFF_TEST_TAG @@ -305,21 +309,39 @@ fun VpnSettingsScreen( text = stringResource(id = R.string.auto_connect_and_lockdown_mode_footer) ) } - } else { - item { - Spacer(modifier = Modifier.height(Dimens.cellLabelVerticalPadding)) - HeaderSwitchComposeCell( - title = stringResource(R.string.auto_connect), - isToggled = state.isAutoConnectEnabled, - isEnabled = true, - onCellClicked = { newValue -> onToggleAutoConnect(newValue) } - ) - } - item { - SwitchComposeSubtitleCell( - text = stringResource(id = R.string.auto_connect_footer) - ) - } + } + item { + Spacer(modifier = Modifier.height(Dimens.cellLabelVerticalPadding)) + HeaderSwitchComposeCell( + title = + stringResource( + if (state.systemVpnSettingsAvailable) { + R.string.auto_connect_legacy + } else { + R.string.auto_connect + } + ), + isToggled = state.isAutoConnectEnabled, + isEnabled = true, + onCellClicked = { newValue -> onToggleAutoConnect(newValue) } + ) + } + item { + SwitchComposeSubtitleCell( + text = + HtmlCompat.fromHtml( + if (state.systemVpnSettingsAvailable) { + textResource( + R.string.auto_connect_footer_legacy, + textResource(R.string.auto_connect_and_lockdown_mode) + ) + } else { + textResource(R.string.auto_connect_footer) + }, + HtmlCompat.FROM_HTML_MODE_COMPACT + ) + .toAnnotatedString(boldFontWeight = FontWeight.ExtraBold) + ) } item { Spacer(modifier = Modifier.height(Dimens.cellLabelVerticalPadding)) diff --git a/android/lib/resource/src/main/res/values/strings.xml b/android/lib/resource/src/main/res/values/strings.xml index b163c9f612b6..4400250dbc29 100644 --- a/android/lib/resource/src/main/res/values/strings.xml +++ b/android/lib/resource/src/main/res/values/strings.xml @@ -280,4 +280,6 @@ Verifying purchase... Copied logs to clipboard Split tunneling is disabled. + Auto-connect (legacy) + Always-on system setting instead by following the guide in %s above.]]> diff --git a/gui/locales/messages.pot b/gui/locales/messages.pot index ccd498d2c35a..4679499198ba 100644 --- a/gui/locales/messages.pot +++ b/gui/locales/messages.pot @@ -2061,6 +2061,9 @@ msgstr "" msgid "Auto-connect & \\nLockdown mode" msgstr "" +msgid "Auto-connect (legacy)" +msgstr "" + msgid "Auto-connect is called Always-on VPN in the Android system settings and it makes sure you are constantly connected to the VPN tunnel and auto connects after restart." msgstr "" @@ -2136,6 +2139,9 @@ msgstr "" msgid "No internet connection" msgstr "" +msgid "Please use the Always-on system setting instead by following the guide in %s above." +msgstr "" + msgid "Preferences" msgstr "" From 2dcc0f313db57785cafba47489cd01809207d47b Mon Sep 17 00:00:00 2001 From: Jonatan Rhodin Date: Tue, 12 Mar 2024 11:53:24 +0100 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28e5dc382d59..c882837effb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,8 +30,7 @@ Line wrap the file at 100 chars. Th #### Android - Add support for all screen orientations. - Add toggle for enabling or disabling split tunneling. -- Replace auto connect with auto connect and lockdown mode guide on platforms that has - system vpn settings. +- Add auto connect and lockdown mode guide on platforms that has system vpn settings. - Add 3D map to Connect screen. ### Changed @@ -40,7 +39,8 @@ Line wrap the file at 100 chars. Th #### Android - Migrate to Compose Navigation which also improves screen transition animations. -- Increase focus highlight opacity +- Increase focus highlight opacity. +- Set auto-connect setting as legacy on platforms with system vpn settings. ### Fixed - Continual excessive attempts to update the API IP were made after testing access methods.