mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix remove entry in Magikeyboard when lock in database performed
This commit is contained in:
@@ -34,9 +34,9 @@ import com.kunzisoft.keepass.activities.helpers.ReadOnlyHelper
|
||||
import com.kunzisoft.keepass.activities.stylish.StylishActivity
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.magikeyboard.KeyboardEntryNotificationService
|
||||
import com.kunzisoft.keepass.magikeyboard.receiver.LockBroadcastReceiver.Companion.LOCK_ACTION
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
|
||||
abstract class LockingActivity : StylishActivity() {
|
||||
|
||||
@@ -79,7 +79,7 @@ abstract class LockingActivity : StylishActivity() {
|
||||
addAction(Intent.ACTION_SCREEN_OFF)
|
||||
addAction(LOCK_ACTION)
|
||||
}
|
||||
registerReceiver(lockReceiver, IntentFilter(intentFilter))
|
||||
registerReceiver(lockReceiver, intentFilter)
|
||||
}
|
||||
|
||||
exitLock = false
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.app.Service
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
@@ -13,10 +14,9 @@ import android.support.v4.app.NotificationCompat
|
||||
import android.support.v7.preference.PreferenceManager
|
||||
import android.util.Log
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.magikeyboard.receiver.LockBroadcastReceiver
|
||||
import com.kunzisoft.keepass.magikeyboard.receiver.LockBroadcastReceiver.Companion.LOCK_ACTION
|
||||
import com.kunzisoft.keepass.magikeyboard.receiver.NotificationDeleteBroadcastReceiver
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
|
||||
class KeyboardEntryNotificationService : Service() {
|
||||
|
||||
@@ -25,7 +25,7 @@ class KeyboardEntryNotificationService : Service() {
|
||||
private val notificationId = 582
|
||||
private var notificationTimeoutMilliSecs: Long = 0
|
||||
|
||||
private var lockBroadcastReceiver: LockBroadcastReceiver? = null
|
||||
private var lockBroadcastReceiver: BroadcastReceiver? = null
|
||||
private var pendingDeleteIntent: PendingIntent? = null
|
||||
|
||||
override fun onBind(intent: Intent): IBinder? {
|
||||
@@ -45,12 +45,19 @@ class KeyboardEntryNotificationService : Service() {
|
||||
}
|
||||
|
||||
// Register a lock receiver to stop notification service when lock on keyboard is performed
|
||||
lockBroadcastReceiver = object : LockBroadcastReceiver() {
|
||||
override fun onReceiveLock(context: Context, intent: Intent) {
|
||||
context.stopService(Intent(context, KeyboardEntryNotificationService::class.java))
|
||||
lockBroadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
context?.let {
|
||||
MagikIME.entryInfoKey = null
|
||||
it.stopService(Intent(context, KeyboardEntryNotificationService::class.java))
|
||||
}
|
||||
}
|
||||
}
|
||||
registerReceiver(lockBroadcastReceiver, IntentFilter(LOCK_ACTION))
|
||||
registerReceiver(lockBroadcastReceiver,
|
||||
IntentFilter().apply {
|
||||
addAction(LOCK_ACTION)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.magikeyboard
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
@@ -37,11 +38,10 @@ import android.widget.PopupWindow
|
||||
import android.widget.TextView
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.magikeyboard.adapter.FieldsAdapter
|
||||
import com.kunzisoft.keepass.magikeyboard.receiver.LockBroadcastReceiver
|
||||
import com.kunzisoft.keepass.magikeyboard.receiver.LockBroadcastReceiver.Companion.LOCK_ACTION
|
||||
import com.kunzisoft.keepass.model.EntryInfo
|
||||
import com.kunzisoft.keepass.model.Field
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
|
||||
class MagikIME : InputMethodService(), KeyboardView.OnKeyboardActionListener {
|
||||
|
||||
@@ -53,19 +53,24 @@ class MagikIME : InputMethodService(), KeyboardView.OnKeyboardActionListener {
|
||||
private var fieldsAdapter: FieldsAdapter? = null
|
||||
private var playSoundDuringCLick: Boolean = false
|
||||
|
||||
private var lockBroadcastReceiver: LockBroadcastReceiver? = null
|
||||
private var lockBroadcastReceiver: BroadcastReceiver? = null
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
// Remove the entry and lock the keyboard when the lock signal is receive
|
||||
lockBroadcastReceiver = object : LockBroadcastReceiver() {
|
||||
override fun onReceiveLock(context: Context, intent: Intent) {
|
||||
lockBroadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
entryInfoKey = null
|
||||
assignKeyboardView()
|
||||
}
|
||||
}
|
||||
registerReceiver(lockBroadcastReceiver, IntentFilter(LOCK_ACTION))
|
||||
|
||||
registerReceiver(lockBroadcastReceiver,
|
||||
IntentFilter().apply {
|
||||
addAction(LOCK_ACTION)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCreateInputView(): View {
|
||||
@@ -285,8 +290,7 @@ class MagikIME : InputMethodService(), KeyboardView.OnKeyboardActionListener {
|
||||
var entryInfoKey: EntryInfo? = null
|
||||
|
||||
fun deleteEntryKey(context: Context) {
|
||||
val lockIntent = Intent(LOCK_ACTION)
|
||||
context.sendBroadcast(lockIntent)
|
||||
context.sendBroadcast(Intent(LOCK_ACTION))
|
||||
entryInfoKey = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.kunzisoft.keepass.magikeyboard.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
abstract class LockBroadcastReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val action = intent.action
|
||||
if (action != null && action == LOCK_ACTION) {
|
||||
onReceiveLock(context, intent)
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun onReceiveLock(context: Context, intent: Intent)
|
||||
|
||||
companion object {
|
||||
|
||||
const val LOCK_ACTION = "com.kunzisoft.keepass.LOCK"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,8 +29,8 @@ import android.util.Log
|
||||
import com.kunzisoft.keepass.activities.lock.LockingActivity
|
||||
import com.kunzisoft.keepass.activities.lock.lock
|
||||
import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.magikeyboard.receiver.LockBroadcastReceiver.Companion.LOCK_ACTION
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
|
||||
object TimeoutHelper {
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.kunzisoft.keepass.utils
|
||||
|
||||
const val LOCK_ACTION = "com.kunzisoft.keepass.LOCK"
|
||||
|
||||
Reference in New Issue
Block a user