From e7a81072796a2a699182af6444e8c86273dcb514 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 27 Mar 2021 15:15:31 -0400 Subject: [PATCH] Reduce height of sheet when on color filter tab --- .../java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt | 4 ++++ .../tachiyomi/ui/reader/setting/ReaderSettingsSheet.kt | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 79d9c3a0e..6b7f6664e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -397,6 +397,10 @@ class ReaderActivity : BaseRxActivity() * [animate] the views. */ fun setMenuVisibility(visible: Boolean, animate: Boolean = true) { + if (visible == menuVisible) { + return + } + menuVisible = visible if (visible) { if (preferences.fullscreen().get()) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsSheet.kt index 2f796be93..6bfe9cd89 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReaderSettingsSheet.kt @@ -1,5 +1,7 @@ package eu.kanade.tachiyomi.ui.reader.setting +import android.view.ViewGroup +import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.tabs.TabLayout import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.reader.ReaderActivity @@ -15,6 +17,10 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : TabbedBottomSh private val sheetBackgroundDim = window?.attributes?.dimAmount ?: 0.25f init { + val sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup) + sheetBehavior.isFitToContents = false + sheetBehavior.halfExpandedRatio = 0.5f + val filterTabIndex = getTabViews().indexOf(colorFilterSettings) binding.tabs.addOnTabSelectedListener(object : SimpleTabSelectedListener() { // Remove dimmed backdrop so color filter changes can be previewed @@ -22,6 +28,9 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : TabbedBottomSh val isFilterTab = tab?.position == filterTabIndex window?.setDimAmount(if (isFilterTab) 0f else sheetBackgroundDim) activity.setMenuVisibility(!isFilterTab) + if (isFilterTab) { + sheetBehavior?.state = BottomSheetBehavior.STATE_HALF_EXPANDED + } } }) }