Add button to collapse reader filters

Also adding gesture ignoring for custom brightness since its extremely close to the nav bar
This commit is contained in:
Jays2Kings 2021-03-30 14:23:22 -04:00
parent 91a5274660
commit 538ad09754
4 changed files with 41 additions and 3 deletions

View File

@ -1,6 +1,8 @@
package eu.kanade.tachiyomi.ui.reader.settings package eu.kanade.tachiyomi.ui.reader.settings
import android.content.Context import android.content.Context
import android.graphics.Rect
import android.os.Build
import android.util.AttributeSet import android.util.AttributeSet
import android.view.Window import android.view.Window
import android.view.WindowManager import android.view.WindowManager
@ -19,6 +21,8 @@ class ReaderFilterView @JvmOverloads constructor(context: Context, attrs: Attrib
BaseReaderSettingsView<ReaderColorFilterBinding>(context, attrs) { BaseReaderSettingsView<ReaderColorFilterBinding>(context, attrs) {
var window: Window? = null var window: Window? = null
private val boundingBox: Rect = Rect()
private val exclusions = listOf(boundingBox)
override fun inflateBinding() = ReaderColorFilterBinding.bind(this) override fun inflateBinding() = ReaderColorFilterBinding.bind(this)
override fun initGeneralPreferences() { override fun initGeneralPreferences() {
@ -266,6 +270,16 @@ class ReaderFilterView @JvmOverloads constructor(context: Context, attrs: Attrib
/** Integer mask of blue value **/ /** Integer mask of blue value **/
const val BLUE_MASK: Long = 0x000000FF 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
}
}
}
} }
/** /**

View File

@ -7,10 +7,13 @@ import androidx.core.content.ContextCompat
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.ReaderColorFilterBinding
import eu.kanade.tachiyomi.ui.main.SearchActivity import eu.kanade.tachiyomi.ui.main.SearchActivity
import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.util.system.dpToPx 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.expand
import eu.kanade.tachiyomi.util.view.isCollapsed
import eu.kanade.tachiyomi.util.view.visInvisIf import eu.kanade.tachiyomi.util.view.visInvisIf
import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog import eu.kanade.tachiyomi.widget.TabbedBottomSheetDialog
@ -61,6 +64,15 @@ class TabbedReaderSettingsSheet(val readerActivity: ReaderActivity) :
generalView.sheet = this generalView.sheet = this
sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup) sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup)
ReaderColorFilterBinding.bind(filterView).swipeDown.setOnClickListener {
if (sheetBehavior.isCollapsed()) {
sheetBehavior.expand()
} else {
sheetBehavior.collapse()
}
}
binding.menu.visible() binding.menu.visible()
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
binding.menu.tooltipText = context.getString(R.string.reader_settings) 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) readerActivity.binding.appBar.visInvisIf(tab?.position != 2)
if (tab?.position == 2) { if (tab?.position == 2) {
sheetBehavior.skipCollapsed = false sheetBehavior.skipCollapsed = false
sheetBehavior.peekHeight = 100.dpToPx sheetBehavior.peekHeight = 110.dpToPx
filterView.setWindowBrightness() filterView.setWindowBrightness()
} else { } else {
sheetBehavior.expand() sheetBehavior.expand()

View File

@ -23,16 +23,27 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="parent" /> app:layout_constraintStart_toEndOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/swipe_down"
style="@style/Theme.Widget.Button.TextButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/preview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- Color filter --> <!-- Color filter -->
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/switch_color_filter" android:id="@+id/switch_color_filter"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/use_custom_color_filter" android:text="@string/use_custom_color_filter"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toBottomOf="@id/swipe_down"/>
<!-- Red filter --> <!-- Red filter -->
@ -188,7 +199,7 @@
android:id="@+id/custom_brightness" android:id="@+id/custom_brightness"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="8dp"
android:text="@string/use_custom_brightness" android:text="@string/use_custom_brightness"
app:layout_constraintTop_toBottomOf="@id/color_filter_mode" /> app:layout_constraintTop_toBottomOf="@id/color_filter_mode" />

View File

@ -840,6 +840,7 @@
<string name="picture_saved">Picture saved</string> <string name="picture_saved">Picture saved</string>
<string name="pin">Pin</string> <string name="pin">Pin</string>
<string name="pinned">Pinned</string> <string name="pinned">Pinned</string>
<string name="preview">Preview</string>
<string name="previous">Previous</string> <string name="previous">Previous</string>
<string name="refresh">Refresh</string> <string name="refresh">Refresh</string>
<string name="refreshing">Refreshing</string> <string name="refreshing">Refreshing</string>