Updating config for side nav to show up on landscape and larger tablets in any orientation

This commit is contained in:
Jays2Kings 2021-08-06 22:38:45 -04:00
parent b26c029e40
commit 9a009f7a76
5 changed files with 6 additions and 436 deletions

View File

@ -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 {

View File

@ -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()

View File

@ -1,221 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.bluelinelabs.conductor.ChangeHandlerFrameLayout
android:id="@+id/controller_container"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@id/side_nav"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
</com.bluelinelabs.conductor.ChangeHandlerFrameLayout>
<com.google.android.material.navigationrail.NavigationRailView
android:id="@+id/side_nav"
style="@style/Widget.MaterialComponents.NavigationRailView.Colored"
android:background="?android:colorBackground"
android:layout_width="wrap_content"
android:layout_height="0dp"
app:itemIconTint="@color/bottom_nav_item_selector"
app:itemRippleColor="@color/ripple_nav"
app:itemTextColor="@color/bottom_nav_item_selector"
app:labelVisibilityMode="labeled"
android:translationZ="-10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/app_bar"
app:menu="@menu/bottom_navigation" />
<View
android:id="@+id/shadow_gap"
android:layout_width="1dp"
android:layout_height="16dp"
app:layout_constraintEnd_toEndOf="@id/side_nav"
app:layout_constraintBottom_toTopOf="@id/side_nav" />
<View
android:id="@+id/side_shadow"
android:layout_width="6dp"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:alpha="0.04"
android:rotation="180"
android:translationZ="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/side_nav"
app:layout_constraintTop_toTopOf="@id/shadow_gap"
android:background="@drawable/shape_gradient_start_shadow" />
<FrameLayout
android:id="@+id/tabs_frame_layout"
android:clickable="true"
android:visibility="gone"
android:layout_width="0dp"
android:background="?attr/colorSecondary"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/app_bar"
app:layout_constraintStart_toEndOf="@id/side_nav"
app:layout_constraintEnd_toEndOf="parent"
tools:visibility="visible"
tools:ignore="KeyboardInaccessibleWidget">
<com.google.android.material.tabs.TabLayout
android:id="@+id/main_tabs"
style="@style/Theme.Widget.Tabs.Highlight"
android:background="?attr/colorSecondary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:tabGravity="fill"/>
</FrameLayout>
<View
android:id="@+id/tab_shadow"
android:layout_width="0dp"
android:visibility="gone"
android:layout_height="6dp"
android:rotation="180"
android:alpha="0.15"
android:background="@drawable/shape_gradient_top_shadow"
app:layout_constraintStart_toStartOf="@id/tabs_frame_layout"
app:layout_constraintEnd_toEndOf="@id/tabs_frame_layout"
app:layout_constraintTop_toBottomOf="@id/tabs_frame_layout"
android:paddingBottom="10dp" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSecondary"
android:stateListAnimator="@null"
android:theme="?attr/actionBarTheme"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<eu.kanade.tachiyomi.ui.base.CenteredToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
app:titleTextColor="?actionBarTintColor"
android:layout_height="?attr/actionBarSize"
app:collapseIcon="@drawable/ic_arrow_back_24dp"
android:background="?attr/colorSecondary">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/toolbar_title"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTint="?actionBarTintColor"
android:ellipsize="end"
android:layout_gravity="center"
android:maxLines="1"
android:textColor="?actionBarTintColor"
android:textSize="20sp"
tools:drawableEnd="@drawable/ic_arrow_drop_down_24dp"
tools:drawableStart="@drawable/ic_blank_24dp"
tools:text="Title Text" />
</eu.kanade.tachiyomi.ui.base.CenteredToolbar>
<FrameLayout
android:id="@+id/card_frame"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" >
<androidx.cardview.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_marginTop="4dp"
app:cardBackgroundColor="?colorPrimaryVariant"
android:layout_marginBottom="4dp"
android:layout_marginStart="14dp"
android:layout_marginEnd="14dp"
app:cardCornerRadius="8dp"
android:layout_height="match_parent" >
<eu.kanade.tachiyomi.ui.base.FloatingToolbar
android:id="@+id/card_toolbar"
tools:title="Search Library..."
app:contentInsetStartWithNavigation="0dp"
app:contentInsetEndWithActions="0dp"
app:contentInsetStart="0dp"
app:contentInsetEnd="0dp"
android:background="@drawable/rect_ripple"
app:navigationIconTint="@color/text_color_secondary"
app:navigationIcon="@drawable/ic_search_24dp"
app:titleTextAppearance="@style/TextAppearance.MaterialComponents.Body1"
app:subtitleTextAppearance="@style/TextAppearance.MaterialComponents.Caption"
app:collapseIcon="@drawable/ic_arrow_back_24dp"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="start|center"
android:orientation="horizontal">
<ImageView
android:id="@+id/card_incog_image"
app:tint="?actionBarTintColor"
android:layout_gravity="center|start"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_marginEnd="6dp"
android:layout_marginStart="0dp"
android:contentDescription="@string/incognito_mode"
android:src="@drawable/ic_incognito_circle_24dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="start|center"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/card_title"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTint="?actionBarTintColor"
android:ellipsize="end"
android:layout_gravity="center"
android:maxLines="1"
android:textColor="?actionBarTintColor"
android:textSize="20sp"
tools:drawableEnd="@drawable/ic_arrow_drop_down_24dp"
tools:drawableStart="@drawable/ic_blank_24dp"
tools:text="Title Text" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/card_subtitle"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:layout_gravity="start|center"
android:maxLines="1"
android:textColor="?actionBarTintColor"
android:textSize="12sp"
tools:text="Title Text" />
</LinearLayout>
</LinearLayout>
</eu.kanade.tachiyomi.ui.base.FloatingToolbar>
</androidx.cardview.widget.CardView>
</FrameLayout>
</com.google.android.material.appbar.AppBarLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,192 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.bluelinelabs.conductor.ChangeHandlerFrameLayout
android:id="@+id/controller_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
</com.bluelinelabs.conductor.ChangeHandlerFrameLayout>
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSecondary"
android:stateListAnimator="@null"
android:theme="?attr/actionBarTheme"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<eu.kanade.tachiyomi.ui.base.CenteredToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
app:titleTextColor="?actionBarTintColor"
android:layout_height="?attr/actionBarSize"
app:collapseIcon="@drawable/ic_arrow_back_24dp"
android:background="?attr/colorSecondary">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/toolbar_title"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTint="?actionBarTintColor"
android:ellipsize="end"
android:layout_gravity="center"
android:maxLines="1"
android:textColor="?actionBarTintColor"
android:textSize="20sp"
tools:drawableEnd="@drawable/ic_arrow_drop_down_24dp"
tools:drawableStart="@drawable/ic_blank_24dp"
tools:text="Title Text" />
</eu.kanade.tachiyomi.ui.base.CenteredToolbar>
<FrameLayout
android:id="@+id/card_frame"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" >
<androidx.cardview.widget.CardView
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_marginTop="4dp"
app:cardBackgroundColor="?colorPrimaryVariant"
android:layout_marginBottom="4dp"
android:layout_marginStart="14dp"
android:layout_marginEnd="14dp"
app:cardCornerRadius="8dp"
android:layout_height="match_parent" >
<eu.kanade.tachiyomi.ui.base.FloatingToolbar
android:id="@+id/card_toolbar"
tools:title="Search Library..."
app:contentInsetStartWithNavigation="0dp"
app:contentInsetEndWithActions="0dp"
app:contentInsetStart="0dp"
app:contentInsetEnd="0dp"
android:background="@drawable/rect_ripple"
app:navigationIconTint="@color/text_color_secondary"
app:navigationIcon="@drawable/ic_search_24dp"
app:titleTextAppearance="@style/TextAppearance.MaterialComponents.Body1"
app:subtitleTextAppearance="@style/TextAppearance.MaterialComponents.Caption"
app:collapseIcon="@drawable/ic_arrow_back_24dp"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="start|center"
android:orientation="horizontal">
<ImageView
android:id="@+id/card_incog_image"
app:tint="?actionBarTintColor"
android:layout_gravity="center|start"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_marginEnd="6dp"
android:layout_marginStart="0dp"
android:contentDescription="@string/incognito_mode"
android:src="@drawable/ic_incognito_circle_24dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="start|center"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/card_title"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTint="?actionBarTintColor"
android:ellipsize="end"
android:layout_gravity="center"
android:maxLines="1"
android:textColor="?actionBarTintColor"
android:textSize="20sp"
tools:drawableEnd="@drawable/ic_arrow_drop_down_24dp"
tools:drawableStart="@drawable/ic_blank_24dp"
tools:text="Title Text" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/card_subtitle"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:layout_gravity="start|center"
android:maxLines="1"
android:textColor="?actionBarTintColor"
android:textSize="12sp"
tools:text="Title Text" />
</LinearLayout>
</LinearLayout>
</eu.kanade.tachiyomi.ui.base.FloatingToolbar>
</androidx.cardview.widget.CardView>
</FrameLayout>
<FrameLayout
android:id="@+id/tabs_frame_layout"
android:clickable="true"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="KeyboardInaccessibleWidget">
<com.google.android.material.tabs.TabLayout
android:id="@+id/main_tabs"
style="@style/Theme.Widget.Tabs.Highlight"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:tabGravity="fill"/>
</FrameLayout>
</com.google.android.material.appbar.AppBarLayout>
<View
android:id="@+id/bottom_view"
android:clickable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="0dp"
tools:ignore="KeyboardInaccessibleWidget" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorPrimaryVariant"
app:itemIconTint="@color/bottom_nav_item_selector"
app:itemRippleColor="@color/ripple_nav"
app:itemTextColor="@color/bottom_nav_item_selector"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_navigation"
app:tabRippleColor="@color/rippleColor"
app:tabTextColor="?attr/tabBarIconColor" />
</androidx.constraintlayout.widget.ConstraintLayout>