From 1d0f6e8bce37a6926c80c21aaa1b8ef4449c332e Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 29 Oct 2019 22:23:47 -0700 Subject: [PATCH] Fixed action mode bar + drawer in 3 button landscape --- .../tachiyomi/ui/library/LibraryController.kt | 12 +++++-- .../kanade/tachiyomi/ui/main/MainActivity.kt | 35 ++++++++++++++++--- app/src/main/res/layout/main_activity.xml | 11 ++++-- 3 files changed, 49 insertions(+), 9 deletions(-) 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 81f65ba012..e56b8bd484 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 @@ -5,6 +5,7 @@ import android.content.Intent import android.content.res.Configuration import android.graphics.Color import android.net.Uri +import android.os.Build import android.os.Bundle import com.google.android.material.tabs.TabLayout import androidx.core.graphics.drawable.DrawableCompat @@ -12,6 +13,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.view.ActionMode import androidx.appcompat.widget.SearchView import android.view.* +import androidx.appcompat.widget.ActionBarContextView import androidx.core.view.GravityCompat import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeType @@ -155,6 +157,13 @@ class LibraryController( if (selectedMangas.isNotEmpty()) { createActionModeIfNeeded() } + view.doOnApplyWindowInsets { view, insets, psdding -> + val contextView = activity?.window?.decorView?.findViewById(R.id.action_mode_bar) + if (Build.VERSION.SDK_INT >= 23) contextView?.updateLayoutParams { + leftMargin = view.rootWindowInsets.systemWindowInsetLeft + rightMargin = view.rootWindowInsets.systemWindowInsetRight + } + } } override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) { @@ -197,8 +206,7 @@ class LibraryController( view.doOnApplyWindowInsets { v, insets, padding -> view.recycler.updatePaddingRelative( bottom = view.recycler.marginBottom + insets.systemWindowInsetBottom, - top = view.recycler.marginTop + insets.systemWindowInsetTop, - end = view.recycler.marginRight + insets.systemWindowInsetRight + top = view.recycler.marginTop + insets.systemWindowInsetTop ) } return view diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 25b1eab35f..6437074f7c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -20,6 +20,8 @@ import androidx.appcompat.graphics.drawable.DrawerArrowDrawable import android.view.View import android.view.ViewGroup import android.view.WindowInsets +import android.view.WindowManager +import android.widget.FrameLayout import android.widget.LinearLayout import com.bluelinelabs.conductor.* import eu.kanade.tachiyomi.Migrations @@ -31,6 +33,7 @@ import eu.kanade.tachiyomi.ui.catalogue.CatalogueController import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController import eu.kanade.tachiyomi.ui.download.DownloadController import eu.kanade.tachiyomi.ui.extension.ExtensionController +import eu.kanade.tachiyomi.ui.library.HeightTopWindowInsetsListener import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController @@ -38,8 +41,12 @@ import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController import eu.kanade.tachiyomi.ui.setting.SettingsMainController import eu.kanade.tachiyomi.util.NoopWindowInsetsListener import eu.kanade.tachiyomi.util.doOnApplyWindowInsets +import eu.kanade.tachiyomi.util.marginBottom +import eu.kanade.tachiyomi.util.marginTop import eu.kanade.tachiyomi.util.openInBrowser +import eu.kanade.tachiyomi.util.updatePadding import eu.kanade.tachiyomi.util.updatePaddingRelative +import kotlinx.android.synthetic.main.chapters_controller.view.* import kotlinx.android.synthetic.main.main_activity.* import uy.kohesive.injekt.injectLazy @@ -120,27 +127,45 @@ class MainActivity : BaseActivity() { true } - nav_view.doOnApplyWindowInsets { v, insets, padding -> + /*nav_view.doOnApplyWindowInsets { v, insets, padding -> v.updatePaddingRelative( start = padding.left + insets.systemWindowInsetLeft ) - } + }*/ val container: ViewGroup = findViewById(R.id.controller_container) val content: LinearLayout = findViewById(R.id.main_content) - container.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION content.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + nav_view.doOnApplyWindowInsets { v, insets, padding -> + v.updatePaddingRelative( + bottom = v.marginBottom, + top = v.marginTop + ) + } content.setOnApplyWindowInsetsListener(NoopWindowInsetsListener) val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK if (Build.VERSION.SDK_INT >= 26 && currentNightMode == Configuration.UI_MODE_NIGHT_NO) { content.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR } + val drawerContainer: FrameLayout = findViewById(R.id.drawer_container) + drawerContainer.setOnApplyWindowInsetsListener { v, insets -> + + // Consume any horizontal insets and pad all content in. There's not much we can do + // with horizontal insets + v.updatePadding( + left = insets.systemWindowInsetLeft, + right = insets.systemWindowInsetRight + ) + insets.replaceSystemWindowInsets( + 0, insets.systemWindowInsetTop, + 0, insets.systemWindowInsetBottom + ) + } + router = Conductor.attachRouter(this, container, savedInstanceState) if (!router.hasRootController()) { // Set start screen diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml index 81669b062c..9721268475 100644 --- a/app/src/main/res/layout/main_activity.xml +++ b/app/src/main/res/layout/main_activity.xml @@ -1,8 +1,14 @@ - + + @@ -57,3 +63,4 @@ app:menu="@menu/menu_navigation"/> + \ No newline at end of file