From 9a009f7a760de6a5bd1f5e50c8887e4ad64e6f8c Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Fri, 6 Aug 2021 22:38:45 -0400 Subject: [PATCH] Updating config for side nav to show up on landscape and larger tablets in any orientation --- .../ui/setting/SettingsGeneralController.kt | 5 +- .../util/view/ControllerExtensions.kt | 24 +- .../res/layout-sw600dp-land/main_activity.xml | 221 ------------------ .../res/layout-sw600dp-port/main_activity.xml | 192 --------------- .../main_activity.xml | 0 5 files changed, 6 insertions(+), 436 deletions(-) delete mode 100644 app/src/main/res/layout-sw600dp-land/main_activity.xml delete mode 100644 app/src/main/res/layout-sw600dp-port/main_activity.xml rename app/src/main/res/{layout-land => layout-w720dp}/main_activity.xml (100%) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index a9f1a0830a..689bf83e61 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -10,12 +10,13 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.asImmediateFlow import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn import eu.kanade.tachiyomi.data.updater.AutoUpdaterJob -import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.util.system.appDelegateNightMode +import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.getPrefTheme import eu.kanade.tachiyomi.util.system.isInNightMode import kotlinx.coroutines.flow.launchIn +import kotlin.math.max import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys class SettingsGeneralController : SettingsController() { @@ -90,7 +91,7 @@ class SettingsGeneralController : SettingsController() { ) entryRange = 0..2 defaultValue = 0 - isVisible = (activity as? MainActivity)?.binding?.sideNav != null + isVisible = max(context.resources.displayMetrics.widthPixels, context.resources.displayMetrics.heightPixels) > 720.dpToPx } preferenceCategory { diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt index 913f8a3cc5..9e2096508e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ControllerExtensions.kt @@ -187,7 +187,6 @@ fun Controller.scrollViewWith( activityBinding?.appBar?.y = 0f activityBinding?.tabsFrameLayout?.elevation = 0f val isSideNavWithTabs = activityBinding?.sideNav != null && includeTabView && recycler.context.isTablet() - activityBinding?.tabShadow?.isVisible = isSideNavWithTabs val attrsArray = intArrayOf(R.attr.actionBarSize) val array = recycler.context.obtainStyledAttributes(attrsArray) var appBarHeight = ( @@ -243,33 +242,18 @@ fun Controller.scrollViewWith( liftOnScroll.invoke(el) } else { elevationAnim?.cancel() - if (isSideNavWithTabs && el) { - activityBinding?.tabShadow?.isVisible = true - } val floatingBar = (this as? FloatingSearchInterface)?.showFloatingBar() == true && !includeTabView if (floatingBar) { - if (isSideNavWithTabs) { - activityBinding?.tabShadow?.alpha = 0f - } else { - activityBinding?.appBar?.elevation = 0f - } + activityBinding?.appBar?.elevation = 0f return@f } elevationAnim = ValueAnimator.ofFloat( - if (isSideNavWithTabs) { - (activityBinding?.tabShadow?.alpha ?: 0f) * 100 - } else { - activityBinding?.appBar?.elevation ?: 0f - }, + activityBinding?.appBar?.elevation ?: 0f, if (el) 15f else 0f ) elevationAnim?.addUpdateListener { valueAnimator -> - if (isSideNavWithTabs) { - activityBinding?.tabShadow?.alpha = valueAnimator.animatedValue as Float / 100 - } else { - activityBinding?.appBar?.elevation = valueAnimator.animatedValue as Float - } + activityBinding?.appBar?.elevation = valueAnimator.animatedValue as Float } elevationAnim?.start() } @@ -287,7 +271,6 @@ fun Controller.scrollViewWith( super.onChangeStart(controller, changeHandler, changeType) isInView = changeType.isEnter if (changeType.isEnter) { - activityBinding?.tabShadow?.isVisible = isSideNavWithTabs elevateFunc(elevate) if (fakeToolbarView?.parent != null) { val parent = fakeToolbarView?.parent as? ViewGroup ?: return @@ -309,7 +292,6 @@ fun Controller.scrollViewWith( } } } else { - activityBinding?.tabShadow?.isVisible = false if (!customPadding && lastY == 0f && ( ( this@scrollViewWith !is FloatingSearchInterface && router.backstack.lastOrNull() diff --git a/app/src/main/res/layout-sw600dp-land/main_activity.xml b/app/src/main/res/layout-sw600dp-land/main_activity.xml deleted file mode 100644 index 6961920418..0000000000 --- a/app/src/main/res/layout-sw600dp-land/main_activity.xml +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout-sw600dp-port/main_activity.xml b/app/src/main/res/layout-sw600dp-port/main_activity.xml deleted file mode 100644 index 361a931102..0000000000 --- a/app/src/main/res/layout-sw600dp-port/main_activity.xml +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout-land/main_activity.xml b/app/src/main/res/layout-w720dp/main_activity.xml similarity index 100% rename from app/src/main/res/layout-land/main_activity.xml rename to app/src/main/res/layout-w720dp/main_activity.xml