From 538ad09754b3178dfc95f8b67680ccbf974aecd2 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Tue, 30 Mar 2021 14:23:22 -0400 Subject: [PATCH] Add button to collapse reader filters Also adding gesture ignoring for custom brightness since its extremely close to the nav bar --- .../ui/reader/settings/ReaderFilterView.kt | 14 ++++++++++++++ .../reader/settings/TabbedReaderSettingsSheet.kt | 14 +++++++++++++- app/src/main/res/layout/reader_color_filter.xml | 15 +++++++++++++-- app/src/main/res/values/strings.xml | 1 + 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderFilterView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderFilterView.kt index 4f0cb36bcb..1bf9c81876 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderFilterView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/ReaderFilterView.kt @@ -1,6 +1,8 @@ package eu.kanade.tachiyomi.ui.reader.settings import android.content.Context +import android.graphics.Rect +import android.os.Build import android.util.AttributeSet import android.view.Window import android.view.WindowManager @@ -19,6 +21,8 @@ class ReaderFilterView @JvmOverloads constructor(context: Context, attrs: Attrib BaseReaderSettingsView(context, attrs) { var window: Window? = null + private val boundingBox: Rect = Rect() + private val exclusions = listOf(boundingBox) override fun inflateBinding() = ReaderColorFilterBinding.bind(this) override fun initGeneralPreferences() { @@ -266,6 +270,16 @@ class ReaderFilterView @JvmOverloads constructor(context: Context, attrs: Attrib /** Integer mask of blue value **/ const val BLUE_MASK: Long = 0x000000FF } + + override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { + super.onLayout(changed, left, top, right, bottom) + if (Build.VERSION.SDK_INT >= 29 && changed) { + with(binding.brightnessSeekbar) { + boundingBox.set(this.left, this.top, this.right, this.bottom) + this.systemGestureExclusionRects = exclusions + } + } + } } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt index c5f8812db2..36b20c7feb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/settings/TabbedReaderSettingsSheet.kt @@ -7,10 +7,13 @@ import androidx.core.content.ContextCompat import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.tabs.TabLayout import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.databinding.ReaderColorFilterBinding import eu.kanade.tachiyomi.ui.main.SearchActivity import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.util.system.dpToPx +import eu.kanade.tachiyomi.util.view.collapse import eu.kanade.tachiyomi.util.view.expand +import eu.kanade.tachiyomi.util.view.isCollapsed import eu.kanade.tachiyomi.util.view.visInvisIf import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog @@ -61,6 +64,15 @@ class TabbedReaderSettingsSheet(val readerActivity: ReaderActivity) : generalView.sheet = this sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup) + + ReaderColorFilterBinding.bind(filterView).swipeDown.setOnClickListener { + if (sheetBehavior.isCollapsed()) { + sheetBehavior.expand() + } else { + sheetBehavior.collapse() + } + } + binding.menu.visible() if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { binding.menu.tooltipText = context.getString(R.string.reader_settings) @@ -86,7 +98,7 @@ class TabbedReaderSettingsSheet(val readerActivity: ReaderActivity) : readerActivity.binding.appBar.visInvisIf(tab?.position != 2) if (tab?.position == 2) { sheetBehavior.skipCollapsed = false - sheetBehavior.peekHeight = 100.dpToPx + sheetBehavior.peekHeight = 110.dpToPx filterView.setWindowBrightness() } else { sheetBehavior.expand() diff --git a/app/src/main/res/layout/reader_color_filter.xml b/app/src/main/res/layout/reader_color_filter.xml index 2d3fbeb2b4..b444404b9b 100644 --- a/app/src/main/res/layout/reader_color_filter.xml +++ b/app/src/main/res/layout/reader_color_filter.xml @@ -23,16 +23,27 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toEndOf="parent" /> + + + app:layout_constraintTop_toBottomOf="@id/swipe_down"/> @@ -188,7 +199,7 @@ android:id="@+id/custom_brightness" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="16dp" + android:layout_marginTop="8dp" android:text="@string/use_custom_brightness" app:layout_constraintTop_toBottomOf="@id/color_filter_mode" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6f61a8f116..bc544ff279 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -840,6 +840,7 @@ Picture saved Pin Pinned + Preview Previous Refresh Refreshing