diff options
6 files changed, 13 insertions, 18 deletions
diff --git a/app/src/main/java/app/passwordstore/Application.kt b/app/src/main/java/app/passwordstore/Application.kt index 2f1aca88..45bdc5e6 100644 --- a/app/src/main/java/app/passwordstore/Application.kt +++ b/app/src/main/java/app/passwordstore/Application.kt @@ -33,6 +33,7 @@ import logcat.LogPriority.VERBOSE import logcat.LogcatLogger import logcat.logcat +@OptIn(ExperimentalStdlibApi::class) @Suppress("Unused") @HiltAndroidApp class Application : android.app.Application(), SharedPreferences.OnSharedPreferenceChangeListener { @@ -68,7 +69,7 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere Sentry.configureScope { scope -> val user = User() user.data = - Feature.VALUES.associate { feature -> + Feature.entries.associate { feature -> "features.${feature.configKey}" to features.isEnabled(feature).toString() } scope.user = user diff --git a/app/src/main/java/app/passwordstore/ui/dialogs/PasswordGeneratorDialogFragment.kt b/app/src/main/java/app/passwordstore/ui/dialogs/PasswordGeneratorDialogFragment.kt index 06ce2d92..1130ffd1 100644 --- a/app/src/main/java/app/passwordstore/ui/dialogs/PasswordGeneratorDialogFragment.kt +++ b/app/src/main/java/app/passwordstore/ui/dialogs/PasswordGeneratorDialogFragment.kt @@ -37,6 +37,7 @@ import kotlinx.coroutines.flow.onEach import reactivecircus.flowbinding.android.widget.afterTextChanges import reactivecircus.flowbinding.android.widget.checkedChanges +@OptIn(ExperimentalStdlibApi::class) class PasswordGeneratorDialogFragment : DialogFragment() { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { @@ -138,10 +139,9 @@ class PasswordGeneratorDialogFragment : DialogFragment() { */ private fun setPrefs(ctx: Context, options: List<PasswordOption>, targetLength: Int): Boolean { ctx.getSharedPreferences("PasswordGenerator", Context.MODE_PRIVATE).edit { - for (possibleOption in PasswordOption.values()) putBoolean( - possibleOption.key, - possibleOption in options - ) + for (possibleOption in PasswordOption.entries) { + putBoolean(possibleOption.key, possibleOption in options) + } putInt("length", targetLength) } return true diff --git a/app/src/main/java/app/passwordstore/util/features/Feature.kt b/app/src/main/java/app/passwordstore/util/features/Feature.kt index 55e4eaeb..44af5b70 100644 --- a/app/src/main/java/app/passwordstore/util/features/Feature.kt +++ b/app/src/main/java/app/passwordstore/util/features/Feature.kt @@ -25,9 +25,4 @@ enum class Feature( /** Opt into a cache layer for PGP passphrases. */ EnablePGPPassphraseCache(false, "enable_gpg_passphrase_cache"), - ; - - companion object { - @JvmField val VALUES = values() - } } diff --git a/app/src/main/java/app/passwordstore/util/settings/GitSettings.kt b/app/src/main/java/app/passwordstore/util/settings/GitSettings.kt index 00ace530..e01e6317 100644 --- a/app/src/main/java/app/passwordstore/util/settings/GitSettings.kt +++ b/app/src/main/java/app/passwordstore/util/settings/GitSettings.kt @@ -26,10 +26,9 @@ enum class Protocol(val pref: String) { companion object { - private val map = values().associateBy(Protocol::pref) - + @OptIn(ExperimentalStdlibApi::class) fun fromString(type: String?): Protocol { - return map[type ?: return Ssh] + return entries.associateBy(Protocol::pref)[type ?: return Ssh] ?: throw IllegalArgumentException("$type is not a valid Protocol") } } @@ -43,10 +42,9 @@ enum class AuthMode(val pref: String) { companion object { - private val map = values().associateBy(AuthMode::pref) - + @OptIn(ExperimentalStdlibApi::class) fun fromString(type: String?): AuthMode { - return map[type ?: return SshKey] + return entries.associateBy(AuthMode::pref)[type ?: return SshKey] ?: throw IllegalArgumentException("$type is not a valid AuthMode") } } diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinCommonPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinCommonPlugin.kt index 4b69abf7..587f66d1 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinCommonPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinCommonPlugin.kt @@ -26,7 +26,7 @@ class KotlinCommonPlugin : Plugin<Project> { withType<KotlinCompile>().configureEach task@{ compilerOptions { allWarningsAsErrors.set(true) - languageVersion.set(KotlinVersion.KOTLIN_1_8) + languageVersion.set(KotlinVersion.KOTLIN_1_9) freeCompilerArgs.addAll(ADDITIONAL_COMPILER_ARGS) if (!this@task.name.contains("test", ignoreCase = true) && !isAppModule) { freeCompilerArgs.add("-Xexplicit-api=strict") diff --git a/passgen/random/src/main/kotlin/app/passwordstore/passgen/random/PasswordGenerator.kt b/passgen/random/src/main/kotlin/app/passwordstore/passgen/random/PasswordGenerator.kt index 4f08904d..faf0ad4c 100644 --- a/passgen/random/src/main/kotlin/app/passwordstore/passgen/random/PasswordGenerator.kt +++ b/passgen/random/src/main/kotlin/app/passwordstore/passgen/random/PasswordGenerator.kt @@ -7,6 +7,7 @@ package app.passwordstore.passgen.random import app.passwordstore.passgen.random.util.clearFlag import app.passwordstore.passgen.random.util.hasFlag +@OptIn(ExperimentalStdlibApi::class) public object PasswordGenerator { public const val DEFAULT_LENGTH: Int = 16 @@ -39,7 +40,7 @@ public object PasswordGenerator { var phonemes = true var pwgenFlags = DIGITS or UPPERS or LOWERS - for (option in PasswordOption.values()) { + for (option in PasswordOption.entries) { if (option in passwordOptions) { when (option) { PasswordOption.NoDigits -> pwgenFlags = pwgenFlags.clearFlag(DIGITS) |