mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Adjust tablet layout (closes #5113)
This commit is contained in:
parent
68286b2acc
commit
cf99446a12
6 changed files with 155 additions and 36 deletions
|
@ -70,7 +70,7 @@ class BrowseController :
|
|||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||
super.onChangeStarted(handler, type)
|
||||
if (type.isEnter) {
|
||||
(activity as? MainActivity)?.binding?.toolbarLayout?.tabs?.apply {
|
||||
(activity as? MainActivity)?.binding?.tabs?.apply {
|
||||
setupWithViewPager(binding.pager)
|
||||
|
||||
// Show badge on tab for extension updates
|
||||
|
@ -92,7 +92,7 @@ class BrowseController :
|
|||
}
|
||||
|
||||
fun setExtensionUpdateBadge() {
|
||||
(activity as? MainActivity)?.binding?.toolbarLayout?.tabs?.apply {
|
||||
(activity as? MainActivity)?.binding?.tabs?.apply {
|
||||
val updates = preferences.extensionUpdatesCount().get()
|
||||
if (updates > 0) {
|
||||
val badge: BadgeDrawable? = getTabAt(1)?.orCreateBadge
|
||||
|
|
|
@ -218,7 +218,7 @@ class LibraryController(
|
|||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||
super.onChangeStarted(handler, type)
|
||||
if (type.isEnter) {
|
||||
(activity as? MainActivity)?.binding?.toolbarLayout?.tabs?.setupWithViewPager(binding.libraryPager)
|
||||
(activity as? MainActivity)?.binding?.tabs?.setupWithViewPager(binding.libraryPager)
|
||||
presenter.subscribeLibrary()
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ class LibraryController(
|
|||
// Delay the scroll position to allow the view to be properly measured.
|
||||
view.post {
|
||||
if (isAttached) {
|
||||
(activity as? MainActivity)?.binding?.toolbarLayout?.tabs?.setScrollPosition(binding.libraryPager.currentItem, 0f, true)
|
||||
(activity as? MainActivity)?.binding?.tabs?.setScrollPosition(binding.libraryPager.currentItem, 0f, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,11 +96,11 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||
}
|
||||
|
||||
setContentView(binding.root)
|
||||
setSupportActionBar(binding.toolbarLayout.toolbar)
|
||||
setSupportActionBar(binding.toolbar)
|
||||
|
||||
// Draw edge-to-edge
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
binding.toolbarLayout.appbar.applyInsetter {
|
||||
binding.appbar.applyInsetter {
|
||||
type(navigationBars = true, statusBars = true) {
|
||||
padding(left = true, top = true, right = true)
|
||||
}
|
||||
|
@ -131,13 +131,13 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||
insets
|
||||
}
|
||||
|
||||
tabAnimator = ViewHeightAnimator(binding.toolbarLayout.tabs, 0L)
|
||||
tabAnimator = ViewHeightAnimator(binding.tabs, 0L)
|
||||
|
||||
if (binding.bottomNav != null) {
|
||||
bottomNavAnimator = ViewHeightAnimator(binding.bottomNav!!)
|
||||
|
||||
// If bottom nav is hidden, make it visible again when the app bar is expanded
|
||||
binding.toolbarLayout.appbar.addOnOffsetChangedListener(
|
||||
binding.appbar.addOnOffsetChangedListener(
|
||||
AppBarLayout.OnOffsetChangedListener { _, verticalOffset ->
|
||||
if (verticalOffset == 0) {
|
||||
showNav(visible = true)
|
||||
|
@ -186,7 +186,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
binding.toolbarLayout.toolbar.setNavigationOnClickListener {
|
||||
binding.toolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
}
|
||||
|
||||
|
@ -227,13 +227,13 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.downloadedOnly()
|
||||
.asImmediateFlow { binding.toolbarLayout.downloadedOnly.isVisible = it }
|
||||
.asImmediateFlow { binding.downloadedOnly.isVisible = it }
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.incognitoMode().asFlow()
|
||||
.drop(1)
|
||||
.onEach {
|
||||
binding.toolbarLayout.incognitoMode.isVisible = it
|
||||
binding.incognitoMode.isVisible = it
|
||||
|
||||
// Close BrowseSourceController and its MangaController child when incognito mode is disabled
|
||||
if (!it) {
|
||||
|
@ -355,7 +355,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||
|
||||
// Binding sometimes isn't actually instantiated yet somehow
|
||||
nav.setOnItemSelectedListener(null)
|
||||
binding?.toolbarLayout?.toolbar.setNavigationOnClickListener(null)
|
||||
binding?.toolbar.setNavigationOnClickListener(null)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
@ -408,7 +408,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||
supportActionBar?.setDisplayHomeAsUpEnabled(router.backstackSize != 1)
|
||||
|
||||
// Always show appbar again when changing controllers
|
||||
binding.toolbarLayout.appbar.setExpanded(true)
|
||||
binding.appbar.setExpanded(true)
|
||||
|
||||
if ((from == null || from is RootController) && to !is RootController) {
|
||||
showNav(visible = false, collapse = true)
|
||||
|
@ -419,14 +419,14 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||
}
|
||||
|
||||
if (from is TabbedController) {
|
||||
from.cleanupTabs(binding.toolbarLayout.tabs)
|
||||
from.cleanupTabs(binding.tabs)
|
||||
}
|
||||
if (to is TabbedController) {
|
||||
tabAnimator.expand()
|
||||
to.configureTabs(binding.toolbarLayout.tabs)
|
||||
to.configureTabs(binding.tabs)
|
||||
} else {
|
||||
tabAnimator.collapse()
|
||||
binding.toolbarLayout.tabs.setupWithViewPager(null)
|
||||
binding.tabs.setupWithViewPager(null)
|
||||
}
|
||||
|
||||
if (from is FabController) {
|
||||
|
@ -440,13 +440,13 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||
|
||||
when (to) {
|
||||
is NoToolbarElevationController -> {
|
||||
binding.toolbarLayout.appbar.disableElevation()
|
||||
binding.appbar.disableElevation()
|
||||
}
|
||||
is ToolbarLiftOnScrollController -> {
|
||||
binding.toolbarLayout.appbar.enableElevation(true)
|
||||
binding.appbar.enableElevation(true)
|
||||
}
|
||||
else -> {
|
||||
binding.toolbarLayout.appbar.enableElevation(false)
|
||||
binding.appbar.enableElevation(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -489,16 +489,16 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
|||
*/
|
||||
fun fixViewToBottom(view: View) {
|
||||
val listener = AppBarLayout.OnOffsetChangedListener { appBarLayout, verticalOffset ->
|
||||
val maxAbsOffset = appBarLayout.measuredHeight - binding.toolbarLayout.tabs.measuredHeight
|
||||
val maxAbsOffset = appBarLayout.measuredHeight - binding.tabs.measuredHeight
|
||||
view.translationY = -maxAbsOffset - verticalOffset.toFloat() + appBarLayout.marginTop
|
||||
}
|
||||
binding.toolbarLayout.appbar.addOnOffsetChangedListener(listener)
|
||||
binding.appbar.addOnOffsetChangedListener(listener)
|
||||
fixedViewsToBottom[view] = listener
|
||||
}
|
||||
|
||||
fun clearFixViewToBottom(view: View) {
|
||||
val listener = fixedViewsToBottom.remove(view)
|
||||
binding.toolbarLayout.appbar.removeOnOffsetChangedListener(listener)
|
||||
binding.appbar.removeOnOffsetChangedListener(listener)
|
||||
}
|
||||
|
||||
private fun setBottomNavBehaviorOnScroll() {
|
||||
|
|
|
@ -277,7 +277,7 @@ class MangaController :
|
|||
else -> min(binding.recycler.computeVerticalScrollOffset(), 255)
|
||||
}
|
||||
|
||||
(activity as? MainActivity)?.binding?.toolbarLayout?.toolbar?.setTitleTextColor(
|
||||
(activity as? MainActivity)?.binding?.toolbar?.setTitleTextColor(
|
||||
Color.argb(
|
||||
calculatedAlpha,
|
||||
toolbarTextColor.red,
|
||||
|
|
|
@ -1,41 +1,105 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout 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/root_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar_layout"
|
||||
layout="@layout/main_activity_toolbar" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<eu.kanade.tachiyomi.widget.ElevationAppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="?attr/actionBarTheme" />
|
||||
|
||||
</eu.kanade.tachiyomi.widget.ElevationAppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/downloaded_only"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/green"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/appbar"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:padding="4dp"
|
||||
android:text="@string/label_downloaded_only"
|
||||
android:textColor="@color/md_white_1000" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/incognito_mode"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/md_grey_800"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/downloaded_only"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:padding="4dp"
|
||||
android:text="@string/pref_incognito_mode"
|
||||
android:textColor="@color/md_white_1000" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<com.google.android.material.navigationrail.NavigationRailView
|
||||
android:id="@+id/side_nav"
|
||||
style="@style/Widget.MaterialComponents.NavigationRailView.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:itemIconTint="@color/nav_selector"
|
||||
app:itemTextColor="@color/nav_selector"
|
||||
app:labelVisibilityMode="labeled"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/incognito_mode"
|
||||
app:menu="@menu/main_nav" />
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabs"
|
||||
style="@style/Theme.Widget.Tabs"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/side_nav"
|
||||
app:layout_constraintTop_toBottomOf="@+id/incognito_mode" />
|
||||
|
||||
<com.bluelinelabs.conductor.ChangeHandlerFrameLayout
|
||||
android:id="@+id/controller_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/side_nav"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/tabs" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
@ -1,14 +1,69 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout 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/root_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar_layout"
|
||||
layout="@layout/main_activity_toolbar" />
|
||||
<eu.kanade.tachiyomi.widget.ElevationAppBarLayout
|
||||
android:id="@+id/appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="?attr/actionBarTheme"
|
||||
app:layout_scrollFlags="scroll|enterAlways" />
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/tabs"
|
||||
style="@style/Theme.Widget.Tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/downloaded_only"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/green"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:padding="4dp"
|
||||
android:text="@string/label_downloaded_only"
|
||||
android:textColor="@color/md_white_1000" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/incognito_mode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/md_grey_800"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:padding="4dp"
|
||||
android:text="@string/pref_incognito_mode"
|
||||
android:textColor="@color/md_white_1000" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</eu.kanade.tachiyomi.widget.ElevationAppBarLayout>
|
||||
|
||||
<com.bluelinelabs.conductor.ChangeHandlerFrameLayout
|
||||
android:id="@+id/controller_container"
|
||||
|
|
Loading…
Reference in a new issue