From 31670b81132d0e3e5e10f5fd67a486cb179ade45 Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 9 Feb 2020 14:36:55 -0800 Subject: [PATCH] Fixed search activity back button --- .../tachiyomi/ui/main/SearchActivity.kt | 24 ++++++++++++------- .../ui/manga/info/MangaInfoController.kt | 8 +++++-- app/src/main/res/layout/track_controller.xml | 8 +++---- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt index 969220aaf7..641b888b3b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt @@ -1,7 +1,6 @@ package eu.kanade.tachiyomi.ui.main import android.app.SearchManager -import android.content.Context import android.content.Intent import android.content.res.Configuration import android.graphics.Color @@ -98,8 +97,8 @@ class SearchActivity: MainActivity() { content.systemUiVisibility = content.systemUiVisibility.or(View .SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) - val drawerContainer: FrameLayout = findViewById(R.id.search_container) - drawerContainer.setOnApplyWindowInsetsListener { v, insets -> + val searchContainer: FrameLayout = findViewById(R.id.search_container) + searchContainer.setOnApplyWindowInsetsListener { v, insets -> window.statusBarColor = getResourceColor(R.attr.colorPrimary) val contextView = window?.decorView?.findViewById(R.id.action_mode_bar) contextView?.updateLayoutParams { @@ -147,12 +146,21 @@ class SearchActivity: MainActivity() { syncActivityViewWithController(router.backstack.lastOrNull()?.controller()) } - private fun Context.popToRoot() { - val intent = Intent(this, MainActivity::class.java).apply { - flags = Intent.FLAG_ACTIVITY_NEW_TASK + override fun onBackPressed() { + if (router.backstack.size <= 1 || !router.handleBack()) { + unlocked = false + super.onBackPressed() + } + } + + private fun popToRoot() { + if (!router.handleBack()) { + val intent = Intent(this, MainActivity::class.java).apply { + flags = Intent.FLAG_ACTIVITY_NEW_TASK + } + startActivity(intent) + finishAfterTransition() } - startActivity(intent) - finishAfterTransition() } override fun syncActivityViewWithController(to: Controller?, from: Controller?) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt index a9c7d395a9..775acab492 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt @@ -72,7 +72,10 @@ import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.updatePaddingRelative import jp.wasabeef.glide.transformations.CropSquareTransformation import jp.wasabeef.glide.transformations.MaskTransformation +import kotlinx.android.synthetic.main.edit_manga_dialog.* import kotlinx.android.synthetic.main.manga_info_controller.* +import kotlinx.android.synthetic.main.manga_info_controller.manga_artist +import kotlinx.android.synthetic.main.manga_info_controller.manga_author import kotlinx.android.synthetic.main.manga_info_controller.manga_cover import kotlinx.android.synthetic.main.manga_info_controller.manga_genres_tags import uy.kohesive.injekt.Injekt @@ -198,9 +201,10 @@ class MangaInfoController : NucleusController(), val fabBaseMarginBottom = fab_favorite.marginBottom val mangaCoverMarginBottom = manga_cover.marginBottom val fullMarginBottom = manga_cover_full?.marginBottom ?: 0 - setFullCoverToThumb() - container?.setOnApplyWindowInsetsListener { _, insets -> + manga_cover.viewTreeObserver.addOnGlobalLayoutListener { setFullCoverToThumb() + } + container?.setOnApplyWindowInsetsListener { _, insets -> if (MainActivity.bottomNav) return@setOnApplyWindowInsetsListener insets if (resources?.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) { diff --git a/app/src/main/res/layout/track_controller.xml b/app/src/main/res/layout/track_controller.xml index 327dbeb873..b0a35bb1b9 100644 --- a/app/src/main/res/layout/track_controller.xml +++ b/app/src/main/res/layout/track_controller.xml @@ -1,25 +1,23 @@ + tools:listitem="@layout/track_item" /> - +