summaryrefslogtreecommitdiffhomepage
path: root/android/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'android/app/src')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/connectioninfo/ConnectionDetailPanel.kt53
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt35
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Clipboard.kt1
3 files changed, 48 insertions, 41 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/connectioninfo/ConnectionDetailPanel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/connectioninfo/ConnectionDetailPanel.kt
index c0a005ef40..08eec406bf 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/connectioninfo/ConnectionDetailPanel.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/connectioninfo/ConnectionDetailPanel.kt
@@ -24,7 +24,10 @@ import net.mullvad.mullvadvpn.lib.ui.tag.LOCATION_INFO_CONNECTION_IN_TEST_TAG
import net.mullvad.mullvadvpn.lib.ui.tag.LOCATION_INFO_CONNECTION_OUT_TEST_TAG
@Composable
-fun ConnectionDetailPanel(connectionDetails: ConnectionDetails) {
+fun ConnectionDetailPanel(
+ connectionDetails: ConnectionDetails,
+ enableSelectableText: Boolean = true,
+) {
ConnectionInfoHeader(
stringResource(R.string.connect_panel_connection_details),
@@ -37,6 +40,7 @@ fun ConnectionDetailPanel(connectionDetails: ConnectionDetails) {
it.outIpv4Address,
it.outIpv6Address,
modifier = Modifier.padding(bottom = Dimens.smallPadding),
+ enableSelectableText = enableSelectableText,
)
}
}
@@ -48,6 +52,7 @@ fun ConnectionDetails(
outIPV4: String?,
outIPV6: String?,
modifier: Modifier = Modifier,
+ enableSelectableText: Boolean = true,
) {
ConstraintLayout(modifier = modifier.fillMaxWidth()) {
val (inAddrHeader, inAddr, outAddrV4Header, outAddrV4, outAddrV6Header, outAddrV6) =
@@ -131,15 +136,21 @@ fun ConnectionDetails(
width = Dimension.fillToConstraints
}
) {
- SelectionContainer {
- Text(
- modifier = Modifier.testTag(LOCATION_INFO_CONNECTION_OUT_TEST_TAG),
- text = outIPV4,
- color = MaterialTheme.colorScheme.onPrimary,
- style = MaterialTheme.typography.bodySmall,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis,
- )
+ val outIpV4Text =
+ @Composable {
+ Text(
+ modifier = Modifier.testTag(LOCATION_INFO_CONNECTION_OUT_TEST_TAG),
+ text = outIPV4,
+ color = MaterialTheme.colorScheme.onPrimary,
+ style = MaterialTheme.typography.bodySmall,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
+ )
+ }
+ if (enableSelectableText) {
+ SelectionContainer(content = outIpV4Text)
+ } else {
+ outIpV4Text()
}
}
}
@@ -176,14 +187,20 @@ fun ConnectionDetails(
width = Dimension.fillToConstraints
}
) {
- SelectionContainer {
- Text(
- text = outIPV6,
- color = MaterialTheme.colorScheme.onPrimary,
- style = MaterialTheme.typography.bodySmall,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis,
- )
+ val outIpV6Text =
+ @Composable {
+ Text(
+ text = outIPV6,
+ color = MaterialTheme.colorScheme.onPrimary,
+ style = MaterialTheme.typography.bodySmall,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
+ )
+ }
+ if (enableSelectableText) {
+ SelectionContainer(content = outIpV6Text)
+ } else {
+ outIpV6Text()
}
}
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt
index 17aad41efc..94db024b41 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt
@@ -33,6 +33,7 @@ import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.mutableStateOf
@@ -43,13 +44,10 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
-import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.FocusRequester
-import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.layout
-import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.LocalUriHandler
@@ -353,26 +351,12 @@ fun ConnectScreen(
if (isTv()) {
Scaffold(
- modifier =
- Modifier.focusProperties {
- onEnter = {
- // When we return to this screen from SelectLocationScreen the focus is
- // sometimes put on the TV navigation drawer, which causes it expand
- // (when it was previously not expanded). When returning from
- // SelectLocationScreen we get a FocusDirection.Down event, so we focus
- // on the switch location composable.
- // When on TV and we return from account or settings we get a
- // FocusDirection.Enter event, so focus remains on the navigation drawer.
- if (requestedFocusDirection == FocusDirection.Down) contentFocusRequester
- else FocusRequester.Default
- }
- },
snackbarHost = {
SnackbarHost(
snackbarHostState,
snackbar = { snackbarData -> MullvadSnackbar(snackbarData = snackbarData) },
)
- },
+ }
) {
NavigationDrawerTv(
daysLeftUntilExpiry = state.daysLeftUntilExpiry,
@@ -383,6 +367,7 @@ fun ConnectScreen(
content(it)
}
}
+ LaunchedEffect(Unit) { contentFocusRequester.requestFocus() }
} else {
ScaffoldWithTopBarAndDeviceName(
topBarColor = state.tunnelState.topBarColor(),
@@ -666,7 +651,7 @@ private fun ConnectionInfo(
FeatureIndicatorsPanel(featureIndicators, expanded, onToggleExpand, onNavigateToFeature)
if (expanded && connectionDetails != null) {
- ConnectionDetailPanel(connectionDetails)
+ ConnectionDetailPanel(connectionDetails, enableSelectableText = !isTv())
}
}
}
@@ -689,7 +674,7 @@ fun TunnelState.Connected.toConnectionsDetails(): ConnectionDetails =
@Composable
private fun ButtonPanel(
state: ConnectUiState,
- focusRequester: FocusRequester,
+ selectButtonFocusRequester: FocusRequester,
onSwitchLocationClick: () -> Unit,
onDisconnectClick: () -> Unit,
onReconnectClick: () -> Unit,
@@ -714,12 +699,18 @@ private fun ButtonPanel(
stringResource(id = R.string.switch_location)
},
onSwitchLocation = onSwitchLocationClick,
- reconnectClick = { handleThrottledAction(onReconnectClick) },
+ reconnectClick = {
+ handleThrottledAction {
+ onReconnectClick()
+ selectButtonFocusRequester.requestFocus()
+ }
+ },
isReconnectButtonEnabled =
state.tunnelState is TunnelState.Connected ||
state.tunnelState is TunnelState.Connecting,
modifier =
- Modifier.testTag(SELECT_LOCATION_BUTTON_TEST_TAG).focusRequester(focusRequester),
+ Modifier.testTag(SELECT_LOCATION_BUTTON_TEST_TAG)
+ .focusRequester(selectButtonFocusRequester),
reconnectButtonTestTag = RECONNECT_BUTTON_TEST_TAG,
)
Spacer(Modifier.height(Dimens.buttonVerticalPadding))
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Clipboard.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Clipboard.kt
index 5c2c449037..3dbe8e7565 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Clipboard.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/Clipboard.kt
@@ -8,7 +8,6 @@ import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.platform.LocalClipboard
-import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.toClipEntry
import kotlinx.coroutines.launch