Skip to content

Commit

Permalink
Inspection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Sep 12, 2023
1 parent ce2dfda commit 827f7b0
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fun ConnectionButton(

@Preview
@Composable
fun ConnectionButton() {
fun PreviewConnectionButton() {
AppTheme {
ConnectionButton(
text = "Disconnect",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import net.mullvad.mullvadvpn.lib.theme.Dimens
@Composable
fun ChangelogDialog(changesList: List<String>, version: String, onDismiss: () -> Unit) {
AlertDialog(
onDismissRequest = { onDismiss() },
onDismissRequest = onDismiss,
title = {
Text(
text = version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RelayCountry>, val selectedRelay: RelayItem?) :
SelectLocationUiState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppData> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ class MullvadProblemReport {
GlobalScope.actor<Command>(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())
Expand All @@ -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"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ data class RelayCity(

override val hasChildren
get() = relays.isNotEmpty()

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ data class RelayCountry(

override val hasChildren
get() = cities.isNotEmpty()

}
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionState
import net.mullvad.talpid.util.EventNotifier

fun Animation.transitionFinished(): Flow<Unit> =
callbackFlow<Unit> {
callbackFlow {
val transitionAnimationListener =
object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {}
Expand Down Expand Up @@ -44,12 +44,11 @@ fun <R> Flow<ServiceConnectionState>.flatMapReadyConnectionOrDefault(
}
}

fun <T> callbackFlowFromNotifier(notifier: EventNotifier<T>) =
callbackFlow<T> {
val handler: (T) -> Unit = { value -> trySend(value) }
notifier.subscribe(this, handler)
awaitClose { notifier.unsubscribe(this) }
}
fun <T> callbackFlowFromNotifier(notifier: EventNotifier<T>) = callbackFlow {
val handler: (T) -> Unit = { value -> trySend(value) }
notifier.subscribe(this, handler)
awaitClose { notifier.unsubscribe(this) }
}

inline fun <T1, T2, T3, T4, T5, T6, R> combine(
flow: Flow<T1>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ class ChangelogViewModel(
sealed class ChangelogDialogUiState {
data class Show(val changes: List<String>) : ChangelogDialogUiState()

object Hide : ChangelogDialogUiState()
data object Hide : ChangelogDialogUiState()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit 827f7b0

Please sign in to comment.