diff options
| author | Kalle Lindström <karl.lindstrom@mullvad.net> | 2024-12-11 14:59:17 +0100 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2024-12-12 11:06:38 +0100 |
| commit | 15bedbc69db3e4524e50b93c1f435e03252795eb (patch) | |
| tree | 76addd1ef1c536edf2c907e8768b1cdb607aaf41 /android/app | |
| parent | 527cd1170c9ed3cd97e9e92f24a48c7776ae350e (diff) | |
| download | mullvadvpn-15bedbc69db3e4524e50b93c1f435e03252795eb.tar.xz mullvadvpn-15bedbc69db3e4524e50b93c1f435e03252795eb.zip | |
Remove select location horizontal pager on TV
Diffstat (limited to 'android/app')
| -rw-r--r-- | android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreen.kt | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreen.kt index 36a3ed2eee..079c1e175b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/location/SelectLocationScreen.kt @@ -1,6 +1,7 @@ package net.mullvad.mullvadvpn.compose.screen.location import android.annotation.SuppressLint +import android.content.res.Configuration import androidx.compose.animation.AnimatedContent import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement @@ -352,33 +353,46 @@ private fun RelayLists( openDaitaSettings: () -> Unit, onUpdateBottomSheetState: (LocationBottomSheetState) -> Unit, ) { - val pagerState = - rememberPagerState( - initialPage = state.relayListType.ordinal, - pageCount = { RelayListType.entries.size }, - ) - LaunchedEffect(state.relayListType) { - val index = state.relayListType.ordinal - pagerState.animateScrollToPage(index) - } - - HorizontalPager( - state = pagerState, - userScrollEnabled = false, - beyondViewportPageCount = - if (state.multihopEnabled) { - 1 - } else { - 0 - }, - ) { pageIndex -> + // This is a workaround for the HorizontalPager being broken on Android TV when it contains + // focusable views and you navigate with the D-pad. Remove this code once DROID-1639 is fixed. + val configuration = LocalContext.current.resources.configuration + if (configuration.navigation == Configuration.NAVIGATION_DPAD) { SelectLocationList( backgroundColor = backgroundColor, - relayListType = RelayListType.entries[pageIndex], + relayListType = state.relayListType, onSelectRelay = onSelectRelay, openDaitaSettings = openDaitaSettings, onUpdateBottomSheetState = onUpdateBottomSheetState, ) + } else { + val pagerState = + rememberPagerState( + initialPage = state.relayListType.ordinal, + pageCount = { RelayListType.entries.size }, + ) + LaunchedEffect(state.relayListType) { + val index = state.relayListType.ordinal + pagerState.animateScrollToPage(index) + } + + HorizontalPager( + state = pagerState, + userScrollEnabled = false, + beyondViewportPageCount = + if (state.multihopEnabled) { + 1 + } else { + 0 + }, + ) { pageIndex -> + SelectLocationList( + backgroundColor = backgroundColor, + relayListType = RelayListType.entries[pageIndex], + onSelectRelay = onSelectRelay, + openDaitaSettings = openDaitaSettings, + onUpdateBottomSheetState = onUpdateBottomSheetState, + ) + } } } |
