mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Restore previous query in global search. Closes #1040
This commit is contained in:
		| @@ -1,7 +1,6 @@ | ||||
| package eu.kanade.tachiyomi.ui.base.controller | ||||
|  | ||||
| import android.os.Bundle | ||||
| import android.support.v4.view.MenuItemCompat | ||||
| import android.support.v7.app.AppCompatActivity | ||||
| import android.view.LayoutInflater | ||||
| import android.view.MenuItem | ||||
| @@ -52,7 +51,7 @@ abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateContr | ||||
|      * Issue link: https://issuetracker.google.com/issues/37657375 | ||||
|      */ | ||||
|     fun MenuItem.fixExpand() { | ||||
|         val expandListener = object : MenuItemCompat.OnActionExpandListener { | ||||
|         setOnActionExpandListener(object : MenuItem.OnActionExpandListener { | ||||
|             override fun onMenuItemActionExpand(item: MenuItem): Boolean { | ||||
|                 return true | ||||
|             } | ||||
| @@ -61,8 +60,7 @@ abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateContr | ||||
|                 activity?.invalidateOptionsMenu() | ||||
|                 return true | ||||
|             } | ||||
|         } | ||||
|         MenuItemCompat.setOnActionExpandListener(this, expandListener) | ||||
|         }) | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -89,6 +89,19 @@ class CatalogueSearchController(private val initialQuery: String? = null) : | ||||
|         // Initialize search menu | ||||
|         val searchItem = menu.findItem(R.id.action_search) | ||||
|         val searchView = searchItem.actionView as SearchView | ||||
|  | ||||
|         searchItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener { | ||||
|             override fun onMenuItemActionExpand(item: MenuItem?): Boolean { | ||||
|                 searchView.onActionViewExpanded() // Required to show the query in the view | ||||
|                 searchView.setQuery(presenter.query, false) | ||||
|                 return true | ||||
|             } | ||||
|  | ||||
|             override fun onMenuItemActionCollapse(item: MenuItem?): Boolean { | ||||
|                 return true | ||||
|             } | ||||
|         }) | ||||
|  | ||||
|         searchView.queryTextChangeEvents() | ||||
|                 .filter { it.isSubmitted } | ||||
|                 .subscribeUntilDestroy { | ||||
|   | ||||
| @@ -283,7 +283,7 @@ class LibraryController( | ||||
|      */ | ||||
|     private fun onFilterChanged() { | ||||
|         presenter.requestFilterUpdate() | ||||
|         (activity as? AppCompatActivity)?.supportInvalidateOptionsMenu() | ||||
|         activity?.invalidateOptionsMenu() | ||||
|     } | ||||
|  | ||||
|     private fun onDownloadBadgeChanged(){ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user