mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-20 17:11:32 -08:00
fix: dialog to download driver
This commit is contained in:
1 parent
a6cd02d146
commit
e985bd2a20
5 files changed
+37
-13
No files matched your search
@@ -157,7 +157,8 @@
|
||||
<activity
|
||||
android:name="com.kunzisoft.keepass.settings.AutofillSettingsActivity" />
|
||||
<activity
|
||||
android:name="com.kunzisoft.keepass.hardware.HardwareKeyActivity" />
|
||||
android:name="com.kunzisoft.keepass.hardware.HardwareKeyActivity"
|
||||
android:theme="@style/Theme.Transparent" />
|
||||
<activity
|
||||
android:name="com.kunzisoft.keepass.activities.EntrySelectionLauncherActivity"
|
||||
android:theme="@style/Theme.Transparent"
|
||||
|
||||
@@ -20,7 +20,7 @@ abstract class DatabaseActivity: StylishActivity(), DatabaseRetrieval {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
mDatabaseTaskProvider = DatabaseTaskProvider(this)
|
||||
mDatabaseTaskProvider = DatabaseTaskProvider(this, showDatabaseDialog())
|
||||
|
||||
mDatabaseTaskProvider?.onDatabaseRetrieved = { database ->
|
||||
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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -565,7 +565,7 @@
|
||||
</style>
|
||||
|
||||
<!-- Transparent -->
|
||||
<style name="Theme.Transparent" parent="Theme.MaterialComponents">
|
||||
<style name="Theme.Transparent" parent="Theme.Material3.DynamicColors.Dark">
|
||||
<item name="android:windowAnimationStyle">@null</item>
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
|
||||
Reference in new issue
Block a user