From 827792c4f0818b44653afc2a9d959766aaa176db Mon Sep 17 00:00:00 2001 From: inorichi Date: Sat, 28 Oct 2017 18:26:31 +0200 Subject: [PATCH] Restore previous query in global search. Closes #1040 --- .travis/build.sh | 2 +- .../tachiyomi/ui/base/controller/BaseController.kt | 6 ++---- .../global_search/CatalogueSearchController.kt | 13 +++++++++++++ .../tachiyomi/ui/library/LibraryController.kt | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.travis/build.sh b/.travis/build.sh index 66f72baa8a..d0c376befa 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -15,6 +15,6 @@ else TOOLS="${ANDROID_HOME}/build-tools/26.0.1" export ARTIFACT="tachiyomi-${TRAVIS_TAG}.apk" - ${TOOLS}/zipalign -v -p 4 app/build/outputs/apk/standard/release/app-standard-release-unsigned app-aligned.apk + ${TOOLS}/zipalign -v -p 4 app/build/outputs/apk/standard/release/app-standard-release-unsigned.apk app-aligned.apk ${TOOLS}/apksigner sign --ks $STORE_PATH --ks-key-alias $STORE_ALIAS --ks-pass env:STORE_PASS --key-pass env:KEY_PASS --out $ARTIFACT app-aligned.apk fi diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt index 07649e2fd4..8ab55d9f73 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt @@ -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) + }) } } \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchController.kt index ea10a038ed..dcbb42f4c6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/global_search/CatalogueSearchController.kt @@ -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 { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 0842514071..a670a54c3c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -283,7 +283,7 @@ class LibraryController( */ private fun onFilterChanged() { presenter.requestFilterUpdate() - (activity as? AppCompatActivity)?.supportInvalidateOptionsMenu() + activity?.invalidateOptionsMenu() } private fun onDownloadBadgeChanged(){