diff options
| author | David Göransson <david.goransson@mullvad.net> | 2025-05-26 09:41:15 +0200 |
|---|---|---|
| committer | David Göransson <david.goransson@mullvad.net> | 2025-05-26 10:42:23 +0200 |
| commit | 22424b34a4eb445f8cf2e0787d3e2349ef75ee5f (patch) | |
| tree | de1e20c4d2a10c4dfd011f5f41300e8e6249a850 /android | |
| parent | 12b72a171e6e5e0005444685d0605f6021e9090f (diff) | |
| download | mullvadvpn-22424b34a4eb445f8cf2e0787d3e2349ef75ee5f.tar.xz mullvadvpn-22424b34a4eb445f8cf2e0787d3e2349ef75ee5f.zip | |
Fix and update lint baseline
Diffstat (limited to 'android')
10 files changed, 45 insertions, 145 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/ConnectUiStatePreviewParameterProvider.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/ConnectUiStatePreviewParameterProvider.kt index ea19fba8e7..0a332ba385 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/ConnectUiStatePreviewParameterProvider.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/ConnectUiStatePreviewParameterProvider.kt @@ -8,10 +8,10 @@ import net.mullvad.mullvadvpn.lib.model.GeoIpLocation import net.mullvad.mullvadvpn.lib.model.InAppNotification class ConnectUiStatePreviewParameterProvider : PreviewParameterProvider<ConnectUiState> { - override val values = sequenceOf(ConnectUiState.INITIAL) + generateOtherStates() + override val values = sequenceOf(ConnectUiState.INITIAL) + otherStates } -private fun generateOtherStates(): Sequence<ConnectUiState> = +private val otherStates = sequenceOf( TunnelStatePreviewData.generateConnectedState( featureIndicators = 8, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/CustomListLocationUiStatePreviewParameterProvider.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/CustomListLocationUiStatePreviewParameterProvider.kt index 2598c7a9b2..514005095b 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/CustomListLocationUiStatePreviewParameterProvider.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/CustomListLocationUiStatePreviewParameterProvider.kt @@ -20,7 +20,7 @@ class CustomListLocationUiStatePreviewParameterProvider : listOf( RelayLocationListItem( item = - RelayItemPreviewData.generateRelayItemCountry( + generateRelayItemCountry( name = "A relay", cityNames = listOf("City 1", "City 2"), relaysPerCity = 2, @@ -29,7 +29,7 @@ class CustomListLocationUiStatePreviewParameterProvider : ), RelayLocationListItem( item = - RelayItemPreviewData.generateRelayItemCountry( + generateRelayItemCountry( name = "Another relay", cityNames = listOf("City X", "City Y", "City Z"), diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemCheckableCellPreviewParameterProvider.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemCheckableCellPreviewParameterProvider.kt index df6a87602f..c0d4ddc063 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemCheckableCellPreviewParameterProvider.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemCheckableCellPreviewParameterProvider.kt @@ -1,7 +1,6 @@ package net.mullvad.mullvadvpn.compose.preview import androidx.compose.ui.tooling.preview.PreviewParameterProvider -import net.mullvad.mullvadvpn.compose.preview.RelayItemPreviewData.generateRelayItemCountry import net.mullvad.mullvadvpn.lib.model.RelayItem class RelayItemCheckableCellPreviewParameterProvider : diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemPreviewData.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemPreviewData.kt index 20f69e3bcd..3d706443d2 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemPreviewData.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemPreviewData.kt @@ -5,27 +5,20 @@ import net.mullvad.mullvadvpn.lib.model.Ownership import net.mullvad.mullvadvpn.lib.model.ProviderId import net.mullvad.mullvadvpn.lib.model.RelayItem -internal object RelayItemPreviewData { - fun generateRelayItemCountry( - name: String, - cityNames: List<String>, - relaysPerCity: Int, - active: Boolean = true, - ) = - RelayItem.Location.Country( - name = name, - id = name.generateCountryCode(), - cities = - cityNames.map { cityName -> - generateRelayItemCity( - cityName, - name.generateCountryCode(), - relaysPerCity, - active, - ) - }, - ) -} +fun generateRelayItemCountry( + name: String, + cityNames: List<String>, + relaysPerCity: Int, + active: Boolean = true, +) = + RelayItem.Location.Country( + name = name, + id = name.generateCountryCode(), + cities = + cityNames.map { cityName -> + generateRelayItemCity(cityName, name.generateCountryCode(), relaysPerCity, active) + }, + ) private fun generateRelayItemCity( name: String, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemStatusCellPreviewParameterProvider.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemStatusCellPreviewParameterProvider.kt index 2e3494c79a..fcb1fdd194 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemStatusCellPreviewParameterProvider.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemStatusCellPreviewParameterProvider.kt @@ -1,7 +1,6 @@ package net.mullvad.mullvadvpn.compose.preview import androidx.compose.ui.tooling.preview.PreviewParameterProvider -import net.mullvad.mullvadvpn.compose.preview.RelayItemPreviewData.generateRelayItemCountry import net.mullvad.mullvadvpn.lib.model.RelayItem class RelayItemStatusCellPreviewParameterProvider : diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayListItemPreviewData.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayListItemPreviewData.kt index 58bea4810e..aaf5fd5a6e 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayListItemPreviewData.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayListItemPreviewData.kt @@ -28,7 +28,7 @@ object RelayListItemPreviewData { ), locations = listOf( - RelayItemPreviewData.generateRelayItemCountry( + generateRelayItemCountry( name = "Country", cityNames = listOf("City"), relaysPerCity = 2, @@ -48,13 +48,13 @@ object RelayListItemPreviewData { add(RelayListItem.LocationHeader) val locations = listOf( - RelayItemPreviewData.generateRelayItemCountry( + generateRelayItemCountry( name = "First Country", cityNames = listOf("Capital City", "Minor City"), relaysPerCity = 2, active = true, ), - RelayItemPreviewData.generateRelayItemCountry( + generateRelayItemCountry( name = "Second Country", cityNames = listOf("Medium City", "Small City", "Vivec City"), relaysPerCity = 1, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AutoConnectAndLockdownModeScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AutoConnectAndLockdownModeScreen.kt index 8f3b07806a..6fffdc70e8 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AutoConnectAndLockdownModeScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AutoConnectAndLockdownModeScreen.kt @@ -56,6 +56,7 @@ import net.mullvad.mullvadvpn.R import net.mullvad.mullvadvpn.compose.button.PrimaryButton import net.mullvad.mullvadvpn.compose.component.NavigateBackIconButton import net.mullvad.mullvadvpn.compose.component.ScaffoldWithMediumTopBar +import net.mullvad.mullvadvpn.compose.screen.PAGES.Companion.annotatedTopText import net.mullvad.mullvadvpn.compose.transitions.SlideInFromRightTransition import net.mullvad.mullvadvpn.lib.common.util.openVpnSettings import net.mullvad.mullvadvpn.lib.theme.AppTheme @@ -300,26 +301,28 @@ private fun buildLockdownTopText() = buildAnnotatedString { } } -private enum class PAGES( - val annotatedTopText: @Composable () -> AnnotatedString, - val image: Int, - val bottomText: Int, -) { +private enum class PAGES(val image: Int, val bottomText: Int) { FIRST( - annotatedTopText = - @Composable { buildTopText(id = R.string.auto_connect_carousel_first_slide_top_text) }, R.drawable.carousel_slide_1_cogwheel, R.string.auto_connect_carousel_first_slide_bottom_text, ), SECOND( - annotatedTopText = - @Composable { buildTopText(id = R.string.auto_connect_carousel_second_slide_top_text) }, R.drawable.carousel_slide_2_always_on, R.string.auto_connect_carousel_second_slide_bottom_text, ), THIRD( - annotatedTopText = @Composable { buildLockdownTopText() }, R.drawable.carousel_slide_3_block_connections, R.string.auto_connect_carousel_third_slide_bottom_text, - ), + ); + + companion object { + + @Composable + fun PAGES.annotatedTopText(): AnnotatedString = + when (this) { + FIRST -> buildTopText(id = R.string.auto_connect_carousel_first_slide_top_text) + SECOND -> buildTopText(id = R.string.auto_connect_carousel_second_slide_top_text) + THIRD -> buildLockdownTopText() + } + } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SplitTunnelingViewModelState.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SplitTunnelingViewModelState.kt index ee96248f4b..9dda1ddaff 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SplitTunnelingViewModelState.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SplitTunnelingViewModelState.kt @@ -22,19 +22,22 @@ data class SplitTunnelingViewModelState( ?.let { (excluded, included) -> SplitTunnelingUiState.ShowAppList( enabled = enabled, - excludedApps = excluded.sort(), + excludedApps = excluded.sortedWith(descendingByNameComparator), includedApps = if (showSystemApps) { included } else { included.filter { appData -> !appData.isSystemApp } } - .sort(), + .sortedWith(descendingByNameComparator), showSystemApps = showSystemApps, isModal = isModal, ) } ?: SplitTunnelingUiState.Loading(enabled = enabled, isModal) } -} -private fun List<AppData>.sort() = sortedBy { it.name.lowercase() } + companion object { + private val descendingByNameComparator = + compareByDescending<AppData> { it.name.lowercase() } + } +} diff --git a/android/config/lint-baseline.xml b/android/config/lint-baseline.xml index bc01f77561..674a462903 100644 --- a/android/config/lint-baseline.xml +++ b/android/config/lint-baseline.xml @@ -63,106 +63,7 @@ id="Aligned16KB" message="The native library `arm64-v8a/libmockkjvmtiagent.so` (from `io.mockk:mockk-agent-android:1.14.2`) is not 16 KB aligned"> <location - file="../../../../.gradle/caches/8.14.1/transforms/5539342577cc00b53e44ce9b0769cbe0/transformed/mockk-agent-android-1.14.2/jni/arm64-v8a/libmockkjvmtiagent.so"/> - </issue> - - <issue - id="SyntheticAccessor" - message="Access to `private` method `buildTopText` of class `AutoConnectAndLockdownModeScreenKt` requires synthetic accessor" - errorLine1=" @Composable { buildTopText(id = R.string.auto_connect_carousel_first_slide_top_text) }," - errorLine2=" ~~~~~~~~~~~~"> - <location - file="src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AutoConnectAndLockdownModeScreen.kt" - line="310" - column="27"/> - </issue> - - <issue - id="SyntheticAccessor" - message="Access to `private` method `buildTopText` of class `AutoConnectAndLockdownModeScreenKt` requires synthetic accessor" - errorLine1=" @Composable { buildTopText(id = R.string.auto_connect_carousel_second_slide_top_text) }," - errorLine2=" ~~~~~~~~~~~~"> - <location - file="src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AutoConnectAndLockdownModeScreen.kt" - line="316" - column="27"/> - </issue> - - <issue - id="SyntheticAccessor" - message="Access to `private` method `buildLockdownTopText` of class `AutoConnectAndLockdownModeScreenKt` requires synthetic accessor" - errorLine1=" annotatedTopText = @Composable { buildLockdownTopText() }," - errorLine2=" ~~~~~~~~~~~~~~~~~~~~"> - <location - file="src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AutoConnectAndLockdownModeScreen.kt" - line="321" - column="42"/> - </issue> - - <issue - id="SyntheticAccessor" - message="Access to `private` method `generateOtherStates` of class `ConnectUiStatePreviewParameterProviderKt` requires synthetic accessor" - errorLine1=" override val values = sequenceOf(ConnectUiState.INITIAL) + generateOtherStates()" - errorLine2=" ~~~~~~~~~~~~~~~~~~~"> - <location - file="src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/ConnectUiStatePreviewParameterProvider.kt" - line="11" - column="64"/> - </issue> - - <issue - id="SyntheticAccessor" - message="Access to `private` method `generateCountryCode` of class `RelayItemPreviewDataKt` requires synthetic accessor" - errorLine1=" id = name.generateCountryCode()," - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~"> - <location - file="src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemPreviewData.kt" - line="17" - column="18"/> - </issue> - - <issue - id="SyntheticAccessor" - message="Access to `private` method `generateRelayItemCity` of class `RelayItemPreviewDataKt` requires synthetic accessor" - errorLine1=" generateRelayItemCity(" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~"> - <location - file="src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemPreviewData.kt" - line="20" - column="21"/> - </issue> - - <issue - id="SyntheticAccessor" - message="Access to `private` method `generateCountryCode` of class `RelayItemPreviewDataKt` requires synthetic accessor" - errorLine1=" name.generateCountryCode()," - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~"> - <location - file="src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/RelayItemPreviewData.kt" - line="22" - column="25"/> - </issue> - - <issue - id="SyntheticAccessor" - message="Access to `private` method `sort` of class `SplitTunnelingViewModelStateKt` requires synthetic accessor" - errorLine1=" excludedApps = excluded.sort()," - errorLine2=" ~~~~~~~~~~~~~"> - <location - file="src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SplitTunnelingViewModelState.kt" - line="25" - column="36"/> - </issue> - - <issue - id="SyntheticAccessor" - message="Access to `private` method `sort` of class `SplitTunnelingViewModelStateKt` requires synthetic accessor" - errorLine1=" if (showSystemApps) {" - errorLine2=" ^"> - <location - file="src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SplitTunnelingViewModelState.kt" - line="27" - column="25"/> + file="*/caches/8.14.1/transforms/5539342577cc00b53e44ce9b0769cbe0/transformed/mockk-agent-android-1.14.2/jni/arm64-v8a/libmockkjvmtiagent.so"/> </issue> </issues> diff --git a/android/lib/billing/build.gradle.kts b/android/lib/billing/build.gradle.kts index 69e160f84f..9c124d7358 100644 --- a/android/lib/billing/build.gradle.kts +++ b/android/lib/billing/build.gradle.kts @@ -40,6 +40,8 @@ android { ) } } + + lint { baseline = file("${rootProject.projectDir.absolutePath}/config/lint-baseline.xml") } } dependencies { |
