Skip to content

Commit b19cb78

Browse files
committed
added new search icon
1 parent 2d879e4 commit b19cb78

24 files changed

+11
-15
lines changed

app/src/main/java/danbroid/searchview/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class MainActivity : AppCompatActivity() {
5252
super.onNewIntent(intent)
5353

5454
log.info("onNewIntent() :{}", intent)
55-
searchViewSupport.showSearch = false
55+
invalidateOptionsMenu()
5656

5757
intent.extras?.let {
5858
/**
@@ -73,7 +73,7 @@ class MainActivity : AppCompatActivity() {
7373
*/
7474
override fun onSearchRequested(): Boolean {
7575
log.trace("onSearchRequested();")
76-
searchViewSupport.showSearch = false
76+
7777

7878
// dont show the built-in search dialog
7979
return false

app/src/main/java/danbroid/searchview/SearchViewSupport.kt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,11 @@ class SearchViewSupport(val activity: AppCompatActivity) {
2626
private lateinit var searchItem: MenuItem
2727

2828

29-
var showSearch: Boolean
30-
get() = searchItem.isActionViewExpanded
31-
set(value):Unit {
32-
if (value)
33-
searchItem.expandActionView()
34-
else
35-
searchItem.collapseActionView()
36-
}
37-
3829

3930
fun createSearchView(menu: Menu) {
4031

4132
searchItem = menu.add(android.R.string.search_go)
42-
searchItem.setIcon(R.drawable.ic_search_white_36dp)
33+
searchItem.setIcon(R.drawable.ic_search)
4334
searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS or MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW)
4435

4536
searchView = SearchView(activity.supportActionBar!!.themedContext).apply {
@@ -58,8 +49,9 @@ class SearchViewSupport(val activity: AppCompatActivity) {
5849
// Collapse the search menu when the user hits the back key
5950
searchAutoComplete.setOnFocusChangeListener { v, hasFocus ->
6051
log.trace("onFocusChange(): $hasFocus")
61-
if (!hasFocus)
62-
showSearch = false
52+
if (!hasFocus){
53+
log.debug("lost focus .. closing search view") //TODO
54+
}
6355
}
6456

6557
try {
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24.0" android:viewportWidth="24.0"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="#FF000000" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
5+
</vector>

app/src/main/res/layout/layout.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
android:layout_width="match_parent"
1212
android:layout_height="?attr/actionBarSize"
1313
android:popupBackground="@color/red"
14-
app:logo="@drawable/ic_launcher"
1514
app:popupTheme="@style/PopupTheme"
1615
app:theme="@style/ToolbarTheme" >
1716
</androidx.appcompat.widget.Toolbar>

0 commit comments

Comments
 (0)