mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix lock loop
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.activities.lock
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
@@ -75,7 +74,10 @@ abstract class LockingActivity : StylishActivity() {
|
||||
|
||||
if (mTimeoutEnable) {
|
||||
mLockReceiver = LockReceiver {
|
||||
lockAndExit()
|
||||
closeDatabase()
|
||||
// Add onActivityForResult response
|
||||
setResult(RESULT_EXIT_LOCK)
|
||||
finish()
|
||||
}
|
||||
registerLockReceiver(mLockReceiver)
|
||||
}
|
||||
@@ -148,7 +150,6 @@ abstract class LockingActivity : StylishActivity() {
|
||||
|
||||
protected fun lockAndExit() {
|
||||
sendBroadcast(Intent(LOCK_ACTION))
|
||||
lock()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,11 +181,3 @@ abstract class LockingActivity : StylishActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.lock() {
|
||||
closeDatabase()
|
||||
|
||||
// Add onActivityForResult response
|
||||
setResult(LockingActivity.RESULT_EXIT_LOCK)
|
||||
finish()
|
||||
}
|
||||
|
||||
@@ -19,14 +19,12 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.timeout
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.AlarmManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import com.kunzisoft.keepass.activities.lock.lock
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
@@ -130,20 +128,20 @@ object TimeoutHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the time previously record with recordTime and lock the activity if timeout
|
||||
* Check the time previously record with recordTime and lock the database if timeout
|
||||
*/
|
||||
fun checkTimeAndLockIfTimeout(activity: Activity): Boolean {
|
||||
return checkTime(activity) {
|
||||
activity.lock()
|
||||
fun checkTimeAndLockIfTimeout(context: Context): Boolean {
|
||||
return checkTime(context) {
|
||||
context.sendBroadcast(Intent(LOCK_ACTION))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the time previously record then, if timeout lock the activity, else reset the timer
|
||||
* Check the time previously record then, if timeout lock the database, else reset the timer
|
||||
*/
|
||||
fun checkTimeAndLockIfTimeoutOrResetTimeout(activity: Activity, action: (() -> Unit)? = null) {
|
||||
if (checkTimeAndLockIfTimeout(activity)) {
|
||||
recordTime(activity)
|
||||
fun checkTimeAndLockIfTimeoutOrResetTimeout(context: Context, action: (() -> Unit)? = null) {
|
||||
if (checkTimeAndLockIfTimeout(context)) {
|
||||
recordTime(context)
|
||||
action?.invoke()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user