mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-04-03 21:07:35 +03:00
Search with regular expression #175
This commit is contained in:
parent
ee9b072f45
commit
7697713c44
10 changed files with 145 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
KeePassDX(3.3.0)
|
||||
* Quick search and dynamic filters #163 #462 #521
|
||||
* Keep search context #1141
|
||||
* Search with regular expression #175
|
||||
|
||||
KeePassDX(3.2.0)
|
||||
* Manage data merge #840 #977
|
||||
|
|
|
@ -207,12 +207,21 @@ class SearchHelper {
|
|||
private fun checkSearchQuery(stringToCheck: String, searchParameters: SearchParameters): Boolean {
|
||||
/*
|
||||
// TODO Search settings
|
||||
var regularExpression = false
|
||||
var removeAccents = true <- Too much time, to study
|
||||
*/
|
||||
return stringToCheck.isNotEmpty()
|
||||
&& stringToCheck.contains(
|
||||
searchParameters.searchQuery, !searchParameters.caseSensitive)
|
||||
if (stringToCheck.isEmpty())
|
||||
return false
|
||||
return if (searchParameters.isRegex) {
|
||||
val regex = if (searchParameters.caseSensitive) {
|
||||
searchParameters.searchQuery.toRegex(RegexOption.DOT_MATCHES_ALL)
|
||||
} else {
|
||||
searchParameters.searchQuery
|
||||
.toRegex(setOf(RegexOption.DOT_MATCHES_ALL, RegexOption.IGNORE_CASE))
|
||||
}
|
||||
regex.matches(stringToCheck)
|
||||
} else {
|
||||
stringToCheck.contains(searchParameters.searchQuery, !searchParameters.caseSensitive)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import android.os.Parcelable
|
|||
class SearchParameters() : Parcelable{
|
||||
var searchQuery: String = ""
|
||||
var caseSensitive = false
|
||||
var isRegex = false
|
||||
|
||||
var searchInTitles = true
|
||||
var searchInUsernames = true
|
||||
|
|
|
@ -24,6 +24,7 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
|||
private var searchNumbers: TextView
|
||||
private var searchCurrentGroup: CompoundButton
|
||||
private var searchCaseSensitive: CompoundButton
|
||||
private var searchRegex: CompoundButton
|
||||
private var searchTitle: CompoundButton
|
||||
private var searchUsername: CompoundButton
|
||||
private var searchPassword: CompoundButton
|
||||
|
@ -41,6 +42,7 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
|||
return field.apply {
|
||||
this.searchInCurrentGroup = searchCurrentGroup.isChecked
|
||||
this.caseSensitive = searchCaseSensitive.isChecked
|
||||
this.isRegex = searchRegex.isChecked
|
||||
this.searchInTitles = searchTitle.isChecked
|
||||
this.searchInUsernames = searchUsername.isChecked
|
||||
this.searchInPasswords = searchPassword.isChecked
|
||||
|
@ -60,6 +62,7 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
|||
mOnParametersChangeListener = null
|
||||
searchCurrentGroup.isChecked = value.searchInCurrentGroup
|
||||
searchCaseSensitive.isChecked = value.caseSensitive
|
||||
searchRegex.isChecked = value.isRegex
|
||||
searchTitle.isChecked = value.searchInTitles
|
||||
searchUsername.isChecked = value.searchInUsernames
|
||||
searchPassword.isChecked = value.searchInPasswords
|
||||
|
@ -96,6 +99,7 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
|||
searchNumbers = findViewById(R.id.search_numbers)
|
||||
searchCurrentGroup = findViewById(R.id.search_chip_current_group)
|
||||
searchCaseSensitive = findViewById(R.id.search_chip_case_sensitive)
|
||||
searchRegex = findViewById(R.id.search_chip_regex)
|
||||
searchTitle = findViewById(R.id.search_chip_title)
|
||||
searchUsername = findViewById(R.id.search_chip_username)
|
||||
searchPassword = findViewById(R.id.search_chip_password)
|
||||
|
@ -125,6 +129,10 @@ class SearchFiltersView @JvmOverloads constructor(context: Context,
|
|||
searchParameters.caseSensitive = isChecked
|
||||
mOnParametersChangeListener?.invoke(searchParameters)
|
||||
}
|
||||
searchRegex.setOnCheckedChangeListener { _, isChecked ->
|
||||
searchParameters.isRegex = isChecked
|
||||
mOnParametersChangeListener?.invoke(searchParameters)
|
||||
}
|
||||
searchTitle.setOnCheckedChangeListener { _, isChecked ->
|
||||
searchParameters.searchInTitles = isChecked
|
||||
mOnParametersChangeListener?.invoke(searchParameters)
|
||||
|
|
12
app/src/main/res/drawable/ic_regex_white_24dp.xml
Normal file
12
app/src/main/res/drawable/ic_regex_white_24dp.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<group>
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M 4.3105469,5.0878906 a 0.9014779,0.9014779 0 0 0 -0.00586,0.00195 0.9014779,0.9014779 0 0 0 -0.6679687,0.3671874 c -1.6307378,2.1650454 -2.540913,4.467681 -2.5664063,6.853516 -0.025422,2.385835 0.8330899,4.807465 2.5527344,7.212891 a 0.90239526,0.90239526 0 0 0 1.46875,-1.048829 C 3.5374502,16.300396 2.8522647,14.272141 2.8730469,12.328125 2.8938469,10.384107 3.6199739,8.4788746 5.078125,6.5429688 A 0.9014779,0.9014779 0 0 0 4.3105469,5.0878906 Z m 15.2246091,0 a 0.9014779,0.9014779 0 0 0 -0.08984,0.00195 0.9014779,0.9014779 0 0 0 -0.658203,1.453125 c 1.458152,1.9359058 2.184296,3.8411384 2.205079,5.7851564 0.0208,1.944016 -0.664404,3.972271 -2.21875,6.146484 a 0.90239526,0.90239526 0 1 0 1.46875,1.048829 c 1.719644,-2.405426 2.576274,-4.827056 2.550781,-7.212891 C 22.767547,9.9247122 21.8573,7.6220766 20.226562,5.4570312 A 0.9014779,0.9014779 0 0 0 19.535156,5.0878906 Z m -5.050781,1.0292969 a 0.40003999,0.40003999 0 0 0 -0.353516,0.2695313 l -0.833984,2.4628906 -2.597656,0.03125 a 0.40003999,0.40003999 0 0 0 -0.236328,0.71875 l 2.08789,1.5527346 -0.77539,2.478515 a 0.40003999,0.40003999 0 0 0 0.611328,0.447266 l 2.121093,-1.503906 2.119141,1.503906 a 0.40003999,0.40003999 0 0 0 0.615235,-0.447266 l -0.775391,-2.478515 2.083984,-1.5527346 a 0.40003999,0.40003999 0 0 0 -0.232422,-0.71875 L 15.716797,8.8496094 14.886719,6.3867188 A 0.40003999,0.40003999 0 0 0 14.484375,6.1171875 Z M 10,16 a 2,2 0 0 0 -2,2 2,2 0 0 0 2,2 2,2 0 0 0 2,-2 2,2 0 0 0 -2,-2 z" />
|
||||
</group>
|
||||
</vector>
|
|
@ -180,6 +180,14 @@
|
|||
style="@style/KeepassDXStyle.Chip.Filter.Icon"
|
||||
android:text="@string/case_sensitive"
|
||||
app:closeIcon="@drawable/ic_case_sensitive_white_24dp" />
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/search_chip_regex"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
style="@style/KeepassDXStyle.Chip.Filter.Icon"
|
||||
android:text="@string/regex"
|
||||
app:closeIcon="@drawable/ic_regex_white_24dp" />
|
||||
</com.google.android.material.chip.ChipGroup>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
|
@ -107,6 +107,7 @@
|
|||
<string name="otp_algorithm">Algorithm</string>
|
||||
<string name="current_group">Current group</string>
|
||||
<string name="case_sensitive">Case sensitive</string>
|
||||
<string name="regex">Regular expression</string>
|
||||
<string name="debit_credit_card">Debit / Credit Card</string>
|
||||
<string name="holder">Holder</string>
|
||||
<string name="number">Number</string>
|
||||
|
|
97
art/ic_regex.svg
Normal file
97
art/ic_regex.svg
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="24"
|
||||
height="24"
|
||||
id="svg4830"
|
||||
version="1.1"
|
||||
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
|
||||
inkscape:export-filename="/home/joker/Project/Scratcheck/TestExport.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90"
|
||||
sodipodi:docname="ic_regex.svg">
|
||||
<defs
|
||||
id="defs4832" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#acacac"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="11.313709"
|
||||
inkscape:cx="22.24941"
|
||||
inkscape:cy="1.6287076"
|
||||
inkscape:current-layer="g4770"
|
||||
showgrid="true"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:document-units="px"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1016"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="27"
|
||||
inkscape:window-maximized="1">
|
||||
<sodipodi:guide
|
||||
position="0.99999471,22.999999"
|
||||
orientation="22,0"
|
||||
id="guide2987"
|
||||
inkscape:locked="false" />
|
||||
<sodipodi:guide
|
||||
position="0.99999471,0.99999888"
|
||||
orientation="0,22"
|
||||
id="guide2989"
|
||||
inkscape:locked="false" />
|
||||
<sodipodi:guide
|
||||
position="22.999995,0.99999888"
|
||||
orientation="-22,0"
|
||||
id="guide2991"
|
||||
inkscape:locked="false" />
|
||||
<sodipodi:guide
|
||||
position="22.999995,22.999999"
|
||||
orientation="0,-22"
|
||||
id="guide2993"
|
||||
inkscape:locked="false" />
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid2989" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata4835">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
transform="translate(0,-8)">
|
||||
<g
|
||||
id="g4770"
|
||||
transform="matrix(1.7777778,0,0,1.7777778,-205.48441,-31.997877)">
|
||||
<g
|
||||
id="Layer_1"
|
||||
transform="matrix(-0.00397893,0,0,0.00397893,125.58386,23.674135)" />
|
||||
<path
|
||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2.84444451;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
d="m 4.3105469,5.0878906 a 0.9014779,0.9014779 0 0 0 -0.00586,0.00195 0.9014779,0.9014779 0 0 0 -0.6679687,0.3671874 c -1.6307378,2.1650454 -2.540913,4.467681 -2.5664063,6.853516 -0.025422,2.385835 0.8330899,4.807465 2.5527344,7.212891 a 0.90239526,0.90239526 0 0 0 1.46875,-1.048829 C 3.5374502,16.300396 2.8522647,14.272141 2.8730469,12.328125 2.8938469,10.384107 3.6199739,8.4788746 5.078125,6.5429688 A 0.9014779,0.9014779 0 0 0 4.3105469,5.0878906 Z m 15.2246091,0 a 0.9014779,0.9014779 0 0 0 -0.08984,0.00195 0.9014779,0.9014779 0 0 0 -0.658203,1.453125 c 1.458152,1.9359058 2.184296,3.8411384 2.205079,5.7851564 0.0208,1.944016 -0.664404,3.972271 -2.21875,6.146484 a 0.90239526,0.90239526 0 1 0 1.46875,1.048829 c 1.719644,-2.405426 2.576274,-4.827056 2.550781,-7.212891 C 22.767547,9.9247122 21.8573,7.6220766 20.226562,5.4570312 A 0.9014779,0.9014779 0 0 0 19.535156,5.0878906 Z m -5.050781,1.0292969 a 0.40003999,0.40003999 0 0 0 -0.353516,0.2695313 l -0.833984,2.4628906 -2.597656,0.03125 a 0.40003999,0.40003999 0 0 0 -0.236328,0.71875 l 2.08789,1.5527346 -0.77539,2.478515 a 0.40003999,0.40003999 0 0 0 0.611328,0.447266 l 2.121093,-1.503906 2.119141,1.503906 a 0.40003999,0.40003999 0 0 0 0.615235,-0.447266 l -0.775391,-2.478515 2.083984,-1.5527346 a 0.40003999,0.40003999 0 0 0 -0.232422,-0.71875 L 15.716797,8.8496094 14.886719,6.3867188 A 0.40003999,0.40003999 0 0 0 14.484375,6.1171875 Z M 10,16 a 2,2 0 0 0 -2,2 2,2 0 0 0 2,2 2,2 0 0 0 2,-2 2,2 0 0 0 -2,-2 z"
|
||||
transform="matrix(0.56249999,0,0,0.56249999,115.58498,22.498806)"
|
||||
id="path837"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.4 KiB |
|
@ -1,2 +1,3 @@
|
|||
* Quick search and dynamic filters #163 #462 #521
|
||||
* Keep search context #1141
|
||||
* Keep search context #1141
|
||||
* Search with regular expression #175
|
|
@ -1,2 +1,3 @@
|
|||
* Recherche rapide et filtres dynamiques #163 #462 #521
|
||||
* Garde le contexte de recherche #1141
|
||||
* Garde le contexte de recherche #1141
|
||||
* Recherche avec expression régulière #175
|
Loading…
Add table
Add a link
Reference in a new issue