Author: Adam Pioterek <adam.pioterek@protonmail.ch>
searchbar text handles
%!v(PANIC=String method: strings: negative Repeat count)
diff --git a/app/src/main/java/ml/adamsprogs/bimba/models/adapters/SuggestionsAdapter.kt b/app/src/main/java/ml/adamsprogs/bimba/models/adapters/SuggestionsAdapter.kt index 4769220894b85cb69b1596ece78cf47291d1e34b..4f3a969d6d688d1db3201aa44f9d942b9fa0a743 100644 --- a/app/src/main/java/ml/adamsprogs/bimba/models/adapters/SuggestionsAdapter.kt +++ b/app/src/main/java/ml/adamsprogs/bimba/models/adapters/SuggestionsAdapter.kt @@ -4,15 +4,20 @@ import android.content.Context import android.graphics.PorterDuff import android.os.Build import android.text.Html -import android.view.* -import android.widget.* +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.ImageView +import android.widget.TextView import androidx.core.content.ContextCompat.getColor import ml.adamsprogs.bimba.R import ml.adamsprogs.bimba.getDrawable -import com.mancj.materialsearchbar.adapter.SuggestionsAdapter as SearchBarSuggestionsAdapter import ml.adamsprogs.bimba.models.suggestions.GtfsSuggestion import ml.adamsprogs.bimba.models.suggestions.LineSuggestion import ml.adamsprogs.bimba.models.suggestions.StopSuggestion +import com.mancj.materialsearchbar.adapter.SuggestionsAdapter as SearchBarSuggestionsAdapter + +// todo on click ripple class SuggestionsAdapter(inflater: LayoutInflater, private val onSuggestionClickListener: OnSuggestionClickListener, private val context: Context) : SearchBarSuggestionsAdapter<GtfsSuggestion, SuggestionsAdapter.ViewHolder>(inflater) { diff --git a/app/src/main/res/drawable/ic_texthandle_end.xml b/app/src/main/res/drawable/ic_texthandle_end.xml new file mode 100644 index 0000000000000000000000000000000000000000..923f2b49a542f61b7fa1b19c720cba506b6767fb --- /dev/null +++ b/app/src/main/res/drawable/ic_texthandle_end.xml @@ -0,0 +1,8 @@ +<vector android:autoMirrored="true" android:height="24dp" + android:viewportHeight="88" android:viewportWidth="176" + android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillAlpha="1" android:fillColor="#54af39" + android:pathData="M88,0A44,44 0,0 1,132 44,44 44,0 0,1 88,88 44,44 0,0 1,44 44V0Z" + android:strokeAlpha="1" android:strokeColor="#00000000" + android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="0.01982322"/> +</vector> diff --git a/app/src/main/res/drawable/ic_texthandle_middle.xml b/app/src/main/res/drawable/ic_texthandle_middle.xml new file mode 100644 index 0000000000000000000000000000000000000000..da3c7962d98b2e2ef0113080f7491bad6e6c6dc6 --- /dev/null +++ b/app/src/main/res/drawable/ic_texthandle_middle.xml @@ -0,0 +1,7 @@ +<vector android:height="24dp" android:viewportHeight="88" + android:viewportWidth="88" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillAlpha="1" android:fillColor="#54af39" + android:pathData="m69.7747,25.7746a36.4509,36.4508 0,0 1,0 51.5492,36.4509 36.4508,0 0,1 -51.5494,0 36.4509,36.4508 0,0 1,0 -51.5492L44,0Z" + android:strokeAlpha="1" android:strokeColor="#00000000" + android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="0.01642212"/> +</vector> diff --git a/app/src/main/res/drawable/ic_texthandle_start.xml b/app/src/main/res/drawable/ic_texthandle_start.xml new file mode 100644 index 0000000000000000000000000000000000000000..577a11d14e6d46dade232eca4176dbcf8f469879 --- /dev/null +++ b/app/src/main/res/drawable/ic_texthandle_start.xml @@ -0,0 +1,8 @@ +<vector android:autoMirrored="true" android:height="24dp" + android:viewportHeight="88" android:viewportWidth="176" + android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillAlpha="1" android:fillColor="#54af39" + android:pathData="M88,0A44,44 0,0 0,44 44,44 44,0 0,0 88,88 44,44 0,0 0,132 44V0Z" + android:strokeAlpha="1" android:strokeColor="#00000000" + android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="0.01982322"/> +</vector> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 321823a1de36e036af6fc66617b149638df0ba60..07853229e13da30362e58a0e22f30edd3ebd36c3 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -17,6 +17,8 @@ <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> + <!-- todo night background --> + <!-- todo shadow (elevation) --> <style name="SearchBarTheme" parent="MaterialSearchBarLight"> <item name="mt_navIconTint">@color/textDark</item> <item name="mt_backIconTint">@color/textDark</item> @@ -24,17 +26,14 @@- @color/textDark
<item name="mt_searchIconTint">@color/textDark</item> <item name="mt_textCursorTint">@color/colorAccent</item> <item name="mt_highlightedTextColor">@color/colorAccent</item> - <item name="mt_leftTextSelectorTint">@color/colorAccent</item> - <item name="mt_middleTextSelectorTint">@color/colorAccent</item> - <item name="mt_rightTextSelectorTint">@color/colorAccent</item> <item name="mt_leftTextSelectorDrawable"> - @drawable/text_select_handle_left_mtrl_alpha_mtrlsearch + @drawable/ic_texthandle_start </item> <item name="mt_middleTextSelectorDrawable"> - @drawable/text_select_handle_middle_mtrl_alpha_mtrlsearch + @drawable/ic_texthandle_middle </item> <item name="mt_rightTextSelectorDrawable"> - @drawable/text_select_handle_right_mtrl_alpha_mtrlsearch + @drawable/ic_texthandle_end </item> </style> diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml index f6cda290911ab8586bd2c32885977fe2700680a2..bd618948b05adc10285137774305e9f390997f1f 100644 --- a/app/src/main/res/values-night/styles.xml +++ b/app/src/main/res/values-night/styles.xml @@ -8,17 +8,14 @@- @color/textDark
<item name="mt_searchIconTint">@color/textDark</item> <item name="mt_textCursorTint">@color/colorAccent</item> <item name="mt_highlightedTextColor">@color/colorAccent</item> - <item name="mt_leftTextSelectorTint">@color/colorAccent</item> - <item name="mt_middleTextSelectorTint">@color/colorAccent</item> - <item name="mt_rightTextSelectorTint">@color/colorAccent</item> <item name="mt_leftTextSelectorDrawable"> - @drawable/text_select_handle_left_mtrl_alpha_mtrlsearch + @drawable/ic_texthandle_start </item> <item name="mt_middleTextSelectorDrawable"> - @drawable/text_select_handle_middle_mtrl_alpha_mtrlsearch + @drawable/ic_texthandle_middle </item> <item name="mt_rightTextSelectorDrawable"> - @drawable/text_select_handle_right_mtrl_alpha_mtrlsearch + @drawable/ic_texthandle_end </item> </style> </resources> \ No newline at end of file diff --git a/app/src/main/res/values-notnight/styles.xml b/app/src/main/res/values-notnight/styles.xml index ad6a69593e7e90d9c5862aeacb607a6ac044344a..aabb27040d3506702ab96ae5b140c8dbb670f122 100644 --- a/app/src/main/res/values-notnight/styles.xml +++ b/app/src/main/res/values-notnight/styles.xml @@ -8,17 +8,14 @@- @color/textDark
<item name="mt_searchIconTint">@color/textDark</item> <item name="mt_textCursorTint">@color/colorAccent</item> <item name="mt_highlightedTextColor">@color/colorAccent</item> - <item name="mt_leftTextSelectorTint">@color/colorAccent</item> - <item name="mt_middleTextSelectorTint">@color/colorAccent</item> - <item name="mt_rightTextSelectorTint">@color/colorAccent</item> <item name="mt_leftTextSelectorDrawable"> - @drawable/text_select_handle_left_mtrl_alpha_mtrlsearch + @drawable/ic_texthandle_start </item> <item name="mt_middleTextSelectorDrawable"> - @drawable/text_select_handle_middle_mtrl_alpha_mtrlsearch + @drawable/ic_texthandle_middle </item> <item name="mt_rightTextSelectorDrawable"> - @drawable/text_select_handle_right_mtrl_alpha_mtrlsearch + @drawable/ic_texthandle_end </item> </style> </resources> \ No newline at end of file diff --git a/research/svg/textHandle_left.svg b/research/svg/textHandle_left.svg new file mode 100644 index 0000000000000000000000000000000000000000..e929f21ce40749c272b2386ffcb847e25d98f78d --- /dev/null +++ b/research/svg/textHandle_left.svg @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<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" + viewBox="0 0 176 88" + height="88" + width="176" + id="svg2" + version="1.1"> + <metadata + id="metadata8"> + <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> + <defs + id="defs6" /> + <path + id="path817" + d="M 88,0 A 44,44 0 0 0 44,44 44,44 0 0 0 88,88 44,44 0 0 0 132,44 V 0 Z" + style="opacity:1;fill:#54af39;fill-opacity:1;stroke:none;stroke-width:0.01982322;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> +</svg> diff --git a/research/svg/textHandle_middle.svg b/research/svg/textHandle_middle.svg new file mode 100644 index 0000000000000000000000000000000000000000..4e8b5c388a1d204b1f2f0c44766b611759e23728 --- /dev/null +++ b/research/svg/textHandle_middle.svg @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<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" + viewBox="0 0 87.999999 87.999998" + height="88" + width="88" + id="svg2" + version="1.1"> + <metadata + id="metadata8"> + <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> + <defs + id="defs6" /> + <path + id="path817" + d="m 69.774698,25.774604 a 36.450926,36.45079 0 0 1 0,51.549207 36.450926,36.45079 0 0 1 -51.549395,0 36.450926,36.45079 0 0 1 0,-51.549207 L 44,0 Z" + style="opacity:1;fill:#54af39;fill-opacity:1;stroke:none;stroke-width:0.01642212;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> +</svg> diff --git a/research/svg/textHandle_right.svg b/research/svg/textHandle_right.svg new file mode 100644 index 0000000000000000000000000000000000000000..6db4aeec1cbb7dc1696d4d3db08884a2708e7873 --- /dev/null +++ b/research/svg/textHandle_right.svg @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<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" + viewBox="0 0 176 88" + height="88" + width="176" + id="svg2" + version="1.1"> + <metadata + id="metadata8"> + <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> + <defs + id="defs6" /> + <path + id="path817" + d="M 88,0 A 44,44 0 0 1 132,44 44,44 0 0 1 88,88 44,44 0 0 1 44,44 V 0 Z" + style="opacity:1;fill:#54af39;fill-opacity:1;stroke:none;stroke-width:0.01982322;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> +</svg>