summaryrefslogtreecommitdiffhomepage
path: root/android/app/src
diff options
context:
space:
mode:
authorDavid Göransson <david.goransson@mullvad.net>2024-10-21 12:56:41 +0200
committerDavid Göransson <david.goransson@mullvad.net>2024-10-21 12:56:41 +0200
commit837da623777207d8097b571168772f0c6027f778 (patch)
treec2162f73dddd4c4f124a7aa19638eb83d5f9f526 /android/app/src
parentde12dc2a35fee8bdf4810373cc5b83757b047d92 (diff)
parentfa120ef14ca1c85105f92c1bd6bca59845a512c6 (diff)
downloadmullvadvpn-837da623777207d8097b571168772f0c6027f778.tar.xz
mullvadvpn-837da623777207d8097b571168772f0c6027f778.zip
Merge branch 'feature-indicators-sometimes-flash-droid-1447'
Diffstat (limited to 'android/app/src')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/connectioninfo/ConnectionDetailPanel.kt19
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/connectioninfo/FeatureIndicatorsPanel.kt4
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ConnectScreen.kt38
3 files changed, 43 insertions, 18 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 b6ab3f2166..5feffc83a9 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
@@ -1,5 +1,6 @@
package net.mullvad.mullvadvpn.compose.component.connectioninfo
+import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
@@ -14,26 +15,28 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.constraintlayout.compose.Dimension
import net.mullvad.mullvadvpn.R
+import net.mullvad.mullvadvpn.compose.screen.ConnectionDetails
import net.mullvad.mullvadvpn.compose.test.LOCATION_INFO_CONNECTION_OUT_TEST_TAG
import net.mullvad.mullvadvpn.lib.model.TransportProtocol
import net.mullvad.mullvadvpn.lib.model.TunnelEndpoint
-import net.mullvad.mullvadvpn.lib.model.TunnelState
import net.mullvad.mullvadvpn.lib.theme.Dimens
@Composable
-fun ConnectionDetailPanel(tunnelState: TunnelState.Connected) {
+fun ConnectionDetailPanel(connectionDetails: ConnectionDetails) {
ConnectionInfoHeader(
stringResource(R.string.connect_panel_connection_details),
Modifier.fillMaxWidth().padding(bottom = Dimens.smallPadding),
)
- ConnectionDetails(
- tunnelState.endpoint.toInAddress(),
- tunnelState.location()?.ipv4?.hostAddress,
- tunnelState.location()?.ipv6?.hostAddress,
- modifier = Modifier.padding(bottom = Dimens.smallPadding),
- )
+ AnimatedContent(connectionDetails, label = "ConnectionDetails") {
+ ConnectionDetails(
+ it.inAddress,
+ it.outIpv4Address,
+ it.outIpv6Address,
+ modifier = Modifier.padding(bottom = Dimens.smallPadding),
+ )
+ }
}
@Suppress("LongMethod")
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/connectioninfo/FeatureIndicatorsPanel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/connectioninfo/FeatureIndicatorsPanel.kt
index 8815149f27..8b04017f0a 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/connectioninfo/FeatureIndicatorsPanel.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/connectioninfo/FeatureIndicatorsPanel.kt
@@ -70,7 +70,9 @@ fun FeatureIndicators(
MullvadFeatureChip(text = features[index].text())
}
- // Spacing are added to compensate for when the
+ // Spacing are added to compensate for when there are no feature indicators, since each feature
+ // indicator has built-in padding. Padding looks the same towards Switch Location button with or
+ // without feature indicators.
if (features.isEmpty() && !expanded) {
Spacer(Modifier.height(Dimens.smallSpacer))
}
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 9e99ae2daa..26a3382a5f 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
@@ -61,6 +61,7 @@ import com.ramcosta.composedestinations.generated.destinations.SettingsDestinati
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import com.ramcosta.composedestinations.result.ResultRecipient
import kotlinx.coroutines.launch
+import mullvad_daemon.management_interface.tunnelState
import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.compose.button.ConnectionButton
import net.mullvad.mullvadvpn.compose.button.SwitchLocationButton
@@ -70,6 +71,7 @@ import net.mullvad.mullvadvpn.compose.component.MullvadCircularProgressIndicator
import net.mullvad.mullvadvpn.compose.component.ScaffoldWithTopBarAndDeviceName
import net.mullvad.mullvadvpn.compose.component.connectioninfo.ConnectionDetailPanel
import net.mullvad.mullvadvpn.compose.component.connectioninfo.FeatureIndicatorsPanel
+import net.mullvad.mullvadvpn.compose.component.connectioninfo.toInAddress
import net.mullvad.mullvadvpn.compose.component.drawVerticalScrollbar
import net.mullvad.mullvadvpn.compose.component.notificationbanner.NotificationBanner
import net.mullvad.mullvadvpn.compose.extensions.createOpenAccountPageHook
@@ -93,6 +95,7 @@ import net.mullvad.mullvadvpn.lib.map.AnimatedMap
import net.mullvad.mullvadvpn.lib.map.data.GlobeColors
import net.mullvad.mullvadvpn.lib.map.data.LocationMarkerColors
import net.mullvad.mullvadvpn.lib.map.data.Marker
+import net.mullvad.mullvadvpn.lib.model.FeatureIndicator
import net.mullvad.mullvadvpn.lib.model.GeoIpLocation
import net.mullvad.mullvadvpn.lib.model.LatLong
import net.mullvad.mullvadvpn.lib.model.Latitude
@@ -343,15 +346,17 @@ private fun ConnectionCard(
) {
ConnectionCardHeader(state, state.location, expanded) { expanded = !expanded }
+ Logger.d("Tunnelstate: ${state.tunnelState}, expanded: $expanded")
AnimatedContent(
- state.tunnelState as? TunnelState.Connected to expanded,
+ (state.tunnelState as? TunnelState.Connected)?.featureIndicators,
modifier = Modifier.weight(1f, fill = false),
label = "connection_card_connection_details",
- ) { (connectedState, isExpanded) ->
- if (connectedState != null) {
+ ) { featureIndicators ->
+ if (featureIndicators != null) {
ConnectionInfo(
- connectedState,
- isExpanded,
+ featureIndicators,
+ (state.tunnelState as? TunnelState.Connected)?.toConnectionsDetails(),
+ expanded,
onToggleExpand = { expanded = !expanded },
)
} else {
@@ -436,7 +441,8 @@ private fun GeoIpLocation?.asString(): String {
@Composable
private fun ConnectionInfo(
- tunnelState: TunnelState.Connected,
+ featureIndicators: List<FeatureIndicator>,
+ connectionDetails: ConnectionDetails?,
expanded: Boolean,
onToggleExpand: () -> Unit,
) {
@@ -457,15 +463,29 @@ private fun ConnectionInfo(
)
.verticalScroll(scrollState)
) {
- FeatureIndicatorsPanel(tunnelState.featureIndicators, expanded, onToggleExpand)
+ FeatureIndicatorsPanel(featureIndicators, expanded, onToggleExpand)
- if (expanded) {
- ConnectionDetailPanel(tunnelState)
+ if (expanded && connectionDetails != null) {
+ ConnectionDetailPanel(connectionDetails)
}
}
}
}
+data class ConnectionDetails(
+ val inAddress: String,
+ val outIpv4Address: String?,
+ val outIpv6Address: String?,
+)
+
+@Composable
+fun TunnelState.Connected.toConnectionsDetails(): ConnectionDetails =
+ ConnectionDetails(
+ endpoint.toInAddress(),
+ location()?.ipv4?.hostAddress,
+ location()?.ipv6?.hostAddress,
+ )
+
@Composable
private fun ButtonPanel(
state: ConnectUiState,