diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/ConnectionButton.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/ConnectionButton.kt index 06b40747302b..78521592478f 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/ConnectionButton.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/button/ConnectionButton.kt @@ -100,7 +100,7 @@ fun ConnectionButton( @Preview @Composable -fun ConnectionButton() { +fun PreviewConnectionButton() { AppTheme { ConnectionButton( text = "Disconnect", diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SplitTunnelingCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SplitTunnelingCell.kt index aaf0d288382f..1bf64e006229 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SplitTunnelingCell.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/SplitTunnelingCell.kt @@ -27,7 +27,6 @@ import net.mullvad.mullvadvpn.R import net.mullvad.mullvadvpn.lib.theme.AppTheme import net.mullvad.mullvadvpn.lib.theme.Dimens import net.mullvad.mullvadvpn.lib.theme.typeface.listItemText -import org.koin.androidx.compose.get @Preview @Composable diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/CollapsingToolbarScaffold.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/CollapsingToolbarScaffold.kt index f4b81826bc02..0856fc196f77 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/CollapsingToolbarScaffold.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/CollapsingToolbarScaffold.kt @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue @@ -71,7 +72,7 @@ fun CollapsingToolbarScaffold( enabled = isEnabledWhenCollapsable && isCollapsable, toolbar = { toolbar() } ) { - var bodyHeight by remember { mutableStateOf(0) } + var bodyHeight by remember { mutableIntStateOf(0) } BoxWithConstraints( modifier = diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Text.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Text.kt index 79112f58ff75..39e3382a0967 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Text.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/Text.kt @@ -4,6 +4,7 @@ import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue @@ -71,7 +72,7 @@ fun AutoResizeText( style: TextStyle = LocalTextStyle.current, maxLines: Int = Int.MAX_VALUE, ) { - var adjustedFontSize by remember { mutableStateOf(maxTextSize.value) } + var adjustedFontSize by remember { mutableFloatStateOf(maxTextSize.value) } var isReadyToDraw by remember { mutableStateOf(false) } Text( diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt index df31400ca28c..301ee649b168 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/ChangelogDialog.kt @@ -28,7 +28,7 @@ import net.mullvad.mullvadvpn.lib.theme.Dimens @Composable fun ChangelogDialog(changesList: List, version: String, onDismiss: () -> Unit) { AlertDialog( - onDismissRequest = { onDismiss() }, + onDismissRequest = onDismiss, title = { Text( text = version, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/extensions/ResourcesExtensions.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/extensions/ResourcesExtensions.kt index dca2a6aeb944..89d985a40837 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/extensions/ResourcesExtensions.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/extensions/ResourcesExtensions.kt @@ -23,18 +23,14 @@ private fun getExpiryQuantityString( val remainingTimeInfo = remainingTime.toPeriodTo(accountExpiry, PeriodType.yearMonthDayTime()) - if (remainingTimeInfo.years > 0) { - return getRemainingText(resources, R.plurals.years_left, remainingTimeInfo.years) + return if (remainingTimeInfo.years > 0) { + getRemainingText(resources, R.plurals.years_left, remainingTimeInfo.years) } else if (remainingTimeInfo.months >= 3) { - return getRemainingText(resources, R.plurals.months_left, remainingTimeInfo.months) + getRemainingText(resources, R.plurals.months_left, remainingTimeInfo.months) } else if (remainingTimeInfo.months > 0 || remainingTimeInfo.days >= 1) { - return getRemainingText( - resources, - R.plurals.days_left, - remainingTime.standardDays.toInt() - ) + getRemainingText(resources, R.plurals.days_left, remainingTime.standardDays.toInt()) } else { - return resources.getString(R.string.less_than_a_day_left) + resources.getString(R.string.less_than_a_day_left) } } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt index 863d938506f1..df7d225deb32 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt @@ -85,7 +85,7 @@ fun AccountScreen( ) CollapsingTopBar( backgroundColor = MaterialTheme.colorScheme.secondary, - onBackClicked = { onBackClick() }, + onBackClicked = onBackClick, title = stringResource(id = R.string.settings_account), progress = progress, modifier = scaffoldModifier, @@ -153,7 +153,7 @@ fun AccountScreen( if (BuildConfig.BUILD_TYPE != BuildTypes.RELEASE) { ActionButton( text = stringResource(id = R.string.manage_account), - onClick = { onManageAccountClick() }, + onClick = onManageAccountClick, modifier = Modifier.padding( start = Dimens.sideMargin, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SelectLocationUiState.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SelectLocationUiState.kt index 9d230a98feda..fece45f0aa91 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SelectLocationUiState.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SelectLocationUiState.kt @@ -4,7 +4,7 @@ import net.mullvad.mullvadvpn.relaylist.RelayCountry import net.mullvad.mullvadvpn.relaylist.RelayItem sealed interface SelectLocationUiState { - object Loading : SelectLocationUiState + data object Loading : SelectLocationUiState data class ShowData(val countries: List, val selectedRelay: RelayItem?) : SelectLocationUiState diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SplitTunnelingUiState.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SplitTunnelingUiState.kt index 1ebb8fb379b1..77522935163d 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SplitTunnelingUiState.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SplitTunnelingUiState.kt @@ -3,7 +3,7 @@ package net.mullvad.mullvadvpn.compose.state import net.mullvad.mullvadvpn.applist.AppData sealed interface SplitTunnelingUiState { - object Loading : SplitTunnelingUiState + data object Loading : SplitTunnelingUiState data class ShowAppList( val excludedApps: List = emptyList(), diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt index 27b1eb694db5..69fd7275e70a 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/dataproxy/MullvadProblemReport.kt @@ -71,9 +71,8 @@ class MullvadProblemReport { GlobalScope.actor(Dispatchers.Default, Channel.UNLIMITED) { try { while (true) { - val command = channel.receive() - when (command) { + when (val command = channel.receive()) { is Command.Collect -> doCollect() is Command.Load -> command.logs.complete(doLoad()) is Command.Send -> command.result.complete(doSend()) @@ -97,10 +96,10 @@ class MullvadProblemReport { doCollect() } - if (isCollected) { - return problemReportPath.await().readText() + return if (isCollected) { + problemReportPath.await().readText() } else { - return "Failed to collect logs for problem report" + "Failed to collect logs for problem report" } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCity.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCity.kt index eee85252cdaa..d1a3332a78b6 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCity.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCity.kt @@ -16,5 +16,4 @@ data class RelayCity( override val hasChildren get() = relays.isNotEmpty() - } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCountry.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCountry.kt index 6c9367aacd7c..d418fd3a4ae3 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCountry.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayCountry.kt @@ -16,5 +16,4 @@ data class RelayCountry( override val hasChildren get() = cities.isNotEmpty() - } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/ChangelogDataProvider.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/ChangelogDataProvider.kt index 8ce36fd717f0..c1dc72ebfe52 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/ChangelogDataProvider.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/ChangelogDataProvider.kt @@ -7,7 +7,7 @@ import java.io.IOException private const val CHANGELOG_FILE = "en-US/default.txt" private const val EMPTY_DEFAULT_STRING_WHEN_UNABLE_TO_READ_CHANGELOG = "" -class ChangelogDataProvider(var assets: AssetManager) : IChangelogDataProvider { +class ChangelogDataProvider(private var assets: AssetManager) : IChangelogDataProvider { override fun getChangelog(): String { return try { assets.open(CHANGELOG_FILE).bufferedReader().use { it.readText() } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/FlowUtils.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/FlowUtils.kt index 77caddec8537..d18e4f8fc988 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/FlowUtils.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/FlowUtils.kt @@ -13,7 +13,7 @@ import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionState import net.mullvad.talpid.util.EventNotifier fun Animation.transitionFinished(): Flow = - callbackFlow { + callbackFlow { val transitionAnimationListener = object : Animation.AnimationListener { override fun onAnimationStart(animation: Animation?) {} @@ -44,12 +44,11 @@ fun Flow.flatMapReadyConnectionOrDefault( } } -fun callbackFlowFromNotifier(notifier: EventNotifier) = - callbackFlow { - val handler: (T) -> Unit = { value -> trySend(value) } - notifier.subscribe(this, handler) - awaitClose { notifier.unsubscribe(this) } - } +fun callbackFlowFromNotifier(notifier: EventNotifier) = callbackFlow { + val handler: (T) -> Unit = { value -> trySend(value) } + notifier.subscribe(this, handler) + awaitClose { notifier.unsubscribe(this) } +} inline fun combine( flow: Flow, diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/LinearInterpolation.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/LinearInterpolation.kt index 750780aa6aa6..ff03844e91b2 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/LinearInterpolation.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/util/LinearInterpolation.kt @@ -22,11 +22,11 @@ class LinearInterpolation { var updated = true get() { - if (field == true) { + return if (field) { field = false - return true + true } else { - return false + false } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ChangelogViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ChangelogViewModel.kt index bbfac3e02404..1c541944d2df 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ChangelogViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ChangelogViewModel.kt @@ -40,5 +40,5 @@ class ChangelogViewModel( sealed class ChangelogDialogUiState { data class Show(val changes: List) : ChangelogDialogUiState() - object Hide : ChangelogDialogUiState() + data object Hide : ChangelogDialogUiState() } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt index 6fb00b1922a6..07e8f487053f 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt @@ -26,23 +26,23 @@ class LoginViewModel( val accountHistory = accountRepository.accountHistoryEvents sealed class LoginUiState { - object Default : LoginUiState() + data object Default : LoginUiState() - object Loading : LoginUiState() + data object Loading : LoginUiState() data class Success(val isOutOfTime: Boolean) : LoginUiState() - object CreatingAccount : LoginUiState() + data object CreatingAccount : LoginUiState() - object AccountCreated : LoginUiState() + data object AccountCreated : LoginUiState() - object UnableToCreateAccountError : LoginUiState() + data object UnableToCreateAccountError : LoginUiState() - object InvalidAccountError : LoginUiState() + data object InvalidAccountError : LoginUiState() data class TooManyDevicesError(val accountToken: String) : LoginUiState() - object TooManyDevicesMissingListError : LoginUiState() + data object TooManyDevicesMissingListError : LoginUiState() data class OtherError(val errorMessage: String) : LoginUiState() diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModelState.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModelState.kt index fbcc60258a7b..aba6dd7e366f 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModelState.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/VpnSettingsViewModelState.kt @@ -199,27 +199,27 @@ data class VpnSettingsViewModelState( } sealed class VpnSettingsDialogState { - object NoDialog : VpnSettingsDialogState() + data object NoDialog : VpnSettingsDialogState() data class MtuDialog(val mtuEditValue: String) : VpnSettingsDialogState() data class DnsDialog(val stagedDns: StagedDns) : VpnSettingsDialogState() - object LocalNetworkSharingInfoDialog : VpnSettingsDialogState() + data object LocalNetworkSharingInfoDialog : VpnSettingsDialogState() - object ContentBlockersInfoDialog : VpnSettingsDialogState() + data object ContentBlockersInfoDialog : VpnSettingsDialogState() - object CustomDnsInfoDialog : VpnSettingsDialogState() + data object CustomDnsInfoDialog : VpnSettingsDialogState() - object MalwareInfoDialog : VpnSettingsDialogState() + data object MalwareInfoDialog : VpnSettingsDialogState() - object ObfuscationInfoDialog : VpnSettingsDialogState() + data object ObfuscationInfoDialog : VpnSettingsDialogState() - object QuantumResistanceInfoDialog : VpnSettingsDialogState() + data object QuantumResistanceInfoDialog : VpnSettingsDialogState() - object WireguardPortInfoDialog : VpnSettingsDialogState() + data object WireguardPortInfoDialog : VpnSettingsDialogState() - object CustomPortDialog : VpnSettingsDialogState() + data object CustomPortDialog : VpnSettingsDialogState() } sealed interface StagedDns { @@ -238,11 +238,11 @@ sealed interface StagedDns { ) : StagedDns sealed class ValidationResult { - object Success : ValidationResult() + data object Success : ValidationResult() - object InvalidAddress : ValidationResult() + data object InvalidAddress : ValidationResult() - object DuplicateAddress : ValidationResult() + data object DuplicateAddress : ValidationResult() } fun isValid() = (validationResult is ValidationResult.Success)