diff options
-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> |