mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-05 16:22:31 -08:00
fix: Save mode as registration mode
This commit is contained in:
61 files changed
+107
-265
No files matched your search
@@ -206,8 +206,8 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
mDatabase,
|
||||
entryId,
|
||||
parentId,
|
||||
EntrySelectionHelper.retrieveRegisterInfoFromIntent(intent),
|
||||
EntrySelectionHelper.retrieveSearchInfoFromIntent(intent)
|
||||
EntrySelectionHelper.retrieveRegisterInfoFromIntent(intent)
|
||||
?: EntrySelectionHelper.retrieveSearchInfoFromIntent(intent)?.toRegisterInfo()
|
||||
)
|
||||
|
||||
// To retrieve attachment
|
||||
@@ -381,7 +381,7 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
intent = intent,
|
||||
defaultAction = {},
|
||||
searchAction = {},
|
||||
saveAction = {},
|
||||
registrationAction = {},
|
||||
keyboardSelectionAction = {
|
||||
entryValidatedForKeyboardSelection(database, entrySave.newEntry)
|
||||
},
|
||||
@@ -442,7 +442,7 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
searchAction = {
|
||||
// Nothing when search retrieved
|
||||
},
|
||||
saveAction = {
|
||||
registrationAction = {
|
||||
entryValidatedForSave(entry)
|
||||
},
|
||||
keyboardSelectionAction = {
|
||||
@@ -783,7 +783,7 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
val bundle = buildEntryResult(entry)
|
||||
val intentEntry = Intent()
|
||||
intentEntry.putExtras(bundle)
|
||||
setResult(Activity.RESULT_OK, intentEntry)
|
||||
setResult(RESULT_OK, intentEntry)
|
||||
super.finish()
|
||||
} catch (e: Exception) {
|
||||
// Exception when parcelable can't be done
|
||||
@@ -803,7 +803,7 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
fun registerForEntryResult(fragment: Fragment,
|
||||
entryAddedOrUpdatedListener: (NodeId<UUID>?) -> Unit): ActivityResultLauncher<Intent> {
|
||||
return fragment.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
if (result.resultCode == Activity.RESULT_OK) {
|
||||
if (result.resultCode == RESULT_OK) {
|
||||
entryAddedOrUpdatedListener.invoke(
|
||||
result.data?.getParcelableExtraCompat(ADD_OR_UPDATE_ENTRY_KEY)
|
||||
)
|
||||
@@ -816,7 +816,7 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
fun registerForEntryResult(activity: FragmentActivity,
|
||||
entryAddedOrUpdatedListener: (NodeId<UUID>?) -> Unit): ActivityResultLauncher<Intent> {
|
||||
return activity.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
if (result.resultCode == Activity.RESULT_OK) {
|
||||
if (result.resultCode == RESULT_OK) {
|
||||
entryAddedOrUpdatedListener.invoke(
|
||||
result.data?.getParcelableExtraCompat(ADD_OR_UPDATE_ENTRY_KEY)
|
||||
)
|
||||
@@ -858,40 +858,6 @@ class EntryEditActivity : DatabaseLockActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
fun launchToUpdateForSave(context: Context,
|
||||
database: ContextualDatabase,
|
||||
entryId: NodeId<UUID>,
|
||||
searchInfo: SearchInfo) {
|
||||
if (database.loaded && !database.isReadOnly) {
|
||||
if (TimeoutHelper.checkTimeAndLockIfTimeout(context)) {
|
||||
val intent = Intent(context, EntryEditActivity::class.java)
|
||||
intent.putExtra(KEY_ENTRY, entryId)
|
||||
EntrySelectionHelper.startActivityForSaveModeResult(
|
||||
context,
|
||||
intent,
|
||||
searchInfo
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun launchToCreateForSave(context: Context,
|
||||
database: ContextualDatabase,
|
||||
groupId: NodeId<*>,
|
||||
searchInfo: SearchInfo) {
|
||||
if (database.loaded && !database.isReadOnly) {
|
||||
if (TimeoutHelper.checkTimeAndLockIfTimeout(context)) {
|
||||
val intent = Intent(context, EntryEditActivity::class.java)
|
||||
intent.putExtra(KEY_PARENT, groupId)
|
||||
EntrySelectionHelper.startActivityForSaveModeResult(
|
||||
context,
|
||||
intent,
|
||||
searchInfo
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch EntryEditActivity to add a new entry in keyboard selection
|
||||
*/
|
||||
|
||||
@@ -449,19 +449,6 @@ class FileDatabaseSelectActivity : DatabaseModeActivity(),
|
||||
searchInfo)
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Save Launch
|
||||
* -------------------------
|
||||
*/
|
||||
|
||||
fun launchForSaveResult(context: Context,
|
||||
searchInfo: SearchInfo) {
|
||||
EntrySelectionHelper.startActivityForSaveModeResult(context,
|
||||
Intent(context, FileDatabaseSelectActivity::class.java),
|
||||
searchInfo)
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Keyboard Launch
|
||||
|
||||
@@ -500,12 +500,14 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
searchAction = {
|
||||
// Search not used
|
||||
},
|
||||
saveAction = { searchInfo ->
|
||||
EntryEditActivity.launchToCreateForSave(
|
||||
registrationAction = { registerInfo ->
|
||||
EntryEditActivity.launchToCreateForRegistration(
|
||||
context = this@GroupActivity,
|
||||
database = database,
|
||||
activityResultLauncher = null,
|
||||
groupId = currentGroup.nodeId,
|
||||
searchInfo = searchInfo
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.DEFAULT
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
@@ -714,7 +716,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
searchAction = {
|
||||
// Search not used
|
||||
},
|
||||
saveAction = {
|
||||
registrationAction = {
|
||||
// Save not used
|
||||
},
|
||||
keyboardSelectionAction = {
|
||||
@@ -739,7 +741,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
}
|
||||
},
|
||||
passkeyRegistrationAction = {
|
||||
// TODO Passkey Registration
|
||||
// Not use
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -897,9 +899,15 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
searchAction = {
|
||||
// Nothing here, a search is simply performed
|
||||
},
|
||||
saveAction = { searchInfo ->
|
||||
registrationAction = { registerInfo ->
|
||||
if (!database.isReadOnly) {
|
||||
entrySelectedForSave(database, entryVersioned, searchInfo)
|
||||
entrySelectedForRegistration(
|
||||
database = database,
|
||||
entry = entryVersioned,
|
||||
activityResultLauncher = null,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.DEFAULT
|
||||
)
|
||||
loadGroup()
|
||||
} else
|
||||
finish()
|
||||
@@ -909,7 +917,11 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
&& searchInfo != null
|
||||
&& PreferencesUtil.isKeyboardSaveSearchInfoEnable(this@GroupActivity)
|
||||
) {
|
||||
updateEntryWithSearchInfo(database, entryVersioned, searchInfo)
|
||||
updateEntryWithRegisterInfo(
|
||||
database,
|
||||
entryVersioned,
|
||||
searchInfo.toRegisterInfo()
|
||||
)
|
||||
}
|
||||
entrySelectedForKeyboardSelection(database, entryVersioned)
|
||||
loadGroup()
|
||||
@@ -919,7 +931,11 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
&& searchInfo != null
|
||||
&& PreferencesUtil.isAutofillSaveSearchInfoEnable(this@GroupActivity)
|
||||
) {
|
||||
updateEntryWithSearchInfo(database, entryVersioned, searchInfo)
|
||||
updateEntryWithRegisterInfo(
|
||||
database,
|
||||
entryVersioned,
|
||||
searchInfo.toRegisterInfo()
|
||||
)
|
||||
}
|
||||
entrySelectedForAutofillSelection(database, entryVersioned)
|
||||
loadGroup()
|
||||
@@ -938,11 +954,6 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
finish()
|
||||
},
|
||||
passkeySelectionAction = { searchInfo ->
|
||||
if (!database.isReadOnly
|
||||
&& searchInfo != null
|
||||
) {
|
||||
updateEntryWithSearchInfo(database, entryVersioned, searchInfo)
|
||||
}
|
||||
entrySelectedForPasskeySelection(database, entryVersioned)
|
||||
loadGroup()
|
||||
},
|
||||
@@ -966,18 +977,6 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
private fun entrySelectedForSave(database: ContextualDatabase, entry: Entry, searchInfo: SearchInfo) {
|
||||
removeSearch()
|
||||
// Save to update the entry
|
||||
EntryEditActivity.launchToUpdateForSave(
|
||||
this@GroupActivity,
|
||||
database,
|
||||
entry.nodeId,
|
||||
searchInfo
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
}
|
||||
|
||||
private fun entrySelectedForKeyboardSelection(database: ContextualDatabase, entry: Entry) {
|
||||
removeSearch()
|
||||
// Populate Magikeyboard with entry
|
||||
@@ -1032,10 +1031,10 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
onLaunchActivitySpecialMode()
|
||||
}
|
||||
|
||||
private fun updateEntryWithSearchInfo(
|
||||
private fun updateEntryWithRegisterInfo(
|
||||
database: ContextualDatabase,
|
||||
entry: Entry,
|
||||
searchInfo: SearchInfo
|
||||
registerInfo: RegisterInfo
|
||||
) {
|
||||
val newEntry = Entry(entry)
|
||||
val entryInfo = newEntry.getEntryInfo(
|
||||
@@ -1043,8 +1042,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
raw = true,
|
||||
removeTemplateConfiguration = false
|
||||
)
|
||||
// TODO Transform SearchInfo in RegisterInfo
|
||||
entryInfo.saveSearchInfo(database, searchInfo)
|
||||
entryInfo.saveRegisterInfo(database, registerInfo)
|
||||
newEntry.setEntryInfo(database, entryInfo)
|
||||
updateEntry(entry, newEntry)
|
||||
}
|
||||
@@ -1603,27 +1601,6 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Search save Launch
|
||||
* -------------------------
|
||||
*/
|
||||
fun launchForSaveResult(context: Context,
|
||||
database: ContextualDatabase,
|
||||
searchInfo: SearchInfo,
|
||||
autoSearch: Boolean = false) {
|
||||
if (database.loaded && !database.isReadOnly) {
|
||||
checkTimeAndBuildIntent(context, null) { intent ->
|
||||
intent.putExtra(AUTO_SEARCH_KEY, autoSearch)
|
||||
EntrySelectionHelper.startActivityForSaveModeResult(
|
||||
context,
|
||||
intent,
|
||||
searchInfo
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Keyboard Launch
|
||||
@@ -1753,15 +1730,16 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
onCancelSpecialMode()
|
||||
}
|
||||
},
|
||||
saveAction = { searchInfo ->
|
||||
registrationAction = { registerInfo ->
|
||||
// Save info
|
||||
if (database.loaded) {
|
||||
if (!database.isReadOnly) {
|
||||
launchForSaveResult(
|
||||
activity,
|
||||
database,
|
||||
searchInfo,
|
||||
false
|
||||
launchForRegistration(
|
||||
context = activity,
|
||||
activityResultLauncher = null,
|
||||
database = database,
|
||||
registerInfo = registerInfo,
|
||||
typeMode = TypeMode.DEFAULT
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
} else {
|
||||
|
||||
@@ -572,10 +572,7 @@ class MainCredentialActivity : DatabaseModeActivity() {
|
||||
clearCredentialsViews()
|
||||
}
|
||||
|
||||
if (mReadOnly && (
|
||||
mSpecialMode == SpecialMode.SAVE
|
||||
|| mSpecialMode == SpecialMode.REGISTRATION)
|
||||
) {
|
||||
if (mReadOnly && mSpecialMode == SpecialMode.REGISTRATION) {
|
||||
Log.e(TAG, getString(R.string.error_save_read_only))
|
||||
Snackbar.make(coordinatorLayout,
|
||||
R.string.error_save_read_only,
|
||||
@@ -802,26 +799,6 @@ class MainCredentialActivity : DatabaseModeActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Save Launch
|
||||
* -------------------------
|
||||
*/
|
||||
|
||||
@Throws(FileNotFoundException::class)
|
||||
fun launchForSaveResult(activity: Activity,
|
||||
databaseFile: Uri,
|
||||
keyFile: Uri?,
|
||||
hardwareKey: HardwareKey?,
|
||||
searchInfo: SearchInfo) {
|
||||
buildAndLaunchIntent(activity, databaseFile, keyFile, hardwareKey) { intent ->
|
||||
EntrySelectionHelper.startActivityForSaveModeResult(
|
||||
activity,
|
||||
intent,
|
||||
searchInfo)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* -------------------------
|
||||
* Keyboard Launch
|
||||
@@ -950,13 +927,15 @@ class MainCredentialActivity : DatabaseModeActivity() {
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
saveAction = { searchInfo ->
|
||||
launchForSaveResult(
|
||||
registrationAction = { registerInfo ->
|
||||
launchForRegistration(
|
||||
activity = activity,
|
||||
activityResultLauncher = activityResultLauncher,
|
||||
databaseFile = databaseUri,
|
||||
keyFile = keyFile,
|
||||
hardwareKey = hardwareKey,
|
||||
searchInfo = searchInfo
|
||||
typeMode = TypeMode.DEFAULT,
|
||||
registerInfo = registerInfo
|
||||
)
|
||||
onLaunchActivitySpecialMode()
|
||||
},
|
||||
|
||||
@@ -392,10 +392,8 @@ abstract class DatabaseLockActivity : DatabaseModeActivity(),
|
||||
}
|
||||
|
||||
private fun checkRegister() {
|
||||
// If in ave or registration mode, don't allow read only
|
||||
if ((mSpecialMode == SpecialMode.SAVE
|
||||
|| mSpecialMode == SpecialMode.REGISTRATION)
|
||||
&& mDatabaseReadOnly) {
|
||||
// If in registration mode, don't allow read only
|
||||
if (mSpecialMode == SpecialMode.REGISTRATION && mDatabaseReadOnly) {
|
||||
Toast.makeText(this, R.string.error_registration_read_only , Toast.LENGTH_LONG).show()
|
||||
EntrySelectionHelper.removeModesFromIntent(intent)
|
||||
finish()
|
||||
|
||||
@@ -125,9 +125,8 @@ abstract class DatabaseModeActivity : DatabaseActivity() {
|
||||
val selectionModeStringId = when (mSpecialMode) {
|
||||
SpecialMode.DEFAULT, // Not important because hidden
|
||||
SpecialMode.SEARCH -> R.string.search_mode
|
||||
SpecialMode.SAVE -> R.string.save_mode
|
||||
SpecialMode.SELECTION -> R.string.selection_mode
|
||||
SpecialMode.REGISTRATION -> R.string.registration_mode
|
||||
SpecialMode.REGISTRATION -> R.string.save_mode // Save is registration mode
|
||||
}
|
||||
val typeModeStringId = when (mTypeMode) {
|
||||
TypeMode.DEFAULT, // Not important because hidden
|
||||
@@ -145,7 +144,6 @@ abstract class DatabaseModeActivity : DatabaseActivity() {
|
||||
visible = when (mSpecialMode) {
|
||||
SpecialMode.DEFAULT -> false
|
||||
SpecialMode.SEARCH -> true
|
||||
SpecialMode.SAVE -> true
|
||||
SpecialMode.SELECTION -> true
|
||||
SpecialMode.REGISTRATION -> true
|
||||
}
|
||||
|
||||
+17
-31
@@ -102,16 +102,6 @@ object EntrySelectionHelper {
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
fun startActivityForSaveModeResult(context: Context,
|
||||
intent: Intent,
|
||||
searchInfo: SearchInfo) {
|
||||
addSpecialModeInIntent(intent, SpecialMode.SAVE)
|
||||
addTypeModeInIntent(intent, TypeMode.DEFAULT)
|
||||
addSearchInfoInIntent(intent, searchInfo)
|
||||
intent.flags = intent.flags or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
context.startActivity(intent)
|
||||
}
|
||||
|
||||
fun startActivityForKeyboardSelectionModeResult(context: Context,
|
||||
intent: Intent,
|
||||
searchInfo: SearchInfo?) {
|
||||
@@ -245,16 +235,18 @@ object EntrySelectionHelper {
|
||||
&& typeMode == TypeMode.PASSKEY)
|
||||
}
|
||||
|
||||
fun doSpecialAction(intent: Intent,
|
||||
defaultAction: () -> Unit,
|
||||
searchAction: (searchInfo: SearchInfo) -> Unit,
|
||||
saveAction: (searchInfo: SearchInfo) -> Unit,
|
||||
keyboardSelectionAction: (searchInfo: SearchInfo?) -> Unit,
|
||||
autofillSelectionAction: (searchInfo: SearchInfo?,
|
||||
autofillComponent: AutofillComponent) -> Unit,
|
||||
autofillRegistrationAction: (registerInfo: RegisterInfo?) -> Unit,
|
||||
passkeySelectionAction: (searchInfo: SearchInfo?) -> Unit,
|
||||
passkeyRegistrationAction: (registerInfo: RegisterInfo?) -> Unit) {
|
||||
fun doSpecialAction(
|
||||
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
|
||||
) {
|
||||
|
||||
when (retrieveSpecialModeFromIntent(intent)) {
|
||||
SpecialMode.DEFAULT -> {
|
||||
@@ -272,16 +264,6 @@ object EntrySelectionHelper {
|
||||
defaultAction.invoke()
|
||||
}
|
||||
}
|
||||
SpecialMode.SAVE -> {
|
||||
val searchInfo = retrieveSearchInfoFromIntent(intent)
|
||||
removeModesFromIntent(intent)
|
||||
removeInfoFromIntent(intent)
|
||||
if (searchInfo != null)
|
||||
saveAction.invoke(searchInfo)
|
||||
else {
|
||||
defaultAction.invoke()
|
||||
}
|
||||
}
|
||||
SpecialMode.SELECTION -> {
|
||||
val searchInfo: SearchInfo? = retrieveSearchInfoFromIntent(intent)
|
||||
var autofillComponentInit = false
|
||||
@@ -334,7 +316,11 @@ object EntrySelectionHelper {
|
||||
passkeyRegistrationAction.invoke(registerInfo)
|
||||
}
|
||||
else -> {
|
||||
// Do other registration type
|
||||
if (registerInfo != null)
|
||||
registrationAction.invoke(registerInfo)
|
||||
else {
|
||||
defaultAction.invoke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.kunzisoft.keepass.credentialprovider
|
||||
enum class SpecialMode {
|
||||
DEFAULT,
|
||||
SEARCH,
|
||||
SAVE,
|
||||
SELECTION,
|
||||
REGISTRATION;
|
||||
}
|
||||
+19
-16
@@ -22,12 +22,11 @@ package com.kunzisoft.keepass.credentialprovider.activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.core.net.toUri
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.FileDatabaseSelectActivity
|
||||
import com.kunzisoft.keepass.activities.GroupActivity
|
||||
import com.kunzisoft.keepass.activities.legacy.DatabaseModeActivity
|
||||
import com.kunzisoft.keepass.credentialprovider.TypeMode
|
||||
import com.kunzisoft.keepass.credentialprovider.magikeyboard.MagikeyboardService
|
||||
import com.kunzisoft.keepass.database.ContextualDatabase
|
||||
import com.kunzisoft.keepass.database.exception.RegisterInReadOnlyDatabaseException
|
||||
@@ -88,7 +87,7 @@ class EntrySelectionLauncherActivity : DatabaseModeActivity() {
|
||||
if (OtpEntryFields.isOTPUri(extra))
|
||||
otpString = extra
|
||||
}
|
||||
launchSelection(database, sharedWebDomain, otpString)
|
||||
launchSelection(database, null, otpString)
|
||||
}
|
||||
else -> {
|
||||
if (database != null) {
|
||||
@@ -133,11 +132,12 @@ class EntrySelectionLauncherActivity : DatabaseModeActivity() {
|
||||
// Items found
|
||||
if (searchInfo.otpString != null) {
|
||||
if (!readOnly) {
|
||||
GroupActivity.launchForSaveResult(
|
||||
this,
|
||||
openedDatabase,
|
||||
searchInfo,
|
||||
false
|
||||
GroupActivity.launchForRegistration(
|
||||
context = this,
|
||||
activityResultLauncher = null,
|
||||
database = openedDatabase,
|
||||
registerInfo = searchInfo.toRegisterInfo(),
|
||||
typeMode = TypeMode.DEFAULT
|
||||
)
|
||||
} else {
|
||||
toastError(RegisterInReadOnlyDatabaseException())
|
||||
@@ -174,11 +174,12 @@ class EntrySelectionLauncherActivity : DatabaseModeActivity() {
|
||||
// Show the database UI to select the entry
|
||||
if (searchInfo.otpString != null) {
|
||||
if (!readOnly) {
|
||||
GroupActivity.launchForSaveResult(
|
||||
this,
|
||||
openedDatabase,
|
||||
searchInfo,
|
||||
false
|
||||
GroupActivity.launchForRegistration(
|
||||
context = this,
|
||||
activityResultLauncher = null,
|
||||
database = openedDatabase,
|
||||
registerInfo = searchInfo.toRegisterInfo(),
|
||||
typeMode = TypeMode.DEFAULT
|
||||
)
|
||||
} else {
|
||||
toastError(RegisterInReadOnlyDatabaseException())
|
||||
@@ -202,9 +203,11 @@ class EntrySelectionLauncherActivity : DatabaseModeActivity() {
|
||||
onDatabaseClosed = {
|
||||
// If database not open
|
||||
if (searchInfo.otpString != null) {
|
||||
FileDatabaseSelectActivity.launchForSaveResult(
|
||||
this,
|
||||
searchInfo
|
||||
FileDatabaseSelectActivity.launchForRegistration(
|
||||
context = this,
|
||||
activityResultLauncher = null,
|
||||
registerInfo = searchInfo.toRegisterInfo(),
|
||||
typeMode = TypeMode.DEFAULT
|
||||
)
|
||||
} else if (searchShareForMagikeyboard) {
|
||||
FileDatabaseSelectActivity.launchForKeyboardSelectionResult(
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.kunzisoft.keepass.model.AttachmentState
|
||||
import com.kunzisoft.keepass.model.EntryAttachmentState
|
||||
import com.kunzisoft.keepass.model.EntryInfo
|
||||
import com.kunzisoft.keepass.model.RegisterInfo
|
||||
import com.kunzisoft.keepass.model.SearchInfo
|
||||
import com.kunzisoft.keepass.model.StreamDirection
|
||||
import com.kunzisoft.keepass.otp.OtpElement
|
||||
import com.kunzisoft.keepass.utils.IOActionTask
|
||||
@@ -28,7 +27,6 @@ class EntryEditViewModel: NodeEditViewModel() {
|
||||
private var mEntryId: NodeId<UUID>? = null
|
||||
private var mParentId: NodeId<*>? = null
|
||||
private var mRegisterInfo: RegisterInfo? = null
|
||||
private var mSearchInfo: SearchInfo? = null
|
||||
private var mParent: Group? = null
|
||||
private var mEntry: Entry? = null
|
||||
private var mIsTemplate: Boolean = false
|
||||
@@ -74,18 +72,18 @@ class EntryEditViewModel: NodeEditViewModel() {
|
||||
private val _onBinaryPreviewLoaded = SingleLiveEvent<AttachmentPosition>()
|
||||
|
||||
fun loadDatabase(database: ContextualDatabase?) {
|
||||
loadTemplateEntry(database, mEntryId, mParentId, mRegisterInfo, mSearchInfo)
|
||||
loadTemplateEntry(database, mEntryId, mParentId, mRegisterInfo)
|
||||
}
|
||||
|
||||
fun loadTemplateEntry(database: ContextualDatabase?,
|
||||
entryId: NodeId<UUID>?,
|
||||
parentId: NodeId<*>?,
|
||||
registerInfo: RegisterInfo?,
|
||||
searchInfo: SearchInfo?) {
|
||||
fun loadTemplateEntry(
|
||||
database: ContextualDatabase?,
|
||||
entryId: NodeId<UUID>?,
|
||||
parentId: NodeId<*>?,
|
||||
registerInfo: RegisterInfo?
|
||||
) {
|
||||
this.mEntryId = entryId
|
||||
this.mParentId = parentId
|
||||
this.mRegisterInfo = registerInfo
|
||||
this.mSearchInfo = searchInfo
|
||||
|
||||
database?.let {
|
||||
mEntryId?.let {
|
||||
@@ -105,8 +103,7 @@ class EntryEditViewModel: NodeEditViewModel() {
|
||||
database,
|
||||
entry,
|
||||
mIsTemplate,
|
||||
registerInfo,
|
||||
searchInfo
|
||||
registerInfo
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -145,8 +142,7 @@ class EntryEditViewModel: NodeEditViewModel() {
|
||||
database,
|
||||
mEntry,
|
||||
mIsTemplate,
|
||||
registerInfo,
|
||||
searchInfo
|
||||
registerInfo
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -159,11 +155,12 @@ class EntryEditViewModel: NodeEditViewModel() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun decodeTemplateEntry(database: ContextualDatabase,
|
||||
entry: Entry?,
|
||||
isTemplate: Boolean,
|
||||
registerInfo: RegisterInfo?,
|
||||
searchInfo: SearchInfo?): TemplatesEntry {
|
||||
private fun decodeTemplateEntry(
|
||||
database: ContextualDatabase,
|
||||
entry: Entry?,
|
||||
isTemplate: Boolean,
|
||||
registerInfo: RegisterInfo?
|
||||
): TemplatesEntry {
|
||||
val templates = database.getTemplates(isTemplate)
|
||||
val entryTemplate = entry?.let { database.getTemplate(it) }
|
||||
?: Template.STANDARD
|
||||
@@ -174,10 +171,6 @@ class EntryEditViewModel: NodeEditViewModel() {
|
||||
// Load entry info
|
||||
entry.getEntryInfo(database, true).let { tempEntryInfo ->
|
||||
// Retrieve data from registration
|
||||
// TODO only save registration
|
||||
searchInfo?.let { tempSearchInfo ->
|
||||
tempEntryInfo.saveSearchInfo(database, tempSearchInfo)
|
||||
}
|
||||
registerInfo?.let { regInfo ->
|
||||
tempEntryInfo.saveRegisterInfo(database, regInfo)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user