mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 15:41:52 +01:00
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:
parent
91a5274660
commit
538ad09754
@ -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<ReaderColorFilterBinding>(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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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()
|
||||
|
@ -23,16 +23,27 @@
|
||||
app:layout_constraintTop_toTopOf="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 -->
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/switch_color_filter"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="@string/use_custom_color_filter"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toBottomOf="@id/swipe_down"/>
|
||||
|
||||
<!-- Red filter -->
|
||||
|
||||
@ -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" />
|
||||
|
||||
|
@ -840,6 +840,7 @@
|
||||
<string name="picture_saved">Picture saved</string>
|
||||
<string name="pin">Pin</string>
|
||||
<string name="pinned">Pinned</string>
|
||||
<string name="preview">Preview</string>
|
||||
<string name="previous">Previous</string>
|
||||
<string name="refresh">Refresh</string>
|
||||
<string name="refreshing">Refreshing</string>
|
||||
|
Loading…
Reference in New Issue
Block a user