diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/applist/ListItemData.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/applist/ListItemData.kt deleted file mode 100644 index 613fe49e8f99..000000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/applist/ListItemData.kt +++ /dev/null @@ -1,64 +0,0 @@ -package net.mullvad.mullvadvpn.applist - -import androidx.annotation.DrawableRes -import androidx.annotation.IntDef -import androidx.annotation.StringRes -import net.mullvad.mullvadvpn.ui.widget.WidgetState - -data class ListItemData -private constructor( - val identifier: String, - val text: String? = null, - @StringRes val textRes: Int? = null, - @DrawableRes val iconRes: Int?, - val isSelected: Boolean, - @ItemType val type: Int, - val widget: WidgetState? = null, - val action: ItemAction? = null -) { - - @Retention @IntDef(DIVIDER, PLAIN, ACTION) annotation class ItemType - - class Builder(private val identifier: String) { - var text: String? = null - - @StringRes var textRes: Int? = null - - @DrawableRes var iconRes: Int? = null - var isSelected: Boolean = false - - @ItemType var type: Int = 0 - var widget: WidgetState? = null - var action: ItemAction? = null - - fun build(): ListItemData { - if ((this.text == null && this.textRes == null) && type > PROGRESS) - throw IllegalArgumentException("ListItem should be configured with text") - - return ListItemData( - this.identifier, - this.text, - this.textRes, - this.iconRes, - this.isSelected, - this.type, - this.widget, - this.action - ) - } - } - - data class ItemAction(val identifier: String) - - companion object { - const val DIVIDER = 0 - const val PROGRESS = 1 - const val PLAIN = 2 - const val ACTION = 3 - const val DOUBLE_ACTION = 4 - const val APPLICATION = 5 - - fun build(identifier: String, setUp: Builder.() -> Unit): ListItemData = - Builder(identifier).also(setUp).build() - } -} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/applist/ViewIntent.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/applist/ViewIntent.kt deleted file mode 100644 index 4469bd00ef95..000000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/applist/ViewIntent.kt +++ /dev/null @@ -1,10 +0,0 @@ -package net.mullvad.mullvadvpn.applist - -sealed class ViewIntent { - // In future we will have search intent - data class ChangeApplicationGroup(val item: ListItemData) : ViewIntent() - - object ViewIsReady : ViewIntent() - - data class ShowSystemApps(internal val show: Boolean) : ViewIntent() -} 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 dd5e075d70bc..72cce59124c5 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 @@ -29,7 +29,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/compose/util/RememberPrevious.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/RememberPrevious.kt index ef47f6147234..6782e0ab5519 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/RememberPrevious.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/RememberPrevious.kt @@ -31,7 +31,7 @@ fun rememberPrevious( private fun rememberRef(): MutableState { // for some reason it always recreated the value with vararg keys, // leaving out the keys as a parameter for remember for now - return remember() { + return remember { object : MutableState { override var value: T? = null 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 7104deb686d8..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 @@ -15,13 +15,13 @@ const val PROBLEM_REPORT_FILE = "problem_report.txt" class MullvadProblemReport { private sealed class Command { - class Collect() : Command() + data object Collect : Command() class Load(val logs: CompletableDeferred) : Command() class Send(val result: CompletableDeferred) : Command() - class Delete() : Command() + data object Delete : Command() } val logDirectory = CompletableDeferred() @@ -44,7 +44,7 @@ class MullvadProblemReport { } fun collect() { - commandChannel.trySendBlocking(Command.Collect()) + commandChannel.trySendBlocking(Command.Collect) } suspend fun load(): String { @@ -64,16 +64,15 @@ class MullvadProblemReport { } fun deleteReportFile() { - commandChannel.trySendBlocking(Command.Delete()) + commandChannel.trySendBlocking(Command.Delete) } private fun spawnActor() = 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/GetItemResult.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/GetItemResult.kt deleted file mode 100644 index edbaaf39d1bb..000000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/GetItemResult.kt +++ /dev/null @@ -1,7 +0,0 @@ -package net.mullvad.mullvadvpn.relaylist - -sealed class GetItemResult { - data class Item(val item: RelayItem) : GetItemResult() - - data class Count(val count: Int) : GetItemResult() -} 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 4817b401bf13..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,31 +16,4 @@ data class RelayCity( override val hasChildren get() = relays.isNotEmpty() - - fun getItem(position: Int): GetItemResult { - if (position == 0) { - return GetItemResult.Item(this) - } - - if (!expanded) { - return GetItemResult.Count(1) - } - - val offset = position - 1 - val relayCount = relays.size - - return if (offset >= relayCount) { - GetItemResult.Count(1 + relayCount) - } else { - GetItemResult.Item(relays[offset]) - } - } - - fun getItemCount(): Int { - return if (expanded) { - 1 + relays.size - } else { - 1 - } - } } 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 e9487c7b4cc0..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,28 +16,4 @@ data class RelayCountry( override val hasChildren get() = cities.isNotEmpty() - - fun getItem(position: Int): GetItemResult { - if (position == 0) { - return GetItemResult.Item(this) - } - - var itemCount = 1 - var remaining = position - 1 - - if (expanded) { - for (city in cities) { - - when (val itemOrCount = city.getItem(remaining)) { - is GetItemResult.Item -> return itemOrCount - is GetItemResult.Count -> { - remaining -= itemOrCount.count - itemCount += itemOrCount.count - } - } - } - } - - return GetItemResult.Count(itemCount) - } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayListAdapterPosition.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayListAdapterPosition.kt deleted file mode 100644 index 09dfafebc8b7..000000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/relaylist/RelayListAdapterPosition.kt +++ /dev/null @@ -1,3 +0,0 @@ -package net.mullvad.mullvadvpn.relaylist - -data class RelayListAdapterPosition(var position: Int) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/BlockingController.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/BlockingController.kt deleted file mode 100644 index 4dd53fa937bb..000000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/BlockingController.kt +++ /dev/null @@ -1,39 +0,0 @@ -package net.mullvad.mullvadvpn.ui - -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.Job -import kotlinx.coroutines.launch - -class BlockingController(val blockableView: BlockableView) { - var job: Job? = null - var innerJob: Job? = null - - fun action() { - if (!(job?.isActive ?: false)) { - job = - GlobalScope.launch(Dispatchers.Main) { - blockableView.setEnabled(false) - innerJob = blockableView.onClick() - innerJob?.join() - blockableView.setEnabled(true) - } - } - } - - fun onPause() { - innerJob?.cancel() - job?.cancel() - blockableView.setEnabled(true) - } - - fun onDestroy() { - onPause() - } -} - -interface BlockableView { - fun setEnabled(enabled: Boolean) - - fun onClick(): Job -} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt index 658fd3fed3ee..1c37945602fa 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CollapsibleTitleController.kt @@ -46,16 +46,15 @@ class CollapsibleTitleController(val parentView: View, scrollAreaId: Int = R.id. private val xOffsetInterpolation = LinearInterpolation() private val yOffsetInterpolation = LinearInterpolation() - private val collapsedTitleLayoutListener: LayoutListener = - LayoutListener() { collapsedTitle -> - val (x, y) = calculateViewCoordinates(collapsedTitle) + private val collapsedTitleLayoutListener: LayoutListener = LayoutListener { collapsedTitle -> + val (x, y) = calculateViewCoordinates(collapsedTitle) - collapsedTitleHeight = collapsedTitle.height.toFloat() + collapsedTitleHeight = collapsedTitle.height.toFloat() - scaleInterpolation.end = collapsedTitleHeight / maxOf(1.0f, titleHeight) - xOffsetInterpolation.end = x - yOffsetInterpolation.end = y - } + scaleInterpolation.end = collapsedTitleHeight / maxOf(1.0f, titleHeight) + xOffsetInterpolation.end = x + yOffsetInterpolation.end = y + } private val collapsedTitleView = parentView.findViewById(R.id.collapsed_title).apply { @@ -63,37 +62,35 @@ class CollapsibleTitleController(val parentView: View, scrollAreaId: Int = R.id. visibility = View.INVISIBLE } - private val expandedTitleLayoutListener: LayoutListener = - LayoutListener() { expandedTitle -> - val (x, y) = calculateViewCoordinates(expandedTitle) + private val expandedTitleLayoutListener: LayoutListener = LayoutListener { expandedTitle -> + val (x, y) = calculateViewCoordinates(expandedTitle) - val expandedTitleMarginTop = - when (val layoutParams = expandedTitle.layoutParams) { - is MarginLayoutParams -> layoutParams.topMargin - else -> 0 - } + val expandedTitleMarginTop = + when (val layoutParams = expandedTitle.layoutParams) { + is MarginLayoutParams -> layoutParams.topMargin + else -> 0 + } - expandedTitleHeight = expandedTitle.height.toFloat() + expandedTitleHeight = expandedTitle.height.toFloat() - scaleInterpolation.start = expandedTitleHeight / maxOf(1.0f, titleHeight) - xOffsetInterpolation.start = x - yOffsetInterpolation.start = y + scaleInterpolation.start = expandedTitleHeight / maxOf(1.0f, titleHeight) + xOffsetInterpolation.start = x + yOffsetInterpolation.start = y - scrollInterpolation.end = expandedTitleHeight + expandedTitleMarginTop - } + scrollInterpolation.end = expandedTitleHeight + expandedTitleMarginTop + } - private val titleLayoutListener: LayoutListener = - LayoutListener() { title -> - val (x, y) = calculateViewCoordinates(title) + private val titleLayoutListener: LayoutListener = LayoutListener { title -> + val (x, y) = calculateViewCoordinates(title) - titleWidth = title.width.toFloat() - titleHeight = title.height.toFloat() + titleWidth = title.width.toFloat() + titleHeight = title.height.toFloat() - scaleInterpolation.start = expandedTitleHeight / maxOf(1.0f, titleHeight) - scaleInterpolation.end = collapsedTitleHeight / maxOf(1.0f, titleHeight) - xOffsetInterpolation.reference = x - yOffsetInterpolation.reference = y - } + scaleInterpolation.start = expandedTitleHeight / maxOf(1.0f, titleHeight) + scaleInterpolation.end = collapsedTitleHeight / maxOf(1.0f, titleHeight) + xOffsetInterpolation.reference = x + yOffsetInterpolation.reference = y + } private val titleView = parentView.findViewById(R.id.title).apply { @@ -104,8 +101,9 @@ class CollapsibleTitleController(val parentView: View, scrollAreaId: Int = R.id. pivotY = 0.0f } - private val scrollAreaLayoutListener: LayoutListener = - LayoutListener() { scrollOffset = scrollArea.verticalScrollOffset.toFloat() } + private val scrollAreaLayoutListener: LayoutListener = LayoutListener { + scrollOffset = scrollArea.verticalScrollOffset.toFloat() + } private val scrollArea = parentView.findViewById(scrollAreaId).let { view -> diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CustomTransformationMethod.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CustomTransformationMethod.kt index 083258c62d35..451c51fa3f0f 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CustomTransformationMethod.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/CustomTransformationMethod.kt @@ -10,7 +10,7 @@ private const val DOT_CHAR = '\u2022' private const val EMPTY_STRING = "" private const val SPACE_CHAR = ' ' -class GroupedTransformationMethod() : TransformationMethod { +class GroupedTransformationMethod : TransformationMethod { override fun getTransformation(source: CharSequence?, view: View?): CharSequence { return source?.groupWithSpaces() ?: EMPTY_STRING } @@ -26,7 +26,7 @@ class GroupedTransformationMethod() : TransformationMethod { } } -class GroupedPasswordTransformationMethod() : PasswordTransformationMethod() { +class GroupedPasswordTransformationMethod : PasswordTransformationMethod() { override fun getTransformation(source: CharSequence?, view: View?): CharSequence { return if (source != null && view != null) { super.getTransformation(source, view) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ListItemListener.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ListItemListener.kt deleted file mode 100644 index 07c5520d3434..000000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/ListItemListener.kt +++ /dev/null @@ -1,7 +0,0 @@ -package net.mullvad.mullvadvpn.ui - -import net.mullvad.mullvadvpn.applist.ListItemData - -interface ListItemListener { - fun onItemAction(item: ListItemData) -} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/LoginFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/LoginFragment.kt index c02ed0b65269..7e298e3f7392 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/LoginFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/LoginFragment.kt @@ -272,7 +272,7 @@ class LoginFragment : BaseFragment(), NavigationBarPainter { private fun loginFailure(description: String? = "") { title.setText(R.string.login_fail_title) - subtitle.setText(description) + subtitle.text = description loggingInStatus.visibility = View.GONE loginFailStatus.visibility = View.VISIBLE diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt index 9b5eb395ad97..1a59f19ff760 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/OutOfTimeFragment.kt @@ -96,11 +96,11 @@ class OutOfTimeFragment : BaseFragment() { newAccount = false setOnClickAction("openAccountPageInBrowser", jobTracker) { - setEnabled(false) + isEnabled = false serviceConnectionManager.authTokenCache()?.fetchAuthToken()?.let { token -> context.openAccountPageInBrowser(token) } - setEnabled(true) + isEnabled = true } isEnabled = true @@ -170,10 +170,10 @@ class OutOfTimeFragment : BaseFragment() { disconnectButton.apply { if (showButton) { - setEnabled(true) + isEnabled = true visibility = View.VISIBLE } else { - setEnabled(false) + isEnabled = false visibility = View.GONE } } @@ -182,17 +182,17 @@ class OutOfTimeFragment : BaseFragment() { private fun updateBuyButtons() { val currentState = tunnelState val hasConnectivity = currentState is TunnelState.Disconnected - sitePaymentButton.setEnabled(hasConnectivity) + sitePaymentButton.isEnabled = hasConnectivity val isOffline = currentState is TunnelState.Error && currentState.errorState.cause is ErrorStateCause.IsOffline - redeemButton.setEnabled(!isOffline) + redeemButton.isEnabled = !isOffline } private fun checkExpiry(maybeExpiry: DateTime?) { maybeExpiry?.let { expiry -> - if (expiry.isAfterNow()) { + if (expiry.isAfterNow) { jobTracker.newUiJob("advanceToConnectScreen") { advanceToConnectScreen() } } } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/ProblemReportFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/ProblemReportFragment.kt index 4d5ca3c9b59a..b30b5713fbba 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/ProblemReportFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/ProblemReportFragment.kt @@ -280,7 +280,7 @@ class ProblemReportFragment : BaseFragment() { } private fun setSendButtonEnabled(enabled: Boolean) { - sendButton.setEnabled(enabled) + sendButton.isEnabled = enabled sendButton.alpha = if (enabled) 1.0F else 0.5F } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt index 59318a8268b9..46472ea6cc1e 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/RedeemVoucherDialogFragment.kt @@ -88,7 +88,7 @@ class RedeemVoucherDialogFragment : DialogFragment() { redeemButton = view.findViewById