chore: Update Kotlin to 2.0.20

This commit is contained in:
Artem Chepurnyi 2024-09-01 10:18:02 +03:00
parent 2c82d57f72
commit 62b24bb462
25 changed files with 66 additions and 60 deletions

View File

@ -91,6 +91,7 @@ kotlin {
all {
languageSettings.optIn("kotlin.ExperimentalStdlibApi")
languageSettings.optIn("kotlin.time.ExperimentalTime")
languageSettings.optIn("kotlin.uuid.ExperimentalUuidApi")
languageSettings.optIn("androidx.compose.animation.ExperimentalAnimationApi")
languageSettings.optIn("androidx.compose.material.ExperimentalMaterialApi")
languageSettings.optIn("androidx.compose.foundation.ExperimentalFoundationApi")

View File

@ -1,7 +1,7 @@
package com.artemchep.keyguard.android
import java.nio.ByteBuffer
import java.util.UUID
import kotlin.uuid.Uuid
object PasskeyCredentialId {
private const val UUID_SIZE_BYTES = Long.SIZE_BYTES * 2
@ -11,7 +11,7 @@ object PasskeyCredentialId {
): ByteArray {
val uuid = kotlin
.runCatching {
UUID.fromString(credentialId)
Uuid.parse(credentialId)
}
// The credential id is not conforming to UUID rules,
// this is fine for us (although should not happen), we
@ -20,8 +20,13 @@ object PasskeyCredentialId {
return PasskeyBase64.decode(credentialId)
}
return ByteBuffer.allocate(UUID_SIZE_BYTES)
.putLong(uuid.mostSignificantBits)
.putLong(uuid.leastSignificantBits)
.apply {
uuid.toLongs { m, l ->
putLong(m)
putLong(l)
Unit
}
}
.array()
}
@ -30,7 +35,7 @@ object PasskeyCredentialId {
): String {
if (data.size == UUID_SIZE_BYTES) {
val bb = ByteBuffer.wrap(data)
return UUID(
return Uuid.fromLongs(
bb.getLong(),
bb.getLong(),
).toString()

View File

@ -37,7 +37,7 @@ import kotlinx.collections.immutable.PersistentMap
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.collections.immutable.toImmutableSet
import java.io.IOException
import java.util.UUID
import kotlin.uuid.Uuid
@Composable
actual fun rememberYubiKey(
@ -127,7 +127,7 @@ private fun YubiKitManager.rememberYubiKeyUsbState(
DisposableEffect(context, this) {
val callback = Callback<UsbYubiKeyDevice> { device: UsbYubiKeyDevice ->
val info = ActiveDevice(
id = UUID.randomUUID().toString(),
id = Uuid.random().toString(),
pid = device.pid,
)

View File

@ -1,9 +1,9 @@
package com.artemchep.keyguard.common.model
import java.util.UUID
import kotlin.uuid.Uuid
data class ToastMessage(
val id: String = UUID.randomUUID().toString(),
val id: String = Uuid.random().toString(),
val type: Type? = null,
val title: String,
val text: String? = null,

View File

@ -7,7 +7,7 @@ import com.artemchep.keyguard.common.io.io
import com.artemchep.keyguard.common.service.id.IdRepository
import org.kodein.di.DirectDI
import org.kodein.di.instance
import java.util.UUID
import kotlin.uuid.Uuid
class DeviceIdUseCase(
private val deviceIdRepository: IdRepository,
@ -45,4 +45,4 @@ class DeviceIdUseCase(
}
}
private fun getDeviceId() = UUID.randomUUID().toString()
private fun getDeviceId() = Uuid.random().toString()

View File

@ -4,7 +4,7 @@ import com.artemchep.keyguard.common.model.ToastMessage
import com.artemchep.keyguard.common.usecase.MessageHub
import com.artemchep.keyguard.common.usecase.ShowMessage
import org.kodein.di.DirectDI
import java.util.UUID
import kotlin.uuid.Uuid
class MessageHubImpl() : MessageHub, ShowMessage {
constructor(directDI: DirectDI) : this()
@ -21,7 +21,7 @@ class MessageHubImpl() : MessageHub, ShowMessage {
key: String,
onMessage: (ToastMessage) -> Unit,
): () -> Unit {
val id = UUID.randomUUID().toString()
val id = Uuid.random().toString()
val entry = Entry(
id = id,
key = key,

View File

@ -5,8 +5,8 @@ import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import java.util.UUID
import kotlin.time.Duration.Companion.days
import kotlin.uuid.Uuid
@Serializable
@optics
@ -317,7 +317,7 @@ fun BitwardenCipher.Companion.generated(): BitwardenCipher {
"Cum ita esset affecta, secundum non recte, si voluptas esset bonum, fuisse desideraturam. Idcirco enim non desideraret, quia, quod dolore caret, id in hominum consuetudine facilius fieri poterit et iustius?",
)
return BitwardenCipher(
cipherId = UUID.randomUUID().toString(),
cipherId = Uuid.random().toString(),
accountId = accountIds.random(),
folderId = folderIds.random(),
revisionDate = Clock.System.now().minus(20L.days),

View File

@ -5,11 +5,11 @@ import com.artemchep.keyguard.provider.bitwarden.ServerEnv
import com.artemchep.keyguard.provider.bitwarden.ServerHeader
import kotlinx.datetime.Instant
import kotlinx.serialization.Serializable
import java.util.UUID
import kotlin.uuid.Uuid
@Serializable
data class BitwardenToken(
val id: String = UUID.randomUUID().toString(),
val id: String = Uuid.random().toString(),
val key: Key,
val token: Token? = null,
val user: User,

View File

@ -64,7 +64,7 @@ import org.kodein.di.compose.localDI
import org.kodein.di.direct
import org.kodein.di.instance
import java.io.Serializable
import java.util.UUID
import kotlin.uuid.Uuid
private const val TAG = "login"
@ -850,7 +850,7 @@ suspend fun <T, Argument> RememberStateFlowScope.foo3(
val initialState = Foo2InitialState(
items = initial
.associateBy {
UUID.randomUUID().toString()
Uuid.random().toString()
}
.map { entry ->
Foo2InitialState.Item(
@ -983,7 +983,7 @@ suspend fun <T, Argument> RememberStateFlowScope.foo(
}
fun add(type: String, arg: Argument?) {
val key = "$scope.items." + UUID.randomUUID().toString()
val key = "$scope.items." + Uuid.random().toString()
// Remember the argument, so we can grab it and construct something
// persistent from it.
if (arg != null) {

View File

@ -8,7 +8,7 @@ import com.artemchep.keyguard.ui.FlatItemAction
import kotlinx.collections.immutable.PersistentList
import kotlinx.coroutines.flow.StateFlow
import kotlinx.datetime.Instant
import java.util.UUID
import kotlin.uuid.Uuid
@Immutable
@optics
@ -19,7 +19,7 @@ sealed interface GeneratorHistoryItem {
@Immutable
data class Section(
override val id: String = UUID.randomUUID().toString(),
override val id: String = Uuid.random().toString(),
val text: String? = null,
val caps: Boolean = true,
) : GeneratorHistoryItem {

View File

@ -5,7 +5,7 @@ import androidx.compose.ui.text.AnnotatedString
import arrow.optics.optics
import com.artemchep.keyguard.feature.home.vault.model.VaultItemIcon
import com.artemchep.keyguard.ui.FlatItemAction
import java.util.UUID
import kotlin.uuid.Uuid
@optics
sealed interface AccountItem {
@ -15,7 +15,7 @@ sealed interface AccountItem {
@optics
data class Section(
override val id: String = UUID.randomUUID().toString(),
override val id: String = Uuid.random().toString(),
val text: String? = null,
) : AccountItem {
companion object

View File

@ -11,7 +11,7 @@ import com.artemchep.keyguard.ui.icons.icon
import kotlinx.coroutines.flow.flowOf
import org.kodein.di.DirectDI
import org.kodein.di.instance
import java.util.UUID
import kotlin.uuid.Uuid
fun settingEmitMessageProvider(
directDI: DirectDI,
@ -31,7 +31,7 @@ fun settingEmitMessageProvider(
val model = ToastMessage(
title = "Test message",
type = type,
text = UUID.randomUUID().toString(),
text = Uuid.random().toString(),
)
showMessage.copy(model)
},

View File

@ -19,7 +19,7 @@ import com.artemchep.keyguard.ui.icons.icon
import kotlinx.coroutines.flow.flow
import org.kodein.di.DirectDI
import org.kodein.di.instance
import java.util.UUID
import kotlin.uuid.Uuid
fun settingLaunchAppPicker(
directDI: DirectDI,
@ -39,7 +39,7 @@ fun settingLaunchAppPicker(
if (result is AppPickerResult.Confirm) {
val model = ToastMessage(
title = result.uri,
text = UUID.randomUUID().toString(),
text = Uuid.random().toString(),
)
showMessage.copy(model)
}

View File

@ -178,7 +178,7 @@ import org.kodein.di.compose.localDI
import org.kodein.di.direct
import org.kodein.di.instance
import java.io.Serializable
import java.util.UUID
import kotlin.uuid.Uuid
// TODO: Support hide password option
@Composable
@ -468,7 +468,7 @@ fun produceAddScreenState(
if (info != null) {
val model = SkeletonAttachment.Local(
identity = SkeletonAttachment.Local.Identity(
id = UUID.randomUUID().toString(),
id = Uuid.random().toString(),
uri = info.uri,
size = info.size,
),
@ -1593,7 +1593,7 @@ suspend fun <T, Argument> RememberStateFlowScope.foo3(
val initialState = Foo2InitialState(
items = initial
.associateBy {
UUID.randomUUID().toString()
Uuid.random().toString()
}
.map { entry ->
Foo2InitialState.Item(
@ -1760,7 +1760,7 @@ suspend fun <T, Argument> RememberStateFlowScope.foo(
}
fun add(type: String, arg: Argument?) {
val key = "$scope.items." + UUID.randomUUID().toString()
val key = "$scope.items." + Uuid.random().toString()
// Remember the argument, so we can grab it and construct something
// persistent from it.
if (arg != null) {

View File

@ -35,7 +35,7 @@ import kotlinx.coroutines.flow.shareIn
import org.kodein.di.compose.localDI
import org.kodein.di.direct
import org.kodein.di.instance
import java.util.UUID
import kotlin.uuid.Uuid
@Composable
fun collectionsScreenState(
@ -358,7 +358,7 @@ private class OrganizationDecorator : Decorator {
lastOrganization = organization
if (organization != null) {
val itemKey = if (organization.id in seenOrganizationIds) {
val randomId = UUID.randomUUID().toString()
val randomId = Uuid.random().toString()
"duplicate.$randomId"
} else {
organization.id

View File

@ -18,7 +18,7 @@ import com.artemchep.keyguard.ui.icons.AccentColors
import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.flow.StateFlow
import kotlinx.datetime.Instant
import java.util.UUID
import kotlin.uuid.Uuid
@Immutable
@optics
@ -35,7 +35,7 @@ sealed interface VaultItem2 {
companion object;
data class Item(
val key: String = UUID.randomUUID().toString(),
val key: String = Uuid.random().toString(),
val leading: (@Composable () -> Unit)? = null,
val imageVector: ImageVector? = null,
val title: String,
@ -67,7 +67,7 @@ sealed interface VaultItem2 {
@Immutable
data class Section(
override val id: String = UUID.randomUUID().toString(),
override val id: String = Uuid.random().toString(),
val text: TextHolder? = null,
val caps: Boolean = true,
) : VaultItem2 {

View File

@ -4,7 +4,7 @@ import androidx.compose.runtime.Immutable
import androidx.compose.ui.text.AnnotatedString
import arrow.optics.optics
import com.artemchep.keyguard.common.service.logging.LogLevel
import java.util.UUID
import kotlin.uuid.Uuid
@Immutable
@optics
@ -15,7 +15,7 @@ sealed interface LogsItem {
@Immutable
data class Section(
override val id: String = UUID.randomUUID().toString(),
override val id: String = Uuid.random().toString(),
val text: String? = null,
val caps: Boolean = true,
) : LogsItem {

View File

@ -18,7 +18,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.plus
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.withContext
import java.util.UUID
import kotlin.uuid.Uuid
interface NavigationEntry : BackPressInterceptorHost {
companion object {
@ -83,7 +83,7 @@ data class NavigationEntryImpl(
override fun interceptBackPress(
block: () -> Unit,
): () -> Unit {
val id = UUID.randomUUID().toString()
val id = Uuid.random().toString()
val entry = BackPressInterceptorRegistration(
id = id,
block = block,

View File

@ -14,7 +14,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import java.util.UUID
import kotlin.uuid.Uuid
@Composable
fun NavigationRouter(
@ -295,7 +295,7 @@ private fun NavigationIntentScope.exec(
val r = intent.route
val e = NavigationEntryImpl(
source = "router",
id = UUID.randomUUID().toString(),
id = Uuid.random().toString(),
parent = scope,
route = r,
)
@ -308,7 +308,7 @@ private fun NavigationIntentScope.exec(
val r = intent.route
val e = NavigationEntryImpl(
source = "router",
id = UUID.randomUUID().toString(),
id = Uuid.random().toString(),
parent = scope,
route = r,
)
@ -343,7 +343,7 @@ private fun NavigationIntentScope.exec(
val factory = fun(route: Route): NavigationEntry =
NavigationEntryImpl(
source = "router",
id = UUID.randomUUID().toString(),
id = Uuid.random().toString(),
parent = scope,
route = route,
)

View File

@ -7,7 +7,7 @@ import androidx.compose.runtime.remember
import kotlinx.collections.immutable.PersistentMap
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.coroutines.flow.MutableStateFlow
import java.util.UUID
import kotlin.uuid.Uuid
/**
* A definition of the distinct application component that
@ -48,7 +48,7 @@ class BackHandler(
controller: NavigationController,
backStack: List<NavigationEntry>,
): () -> Unit {
val id = UUID.randomUUID().toString()
val id = Uuid.random().toString()
eek.value = eek.value.put(
key = id,
value = Entry(
@ -67,7 +67,7 @@ class BackHandler(
onBack: () -> Unit,
priority: Int,
): () -> Unit {
val id = UUID.randomUUID().toString()
val id = Uuid.random().toString()
eek2.value = eek2.value.put(
key = id,
value = Entry2(

View File

@ -9,7 +9,7 @@ import com.artemchep.keyguard.feature.attachments.SelectableItemState
import com.artemchep.keyguard.feature.home.vault.model.VaultItemIcon
import kotlinx.coroutines.flow.StateFlow
import kotlinx.datetime.Instant
import java.util.UUID
import kotlin.uuid.Uuid
@Immutable
@optics
@ -20,7 +20,7 @@ sealed interface SendItem {
@Immutable
data class Section(
override val id: String = UUID.randomUUID().toString(),
override val id: String = Uuid.random().toString(),
val text: String? = null,
val caps: Boolean = true,
) : SendItem {

View File

@ -6,7 +6,7 @@ import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color
import java.util.UUID
import kotlin.uuid.Uuid
class BackgroundManager {
private val surfaceColorsState = mutableStateMapOf<String, Color>()
@ -42,7 +42,7 @@ class BackgroundManager {
fun register(
color: Color,
): () -> Unit {
val key = UUID.randomUUID().toString()
val key = Uuid.random().toString()
surfaceColorsState[key] = color
return {

View File

@ -9,7 +9,7 @@ import androidx.compose.ui.text.withStyle
import com.artemchep.keyguard.feature.navigation.state.TranslatorScope
import org.jetbrains.compose.resources.StringResource
import org.jetbrains.compose.resources.stringResource
import java.util.UUID
import kotlin.uuid.Uuid
@Composable
fun annotatedResource(
@ -20,7 +20,7 @@ fun annotatedResource(
// arguments. Later, we will replace those with
// actual values.
val placeholders = remember {
Array(args.size) { UUID.randomUUID().toString() }
Array(args.size) { Uuid.random().toString() }
}
val value = stringResource(resource, *placeholders)
return remember(value) {
@ -40,7 +40,7 @@ suspend fun TranslatorScope.annotate(
// arguments. Later, we will replace those with
// actual values.
val placeholders =
Array(args.size) { UUID.randomUUID().toString() }
Array(args.size) { Uuid.random().toString() }
val value = translate(resource, *placeholders)
return rebuild(
value,

View File

@ -10,9 +10,9 @@ import org.bouncycastle.crypto.generators.Argon2BytesGenerator
import org.bouncycastle.crypto.params.Argon2Parameters
import java.security.MessageDigest
import java.security.SecureRandom
import java.util.UUID
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
import kotlin.uuid.Uuid
class CryptoGeneratorJvm() : CryptoGenerator {
companion object {
@ -92,7 +92,7 @@ class CryptoGeneratorJvm() : CryptoGenerator {
return md.digest()
}
override fun uuid(): String = UUID.randomUUID().toString()
override fun uuid(): String = Uuid.random().toString()
override fun random(): Int = secureRandom.nextInt()

View File

@ -72,7 +72,7 @@ kdrag0nColorKt = "1.0.5"
# https://github.com/Kodein-Framework/Kodein-DI
kodeinDi = "7.22.0"
# https://github.com/JetBrains/kotlin
kotlin = "2.0.10"
kotlin = "2.0.20"
# https://github.com/Kotlin/kotlinx.collections.immutable
kotlinCollections = "0.3.7"
# https://github.com/Kotlin/kotlinx.coroutines
@ -81,9 +81,9 @@ kotlinCoroutines = "1.8.1"
kotlinDatetime = "0.6.1"
kotlinDsl = "4.3.0"
# https://github.com/Kotlin/kotlinx.serialization
kotlinSerialization = "1.7.1"
kotlinSerialization = "1.7.2"
# https://github.com/google/ksp/releases
kspPlugin = "2.0.10-1.0.24"
kspPlugin = "2.0.20-1.0.24"
# https://github.com/pinterest/ktlint/releases
# @keep
ktlint = "0.50.0"