diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-26 13:25:17 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-26 13:25:17 -0700 |
commit | c9302a7b0f3c66b3514f1f5b83c86757db33008a (patch) | |
tree | c14f8b1ae70997be4905d0675deffd37b0ca0562 /library | |
parent | 3839f9a406b4da9ba888afdaa6ba9c9a157badf6 (diff) | |
download | kau-c9302a7b0f3c66b3514f1f5b83c86757db33008a.tar.gz kau-c9302a7b0f3c66b3514f1f5b83c86757db33008a.tar.bz2 kau-c9302a7b0f3c66b3514f1f5b83c86757db33008a.zip |
add Extra icon
Diffstat (limited to 'library')
-rw-r--r-- | library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt | 12 | ||||
-rw-r--r-- | library/src/main/res/layout/kau_search_view.xml | 28 |
2 files changed, 31 insertions, 9 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt index e3931b9..46bce6a 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt @@ -55,6 +55,17 @@ class SearchView @JvmOverloads constructor( iconNav.setSearchIcon(value) if (value == null) iconNav.gone() } + /** + * Optional icon just to the left of the clear icon + * This is not implemented by default, but can be used for anything, such as mic or redirects + * Make sure you add a click listener to [iconExtra] if you plan on using this + */ + var extraIcon: IIcon? = null + set(value) { + field = value + iconExtra.setSearchIcon(value) + if (value == null) iconClear.gone() + } var clearIcon: IIcon? = GoogleMaterial.Icon.gmd_clear set(value) { field = value @@ -145,6 +156,7 @@ class SearchView @JvmOverloads constructor( private val editText: AppCompatEditText by bindView(R.id.search_edit_text) val textEvents: Observable<String> private val progress: ProgressBar by bindView(R.id.search_progress) + val iconExtra: ImageView by bindView(R.id.search_extra) private val iconClear: ImageView by bindView(R.id.search_clear) private val divider: View by bindView(R.id.search_divider) private val recycler: RecyclerView by bindView(R.id.search_recycler) diff --git a/library/src/main/res/layout/kau_search_view.xml b/library/src/main/res/layout/kau_search_view.xml index ddde753..d927c68 100644 --- a/library/src/main/res/layout/kau_search_view.xml +++ b/library/src/main/res/layout/kau_search_view.xml @@ -68,16 +68,26 @@ android:layout_height="match_parent" android:visibility="gone" /> + <ImageView + android:id="@+id/search_extra" + android:layout_width="48dp" + android:layout_height="match_parent" + android:background="?android:attr/selectableItemBackgroundBorderless" + android:clickable="true" + android:contentDescription="@string/kau_search" + android:focusable="true" + android:scaleType="center" + android:visibility="gone" /> - <ImageView - android:id="@+id/search_clear" - android:layout_width="48dp" - android:layout_height="match_parent" - android:background="?android:attr/selectableItemBackgroundBorderless" - android:clickable="true" - android:contentDescription="@string/kau_search" - android:focusable="true" - android:scaleType="center" /> + <ImageView + android:id="@+id/search_clear" + android:layout_width="48dp" + android:layout_height="match_parent" + android:background="?android:attr/selectableItemBackgroundBorderless" + android:clickable="true" + android:contentDescription="@string/kau_search" + android:focusable="true" + android:scaleType="center" /> </LinearLayout> |