fix: Refactoring type mode call

This commit is contained in:
J-Jamet
2025-09-25 20:50:14 +02:00
parent e447388611
commit 76c20263f7
5 changed files with 235 additions and 427 deletions

View File

@@ -378,21 +378,26 @@ class EntryEditActivity : DatabaseLockActivity(),
intent = intent, intent = intent,
defaultAction = {}, defaultAction = {},
searchAction = {}, searchAction = {},
registrationAction = {}, selectionAction = { intentSender, typeMode, searchInfo, autofillComponent ->
keyboardSelectionAction = { when(typeMode) {
entryValidatedForKeyboardSelection(database, entrySave.newEntry) TypeMode.DEFAULT -> {}
TypeMode.MAGIKEYBOARD ->
entryValidatedForKeyboardSelection(database, entrySave.newEntry)
TypeMode.PASSKEY ->
entryValidatedForPasskeySelection(database, entrySave.newEntry)
TypeMode.AUTOFILL ->
entryValidatedForAutofillSelection(database, entrySave.newEntry)
}
}, },
autofillSelectionAction = { _, _ -> registrationAction = { intentSender, typeMode, registerInfo ->
entryValidatedForAutofillSelection(database, entrySave.newEntry) when(typeMode) {
}, TypeMode.DEFAULT -> {}
autofillRegistrationAction = { TypeMode.MAGIKEYBOARD -> {}
entryValidatedForAutofillRegistration(entrySave.newEntry) TypeMode.PASSKEY ->
}, entryValidatedForPasskeyRegistration(database, entrySave.newEntry)
passkeySelectionAction = { TypeMode.AUTOFILL ->
entryValidatedForPasskeySelection(database, entrySave.newEntry) entryValidatedForAutofillRegistration(entrySave.newEntry)
}, }
passkeyRegistrationAction = {
entryValidatedForPasskeyRegistration(database, entrySave.newEntry)
} }
) )
} }
@@ -439,23 +444,27 @@ class EntryEditActivity : DatabaseLockActivity(),
searchAction = { searchAction = {
// Nothing when search retrieved // Nothing when search retrieved
}, },
registrationAction = { selectionAction = { intentSender, typeMode, searchInfo, autofillComponent ->
entryValidatedForSave(entry) when(typeMode) {
TypeMode.DEFAULT -> {}
TypeMode.MAGIKEYBOARD ->
entryValidatedForKeyboardSelection(database, entry)
TypeMode.PASSKEY ->
entryValidatedForPasskeySelection(database, entry)
TypeMode.AUTOFILL ->
entryValidatedForAutofillSelection(database, entry)
}
}, },
keyboardSelectionAction = { registrationAction = { _, typeMode, _ ->
entryValidatedForKeyboardSelection(database, entry) when(typeMode) {
}, TypeMode.DEFAULT ->
autofillSelectionAction = { _, _ -> entryValidatedForSave(entry)
entryValidatedForAutofillSelection(database, entry) TypeMode.MAGIKEYBOARD -> {}
}, TypeMode.PASSKEY ->
autofillRegistrationAction = { entryValidatedForPasskeyRegistration(database, entry)
entryValidatedForAutofillRegistration(entry) TypeMode.AUTOFILL ->
}, entryValidatedForAutofillRegistration(entry)
passkeySelectionAction = { }
entryValidatedForPasskeySelection(database, entry)
},
passkeyRegistrationAction = {
entryValidatedForPasskeyRegistration(database, entry)
} }
) )
} }

View File

@@ -303,74 +303,29 @@ class FileDatabaseSelectActivity : DatabaseModeActivity(),
) )
onLaunchActivitySpecialMode() onLaunchActivitySpecialMode()
}, },
registrationAction = { registerInfo -> selectionAction = { intentSenderMode, typeMode, searchInfo, autofillComponent ->
MainCredentialActivity.launchForRegistration(
activity = this,
activityResultLauncher = mCredentialActivityResultLauncher,
databaseFile = databaseUri,
keyFile = keyFile,
hardwareKey = hardwareKey,
typeMode = TypeMode.DEFAULT,
registerInfo = registerInfo
)
onLaunchActivitySpecialMode()
},
keyboardSelectionAction = { searchInfo ->
MainCredentialActivity.launchForSelection( MainCredentialActivity.launchForSelection(
activity = this, activity = this,
activityResultLauncher = if (intentSenderMode)
mCredentialActivityResultLauncher else null,
databaseFile = databaseUri, databaseFile = databaseUri,
keyFile = keyFile, keyFile = keyFile,
hardwareKey = hardwareKey, hardwareKey = hardwareKey,
typeMode = TypeMode.MAGIKEYBOARD, typeMode = typeMode,
searchInfo = searchInfo
)
onLaunchActivitySpecialMode()
},
autofillSelectionAction = { searchInfo, autofillComponent ->
MainCredentialActivity.launchForSelection(
activity = this,
activityResultLauncher = mCredentialActivityResultLauncher,
databaseFile = databaseUri,
keyFile = keyFile,
hardwareKey = hardwareKey,
typeMode = TypeMode.AUTOFILL,
searchInfo = searchInfo, searchInfo = searchInfo,
autofillComponent = autofillComponent, autofillComponent = autofillComponent,
) )
onLaunchActivitySpecialMode() onLaunchActivitySpecialMode()
}, },
autofillRegistrationAction = { registerInfo -> registrationAction = { intentSenderMode, typeMode, registerInfo ->
MainCredentialActivity.launchForRegistration( MainCredentialActivity.launchForRegistration(
activity = this, activity = this,
activityResultLauncher = mCredentialActivityResultLauncher, activityResultLauncher = if (intentSenderMode)
mCredentialActivityResultLauncher else null,
databaseFile = databaseUri, databaseFile = databaseUri,
keyFile = keyFile, keyFile = keyFile,
hardwareKey = hardwareKey, hardwareKey = hardwareKey,
typeMode = TypeMode.AUTOFILL, typeMode = typeMode,
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,
registerInfo = registerInfo registerInfo = registerInfo
) )
onLaunchActivitySpecialMode() onLaunchActivitySpecialMode()

View File

@@ -18,7 +18,6 @@
*/ */
package com.kunzisoft.keepass.activities package com.kunzisoft.keepass.activities
import android.app.Activity
import android.app.SearchManager import android.app.SearchManager
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context
@@ -496,70 +495,29 @@ class GroupActivity : DatabaseLockActivity(),
searchAction = { searchAction = {
// Search not used // Search not used
}, },
registrationAction = { registerInfo -> selectionAction = { intentSenderMode, typeMode, searchInfo, autofillComponent ->
EntryEditActivity.launchForRegistration(
context = this@GroupActivity,
database = database,
nodeId = currentGroup.nodeId,
registerInfo = registerInfo,
typeMode = TypeMode.DEFAULT,
registrationType = EntryEditActivity.RegistrationType.CREATE
)
onLaunchActivitySpecialMode()
},
keyboardSelectionAction = { searchInfo ->
EntryEditActivity.launchForSelection( EntryEditActivity.launchForSelection(
context = this@GroupActivity, context = this@GroupActivity,
database = database, database = database,
typeMode = TypeMode.MAGIKEYBOARD, typeMode = typeMode,
groupId = currentGroup.nodeId,
searchInfo = searchInfo
)
onLaunchActivitySpecialMode()
},
autofillSelectionAction = { searchInfo, autofillComponent ->
EntryEditActivity.launchForSelection(
context = this@GroupActivity,
database = database,
typeMode = TypeMode.AUTOFILL,
groupId = currentGroup.nodeId, groupId = currentGroup.nodeId,
searchInfo = searchInfo, searchInfo = searchInfo,
autofillComponent = autofillComponent, autofillComponent = autofillComponent,
activityResultLauncher = mCredentialActivityResultLauncher activityResultLauncher = if (intentSenderMode)
mCredentialActivityResultLauncher else null
) )
onLaunchActivitySpecialMode() onLaunchActivitySpecialMode()
}, },
autofillRegistrationAction = { registerInfo -> registrationAction = { intentSenderMode, typeMode, registerInfo ->
EntryEditActivity.launchForRegistration( EntryEditActivity.launchForRegistration(
context = this@GroupActivity, context = this@GroupActivity,
database = database, database = database,
nodeId = currentGroup.nodeId, nodeId = currentGroup.nodeId,
registerInfo = registerInfo, registerInfo = registerInfo,
typeMode = TypeMode.AUTOFILL, typeMode = typeMode,
registrationType = EntryEditActivity.RegistrationType.CREATE registrationType = EntryEditActivity.RegistrationType.CREATE,
) activityResultLauncher = if (intentSenderMode)
onLaunchActivitySpecialMode() mCredentialActivityResultLauncher else null
},
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
) )
onLaunchActivitySpecialMode() onLaunchActivitySpecialMode()
} }
@@ -708,32 +666,22 @@ class GroupActivity : DatabaseLockActivity(),
searchAction = { searchAction = {
// Search not used // Search not used
}, },
registrationAction = { selectionAction = { intentSenderMode, typeMode, searchInfo, autofillComponent ->
when (typeMode) {
TypeMode.DEFAULT -> {}
TypeMode.MAGIKEYBOARD -> entry?.let {
entrySelectedForKeyboardSelection(database, it)
}
TypeMode.PASSKEY -> entry?.let {
entrySelectedForPasskeySelection(database, it)
}
TypeMode.AUTOFILL -> entry?.let {
entrySelectedForAutofillSelection(database, it)
}
}
},
registrationAction = { intentSenderMode, typeMode, searchInfo ->
// Save not used // Save not used
},
keyboardSelectionAction = {
// Keyboard selection
entry?.let {
entrySelectedForKeyboardSelection(database, it)
}
},
autofillSelectionAction = { _, _ ->
// Autofill selection
entry?.let {
entrySelectedForAutofillSelection(database, it)
}
},
autofillRegistrationAction = {
// Not use
},
passkeySelectionAction = {
// Passkey selection
entry?.let {
entrySelectedForPasskeySelection(database, it)
}
},
passkeyRegistrationAction = {
// Not use
} }
) )
} }
@@ -892,73 +840,51 @@ class GroupActivity : DatabaseLockActivity(),
searchAction = { searchAction = {
// Nothing here, a search is simply performed // Nothing here, a search is simply performed
}, },
registrationAction = { registerInfo -> selectionAction = { intentSenderMode, typeMode, searchInfo, autofillComponent ->
if (!database.isReadOnly) { when (typeMode) {
entrySelectedForRegistration( TypeMode.DEFAULT -> {}
database = database, TypeMode.MAGIKEYBOARD -> {
entry = entryVersioned, if (!database.isReadOnly
activityResultLauncher = null, && searchInfo != null
registerInfo = registerInfo, && PreferencesUtil.isKeyboardSaveSearchInfoEnable(this@GroupActivity)
typeMode = TypeMode.DEFAULT ) {
) updateEntryWithRegisterInfo(
loadGroup() database,
} else entryVersioned,
finish() searchInfo.toRegisterInfo()
}, )
keyboardSelectionAction = { searchInfo -> }
if (!database.isReadOnly entrySelectedForKeyboardSelection(database, entryVersioned)
&& searchInfo != null }
&& PreferencesUtil.isKeyboardSaveSearchInfoEnable(this@GroupActivity) TypeMode.PASSKEY -> {
) { entrySelectedForPasskeySelection(database, entryVersioned)
updateEntryWithRegisterInfo( }
database, TypeMode.AUTOFILL -> {
entryVersioned, if (!database.isReadOnly
searchInfo.toRegisterInfo() && searchInfo != null
) && PreferencesUtil.isAutofillSaveSearchInfoEnable(this@GroupActivity)
) {
updateEntryWithRegisterInfo(
database,
entryVersioned,
searchInfo.toRegisterInfo()
)
}
entrySelectedForAutofillSelection(database, entryVersioned)
}
} }
entrySelectedForKeyboardSelection(database, entryVersioned)
loadGroup() loadGroup()
}, },
autofillSelectionAction = { searchInfo, _ -> registrationAction = { intentSenderMode, typeMode, registerInfo ->
if (!database.isReadOnly
&& searchInfo != null
&& PreferencesUtil.isAutofillSaveSearchInfoEnable(this@GroupActivity)
) {
updateEntryWithRegisterInfo(
database,
entryVersioned,
searchInfo.toRegisterInfo()
)
}
entrySelectedForAutofillSelection(database, entryVersioned)
loadGroup()
},
autofillRegistrationAction = { registerInfo ->
if (!database.isReadOnly) { if (!database.isReadOnly) {
// TODO Ask to overwrite data
entrySelectedForRegistration( entrySelectedForRegistration(
database = database, database = database,
entry = entryVersioned, entry = entryVersioned,
registerInfo = registerInfo, registerInfo = registerInfo,
typeMode = TypeMode.AUTOFILL, typeMode = typeMode,
activityResultLauncher = null // TODO Result launcher autofill #765 activityResultLauncher = if (intentSenderMode)
) mCredentialActivityResultLauncher else null
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
) )
loadGroup() loadGroup()
} else } else
@@ -1682,196 +1608,103 @@ class GroupActivity : DatabaseLockActivity(),
onCancelSpecialMode() onCancelSpecialMode()
} }
}, },
registrationAction = { registerInfo -> selectionAction = { intentSenderMode, typeMode, searchInfo, autofillComponent ->
SearchHelper.checkAutoSearchInfo(
context = activity,
database = database,
searchInfo = searchInfo,
onItemsFound = { openedDatabase, items ->
when (typeMode) {
TypeMode.DEFAULT -> {}
TypeMode.MAGIKEYBOARD -> {
MagikeyboardService.performSelection(
items = items,
actionPopulateKeyboard = { entryInfo ->
// Keyboard populated
MagikeyboardService.populateKeyboardAndMoveAppToBackground(
activity,
entryInfo
)
onValidateSpecialMode()
},
actionEntrySelection = { autoSearch ->
launchForSelection(
context = activity,
database = database,
typeMode = TypeMode.MAGIKEYBOARD,
searchInfo = searchInfo,
autoSearch = autoSearch
)
onLaunchActivitySpecialMode()
}
)
}
TypeMode.PASSKEY -> {
// Response is build
EntrySelectionHelper.performSelection(
items = items,
actionPopulateCredentialProvider = { entryInfo ->
activity.buildPasskeyResponseAndSetResult(entryInfo)
onValidateSpecialMode()
},
actionEntrySelection = {
launchForSelection(
context = activity,
database = database,
typeMode = TypeMode.PASSKEY,
searchInfo = searchInfo,
activityResultLauncher = activityResultLauncher,
autoSearch = true
)
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,
searchInfo = searchInfo,
autoSearch = false,
autofillComponent = autofillComponent,
activityResultLauncher = if (intentSenderMode)
activityResultLauncher else null
)
onLaunchActivitySpecialMode()
},
onDatabaseClosed = {
// Simply close if database not opened, normally not happened
onCancelSpecialMode()
}
)
},
registrationAction = { intentSenderMode, typeMode, registerInfo ->
// Save info // Save info
if (database.loaded) { if (database.loaded) {
if (!database.isReadOnly) { if (!database.isReadOnly) {
launchForRegistration( launchForRegistration(
context = activity, context = activity,
activityResultLauncher = null,
database = database, database = database,
registerInfo = registerInfo, registerInfo = registerInfo,
typeMode = TypeMode.DEFAULT typeMode = typeMode,
activityResultLauncher = if (intentSenderMode)
activityResultLauncher else null
) )
onLaunchActivitySpecialMode() onLaunchActivitySpecialMode()
} else { } else {
activity.toastError(RegisterInReadOnlyDatabaseException()) activity.toastError(RegisterInReadOnlyDatabaseException())
onCancelSpecialMode() onCancelSpecialMode()
} }
}
},
keyboardSelectionAction = { searchInfo ->
// Keyboard selection
SearchHelper.checkAutoSearchInfo(
context = activity,
database = database,
searchInfo = searchInfo,
onItemsFound = { _, items ->
MagikeyboardService.performSelection(
items,
{ entryInfo ->
// Keyboard populated
MagikeyboardService.populateKeyboardAndMoveAppToBackground(
activity,
entryInfo
)
onValidateSpecialMode()
},
{ autoSearch ->
launchForSelection(
context = activity,
database = database,
typeMode = TypeMode.MAGIKEYBOARD,
searchInfo = searchInfo,
autoSearch = autoSearch
)
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 { } else {
activity.toastError(RegisterInReadOnlyDatabaseException())
onCancelSpecialMode()
}
},
passkeySelectionAction = { searchInfo ->
// Passkey selection
SearchHelper.checkAutoSearchInfo(
context = activity,
database = database,
searchInfo = searchInfo,
onItemsFound = { _, items ->
// Response is build
EntrySelectionHelper.performSelection(
items = items,
actionPopulateCredentialProvider = { entryInfo ->
activity.buildPasskeyResponseAndSetResult(entryInfo)
onValidateSpecialMode()
},
actionEntrySelection = {
launchForSelection(
context = activity,
database = database,
typeMode = TypeMode.PASSKEY,
searchInfo = searchInfo,
activityResultLauncher = activityResultLauncher,
autoSearch = true
)
onLaunchActivitySpecialMode()
}
)
},
onItemNotFound = {
// Here no search info found, disable auto search
launchForSelection(
context = activity,
database = database,
typeMode = TypeMode.PASSKEY,
searchInfo = searchInfo,
activityResultLauncher = activityResultLauncher
)
onLaunchActivitySpecialMode()
},
onDatabaseClosed = {
// Simply close if database not opened, normally not happened
onCancelSpecialMode()
}
)
},
passkeyRegistrationAction = { registerInfo ->
// Passkey registration
if (!database.isReadOnly) {
launchForRegistration(
context = activity,
activityResultLauncher = activityResultLauncher,
database = database,
registerInfo = registerInfo,
typeMode = TypeMode.PASSKEY
)
onLaunchActivitySpecialMode()
} else {
activity.toastError(RegisterInReadOnlyDatabaseException())
onCancelSpecialMode() onCancelSpecialMode()
} }
} }

View File

@@ -74,9 +74,9 @@ object EntrySelectionHelper {
TypeMode.DEFAULT -> // Close the database TypeMode.DEFAULT -> // Close the database
this.sendBroadcast(Intent(LOCK_ACTION)) this.sendBroadcast(Intent(LOCK_ACTION))
TypeMode.MAGIKEYBOARD -> { } TypeMode.MAGIKEYBOARD -> { }
TypeMode.PASSKEY -> { }
TypeMode.AUTOFILL -> if (PreferencesUtil.isAutofillCloseDatabaseEnable(this)) TypeMode.AUTOFILL -> if (PreferencesUtil.isAutofillCloseDatabaseEnable(this))
this.sendBroadcast(Intent(LOCK_ACTION)) this.sendBroadcast(Intent(LOCK_ACTION))
TypeMode.PASSKEY -> { }
} }
} }
} }
@@ -230,16 +230,19 @@ object EntrySelectionHelper {
intent: Intent, intent: Intent,
defaultAction: () -> Unit, defaultAction: () -> Unit,
searchAction: (searchInfo: SearchInfo) -> Unit, searchAction: (searchInfo: SearchInfo) -> Unit,
registrationAction: (registerInfo: RegisterInfo?) -> Unit, selectionAction: (
keyboardSelectionAction: (searchInfo: SearchInfo?) -> Unit, intentSenderMode: Boolean,
autofillSelectionAction: (searchInfo: SearchInfo?, typeMode: TypeMode,
autofillComponent: AutofillComponent) -> Unit, searchInfo: SearchInfo?,
autofillRegistrationAction: (registerInfo: RegisterInfo?) -> Unit, autofillComponent: AutofillComponent?
passkeySelectionAction: (searchInfo: SearchInfo?) -> Unit, ) -> Unit,
passkeyRegistrationAction: (registerInfo: RegisterInfo?) -> Unit registrationAction: (
intentSenderMode: Boolean,
typeMode: TypeMode,
registerInfo: RegisterInfo?
) -> Unit
) { ) {
when (val specialMode = retrieveSpecialModeFromIntent(intent)) {
when (retrieveSpecialModeFromIntent(intent)) {
SpecialMode.DEFAULT -> { SpecialMode.DEFAULT -> {
removeModesFromIntent(intent) removeModesFromIntent(intent)
removeInfoFromIntent(intent) removeInfoFromIntent(intent)
@@ -260,13 +263,18 @@ object EntrySelectionHelper {
var autofillComponentInit = false var autofillComponentInit = false
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
AutofillHelper.retrieveAutofillComponent(intent)?.let { autofillComponent -> AutofillHelper.retrieveAutofillComponent(intent)?.let { autofillComponent ->
autofillSelectionAction.invoke(searchInfo, autofillComponent) selectionAction.invoke(
isIntentSenderMode(specialMode, TypeMode.AUTOFILL),
TypeMode.AUTOFILL,
searchInfo,
autofillComponent
)
autofillComponentInit = true autofillComponentInit = true
} }
} }
if (!autofillComponentInit) { if (!autofillComponentInit) {
if (intent.getEnumExtra<SpecialMode>(KEY_SPECIAL_MODE) != null) { if (intent.getEnumExtra<SpecialMode>(KEY_SPECIAL_MODE) != null) {
when (retrieveTypeModeFromIntent(intent)) { when (val typeMode = retrieveTypeModeFromIntent(intent)) {
TypeMode.DEFAULT -> { TypeMode.DEFAULT -> {
removeModesFromIntent(intent) removeModesFromIntent(intent)
if (searchInfo != null) if (searchInfo != null)
@@ -274,10 +282,20 @@ object EntrySelectionHelper {
else else
defaultAction.invoke() defaultAction.invoke()
} }
TypeMode.MAGIKEYBOARD -> keyboardSelectionAction.invoke(searchInfo) TypeMode.MAGIKEYBOARD -> selectionAction.invoke(
isIntentSenderMode(specialMode, typeMode),
typeMode,
searchInfo,
null
)
TypeMode.PASSKEY -> TypeMode.PASSKEY ->
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
passkeySelectionAction.invoke(searchInfo) selectionAction.invoke(
isIntentSenderMode(specialMode, typeMode),
typeMode,
searchInfo,
null
)
} else } else
defaultAction.invoke() defaultAction.invoke()
else -> { else -> {
@@ -296,27 +314,20 @@ object EntrySelectionHelper {
} }
SpecialMode.REGISTRATION -> { SpecialMode.REGISTRATION -> {
val registerInfo: RegisterInfo? = retrieveRegisterInfoFromIntent(intent) val registerInfo: RegisterInfo? = retrieveRegisterInfoFromIntent(intent)
if (!isIntentSenderMode( val typeMode = retrieveTypeModeFromIntent(intent)
specialMode = retrieveSpecialModeFromIntent(intent), val intentSenderMode = isIntentSenderMode(specialMode, typeMode)
typeMode = retrieveTypeModeFromIntent(intent)) if (!intentSenderMode) {
) {
removeModesFromIntent(intent) removeModesFromIntent(intent)
removeInfoFromIntent(intent) removeInfoFromIntent(intent)
} }
when (retrieveTypeModeFromIntent(intent)) { if (registerInfo != null)
TypeMode.AUTOFILL -> { registrationAction.invoke(
autofillRegistrationAction.invoke(registerInfo) intentSenderMode,
} typeMode,
TypeMode.PASSKEY -> { registerInfo
passkeyRegistrationAction.invoke(registerInfo) )
} else {
else -> { defaultAction.invoke()
if (registerInfo != null)
registrationAction.invoke(registerInfo)
else {
defaultAction.invoke()
}
}
} }
} }
} }

View File

@@ -1,5 +1,5 @@
package com.kunzisoft.keepass.credentialprovider package com.kunzisoft.keepass.credentialprovider
enum class TypeMode { enum class TypeMode {
DEFAULT, MAGIKEYBOARD, AUTOFILL, PASSKEY DEFAULT, MAGIKEYBOARD, PASSKEY, AUTOFILL
} }