mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix save and app instance in selection mode
This commit is contained in:
@@ -6,6 +6,7 @@ KeePassDX(3.3.0)
|
|||||||
* Merge from file and save as copy #1221 #1204 #840
|
* Merge from file and save as copy #1221 #1204 #840
|
||||||
* Fix custom data #1236
|
* Fix custom data #1236
|
||||||
* Fix education hints #1192
|
* Fix education hints #1192
|
||||||
|
* Fix save and app instance in selection mode
|
||||||
* New UI and fix styles
|
* New UI and fix styles
|
||||||
* Add "Simple" and "Reply" themes
|
* Add "Simple" and "Reply" themes
|
||||||
|
|
||||||
|
|||||||
@@ -838,29 +838,13 @@ class GroupActivity : DatabaseLockActivity(),
|
|||||||
finish()
|
finish()
|
||||||
},
|
},
|
||||||
{ searchInfo ->
|
{ searchInfo ->
|
||||||
// Recheck search, only to fix #783 because workflow allows to open multiple search elements
|
if (!database.isReadOnly
|
||||||
SearchHelper.checkAutoSearchInfo(this,
|
&& searchInfo != null
|
||||||
database,
|
&& PreferencesUtil.isKeyboardSaveSearchInfoEnable(this@GroupActivity)
|
||||||
searchInfo,
|
) {
|
||||||
{ openedDatabase, _ ->
|
updateEntryWithSearchInfo(database, entryVersioned, searchInfo)
|
||||||
// Item in search, don't save
|
}
|
||||||
entrySelectedForKeyboardSelection(openedDatabase, entryVersioned)
|
entrySelectedForKeyboardSelection(database, entryVersioned)
|
||||||
},
|
|
||||||
{
|
|
||||||
// Item not found, save it if required
|
|
||||||
if (!database.isReadOnly
|
|
||||||
&& searchInfo != null
|
|
||||||
&& PreferencesUtil.isKeyboardSaveSearchInfoEnable(this@GroupActivity)
|
|
||||||
) {
|
|
||||||
updateEntryWithSearchInfo(database, entryVersioned, searchInfo)
|
|
||||||
}
|
|
||||||
entrySelectedForKeyboardSelection(database, entryVersioned)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// Normally not append
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
{ searchInfo, _ ->
|
{ searchInfo, _ ->
|
||||||
if (!database.isReadOnly
|
if (!database.isReadOnly
|
||||||
@@ -942,14 +926,16 @@ class GroupActivity : DatabaseLockActivity(),
|
|||||||
searchInfo: SearchInfo
|
searchInfo: SearchInfo
|
||||||
) {
|
) {
|
||||||
val newEntry = Entry(entry)
|
val newEntry = Entry(entry)
|
||||||
newEntry.setEntryInfo(database, newEntry.getEntryInfo(
|
val entryInfo = newEntry.getEntryInfo(
|
||||||
database,
|
database,
|
||||||
raw = true,
|
raw = true,
|
||||||
removeTemplateConfiguration = false
|
removeTemplateConfiguration = false
|
||||||
).apply {
|
)
|
||||||
saveSearchInfo(database, searchInfo)
|
val modification = entryInfo.saveSearchInfo(database, searchInfo)
|
||||||
})
|
newEntry.setEntryInfo(database, entryInfo)
|
||||||
updateEntry(entry, newEntry)
|
if (modification) {
|
||||||
|
updateEntry(entry, newEntry)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDateSet(datePicker: DatePicker?, year: Int, month: Int, day: Int) {
|
override fun onDateSet(datePicker: DatePicker?, year: Int, month: Int, day: Int) {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.kunzisoft.keepass.activities.legacy
|
package com.kunzisoft.keepass.activities.legacy
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.kunzisoft.keepass.R
|
import com.kunzisoft.keepass.R
|
||||||
@@ -11,6 +13,7 @@ import com.kunzisoft.keepass.model.SearchInfo
|
|||||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||||
import com.kunzisoft.keepass.view.SpecialModeView
|
import com.kunzisoft.keepass.view.SpecialModeView
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity to manage database special mode (ie: selection mode)
|
* Activity to manage database special mode (ie: selection mode)
|
||||||
*/
|
*/
|
||||||
@@ -63,8 +66,7 @@ abstract class DatabaseModeActivity : DatabaseActivity() {
|
|||||||
EntrySelectionHelper.removeModesFromIntent(intent)
|
EntrySelectionHelper.removeModesFromIntent(intent)
|
||||||
EntrySelectionHelper.removeInfoFromIntent(intent)
|
EntrySelectionHelper.removeInfoFromIntent(intent)
|
||||||
if (mSpecialMode != SpecialMode.DEFAULT) {
|
if (mSpecialMode != SpecialMode.DEFAULT) {
|
||||||
// To move the app in background
|
backToTheMainAppAndFinish()
|
||||||
moveTaskToBack(true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,8 +79,7 @@ abstract class DatabaseModeActivity : DatabaseActivity() {
|
|||||||
EntrySelectionHelper.removeModesFromIntent(intent)
|
EntrySelectionHelper.removeModesFromIntent(intent)
|
||||||
EntrySelectionHelper.removeInfoFromIntent(intent)
|
EntrySelectionHelper.removeInfoFromIntent(intent)
|
||||||
if (mSpecialMode != SpecialMode.DEFAULT) {
|
if (mSpecialMode != SpecialMode.DEFAULT) {
|
||||||
// To move the app in background
|
backToTheMainAppAndFinish()
|
||||||
moveTaskToBack(true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,11 +89,19 @@ abstract class DatabaseModeActivity : DatabaseActivity() {
|
|||||||
// To get the app caller, only for IntentSender
|
// To get the app caller, only for IntentSender
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
} else {
|
} else {
|
||||||
// To move the app in background
|
backToTheMainAppAndFinish()
|
||||||
moveTaskToBack(true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun backToTheMainAppAndFinish() {
|
||||||
|
// To move the app in background and return to the main app
|
||||||
|
moveTaskToBack(true)
|
||||||
|
// To remove this instance in the OS app selector
|
||||||
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
|
finish()
|
||||||
|
}, 2000)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,9 @@ class EntryInfo : NodeInfo {
|
|||||||
return customFields.lastOrNull { it.name == label }?.protectedValue?.toString() ?: ""
|
return customFields.lastOrNull { it.name == label }?.protectedValue?.toString() ?: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addUniqueField(field: Field, number: Int = 0) {
|
// Return true if modified
|
||||||
|
private fun addUniqueField(field: Field, number: Int = 0): Boolean {
|
||||||
|
var modification = false
|
||||||
var sameName = false
|
var sameName = false
|
||||||
var sameValue = false
|
var sameValue = false
|
||||||
val suffix = if (number > 0) "_$number" else ""
|
val suffix = if (number > 0) "_$number" else ""
|
||||||
@@ -117,20 +119,28 @@ class EntryInfo : NodeInfo {
|
|||||||
// Not write the same data again
|
// Not write the same data again
|
||||||
if (currentField.protectedValue.stringValue == field.protectedValue.stringValue) {
|
if (currentField.protectedValue.stringValue == field.protectedValue.stringValue) {
|
||||||
sameValue = true
|
sameValue = true
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
// Same name but new value, create a new suffix
|
// Same name but new value, create a new suffix
|
||||||
if (currentField.name == field.name + suffix) {
|
if (currentField.name == field.name + suffix) {
|
||||||
sameName = true
|
sameName = true
|
||||||
addUniqueField(field, number + 1)
|
if (addUniqueField(field, number + 1))
|
||||||
return
|
modification = true
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!sameName && !sameValue)
|
if (!sameName && !sameValue) {
|
||||||
(customFields as ArrayList<Field>).add(Field(field.name + suffix, field.protectedValue))
|
(customFields as ArrayList<Field>).add(Field(field.name + suffix, field.protectedValue))
|
||||||
|
modification = true
|
||||||
|
}
|
||||||
|
return modification
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveSearchInfo(database: Database?, searchInfo: SearchInfo) {
|
/**
|
||||||
|
* Add searchInfo to current EntryInfo, return true if new data, false if no modification
|
||||||
|
*/
|
||||||
|
fun saveSearchInfo(database: Database?, searchInfo: SearchInfo): Boolean {
|
||||||
|
var modification = false
|
||||||
searchInfo.otpString?.let { otpString ->
|
searchInfo.otpString?.let { otpString ->
|
||||||
// Replace the OTP field
|
// Replace the OTP field
|
||||||
OtpEntryFields.parseOTPUri(otpString)?.let { otpElement ->
|
OtpEntryFields.parseOTPUri(otpString)?.let { otpElement ->
|
||||||
@@ -145,6 +155,7 @@ class EntryInfo : NodeInfo {
|
|||||||
mutableCustomFields.remove(otpField)
|
mutableCustomFields.remove(otpField)
|
||||||
}
|
}
|
||||||
mutableCustomFields.add(otpField)
|
mutableCustomFields.add(otpField)
|
||||||
|
modification = true
|
||||||
}
|
}
|
||||||
} ?: searchInfo.webDomain?.let { webDomain ->
|
} ?: searchInfo.webDomain?.let { webDomain ->
|
||||||
// If unable to save web domain in custom field or URL not populated, save in URL
|
// If unable to save web domain in custom field or URL not populated, save in URL
|
||||||
@@ -153,23 +164,27 @@ class EntryInfo : NodeInfo {
|
|||||||
val webDomainToStore = "$webScheme://$webDomain"
|
val webDomainToStore = "$webScheme://$webDomain"
|
||||||
if (database?.allowEntryCustomFields() != true || url.isEmpty()) {
|
if (database?.allowEntryCustomFields() != true || url.isEmpty()) {
|
||||||
url = webDomainToStore
|
url = webDomainToStore
|
||||||
|
modification = true
|
||||||
} else if (url != webDomainToStore) {
|
} else if (url != webDomainToStore) {
|
||||||
// Save web domain in custom field
|
// Save web domain in custom field
|
||||||
addUniqueField(Field(WEB_DOMAIN_FIELD_NAME,
|
if (addUniqueField(Field(WEB_DOMAIN_FIELD_NAME,
|
||||||
ProtectedString(false, webDomainToStore)),
|
ProtectedString(false, webDomainToStore)),
|
||||||
1 // Start to one because URL is a standard field name
|
1 // Start to one because URL is a standard field name
|
||||||
)
|
))
|
||||||
|
modification = true
|
||||||
}
|
}
|
||||||
} ?: run {
|
} ?: run {
|
||||||
// Save application id in custom field
|
// Save application id in custom field
|
||||||
if (database?.allowEntryCustomFields() == true) {
|
if (database?.allowEntryCustomFields() == true) {
|
||||||
searchInfo.applicationId?.let { applicationId ->
|
searchInfo.applicationId?.let { applicationId ->
|
||||||
addUniqueField(Field(APPLICATION_ID_FIELD_NAME,
|
if (addUniqueField(Field(APPLICATION_ID_FIELD_NAME,
|
||||||
ProtectedString(false, applicationId))
|
ProtectedString(false, applicationId))
|
||||||
)
|
))
|
||||||
|
modification = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return modification
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveRegisterInfo(database: Database?, registerInfo: RegisterInfo) {
|
fun saveRegisterInfo(database: Database?, registerInfo: RegisterInfo) {
|
||||||
|
|||||||
@@ -5,5 +5,6 @@
|
|||||||
* Merge from file and save as copy #1221 #1204 #840
|
* Merge from file and save as copy #1221 #1204 #840
|
||||||
* Fix custom data #1236
|
* Fix custom data #1236
|
||||||
* Fix education hints #1192
|
* Fix education hints #1192
|
||||||
|
* Fix save and app instance in selection mode
|
||||||
* New UI and fix styles
|
* New UI and fix styles
|
||||||
* Add "Simple" and "Reply" themes
|
* Add "Simple" and "Reply" themes
|
||||||
@@ -5,5 +5,6 @@
|
|||||||
* Fusion depuis un fichier et sauvegarde de copie #1221 #1204 #840
|
* Fusion depuis un fichier et sauvegarde de copie #1221 #1204 #840
|
||||||
* Correction des données customisées #1236
|
* Correction des données customisées #1236
|
||||||
* Correction de écrans d'éducation #1192
|
* Correction de écrans d'éducation #1192
|
||||||
|
* Correction de la sauvegarde en mode sélection
|
||||||
* Nouvelle interface utilisateur et correction des styles
|
* Nouvelle interface utilisateur et correction des styles
|
||||||
* Ajout des thèmes "Simple" et "Réponse"
|
* Ajout des thèmes "Simple" et "Réponse"
|
||||||
Reference in New Issue
Block a user