Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android studio lint #5147

Merged
merged 4 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

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 @@ -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
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 @@ -31,7 +31,7 @@ fun <T> rememberPrevious(
private fun <T> rememberRef(): MutableState<T?> {
// 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<T?> {
override var value: T? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>) : Command()

class Send(val result: CompletableDeferred<Boolean>) : Command()

class Delete() : Command()
data object Delete : Command()
}

val logDirectory = CompletableDeferred<File>()
Expand All @@ -44,7 +44,7 @@ class MullvadProblemReport {
}

fun collect() {
commandChannel.trySendBlocking(Command.Collect())
commandChannel.trySendBlocking(Command.Collect)
}

suspend fun load(): String {
Expand All @@ -64,16 +64,15 @@ class MullvadProblemReport {
}

fun deleteReportFile() {
commandChannel.trySendBlocking(Command.Delete())
commandChannel.trySendBlocking(Command.Delete)
}

private fun spawnActor() =
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

This file was deleted.

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

This file was deleted.

This file was deleted.

Loading
Loading