mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Save search parameters #1254
This commit is contained in:
@@ -6,7 +6,7 @@ KeePassDX(3.4.0)
|
||||
* Better visualization of passwords #454 #1270
|
||||
* Passphrase implementation #218
|
||||
* Fix small bugs #1282
|
||||
* Better search implementation #175
|
||||
* Better search implementation #175 #1254
|
||||
|
||||
KeePassDX(3.3.3)
|
||||
* Fix shared otpauth link if database not open #1274
|
||||
|
||||
@@ -200,7 +200,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
finishNodeAction()
|
||||
if (mSearchState == null) {
|
||||
mSearchState = SearchState(searchFiltersView?.searchParameters
|
||||
?: SearchParameters(), 0)
|
||||
?: PreferencesUtil.getDefaultSearchParameters(this), 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
val stringQuery = intent.getStringExtra(SearchManager.QUERY)?.trim { it <= ' ' } ?: ""
|
||||
intent.action = Intent.ACTION_DEFAULT
|
||||
intent.removeExtra(SearchManager.QUERY)
|
||||
mSearchState = SearchState(SearchParameters().apply {
|
||||
mSearchState = SearchState(PreferencesUtil.getDefaultSearchParameters(this).apply {
|
||||
searchQuery = stringQuery
|
||||
}, mSearchState?.firstVisibleItem ?: 0)
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ class SearchHelper {
|
||||
return false
|
||||
|
||||
// Exclude entry expired
|
||||
if (searchParameters.excludeExpired) {
|
||||
if (!searchParameters.searchInExpired) {
|
||||
if (entry.isCurrentlyExpires)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class SearchParameters() : Parcelable{
|
||||
var searchInUsernames = true
|
||||
var searchInPasswords = false
|
||||
var searchInUrls = true
|
||||
var excludeExpired = false
|
||||
var searchInExpired = false
|
||||
var searchInNotes = true
|
||||
var searchInOTP = false
|
||||
var searchInOther = true
|
||||
@@ -54,7 +54,7 @@ class SearchParameters() : Parcelable{
|
||||
searchInUsernames = parcel.readByte() != 0.toByte()
|
||||
searchInPasswords = parcel.readByte() != 0.toByte()
|
||||
searchInUrls = parcel.readByte() != 0.toByte()
|
||||
excludeExpired = parcel.readByte() != 0.toByte()
|
||||
searchInExpired = parcel.readByte() != 0.toByte()
|
||||
searchInNotes = parcel.readByte() != 0.toByte()
|
||||
searchInOTP = parcel.readByte() != 0.toByte()
|
||||
searchInOther = parcel.readByte() != 0.toByte()
|
||||
@@ -74,7 +74,7 @@ class SearchParameters() : Parcelable{
|
||||
parcel.writeByte(if (searchInUsernames) 1 else 0)
|
||||
parcel.writeByte(if (searchInPasswords) 1 else 0)
|
||||
parcel.writeByte(if (searchInUrls) 1 else 0)
|
||||
parcel.writeByte(if (excludeExpired) 1 else 0)
|
||||
parcel.writeByte(if (searchInExpired) 1 else 0)
|
||||
parcel.writeByte(if (searchInNotes) 1 else 0)
|
||||
parcel.writeByte(if (searchInOTP) 1 else 0)
|
||||
parcel.writeByte(if (searchInOther) 1 else 0)
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.stylish.Stylish
|
||||
import com.kunzisoft.keepass.biometric.AdvancedUnlockManager
|
||||
import com.kunzisoft.keepass.database.element.SortNodeEnum
|
||||
import com.kunzisoft.keepass.database.search.SearchParameters
|
||||
import com.kunzisoft.keepass.education.Education
|
||||
import com.kunzisoft.keepass.password.PassphraseGenerator
|
||||
import com.kunzisoft.keepass.timeout.TimeoutHelper
|
||||
@@ -319,6 +320,82 @@ object PreferencesUtil {
|
||||
}
|
||||
}
|
||||
|
||||
fun getDefaultSearchParameters(context: Context): SearchParameters {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
return SearchParameters().apply {
|
||||
caseSensitive = prefs.getBoolean(context.getString(R.string.search_option_case_sensitive_key),
|
||||
context.resources.getBoolean(R.bool.search_option_case_sensitive_default))
|
||||
isRegex = prefs.getBoolean(context.getString(R.string.search_option_regex_key),
|
||||
context.resources.getBoolean(R.bool.search_option_regex_default))
|
||||
searchInTitles = prefs.getBoolean(context.getString(R.string.search_option_title_key),
|
||||
context.resources.getBoolean(R.bool.search_option_title_default))
|
||||
searchInUsernames = prefs.getBoolean(context.getString(R.string.search_option_username_key),
|
||||
context.resources.getBoolean(R.bool.search_option_username_default))
|
||||
searchInPasswords = prefs.getBoolean(context.getString(R.string.search_option_password_key),
|
||||
context.resources.getBoolean(R.bool.search_option_password_default))
|
||||
searchInUrls = prefs.getBoolean(context.getString(R.string.search_option_url_key),
|
||||
context.resources.getBoolean(R.bool.search_option_url_default))
|
||||
searchInExpired = prefs.getBoolean(context.getString(R.string.search_option_expired_key),
|
||||
context.resources.getBoolean(R.bool.search_option_expired_default))
|
||||
searchInNotes = prefs.getBoolean(context.getString(R.string.search_option_note_key),
|
||||
context.resources.getBoolean(R.bool.search_option_note_default))
|
||||
searchInOTP = prefs.getBoolean(context.getString(R.string.search_option_otp_key),
|
||||
context.resources.getBoolean(R.bool.search_option_otp_default))
|
||||
searchInOther = prefs.getBoolean(context.getString(R.string.search_option_other_key),
|
||||
context.resources.getBoolean(R.bool.search_option_other_default))
|
||||
searchInUUIDs = prefs.getBoolean(context.getString(R.string.search_option_uuid_key),
|
||||
context.resources.getBoolean(R.bool.search_option_uuid_default))
|
||||
searchInTags = prefs.getBoolean(context.getString(R.string.search_option_tag_key),
|
||||
context.resources.getBoolean(R.bool.search_option_tag_default))
|
||||
searchInCurrentGroup = prefs.getBoolean(context.getString(R.string.search_option_current_group_key),
|
||||
context.resources.getBoolean(R.bool.search_option_current_group_default))
|
||||
searchInSearchableGroup = prefs.getBoolean(context.getString(R.string.search_option_searchable_group_key),
|
||||
context.resources.getBoolean(R.bool.search_option_searchable_group_default))
|
||||
searchInRecycleBin = prefs.getBoolean(context.getString(R.string.search_option_recycle_bin_key),
|
||||
context.resources.getBoolean(R.bool.search_option_recycle_bin_default))
|
||||
searchInTemplates = prefs.getBoolean(context.getString(R.string.search_option_templates_key),
|
||||
context.resources.getBoolean(R.bool.search_option_templates_default))
|
||||
}
|
||||
}
|
||||
|
||||
fun setDefaultSearchParameters(context: Context, searchParameters: SearchParameters) {
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().apply {
|
||||
putBoolean(context.getString(R.string.search_option_case_sensitive_key),
|
||||
searchParameters.caseSensitive)
|
||||
putBoolean(context.getString(R.string.search_option_regex_key),
|
||||
searchParameters.isRegex)
|
||||
putBoolean(context.getString(R.string.search_option_title_key),
|
||||
searchParameters.searchInTitles)
|
||||
putBoolean(context.getString(R.string.search_option_username_key),
|
||||
searchParameters.searchInUsernames)
|
||||
putBoolean(context.getString(R.string.search_option_password_key),
|
||||
searchParameters.searchInPasswords)
|
||||
putBoolean(context.getString(R.string.search_option_url_key),
|
||||
searchParameters.searchInUrls)
|
||||
putBoolean(context.getString(R.string.search_option_expired_key),
|
||||
searchParameters.searchInExpired)
|
||||
putBoolean(context.getString(R.string.search_option_note_key),
|
||||
searchParameters.searchInNotes)
|
||||
putBoolean(context.getString(R.string.search_option_otp_key),
|
||||
searchParameters.searchInOTP)
|
||||
putBoolean(context.getString(R.string.search_option_other_key),
|
||||
searchParameters.searchInOther)
|
||||
putBoolean(context.getString(R.string.search_option_uuid_key),
|
||||
searchParameters.searchInUUIDs)
|
||||
putBoolean(context.getString(R.string.search_option_tag_key),
|
||||
searchParameters.searchInTags)
|
||||
putBoolean(context.getString(R.string.search_option_current_group_key),
|
||||
searchParameters.searchInCurrentGroup)
|
||||
putBoolean(context.getString(R.string.search_option_searchable_group_key),
|
||||
searchParameters.searchInSearchableGroup)
|
||||
putBoolean(context.getString(R.string.search_option_recycle_bin_key),
|
||||
searchParameters.searchInRecycleBin)
|
||||
putBoolean(context.getString(R.string.search_option_templates_key),
|
||||
searchParameters.searchInTemplates)
|
||||
apply()
|
||||
}
|
||||
}
|
||||
|
||||
fun isClipboardNotificationsEnable(context: Context): Boolean {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
return prefs.getBoolean(context.getString(R.string.clipboard_notifications_key),
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.core.view.isVisible
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.search.SearchHelper
|
||||
import com.kunzisoft.keepass.database.search.SearchParameters
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
|
||||
class SearchFiltersView @JvmOverloads constructor(context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
@@ -30,7 +31,7 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
||||
private var searchUsername: CompoundButton
|
||||
private var searchPassword: CompoundButton
|
||||
private var searchURL: CompoundButton
|
||||
private var searchExpires: CompoundButton
|
||||
private var searchExpired: CompoundButton
|
||||
private var searchNotes: CompoundButton
|
||||
private var searchOther: CompoundButton
|
||||
private var searchUUID: CompoundButton
|
||||
@@ -49,7 +50,7 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
||||
this.searchInUsernames = searchUsername.isChecked
|
||||
this.searchInPasswords = searchPassword.isChecked
|
||||
this.searchInUrls = searchURL.isChecked
|
||||
this.excludeExpired = !(searchExpires.isChecked)
|
||||
this.searchInExpired = searchExpired.isChecked
|
||||
this.searchInNotes = searchNotes.isChecked
|
||||
this.searchInOther = searchOther.isChecked
|
||||
this.searchInUUIDs = searchUUID.isChecked
|
||||
@@ -69,12 +70,12 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
||||
searchUsername.isChecked = value.searchInUsernames
|
||||
searchPassword.isChecked = value.searchInPasswords
|
||||
searchURL.isChecked = value.searchInUrls
|
||||
searchExpires.isChecked = !value.excludeExpired
|
||||
searchExpired.isChecked = value.searchInExpired
|
||||
searchNotes.isChecked = value.searchInNotes
|
||||
searchOther.isChecked = value.searchInOther
|
||||
searchUUID.isChecked = value.searchInUUIDs
|
||||
searchTag.isChecked = value.searchInTags
|
||||
searchGroupSearchable.isChecked = value.searchInRecycleBin
|
||||
searchGroupSearchable.isChecked = value.searchInSearchableGroup
|
||||
searchRecycleBin.isChecked = value.searchInRecycleBin
|
||||
searchTemplate.isChecked = value.searchInTemplates
|
||||
mOnParametersChangeListener = tempListener
|
||||
@@ -107,7 +108,7 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
||||
searchUsername = findViewById(R.id.search_chip_username)
|
||||
searchPassword = findViewById(R.id.search_chip_password)
|
||||
searchURL = findViewById(R.id.search_chip_url)
|
||||
searchExpires = findViewById(R.id.search_chip_expires)
|
||||
searchExpired = findViewById(R.id.search_chip_expires)
|
||||
searchNotes = findViewById(R.id.search_chip_note)
|
||||
searchUUID = findViewById(R.id.search_chip_uuid)
|
||||
searchOther = findViewById(R.id.search_chip_other)
|
||||
@@ -116,6 +117,9 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
||||
searchRecycleBin = findViewById(R.id.search_chip_recycle_bin)
|
||||
searchTemplate = findViewById(R.id.search_chip_template)
|
||||
|
||||
// Set search
|
||||
searchParameters = PreferencesUtil.getDefaultSearchParameters(context)
|
||||
|
||||
// Expand menu with button
|
||||
searchExpandButton.setOnClickListener {
|
||||
val isVisible = searchAdvanceFiltersContainer?.visibility == View.VISIBLE
|
||||
@@ -153,8 +157,8 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
||||
searchParameters.searchInUrls = isChecked
|
||||
mOnParametersChangeListener?.invoke(searchParameters)
|
||||
}
|
||||
searchExpires.setOnCheckedChangeListener { _, isChecked ->
|
||||
searchParameters.excludeExpired = !isChecked
|
||||
searchExpired.setOnCheckedChangeListener { _, isChecked ->
|
||||
searchParameters.searchInExpired = isChecked
|
||||
mOnParametersChangeListener?.invoke(searchParameters)
|
||||
}
|
||||
searchNotes.setOnCheckedChangeListener { _, isChecked ->
|
||||
@@ -249,4 +253,9 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
PreferencesUtil.setDefaultSearchParameters(context, searchParameters)
|
||||
super.onDetachedFromWindow()
|
||||
}
|
||||
}
|
||||
@@ -219,6 +219,40 @@
|
||||
<string name="passphrase_generator_separator_key" translatable="false">passphrase_generator_separator_key</string>
|
||||
<string name="passphrase_generator_separator_default" translatable="false" />
|
||||
|
||||
<!-- Search settings -->
|
||||
<string name="search_option_case_sensitive_key" translatable="false">search_option_case_sensitive_key</string>
|
||||
<bool name="search_option_case_sensitive_default" translatable="false">false</bool>
|
||||
<string name="search_option_regex_key" translatable="false">search_option_regex_key</string>
|
||||
<bool name="search_option_regex_default" translatable="false">false</bool>
|
||||
<string name="search_option_title_key" translatable="false">search_option_title_key</string>
|
||||
<bool name="search_option_title_default" translatable="false">true</bool>
|
||||
<string name="search_option_username_key" translatable="false">search_option_username_key</string>
|
||||
<bool name="search_option_username_default" translatable="false">true</bool>
|
||||
<string name="search_option_password_key" translatable="false">search_option_password_key</string>
|
||||
<bool name="search_option_password_default" translatable="false">false</bool>
|
||||
<string name="search_option_url_key" translatable="false">search_option_url_key</string>
|
||||
<bool name="search_option_url_default" translatable="false">true</bool>
|
||||
<string name="search_option_expired_key" translatable="false">search_option_expired_key</string>
|
||||
<bool name="search_option_expired_default" translatable="false">true</bool>
|
||||
<string name="search_option_note_key" translatable="false">search_option_note_key</string>
|
||||
<bool name="search_option_note_default" translatable="false">true</bool>
|
||||
<string name="search_option_otp_key" translatable="false">search_option_otp_key</string>
|
||||
<bool name="search_option_otp_default" translatable="false">false</bool>
|
||||
<string name="search_option_other_key" translatable="false">search_option_other_key</string>
|
||||
<bool name="search_option_other_default" translatable="false">true</bool>
|
||||
<string name="search_option_uuid_key" translatable="false">search_option_uuid_key</string>
|
||||
<bool name="search_option_uuid_default" translatable="false">false</bool>
|
||||
<string name="search_option_tag_key" translatable="false">search_option_tag_key</string>
|
||||
<bool name="search_option_tag_default" translatable="false">false</bool>
|
||||
<string name="search_option_current_group_key" translatable="false">search_option_current_group_key</string>
|
||||
<bool name="search_option_current_group_default" translatable="false">false</bool>
|
||||
<string name="search_option_searchable_group_key" translatable="false">search_option_searchable_group_key</string>
|
||||
<bool name="search_option_searchable_group_default" translatable="false">true</bool>
|
||||
<string name="search_option_recycle_bin_key" translatable="false">search_option_recycle_bin_key</string>
|
||||
<bool name="search_option_recycle_bin_default" translatable="false">false</bool>
|
||||
<string name="search_option_templates_key" translatable="false">search_option_templates_key</string>
|
||||
<bool name="search_option_templates_default" translatable="false">false</bool>
|
||||
|
||||
<!-- Database Settings -->
|
||||
<string name="settings_database_key" translatable="false">settings_database_key</string>
|
||||
<string name="settings_database_security_key" translatable="false">settings_database_security_key</string>
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
* Better visualization of passwords #454 #1270
|
||||
* Passphrase implementation #218
|
||||
* Fix small bugs #1282
|
||||
* Better search implementation #175
|
||||
* Better search implementation #175 #1254
|
||||
@@ -4,4 +4,5 @@
|
||||
* Ajout de champs éditable de génération #539
|
||||
* Meilleure visualisation des mots de passe #454 #1270
|
||||
* Phrases secrètes #218
|
||||
* Correction de petits bugs #1282
|
||||
* Correction de petits bugs #1282
|
||||
* Meilleure implémentation de la recherche #175 #1254
|
||||
Reference in New Issue
Block a user