diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9a7f47446..f7ab6482b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -157,7 +157,8 @@
+ android:name="com.kunzisoft.keepass.hardware.HardwareKeyActivity"
+ android:theme="@style/Theme.Transparent" />
val databaseWasReloaded = database?.wasReloaded == true
@@ -36,6 +36,10 @@ abstract class DatabaseActivity: StylishActivity(), DatabaseRetrieval {
}
}
+ protected open fun showDatabaseDialog(): Boolean {
+ return true
+ }
+
override fun onDestroy() {
mDatabaseTaskProvider?.destroy()
mDatabaseTaskProvider = null
diff --git a/app/src/main/java/com/kunzisoft/keepass/database/action/DatabaseTaskProvider.kt b/app/src/main/java/com/kunzisoft/keepass/database/action/DatabaseTaskProvider.kt
index 76cd48e4e..ebf10bb03 100644
--- a/app/src/main/java/com/kunzisoft/keepass/database/action/DatabaseTaskProvider.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/database/action/DatabaseTaskProvider.kt
@@ -90,7 +90,8 @@ import java.util.*
* Utility class to connect an activity or a service to the DatabaseTaskNotificationService,
* Useful to retrieve a database instance and sending tasks commands
*/
-class DatabaseTaskProvider(private var context: Context) {
+class DatabaseTaskProvider(private var context: Context,
+ private var showDialog: Boolean = true) {
// To show dialog only if context is an activity
private var activity: FragmentActivity? = try { context as? FragmentActivity? }
@@ -129,12 +130,14 @@ class DatabaseTaskProvider(private var context: Context) {
private val actionTaskListener = object: DatabaseTaskNotificationService.ActionTaskListener {
override fun onStartAction(database: Database,
progressMessage: ProgressMessage) {
- startDialog(progressMessage)
+ if (showDialog)
+ startDialog(progressMessage)
}
override fun onUpdateAction(database: Database,
progressMessage: ProgressMessage) {
- updateDialog(progressMessage)
+ if (showDialog)
+ updateDialog(progressMessage)
}
override fun onStopAction(database: Database,
diff --git a/app/src/main/java/com/kunzisoft/keepass/hardware/HardwareKeyActivity.kt b/app/src/main/java/com/kunzisoft/keepass/hardware/HardwareKeyActivity.kt
index 1965ce004..40540aed5 100644
--- a/app/src/main/java/com/kunzisoft/keepass/hardware/HardwareKeyActivity.kt
+++ b/app/src/main/java/com/kunzisoft/keepass/hardware/HardwareKeyActivity.kt
@@ -2,6 +2,7 @@ package com.kunzisoft.keepass.hardware
import android.app.Activity
import android.content.Context
+import android.content.DialogInterface
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.util.Log
@@ -39,13 +40,23 @@ class HardwareKeyActivity: DatabaseModeActivity(){
resultCallback
)
+ override fun applyCustomStyle(): Boolean {
+ return false
+ }
+
+ override fun showDatabaseDialog(): Boolean {
+ return false
+ }
+
override fun onDatabaseRetrieved(database: Database?) {
super.onDatabaseRetrieved(database)
val hardwareKey = HardwareKey.getHardwareKeyFromString(
intent.getStringExtra(DATA_HARDWARE_KEY)
)
- if (isHardwareKeyAvailable(this, hardwareKey)) {
+ if (isHardwareKeyAvailable(this, hardwareKey, true) {
+ mDatabaseTaskProvider?.startChallengeResponded(ByteArray(0))
+ }) {
when (hardwareKey) {
/*
HardwareKey.FIDO2_SECRET -> {
@@ -60,8 +71,6 @@ class HardwareKeyActivity: DatabaseModeActivity(){
finish()
}
}
- } else {
- finish()
}
}
@@ -106,7 +115,8 @@ class HardwareKeyActivity: DatabaseModeActivity(){
fun isHardwareKeyAvailable(
context: Context,
hardwareKey: HardwareKey?,
- showDialog: Boolean = true
+ showDialog: Boolean = true,
+ onDialogDismissed: DialogInterface.OnDismissListener? = null
): Boolean {
if (hardwareKey == null)
return false
@@ -125,8 +135,12 @@ class HardwareKeyActivity: DatabaseModeActivity(){
val yubikeyDriverAvailable =
Intent(YUBIKEY_CHALLENGE_RESPONSE_INTENT)
.resolveActivity(context.packageManager) != null
- if (showDialog && !yubikeyDriverAvailable)
- showHardwareKeyDriverNeeded(context, hardwareKey)
+ if (showDialog && !yubikeyDriverAvailable
+ && context is Activity)
+ showHardwareKeyDriverNeeded(context, hardwareKey) {
+ onDialogDismissed?.onDismiss(it)
+ context.finish()
+ }
yubikeyDriverAvailable
}
}
@@ -134,7 +148,8 @@ class HardwareKeyActivity: DatabaseModeActivity(){
private fun showHardwareKeyDriverNeeded(
context: Context,
- hardwareKey: HardwareKey
+ hardwareKey: HardwareKey,
+ onDialogDismissed: DialogInterface.OnDismissListener
) {
val builder = AlertDialog.Builder(context)
builder
@@ -145,6 +160,7 @@ class HardwareKeyActivity: DatabaseModeActivity(){
UriUtil.openExternalApp(context, context.getString(R.string.key_driver_app_id))
}
.setNegativeButton(android.R.string.cancel) { _, _ -> }
+ .setOnDismissListener(onDialogDismissed)
builder.create().show()
}
}
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 8e0ab3909..7c3df40ed 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -565,7 +565,7 @@
-