mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
fix: Refactoring type mode call
This commit is contained in:
@@ -378,21 +378,26 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
intent = intent,
|
||||
defaultAction = {},
|
||||
searchAction = {},
|
||||
registrationAction = {},
|
||||
keyboardSelectionAction = {
|
||||
selectionAction = { intentSender, typeMode, searchInfo, autofillComponent ->
|
||||
when(typeMode) {
|
||||
TypeMode.DEFAULT -> {}
|
||||
TypeMode.MAGIKEYBOARD ->
|
||||
entryValidatedForKeyboardSelection(database, entrySave.newEntry)
|
||||
},
|
||||
autofillSelectionAction = { _, _ ->
|
||||
entryValidatedForAutofillSelection(database, entrySave.newEntry)
|
||||
},
|
||||
autofillRegistrationAction = {
|
||||
entryValidatedForAutofillRegistration(entrySave.newEntry)
|
||||
},
|
||||
passkeySelectionAction = {
|
||||
TypeMode.PASSKEY ->
|
||||
entryValidatedForPasskeySelection(database, entrySave.newEntry)
|
||||
TypeMode.AUTOFILL ->
|
||||
entryValidatedForAutofillSelection(database, entrySave.newEntry)
|
||||
}
|
||||
},
|
||||
passkeyRegistrationAction = {
|
||||
registrationAction = { intentSender, typeMode, registerInfo ->
|
||||
when(typeMode) {
|
||||
TypeMode.DEFAULT -> {}
|
||||
TypeMode.MAGIKEYBOARD -> {}
|
||||
TypeMode.PASSKEY ->
|
||||
entryValidatedForPasskeyRegistration(database, entrySave.newEntry)
|
||||
TypeMode.AUTOFILL ->
|
||||
entryValidatedForAutofillRegistration(entrySave.newEntry)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -439,23 +444,27 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
searchAction = {
|
||||
// Nothing when search retrieved
|
||||
},
|
||||
registrationAction = {
|
||||
entryValidatedForSave(entry)
|
||||
},
|
||||
keyboardSelectionAction = {
|
||||
selectionAction = { intentSender, typeMode, searchInfo, autofillComponent ->
|
||||
when(typeMode) {
|
||||
TypeMode.DEFAULT -> {}
|
||||
TypeMode.MAGIKEYBOARD ->
|
||||
entryValidatedForKeyboardSelection(database, entry)
|
||||
},
|
||||
autofillSelectionAction = { _, _ ->
|
||||
entryValidatedForAutofillSelection(database, entry)
|
||||
},
|
||||
autofillRegistrationAction = {
|
||||
entryValidatedForAutofillRegistration(entry)
|
||||
},
|
||||
passkeySelectionAction = {
|
||||
TypeMode.PASSKEY ->
|
||||
entryValidatedForPasskeySelection(database, entry)
|
||||
TypeMode.AUTOFILL ->
|
||||
entryValidatedForAutofillSelection(database, entry)
|
||||
}
|
||||
},
|
||||
passkeyRegistrationAction = {
|
||||
registrationAction = { _, typeMode, _ ->
|
||||
when(typeMode) {
|
||||
TypeMode.DEFAULT ->
|
||||
entryValidatedForSave(entry)
|
||||
TypeMode.MAGIKEYBOARD -> {}
|
||||
TypeMode.PASSKEY ->
|
||||
entryValidatedForPasskeyRegistration(database, entry)
|
||||
TypeMode.AUTOFILL ->
|
||||
entryValidatedForAutofillRegistration(entry)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -303,74 +303,29 @@ class FileDatabaseSelectActivity : DatabaseModeActivity(),
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
registrationAction = { registerInfo ->
|
||||
MainCredentialActivity.launchForRegistration(
|
||||
activity = this,
|
||||
activityResultLauncher = mCredentialActivityResultLauncher,
|
||||
databaseFile = databaseUri,
|
||||
keyFile = keyFile,
|
||||
hardwareKey = hardwareKey,
|
||||
typeMode = TypeMode.DEFAULT,
|
||||
registerInfo = registerInfo
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
keyboardSelectionAction = { searchInfo ->
|
||||
selectionAction = { intentSenderMode, typeMode, searchInfo, autofillComponent ->
|
||||
MainCredentialActivity.launchForSelection(
|
||||
activity = this,
|
||||
activityResultLauncher = if (intentSenderMode)
|
||||
mCredentialActivityResultLauncher else null,
|
||||
databaseFile = databaseUri,
|
||||
keyFile = keyFile,
|
||||
hardwareKey = hardwareKey,
|
||||
typeMode = TypeMode.MAGIKEYBOARD,
|
||||
searchInfo = searchInfo
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
autofillSelectionAction = { searchInfo, autofillComponent ->
|
||||
MainCredentialActivity.launchForSelection(
|
||||
activity = this,
|
||||
activityResultLauncher = mCredentialActivityResultLauncher,
|
||||
databaseFile = databaseUri,
|
||||
keyFile = keyFile,
|
||||
hardwareKey = hardwareKey,
|
||||
typeMode = TypeMode.AUTOFILL,
|
||||
typeMode = typeMode,
|
||||
searchInfo = searchInfo,
|
||||
autofillComponent = autofillComponent,
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
autofillRegistrationAction = { registerInfo ->
|
||||
registrationAction = { intentSenderMode, typeMode, registerInfo ->
|
||||
MainCredentialActivity.launchForRegistration(
|
||||
activity = this,
|
||||
activityResultLauncher = mCredentialActivityResultLauncher,
|
||||
activityResultLauncher = if (intentSenderMode)
|
||||
mCredentialActivityResultLauncher else null,
|
||||
databaseFile = databaseUri,
|
||||
keyFile = keyFile,
|
||||
hardwareKey = hardwareKey,
|
||||
typeMode = TypeMode.AUTOFILL,
|
||||
registerInfo = registerInfo
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
passkeySelectionAction = { searchInfo ->
|
||||
MainCredentialActivity.launchForSelection(
|
||||
activity = this,
|
||||
activityResultLauncher = mCredentialActivityResultLauncher,
|
||||
databaseFile = databaseUri,
|
||||
keyFile = keyFile,
|
||||
hardwareKey = hardwareKey,
|
||||
typeMode = TypeMode.PASSKEY,
|
||||
searchInfo = searchInfo
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
passkeyRegistrationAction = { registerInfo ->
|
||||
MainCredentialActivity.launchForRegistration(
|
||||
activity = this,
|
||||
activityResultLauncher = mCredentialActivityResultLauncher,
|
||||
databaseFile = databaseUri,
|
||||
keyFile = keyFile,
|
||||
hardwareKey = hardwareKey,
|
||||
typeMode = TypeMode.PASSKEY,
|
||||
typeMode = typeMode,
|
||||
registerInfo = registerInfo
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
package com.kunzisoft.keepass.activities
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.SearchManager
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
@@ -496,70 +495,29 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
searchAction = {
|
||||
// Search not used
|
||||
},
|
||||
registrationAction = { registerInfo ->
|
||||
EntryEditActivity.launchForRegistration(
|
||||
context = this@GroupActivity,
|
||||
database = database,
|
||||
nodeId = currentGroup.nodeId,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.DEFAULT,
|
||||
registrationType = EntryEditActivity.RegistrationType.CREATE
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
keyboardSelectionAction = { searchInfo ->
|
||||
selectionAction = { intentSenderMode, typeMode, searchInfo, autofillComponent ->
|
||||
EntryEditActivity.launchForSelection(
|
||||
context = this@GroupActivity,
|
||||
database = database,
|
||||
typeMode = TypeMode.MAGIKEYBOARD,
|
||||
groupId = currentGroup.nodeId,
|
||||
searchInfo = searchInfo
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
autofillSelectionAction = { searchInfo, autofillComponent ->
|
||||
EntryEditActivity.launchForSelection(
|
||||
context = this@GroupActivity,
|
||||
database = database,
|
||||
typeMode = TypeMode.AUTOFILL,
|
||||
typeMode = typeMode,
|
||||
groupId = currentGroup.nodeId,
|
||||
searchInfo = searchInfo,
|
||||
autofillComponent = autofillComponent,
|
||||
activityResultLauncher = mCredentialActivityResultLauncher
|
||||
activityResultLauncher = if (intentSenderMode)
|
||||
mCredentialActivityResultLauncher else null
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
autofillRegistrationAction = { registerInfo ->
|
||||
registrationAction = { intentSenderMode, typeMode, registerInfo ->
|
||||
EntryEditActivity.launchForRegistration(
|
||||
context = this@GroupActivity,
|
||||
database = database,
|
||||
nodeId = currentGroup.nodeId,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.AUTOFILL,
|
||||
registrationType = EntryEditActivity.RegistrationType.CREATE
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
passkeySelectionAction = { searchInfo ->
|
||||
EntryEditActivity.launchForSelection(
|
||||
context = this@GroupActivity,
|
||||
database = database,
|
||||
typeMode = TypeMode.PASSKEY,
|
||||
groupId = currentGroup.nodeId,
|
||||
searchInfo = searchInfo,
|
||||
activityResultLauncher = mCredentialActivityResultLauncher
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
passkeyRegistrationAction = { registerInfo ->
|
||||
EntryEditActivity.launchForRegistration(
|
||||
context = this@GroupActivity,
|
||||
database = database,
|
||||
activityResultLauncher = mCredentialActivityResultLauncher,
|
||||
nodeId = currentGroup.nodeId,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.PASSKEY,
|
||||
registrationType = EntryEditActivity.RegistrationType.CREATE
|
||||
typeMode = typeMode,
|
||||
registrationType = EntryEditActivity.RegistrationType.CREATE,
|
||||
activityResultLauncher = if (intentSenderMode)
|
||||
mCredentialActivityResultLauncher else null
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
}
|
||||
@@ -708,32 +666,22 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
searchAction = {
|
||||
// Search not used
|
||||
},
|
||||
registrationAction = {
|
||||
// Save not used
|
||||
},
|
||||
keyboardSelectionAction = {
|
||||
// Keyboard selection
|
||||
entry?.let {
|
||||
selectionAction = { intentSenderMode, typeMode, searchInfo, autofillComponent ->
|
||||
when (typeMode) {
|
||||
TypeMode.DEFAULT -> {}
|
||||
TypeMode.MAGIKEYBOARD -> entry?.let {
|
||||
entrySelectedForKeyboardSelection(database, it)
|
||||
}
|
||||
},
|
||||
autofillSelectionAction = { _, _ ->
|
||||
// Autofill selection
|
||||
entry?.let {
|
||||
entrySelectedForAutofillSelection(database, it)
|
||||
}
|
||||
},
|
||||
autofillRegistrationAction = {
|
||||
// Not use
|
||||
},
|
||||
passkeySelectionAction = {
|
||||
// Passkey selection
|
||||
entry?.let {
|
||||
TypeMode.PASSKEY -> entry?.let {
|
||||
entrySelectedForPasskeySelection(database, it)
|
||||
}
|
||||
TypeMode.AUTOFILL -> entry?.let {
|
||||
entrySelectedForAutofillSelection(database, it)
|
||||
}
|
||||
}
|
||||
},
|
||||
passkeyRegistrationAction = {
|
||||
// Not use
|
||||
registrationAction = { intentSenderMode, typeMode, searchInfo ->
|
||||
// Save not used
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -892,20 +840,10 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
searchAction = {
|
||||
// Nothing here, a search is simply performed
|
||||
},
|
||||
registrationAction = { registerInfo ->
|
||||
if (!database.isReadOnly) {
|
||||
entrySelectedForRegistration(
|
||||
database = database,
|
||||
entry = entryVersioned,
|
||||
activityResultLauncher = null,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.DEFAULT
|
||||
)
|
||||
loadGroup()
|
||||
} else
|
||||
finish()
|
||||
},
|
||||
keyboardSelectionAction = { searchInfo ->
|
||||
selectionAction = { intentSenderMode, typeMode, searchInfo, autofillComponent ->
|
||||
when (typeMode) {
|
||||
TypeMode.DEFAULT -> {}
|
||||
TypeMode.MAGIKEYBOARD -> {
|
||||
if (!database.isReadOnly
|
||||
&& searchInfo != null
|
||||
&& PreferencesUtil.isKeyboardSaveSearchInfoEnable(this@GroupActivity)
|
||||
@@ -917,9 +855,11 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
)
|
||||
}
|
||||
entrySelectedForKeyboardSelection(database, entryVersioned)
|
||||
loadGroup()
|
||||
},
|
||||
autofillSelectionAction = { searchInfo, _ ->
|
||||
}
|
||||
TypeMode.PASSKEY -> {
|
||||
entrySelectedForPasskeySelection(database, entryVersioned)
|
||||
}
|
||||
TypeMode.AUTOFILL -> {
|
||||
if (!database.isReadOnly
|
||||
&& searchInfo != null
|
||||
&& PreferencesUtil.isAutofillSaveSearchInfoEnable(this@GroupActivity)
|
||||
@@ -931,34 +871,20 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
)
|
||||
}
|
||||
entrySelectedForAutofillSelection(database, entryVersioned)
|
||||
}
|
||||
}
|
||||
loadGroup()
|
||||
},
|
||||
autofillRegistrationAction = { registerInfo ->
|
||||
registrationAction = { intentSenderMode, typeMode, registerInfo ->
|
||||
if (!database.isReadOnly) {
|
||||
// TODO Ask to overwrite data
|
||||
entrySelectedForRegistration(
|
||||
database = database,
|
||||
entry = entryVersioned,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.AUTOFILL,
|
||||
activityResultLauncher = null // TODO Result launcher autofill #765
|
||||
)
|
||||
loadGroup()
|
||||
} else
|
||||
finish()
|
||||
},
|
||||
passkeySelectionAction = { searchInfo ->
|
||||
entrySelectedForPasskeySelection(database, entryVersioned)
|
||||
loadGroup()
|
||||
},
|
||||
passkeyRegistrationAction = { registerInfo ->
|
||||
if (!database.isReadOnly) {
|
||||
// TODO Passkey setting && PreferencesUtil.isAutofillOverwriteEnable(this@GroupActivity)
|
||||
entrySelectedForRegistration(
|
||||
database = database,
|
||||
entry = entryVersioned,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.PASSKEY,
|
||||
activityResultLauncher = mCredentialActivityResultLauncher
|
||||
typeMode = typeMode,
|
||||
activityResultLauncher = if (intentSenderMode)
|
||||
mCredentialActivityResultLauncher else null
|
||||
)
|
||||
loadGroup()
|
||||
} else
|
||||
@@ -1682,34 +1608,18 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
},
|
||||
registrationAction = { registerInfo ->
|
||||
// Save info
|
||||
if (database.loaded) {
|
||||
if (!database.isReadOnly) {
|
||||
launchForRegistration(
|
||||
context = activity,
|
||||
activityResultLauncher = null,
|
||||
database = database,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.DEFAULT
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
} else {
|
||||
activity.toastError(RegisterInReadOnlyDatabaseException())
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
}
|
||||
},
|
||||
keyboardSelectionAction = { searchInfo ->
|
||||
// Keyboard selection
|
||||
selectionAction = { intentSenderMode, typeMode, searchInfo, autofillComponent ->
|
||||
SearchHelper.checkAutoSearchInfo(
|
||||
context = activity,
|
||||
database = database,
|
||||
searchInfo = searchInfo,
|
||||
onItemsFound = { _, items ->
|
||||
onItemsFound = { openedDatabase, items ->
|
||||
when (typeMode) {
|
||||
TypeMode.DEFAULT -> {}
|
||||
TypeMode.MAGIKEYBOARD -> {
|
||||
MagikeyboardService.performSelection(
|
||||
items,
|
||||
{ entryInfo ->
|
||||
items = items,
|
||||
actionPopulateKeyboard = { entryInfo ->
|
||||
// Keyboard populated
|
||||
MagikeyboardService.populateKeyboardAndMoveAppToBackground(
|
||||
activity,
|
||||
@@ -1717,7 +1627,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
)
|
||||
onValidateSpecialMode()
|
||||
},
|
||||
{ autoSearch ->
|
||||
actionEntrySelection = { autoSearch ->
|
||||
launchForSelection(
|
||||
context = activity,
|
||||
database = database,
|
||||
@@ -1728,100 +1638,8 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
onLaunchActivitySpecialMode()
|
||||
}
|
||||
)
|
||||
},
|
||||
onItemNotFound = {
|
||||
// Here no search info found, disable auto search
|
||||
launchForSelection(
|
||||
context = activity,
|
||||
database = database,
|
||||
typeMode = TypeMode.MAGIKEYBOARD,
|
||||
searchInfo = searchInfo,
|
||||
autoSearch = false
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
onDatabaseClosed = {
|
||||
// Simply close if database not opened, normally not happened
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
)
|
||||
},
|
||||
autofillSelectionAction = { searchInfo, autofillComponent ->
|
||||
// Autofill selection
|
||||
SearchHelper.checkAutoSearchInfo(
|
||||
context = activity,
|
||||
database = database,
|
||||
searchInfo = searchInfo,
|
||||
onItemsFound = { openedDatabase, items ->
|
||||
// Response is build
|
||||
AutofillHelper.buildResponseAndSetResult(activity, openedDatabase, items)
|
||||
onValidateSpecialMode()
|
||||
},
|
||||
onItemNotFound = {
|
||||
// Here no search info found, disable auto search
|
||||
launchForSelection(
|
||||
context = activity,
|
||||
database = database,
|
||||
typeMode = TypeMode.AUTOFILL,
|
||||
searchInfo = searchInfo,
|
||||
autoSearch = false,
|
||||
autofillComponent = autofillComponent,
|
||||
activityResultLauncher = activityResultLauncher
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
onDatabaseClosed = {
|
||||
// Simply close if database not opened, normally not happened
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
)
|
||||
},
|
||||
autofillRegistrationAction = { registerInfo ->
|
||||
// Autofill registration
|
||||
if (!database.isReadOnly) {
|
||||
SearchHelper.checkAutoSearchInfo(
|
||||
context = activity,
|
||||
database = database,
|
||||
searchInfo = registerInfo?.searchInfo,
|
||||
onItemsFound = { _, _ ->
|
||||
// No auto search, it's a registration
|
||||
launchForRegistration(
|
||||
context = activity,
|
||||
activityResultLauncher = null, // TODO Autofill result Launcher #765
|
||||
database = database,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.AUTOFILL
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
onItemNotFound = {
|
||||
// Here no search info found, disable auto search
|
||||
launchForRegistration(
|
||||
context = activity,
|
||||
activityResultLauncher = null, // TODO Autofill result Launcher #765
|
||||
database = database,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.AUTOFILL
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
onDatabaseClosed = {
|
||||
// Simply close if database not opened, normally not happened
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
)
|
||||
} else {
|
||||
activity.toastError(RegisterInReadOnlyDatabaseException())
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
},
|
||||
passkeySelectionAction = { searchInfo ->
|
||||
// Passkey selection
|
||||
SearchHelper.checkAutoSearchInfo(
|
||||
context = activity,
|
||||
database = database,
|
||||
searchInfo = searchInfo,
|
||||
onItemsFound = { _, items ->
|
||||
TypeMode.PASSKEY -> {
|
||||
// Response is build
|
||||
EntrySelectionHelper.performSelection(
|
||||
items = items,
|
||||
@@ -1841,15 +1659,25 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
onLaunchActivitySpecialMode()
|
||||
}
|
||||
)
|
||||
}
|
||||
TypeMode.AUTOFILL -> {
|
||||
// Response is build
|
||||
AutofillHelper.buildResponseAndSetResult(activity, openedDatabase, items)
|
||||
onValidateSpecialMode()
|
||||
}
|
||||
}
|
||||
},
|
||||
onItemNotFound = {
|
||||
// Here no search info found, disable auto search
|
||||
launchForSelection(
|
||||
context = activity,
|
||||
database = database,
|
||||
typeMode = TypeMode.PASSKEY,
|
||||
typeMode = typeMode,
|
||||
searchInfo = searchInfo,
|
||||
activityResultLauncher = activityResultLauncher
|
||||
autoSearch = false,
|
||||
autofillComponent = autofillComponent,
|
||||
activityResultLauncher = if (intentSenderMode)
|
||||
activityResultLauncher else null
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
@@ -1859,21 +1687,26 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
}
|
||||
)
|
||||
},
|
||||
passkeyRegistrationAction = { registerInfo ->
|
||||
// Passkey registration
|
||||
registrationAction = { intentSenderMode, typeMode, registerInfo ->
|
||||
// Save info
|
||||
if (database.loaded) {
|
||||
if (!database.isReadOnly) {
|
||||
launchForRegistration(
|
||||
context = activity,
|
||||
activityResultLauncher = activityResultLauncher,
|
||||
database = database,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.PASSKEY
|
||||
typeMode = typeMode,
|
||||
activityResultLauncher = if (intentSenderMode)
|
||||
activityResultLauncher else null
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
} else {
|
||||
activity.toastError(RegisterInReadOnlyDatabaseException())
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
} else {
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -74,9 +74,9 @@ object EntrySelectionHelper {
|
||||
TypeMode.DEFAULT -> // Close the database
|
||||
this.sendBroadcast(Intent(LOCK_ACTION))
|
||||
TypeMode.MAGIKEYBOARD -> { }
|
||||
TypeMode.PASSKEY -> { }
|
||||
TypeMode.AUTOFILL -> if (PreferencesUtil.isAutofillCloseDatabaseEnable(this))
|
||||
this.sendBroadcast(Intent(LOCK_ACTION))
|
||||
TypeMode.PASSKEY -> { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,16 +230,19 @@ object EntrySelectionHelper {
|
||||
intent: Intent,
|
||||
defaultAction: () -> Unit,
|
||||
searchAction: (searchInfo: SearchInfo) -> Unit,
|
||||
registrationAction: (registerInfo: RegisterInfo?) -> Unit,
|
||||
keyboardSelectionAction: (searchInfo: SearchInfo?) -> Unit,
|
||||
autofillSelectionAction: (searchInfo: SearchInfo?,
|
||||
autofillComponent: AutofillComponent) -> Unit,
|
||||
autofillRegistrationAction: (registerInfo: RegisterInfo?) -> Unit,
|
||||
passkeySelectionAction: (searchInfo: SearchInfo?) -> Unit,
|
||||
passkeyRegistrationAction: (registerInfo: RegisterInfo?) -> Unit
|
||||
selectionAction: (
|
||||
intentSenderMode: Boolean,
|
||||
typeMode: TypeMode,
|
||||
searchInfo: SearchInfo?,
|
||||
autofillComponent: AutofillComponent?
|
||||
) -> Unit,
|
||||
registrationAction: (
|
||||
intentSenderMode: Boolean,
|
||||
typeMode: TypeMode,
|
||||
registerInfo: RegisterInfo?
|
||||
) -> Unit
|
||||
) {
|
||||
|
||||
when (retrieveSpecialModeFromIntent(intent)) {
|
||||
when (val specialMode = retrieveSpecialModeFromIntent(intent)) {
|
||||
SpecialMode.DEFAULT -> {
|
||||
removeModesFromIntent(intent)
|
||||
removeInfoFromIntent(intent)
|
||||
@@ -260,13 +263,18 @@ object EntrySelectionHelper {
|
||||
var autofillComponentInit = false
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
AutofillHelper.retrieveAutofillComponent(intent)?.let { autofillComponent ->
|
||||
autofillSelectionAction.invoke(searchInfo, autofillComponent)
|
||||
selectionAction.invoke(
|
||||
isIntentSenderMode(specialMode, TypeMode.AUTOFILL),
|
||||
TypeMode.AUTOFILL,
|
||||
searchInfo,
|
||||
autofillComponent
|
||||
)
|
||||
autofillComponentInit = true
|
||||
}
|
||||
}
|
||||
if (!autofillComponentInit) {
|
||||
if (intent.getEnumExtra<SpecialMode>(KEY_SPECIAL_MODE) != null) {
|
||||
when (retrieveTypeModeFromIntent(intent)) {
|
||||
when (val typeMode = retrieveTypeModeFromIntent(intent)) {
|
||||
TypeMode.DEFAULT -> {
|
||||
removeModesFromIntent(intent)
|
||||
if (searchInfo != null)
|
||||
@@ -274,10 +282,20 @@ object EntrySelectionHelper {
|
||||
else
|
||||
defaultAction.invoke()
|
||||
}
|
||||
TypeMode.MAGIKEYBOARD -> keyboardSelectionAction.invoke(searchInfo)
|
||||
TypeMode.MAGIKEYBOARD -> selectionAction.invoke(
|
||||
isIntentSenderMode(specialMode, typeMode),
|
||||
typeMode,
|
||||
searchInfo,
|
||||
null
|
||||
)
|
||||
TypeMode.PASSKEY ->
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
passkeySelectionAction.invoke(searchInfo)
|
||||
selectionAction.invoke(
|
||||
isIntentSenderMode(specialMode, typeMode),
|
||||
typeMode,
|
||||
searchInfo,
|
||||
null
|
||||
)
|
||||
} else
|
||||
defaultAction.invoke()
|
||||
else -> {
|
||||
@@ -296,31 +314,24 @@ object EntrySelectionHelper {
|
||||
}
|
||||
SpecialMode.REGISTRATION -> {
|
||||
val registerInfo: RegisterInfo? = retrieveRegisterInfoFromIntent(intent)
|
||||
if (!isIntentSenderMode(
|
||||
specialMode = retrieveSpecialModeFromIntent(intent),
|
||||
typeMode = retrieveTypeModeFromIntent(intent))
|
||||
) {
|
||||
val typeMode = retrieveTypeModeFromIntent(intent)
|
||||
val intentSenderMode = isIntentSenderMode(specialMode, typeMode)
|
||||
if (!intentSenderMode) {
|
||||
removeModesFromIntent(intent)
|
||||
removeInfoFromIntent(intent)
|
||||
}
|
||||
when (retrieveTypeModeFromIntent(intent)) {
|
||||
TypeMode.AUTOFILL -> {
|
||||
autofillRegistrationAction.invoke(registerInfo)
|
||||
}
|
||||
TypeMode.PASSKEY -> {
|
||||
passkeyRegistrationAction.invoke(registerInfo)
|
||||
}
|
||||
else -> {
|
||||
if (registerInfo != null)
|
||||
registrationAction.invoke(registerInfo)
|
||||
registrationAction.invoke(
|
||||
intentSenderMode,
|
||||
typeMode,
|
||||
registerInfo
|
||||
)
|
||||
else {
|
||||
defaultAction.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun performSelection(items: List<EntryInfo>,
|
||||
actionPopulateCredentialProvider: (entryInfo: EntryInfo) -> Unit,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package com.kunzisoft.keepass.credentialprovider
|
||||
|
||||
enum class TypeMode {
|
||||
DEFAULT, MAGIKEYBOARD, AUTOFILL, PASSKEY
|
||||
DEFAULT, MAGIKEYBOARD, PASSKEY, AUTOFILL
|
||||
}
|
||||
Reference in New Issue
Block a user