From 4880e1db276b4cf2ec29eeffbd38539ca643b4be Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 28 Apr 2021 10:27:14 +0530 Subject: Upgrade to Kotlin 1.5 (#1397) * build: upgrade Kotlin to 1.5.0 and Hilt to 2.35.1 Signed-off-by: Harsh Shandilya * all: address kotlin.time.seconds deprecation Signed-off-by: Harsh Shandilya * autofill-parser/openpgp-ktx: require Kotlin 1.5 Signed-off-by: Harsh Shandilya * all: address string method deprecations Signed-off-by: Harsh Shandilya * build: disable NewApi lint Signed-off-by: Harsh Shandilya --- .../java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt | 4 ++-- .../msfjarvis/aps/util/pwgen/RandomPhonemesGenerator.kt | 4 ++-- .../dev/msfjarvis/aps/util/pwgenxkpwd/PasswordBuilder.kt | 14 ++++++++++---- .../aps/util/viewmodel/SearchableRepositoryViewModel.kt | 3 +-- 4 files changed, 15 insertions(+), 10 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt index 72a9a80d..8edd8f0b 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt @@ -27,8 +27,8 @@ import dev.msfjarvis.aps.util.settings.PreferenceKeys import java.io.ByteArrayOutputStream import java.io.File import javax.inject.Inject +import kotlin.time.Duration import kotlin.time.ExperimentalTime -import kotlin.time.seconds import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.flow.collect @@ -121,7 +121,7 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound { @OptIn(ExperimentalTime::class) private fun startAutoDismissTimer() { lifecycleScope.launch { - delay(60.seconds) + delay(Duration.seconds(60)) finish() } } diff --git a/app/src/main/java/dev/msfjarvis/aps/util/pwgen/RandomPhonemesGenerator.kt b/app/src/main/java/dev/msfjarvis/aps/util/pwgen/RandomPhonemesGenerator.kt index 1b2d0fb7..0b8ca872 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/pwgen/RandomPhonemesGenerator.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/pwgen/RandomPhonemesGenerator.kt @@ -60,8 +60,8 @@ object RandomPhonemesGenerator { private class Element(str: String, val flags: Int) { - val upperCase = str.toUpperCase(Locale.ROOT) - val lowerCase = str.toLowerCase(Locale.ROOT) + val upperCase = str.uppercase(Locale.ROOT) + val lowerCase = str.lowercase(Locale.ROOT) val length = str.length val isAmbiguous = str.any { it in PasswordGenerator.AMBIGUOUS_STR } } diff --git a/app/src/main/java/dev/msfjarvis/aps/util/pwgenxkpwd/PasswordBuilder.kt b/app/src/main/java/dev/msfjarvis/aps/util/pwgenxkpwd/PasswordBuilder.kt index cc8257b4..3eb2cce7 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/pwgenxkpwd/PasswordBuilder.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/pwgenxkpwd/PasswordBuilder.kt @@ -101,10 +101,16 @@ class PasswordBuilder(ctx: Context) { val candidate = wordBank.secureRandomElement() val s = when (capsType) { - CapsType.UPPERCASE -> candidate.toUpperCase(Locale.getDefault()) - CapsType.Sentence -> if (i == 0) candidate.capitalize(Locale.getDefault()) else candidate - CapsType.TitleCase -> candidate.capitalize(Locale.getDefault()) - CapsType.lowercase -> candidate.toLowerCase(Locale.getDefault()) + CapsType.UPPERCASE -> candidate.uppercase(Locale.getDefault()) + CapsType.Sentence -> + if (i == 0) + candidate.replaceFirstChar { + if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() + } + else candidate + CapsType.TitleCase -> + candidate.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } + CapsType.lowercase -> candidate.lowercase(Locale.getDefault()) CapsType.As_iS -> candidate } password.append(s) diff --git a/app/src/main/java/dev/msfjarvis/aps/util/viewmodel/SearchableRepositoryViewModel.kt b/app/src/main/java/dev/msfjarvis/aps/util/viewmodel/SearchableRepositoryViewModel.kt index 881f98f4..f0488537 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/viewmodel/SearchableRepositoryViewModel.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/viewmodel/SearchableRepositoryViewModel.kt @@ -442,8 +442,7 @@ open class SearchableRepositoryAdapter( } } } - final override fun getPopupText(position: Int): String { - return getItem(position).name[0].toString().toUpperCase(Locale.getDefault()) + return getItem(position).name[0].toString().uppercase(Locale.getDefault()) } } -- cgit v1.2.3