First pass to update API 31

This commit is contained in:
J-Jamet
2021-12-17 17:57:09 +01:00
parent 9e15ac242d
commit 97cd61fd13
12 changed files with 72 additions and 34 deletions

View File

@@ -3,14 +3,14 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileSdkVersion 31
buildToolsVersion "31.0.0"
ndkVersion "21.4.7075529"
defaultConfig {
applicationId "com.kunzisoft.keepass"
minSdkVersion 15
targetSdkVersion 30
targetSdkVersion 31
versionCode = 92
versionName = "3.1.0"
multiDexEnabled true
@@ -99,7 +99,7 @@ android {
}
}
def room_version = "2.3.0"
def room_version = "2.4.0"
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
@@ -113,7 +113,7 @@ dependencies {
implementation 'androidx.media:media:1.4.3'
// Lifecycle - LiveData - ViewModel - Coroutines
implementation "androidx.core:core-ktx:$android_core_version"
implementation 'androidx.fragment:fragment-ktx:1.3.6'
implementation 'androidx.fragment:fragment-ktx:1.4.0'
implementation "com.google.android.material:material:$android_material_version"
// Database
implementation "androidx.room:room-runtime:$room_version"

View File

@@ -10,6 +10,8 @@
android:anyDensity="true" />
<uses-permission
android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission
android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission
android:name="android.permission.USE_BIOMETRIC" />
<uses-permission

View File

@@ -233,9 +233,8 @@ class AutofillLauncherActivity : DatabaseModeActivity() {
}
})
},
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// TODO Mutable
PendingIntent.FLAG_CANCEL_CURRENT
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_CANCEL_CURRENT
} else {
PendingIntent.FLAG_CANCEL_CURRENT
})
@@ -248,9 +247,8 @@ class AutofillLauncherActivity : DatabaseModeActivity() {
EntrySelectionHelper.addSpecialModeInIntent(this, SpecialMode.REGISTRATION)
putExtra(KEY_REGISTER_INFO, registerInfo)
},
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// TODO Mutable
PendingIntent.FLAG_CANCEL_CURRENT
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_CANCEL_CURRENT
} else {
PendingIntent.FLAG_CANCEL_CURRENT
})

View File

@@ -204,9 +204,9 @@ class EntryActivity : DatabaseLockActivity() {
}
mEntryViewModel.onOtpElementUpdated.observe(this) { otpElement ->
if (otpElement == null)
if (otpElement == null) {
entryProgress?.visibility = View.GONE
when (otpElement?.type) {
} else when (otpElement.type) {
// Only add token if HOTP
OtpType.HOTP -> {
entryProgress?.visibility = View.GONE

View File

@@ -454,6 +454,7 @@ class NodesAdapter (private val context: Context,
progress = otpElement.secondsRemaining
}
}
null -> {}
}
holder?.otpToken?.apply {
text = otpElement?.token

View File

@@ -66,9 +66,27 @@ object TimeoutHelper {
val triggerTime = System.currentTimeMillis() + timeout
Log.d(TAG, "TimeoutHelper start")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
alarmManager.setExact(AlarmManager.RTC, triggerTime, getLockPendingIntent(context))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
&& !alarmManager.canScheduleExactAlarms()) {
alarmManager.set(
AlarmManager.RTC,
triggerTime,
getLockPendingIntent(context)
)
// TODO explain why exact alarm is needed for timeout
} else {
alarmManager.setExact(
AlarmManager.RTC,
triggerTime,
getLockPendingIntent(context)
)
}
} else {
alarmManager.set(AlarmManager.RTC, triggerTime, getLockPendingIntent(context))
alarmManager.set(
AlarmManager.RTC,
triggerTime,
getLockPendingIntent(context)
)
}
}
}

View File

@@ -72,11 +72,29 @@ class LockReceiver(var lockAction: () -> Unit) : BroadcastReceiver() {
)
// Launch the effective action after a small time
val first: Long = System.currentTimeMillis() + context.getString(R.string.timeout_screen_off).toLong()
val alarmManager = context.getSystemService(ALARM_SERVICE) as AlarmManager?
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
alarmManager?.setExact(AlarmManager.RTC_WAKEUP, first, mLockPendingIntent)
} else {
alarmManager?.set(AlarmManager.RTC_WAKEUP, first, mLockPendingIntent)
(context.getSystemService(ALARM_SERVICE) as AlarmManager?)?.let { alarmManager ->
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
&& !alarmManager.canScheduleExactAlarms()) {
alarmManager.set(
AlarmManager.RTC_WAKEUP,
first,
mLockPendingIntent
)
} else {
alarmManager.setExact(
AlarmManager.RTC_WAKEUP,
first,
mLockPendingIntent
)
}
} else {
alarmManager.set(
AlarmManager.RTC_WAKEUP,
first,
mLockPendingIntent
)
}
}
} else {
cancelLockPendingIntent(context)

View File

@@ -80,7 +80,8 @@ class ToolbarAction @JvmOverloads constructor(context: Context,
mActionModeCallback = null
}
fun invalidateMenu() {
override fun invalidateMenu() {
super.invalidateMenu()
open()
mActionModeCallback?.onPrepareActionMode(actionMode, menu)
}

View File

@@ -1,8 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.5.31'
ext.android_core_version = '1.6.0'
ext.android_appcompat_version = '1.3.1'
ext.kotlin_version = '1.6.10'
ext.android_core_version = '1.7.0'
ext.android_appcompat_version = '1.4.0'
ext.android_material_version = '1.4.0'
ext.android_test_version = '1.4.0'
repositories {
@@ -10,7 +10,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

View File

@@ -5,12 +5,12 @@ plugins {
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
compileSdkVersion 31
buildToolsVersion "31.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 30
targetSdkVersion 31
versionCode 1
versionName "1.0"
multiDexEnabled true

View File

@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
compileSdkVersion 31
buildToolsVersion '31.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 30
targetSdkVersion 31
}
resourcePrefix 'classic_'

View File

@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
compileSdkVersion 31
buildToolsVersion '31.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 30
targetSdkVersion 31
}
resourcePrefix 'material_'