build: compile against SDK 30 and resolve deprecations

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-11-01 22:51:02 +05:30
parent 18b6e93bb5
commit cff8d41c91
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
6 changed files with 16 additions and 8 deletions

View file

@ -7,6 +7,7 @@ package com.zeapo.pwdstore
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.edit
import com.zeapo.pwdstore.crypto.DecryptActivity
@ -51,7 +52,7 @@ class LaunchActivity : AppCompatActivity() {
Intent(this, PasswordStore::class.java)
startActivity(intentToStart)
Handler().postDelayed({ finish() }, if (noAuth) 0L else 500L)
Handler(Looper.getMainLooper()).postDelayed({ finish() }, if (noAuth) 0L else 500L)
}
companion object {

View file

@ -45,12 +45,12 @@ open class BasePgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBou
/**
* Full path to the repository
*/
val repoPath: String by lazy(LazyThreadSafetyMode.NONE) { intent.getStringExtra("REPO_PATH") }
val repoPath by lazy(LazyThreadSafetyMode.NONE) { intent.getStringExtra("REPO_PATH")!! }
/**
* Full path to the password file being worked on
*/
val fullPath: String by lazy(LazyThreadSafetyMode.NONE) { intent.getStringExtra("FILE_PATH") }
val fullPath by lazy(LazyThreadSafetyMode.NONE) { intent.getStringExtra("FILE_PATH")!! }
/**
* Name of the password file
@ -186,7 +186,7 @@ open class BasePgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBou
*/
fun getUserInteractionRequestIntent(result: Intent): IntentSender {
i { "RESULT_CODE_USER_INTERACTION_REQUIRED" }
return (result.getParcelableExtra(OpenPgpApi.RESULT_INTENT) as PendingIntent).intentSender
return result.getParcelableExtra<PendingIntent>(OpenPgpApi.RESULT_INTENT)!!.intentSender
}
/**

View file

@ -7,6 +7,7 @@ package com.zeapo.pwdstore.git
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Patterns
import android.view.MenuItem
import androidx.core.os.postDelayed
@ -55,7 +56,7 @@ class GitConfigActivity : BaseGitActivity() {
GitSettings.authorEmail = email
GitSettings.authorName = name
Snackbar.make(binding.root, getString(R.string.git_server_config_save_success), Snackbar.LENGTH_SHORT).show()
Handler().postDelayed(500) { finish() }
Handler(Looper.getMainLooper()).postDelayed(500) { finish() }
}
}
}

View file

@ -8,6 +8,7 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.MenuItem
import android.view.View
import androidx.core.os.postDelayed
@ -144,7 +145,7 @@ class GitServerConfigActivity : BaseGitActivity() {
PasswordRepository.initialize()
if (!isClone) {
Snackbar.make(binding.root, getString(R.string.git_server_config_save_success), Snackbar.LENGTH_SHORT).show()
Handler().postDelayed(500) { finish() }
Handler(Looper.getMainLooper()).postDelayed(500) { finish() }
} else {
cloneRepository()
}

View file

@ -262,7 +262,12 @@ object SshKey {
apply(algorithm.applyToSpec)
if (requireAuthentication) {
setUserAuthenticationRequired(true)
setUserAuthenticationValidityDurationSeconds(30)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
setUserAuthenticationParameters(30, KeyProperties.AUTH_DEVICE_CREDENTIAL)
} else {
@Suppress("DEPRECATION")
setUserAuthenticationValidityDurationSeconds(30)
}
}
build()
}

View file

@ -60,7 +60,7 @@ internal fun Project.configureForAllProjects() {
*/
@Suppress("UnstableApiUsage")
internal fun TestedExtension.configureCommonAndroidOptions() {
compileSdkVersion(29)
compileSdkVersion(30)
defaultConfig {
minSdkVersion(23)