mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 03:07:25 +01:00
Use view binding for sheets
This commit is contained in:
parent
4809d06d04
commit
dc43e41896
@ -3,15 +3,13 @@ package eu.kanade.tachiyomi.ui.browse.source.browse
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.view.inflate
|
||||
import eu.kanade.tachiyomi.databinding.SourceFilterSheetBinding
|
||||
import eu.kanade.tachiyomi.widget.SimpleNavigationView
|
||||
import kotlinx.android.synthetic.main.source_filter_sheet.view.filter_btn
|
||||
import kotlinx.android.synthetic.main.source_filter_sheet.view.reset_btn
|
||||
|
||||
class SourceFilterSheet(
|
||||
activity: Activity,
|
||||
@ -46,14 +44,15 @@ class SourceFilterSheet(
|
||||
.setDisplayHeadersAtStartUp(true)
|
||||
.setStickyHeaders(true)
|
||||
|
||||
private val binding = SourceFilterSheetBinding.inflate(LayoutInflater.from(context), null, false)
|
||||
|
||||
init {
|
||||
recycler.adapter = adapter
|
||||
recycler.setHasFixedSize(true)
|
||||
val view = inflate(R.layout.source_filter_sheet)
|
||||
((view as ViewGroup).getChildAt(1) as ViewGroup).addView(recycler)
|
||||
addView(view)
|
||||
filter_btn.setOnClickListener { onFilterClicked() }
|
||||
reset_btn.setOnClickListener { onResetClicked() }
|
||||
(binding.root.getChildAt(1) as ViewGroup).addView(recycler)
|
||||
addView(binding.root)
|
||||
binding.filterBtn.setOnClickListener { onFilterClicked() }
|
||||
binding.resetBtn.setOnClickListener { onResetClicked() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,14 @@
|
||||
package eu.kanade.tachiyomi.ui.reader
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.SeekBar
|
||||
import androidx.annotation.ColorInt
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.databinding.ReaderColorFilterSheetBinding
|
||||
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
||||
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.brightness_seekbar
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.color_filter_mode
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.custom_brightness
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.seekbar_color_filter_alpha
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.seekbar_color_filter_blue
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.seekbar_color_filter_green
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.seekbar_color_filter_red
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.switch_color_filter
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.txt_brightness_seekbar_value
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.txt_color_filter_alpha_value
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.txt_color_filter_blue_value
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.txt_color_filter_green_value
|
||||
import kotlinx.android.synthetic.main.reader_color_filter_sheet.txt_color_filter_red_value
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.sample
|
||||
@ -37,57 +23,58 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
|
||||
private var sheetBehavior: BottomSheetBehavior<*>? = null
|
||||
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.reader_color_filter_sheet, null)
|
||||
setContentView(view)
|
||||
private val binding = ReaderColorFilterSheetBinding.inflate(activity.layoutInflater, null, false)
|
||||
|
||||
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
|
||||
init {
|
||||
setContentView(binding.root)
|
||||
|
||||
sheetBehavior = BottomSheetBehavior.from(binding.root.parent as ViewGroup)
|
||||
|
||||
preferences.colorFilter().asFlow()
|
||||
.onEach { setColorFilter(it, view) }
|
||||
.onEach { setColorFilter(it) }
|
||||
.launchIn(activity.scope)
|
||||
|
||||
preferences.colorFilterMode().asFlow()
|
||||
.onEach { setColorFilter(preferences.colorFilter().get(), view) }
|
||||
.onEach { setColorFilter(preferences.colorFilter().get()) }
|
||||
.launchIn(activity.scope)
|
||||
|
||||
preferences.customBrightness().asFlow()
|
||||
.onEach { setCustomBrightness(it, view) }
|
||||
.onEach { setCustomBrightness(it) }
|
||||
.launchIn(activity.scope)
|
||||
|
||||
// Get color and update values
|
||||
val color = preferences.colorFilterValue().get()
|
||||
val brightness = preferences.customBrightnessValue().get()
|
||||
|
||||
val argb = setValues(color, view)
|
||||
val argb = setValues(color)
|
||||
|
||||
// Set brightness value
|
||||
txt_brightness_seekbar_value.text = brightness.toString()
|
||||
brightness_seekbar.progress = brightness
|
||||
binding.txtBrightnessSeekbarValue.text = brightness.toString()
|
||||
binding.brightnessSeekbar.progress = brightness
|
||||
|
||||
// Initialize seekBar progress
|
||||
seekbar_color_filter_alpha.progress = argb[0]
|
||||
seekbar_color_filter_red.progress = argb[1]
|
||||
seekbar_color_filter_green.progress = argb[2]
|
||||
seekbar_color_filter_blue.progress = argb[3]
|
||||
binding.seekbarColorFilterAlpha.progress = argb[0]
|
||||
binding.seekbarColorFilterRed.progress = argb[1]
|
||||
binding.seekbarColorFilterGreen.progress = argb[2]
|
||||
binding.seekbarColorFilterBlue.progress = argb[3]
|
||||
|
||||
// Set listeners
|
||||
switch_color_filter.isChecked = preferences.colorFilter().get()
|
||||
switch_color_filter.setOnCheckedChangeListener { _, isChecked ->
|
||||
binding.switchColorFilter.isChecked = preferences.colorFilter().get()
|
||||
binding.switchColorFilter.setOnCheckedChangeListener { _, isChecked ->
|
||||
preferences.colorFilter().set(isChecked)
|
||||
}
|
||||
|
||||
custom_brightness.isChecked = preferences.customBrightness().get()
|
||||
custom_brightness.setOnCheckedChangeListener { _, isChecked ->
|
||||
binding.customBrightness.isChecked = preferences.customBrightness().get()
|
||||
binding.customBrightness.setOnCheckedChangeListener { _, isChecked ->
|
||||
preferences.customBrightness().set(isChecked)
|
||||
}
|
||||
|
||||
color_filter_mode.onItemSelectedListener = IgnoreFirstSpinnerListener { position ->
|
||||
binding.colorFilterMode.onItemSelectedListener = IgnoreFirstSpinnerListener { position ->
|
||||
preferences.colorFilterMode().set(position)
|
||||
}
|
||||
color_filter_mode.setSelection(preferences.colorFilterMode().get(), false)
|
||||
binding.colorFilterMode.setSelection(preferences.colorFilterMode().get(), false)
|
||||
|
||||
seekbar_color_filter_alpha.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
|
||||
binding.seekbarColorFilterAlpha.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
|
||||
override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
setColorValue(value, ALPHA_MASK, 24)
|
||||
@ -95,7 +82,7 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
}
|
||||
})
|
||||
|
||||
seekbar_color_filter_red.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
|
||||
binding.seekbarColorFilterRed.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
|
||||
override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
setColorValue(value, RED_MASK, 16)
|
||||
@ -103,7 +90,7 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
}
|
||||
})
|
||||
|
||||
seekbar_color_filter_green.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
|
||||
binding.seekbarColorFilterGreen.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
|
||||
override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
setColorValue(value, GREEN_MASK, 8)
|
||||
@ -111,7 +98,7 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
}
|
||||
})
|
||||
|
||||
seekbar_color_filter_blue.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
|
||||
binding.seekbarColorFilterBlue.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
|
||||
override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
setColorValue(value, BLUE_MASK, 0)
|
||||
@ -119,7 +106,7 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
}
|
||||
})
|
||||
|
||||
brightness_seekbar.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
|
||||
binding.brightnessSeekbar.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
|
||||
override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
|
||||
if (fromUser) {
|
||||
preferences.customBrightnessValue().set(value)
|
||||
@ -137,40 +124,37 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
/**
|
||||
* Set enabled status of seekBars belonging to color filter
|
||||
* @param enabled determines if seekBar gets enabled
|
||||
* @param view view of the dialog
|
||||
*/
|
||||
private fun setColorFilterSeekBar(enabled: Boolean, view: View) = with(view) {
|
||||
seekbar_color_filter_red.isEnabled = enabled
|
||||
seekbar_color_filter_green.isEnabled = enabled
|
||||
seekbar_color_filter_blue.isEnabled = enabled
|
||||
seekbar_color_filter_alpha.isEnabled = enabled
|
||||
private fun setColorFilterSeekBar(enabled: Boolean) {
|
||||
binding.seekbarColorFilterRed.isEnabled = enabled
|
||||
binding.seekbarColorFilterGreen.isEnabled = enabled
|
||||
binding.seekbarColorFilterBlue.isEnabled = enabled
|
||||
binding.seekbarColorFilterAlpha.isEnabled = enabled
|
||||
}
|
||||
|
||||
/**
|
||||
* Set enabled status of seekBars belonging to custom brightness
|
||||
* @param enabled value which determines if seekBar gets enabled
|
||||
* @param view view of the dialog
|
||||
*/
|
||||
private fun setCustomBrightnessSeekBar(enabled: Boolean, view: View) = with(view) {
|
||||
brightness_seekbar.isEnabled = enabled
|
||||
private fun setCustomBrightnessSeekBar(enabled: Boolean) {
|
||||
binding.brightnessSeekbar.isEnabled = enabled
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the text value's of color filter
|
||||
* @param color integer containing color information
|
||||
* @param view view of the dialog
|
||||
*/
|
||||
fun setValues(color: Int, view: View): Array<Int> {
|
||||
fun setValues(color: Int): Array<Int> {
|
||||
val alpha = getAlphaFromColor(color)
|
||||
val red = getRedFromColor(color)
|
||||
val green = getGreenFromColor(color)
|
||||
val blue = getBlueFromColor(color)
|
||||
|
||||
// Initialize values
|
||||
txt_color_filter_alpha_value.text = alpha.toString()
|
||||
txt_color_filter_red_value.text = red.toString()
|
||||
txt_color_filter_green_value.text = green.toString()
|
||||
txt_color_filter_blue_value.text = blue.toString()
|
||||
binding.txtColorFilterAlphaValue.text = alpha.toString()
|
||||
binding.txtColorFilterRedValue.text = red.toString()
|
||||
binding.txtColorFilterGreenValue.text = green.toString()
|
||||
binding.txtColorFilterBlueValue.text = blue.toString()
|
||||
|
||||
return arrayOf(alpha, red, green, blue)
|
||||
}
|
||||
@ -178,18 +162,17 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
/**
|
||||
* Manages the custom brightness value subscription
|
||||
* @param enabled determines if the subscription get (un)subscribed
|
||||
* @param view view of the dialog
|
||||
*/
|
||||
private fun setCustomBrightness(enabled: Boolean, view: View) {
|
||||
private fun setCustomBrightness(enabled: Boolean) {
|
||||
if (enabled) {
|
||||
preferences.customBrightnessValue().asFlow()
|
||||
.sample(100)
|
||||
.onEach { setCustomBrightnessValue(it, view) }
|
||||
.onEach { setCustomBrightnessValue(it) }
|
||||
.launchIn(activity.scope)
|
||||
} else {
|
||||
setCustomBrightnessValue(0, view, true)
|
||||
setCustomBrightnessValue(0, true)
|
||||
}
|
||||
setCustomBrightnessSeekBar(enabled, view)
|
||||
setCustomBrightnessSeekBar(enabled)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,34 +181,32 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
* From 1 to 100 it sets that value as brightness.
|
||||
* 0 sets system brightness and hides the overlay.
|
||||
*/
|
||||
private fun setCustomBrightnessValue(value: Int, view: View, isDisabled: Boolean = false) = with(view) {
|
||||
private fun setCustomBrightnessValue(value: Int, isDisabled: Boolean = false) {
|
||||
if (!isDisabled) {
|
||||
txt_brightness_seekbar_value.text = value.toString()
|
||||
binding.txtBrightnessSeekbarValue.text = value.toString()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages the color filter value subscription
|
||||
* @param enabled determines if the subscription get (un)subscribed
|
||||
* @param view view of the dialog
|
||||
*/
|
||||
private fun setColorFilter(enabled: Boolean, view: View) {
|
||||
private fun setColorFilter(enabled: Boolean) {
|
||||
if (enabled) {
|
||||
preferences.colorFilterValue().asFlow()
|
||||
.sample(100)
|
||||
.onEach { setColorFilterValue(it, view) }
|
||||
.onEach { setColorFilterValue(it) }
|
||||
.launchIn(activity.scope)
|
||||
}
|
||||
setColorFilterSeekBar(enabled, view)
|
||||
setColorFilterSeekBar(enabled)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color filter overlay of the screen. Determined by HEX of integer
|
||||
* @param color hex of color.
|
||||
* @param view view of the dialog
|
||||
*/
|
||||
private fun setColorFilterValue(@ColorInt color: Int, view: View) = with(view) {
|
||||
setValues(color, view)
|
||||
private fun setColorFilterValue(@ColorInt color: Int) {
|
||||
setValues(color)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -245,7 +226,7 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
* @param color color hex as int
|
||||
* @return alpha of color
|
||||
*/
|
||||
fun getAlphaFromColor(color: Int): Int {
|
||||
private fun getAlphaFromColor(color: Int): Int {
|
||||
return color shr 24 and 0xFF
|
||||
}
|
||||
|
||||
@ -254,7 +235,7 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
* @param color color hex as int
|
||||
* @return red of color
|
||||
*/
|
||||
fun getRedFromColor(color: Int): Int {
|
||||
private fun getRedFromColor(color: Int): Int {
|
||||
return color shr 16 and 0xFF
|
||||
}
|
||||
|
||||
@ -263,7 +244,7 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
* @param color color hex as int
|
||||
* @return green of color
|
||||
*/
|
||||
fun getGreenFromColor(color: Int): Int {
|
||||
private fun getGreenFromColor(color: Int): Int {
|
||||
return color shr 8 and 0xFF
|
||||
}
|
||||
|
||||
@ -272,7 +253,7 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
|
||||
* @param color color hex as int
|
||||
* @return blue of color
|
||||
*/
|
||||
fun getBlueFromColor(color: Int): Int {
|
||||
private fun getBlueFromColor(color: Int): Int {
|
||||
return color and 0xFF
|
||||
}
|
||||
|
||||
|
@ -5,11 +5,9 @@ import android.view.ViewGroup
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.ReaderPageSheetBinding
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import kotlinx.android.synthetic.main.reader_page_sheet.save_layout
|
||||
import kotlinx.android.synthetic.main.reader_page_sheet.set_as_cover_layout
|
||||
import kotlinx.android.synthetic.main.reader_page_sheet.share_layout
|
||||
|
||||
/**
|
||||
* Sheet to show when a page is long clicked.
|
||||
@ -19,14 +17,14 @@ class ReaderPageSheet(
|
||||
private val page: ReaderPage
|
||||
) : BottomSheetDialog(activity) {
|
||||
|
||||
private val view = activity.layoutInflater.inflate(R.layout.reader_page_sheet, null)
|
||||
private val binding = ReaderPageSheetBinding.inflate(activity.layoutInflater, null, false)
|
||||
|
||||
init {
|
||||
setContentView(view)
|
||||
setContentView(binding.root)
|
||||
|
||||
set_as_cover_layout.setOnClickListener { setAsCover() }
|
||||
share_layout.setOnClickListener { share() }
|
||||
save_layout.setOnClickListener { save() }
|
||||
binding.setAsCoverLayout.setOnClickListener { setAsCover() }
|
||||
binding.shareLayout.setOnClickListener { share() }
|
||||
binding.saveLayout.setOnClickListener { save() }
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -9,30 +9,13 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.tfcporciuncula.flow.Preference
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.databinding.ReaderSettingsSheetBinding
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerViewer
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.invisible
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.always_show_chapter_transition
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.background_color
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.crop_borders
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.cutout_short
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.fullscreen
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.keepscreen
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.long_tap
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.navigation_prefs_group
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.page_transitions
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.pager_prefs_group
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.rotation_mode
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.scale_type
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.show_page_number
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.tapping_inverted
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.viewer
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.webtoon_prefs_group
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.webtoon_side_padding
|
||||
import kotlinx.android.synthetic.main.reader_settings_sheet.zoom_start
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
@ -42,11 +25,11 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
|
||||
|
||||
private val preferences by injectLazy<PreferencesHelper>()
|
||||
|
||||
private val binding = ReaderSettingsSheetBinding.inflate(activity.layoutInflater, null, false)
|
||||
|
||||
init {
|
||||
// Use activity theme for this layout
|
||||
val view = activity.layoutInflater.inflate(R.layout.reader_settings_sheet, null)
|
||||
val scroll = NestedScrollView(activity)
|
||||
scroll.addView(view)
|
||||
scroll.addView(binding.root)
|
||||
setContentView(scroll)
|
||||
}
|
||||
|
||||
@ -69,7 +52,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
|
||||
* Init general reader preferences.
|
||||
*/
|
||||
private fun initGeneralPreferences() {
|
||||
viewer.onItemSelectedListener = IgnoreFirstSpinnerListener { position ->
|
||||
binding.viewer.onItemSelectedListener = IgnoreFirstSpinnerListener { position ->
|
||||
activity.presenter.setMangaViewer(position)
|
||||
|
||||
val mangaViewer = activity.presenter.getMangaViewer()
|
||||
@ -79,39 +62,39 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
|
||||
initPagerPreferences()
|
||||
}
|
||||
}
|
||||
viewer.setSelection(activity.presenter.manga?.viewer ?: 0, false)
|
||||
binding.viewer.setSelection(activity.presenter.manga?.viewer ?: 0, false)
|
||||
|
||||
rotation_mode.bindToPreference(preferences.rotation(), 1)
|
||||
background_color.bindToIntPreference(preferences.readerTheme(), R.array.reader_themes_values)
|
||||
show_page_number.bindToPreference(preferences.showPageNumber())
|
||||
fullscreen.bindToPreference(preferences.fullscreen())
|
||||
cutout_short.bindToPreference(preferences.cutoutShort())
|
||||
keepscreen.bindToPreference(preferences.keepScreenOn())
|
||||
long_tap.bindToPreference(preferences.readWithLongTap())
|
||||
always_show_chapter_transition.bindToPreference(preferences.alwaysShowChapterTransition())
|
||||
crop_borders.bindToPreference(preferences.cropBorders())
|
||||
page_transitions.bindToPreference(preferences.pageTransitions())
|
||||
binding.rotationMode.bindToPreference(preferences.rotation(), 1)
|
||||
binding.backgroundColor.bindToIntPreference(preferences.readerTheme(), R.array.reader_themes_values)
|
||||
binding.showPageNumber.bindToPreference(preferences.showPageNumber())
|
||||
binding.fullscreen.bindToPreference(preferences.fullscreen())
|
||||
binding.cutoutShort.bindToPreference(preferences.cutoutShort())
|
||||
binding.keepscreen.bindToPreference(preferences.keepScreenOn())
|
||||
binding.longTap.bindToPreference(preferences.readWithLongTap())
|
||||
binding.alwaysShowChapterTransition.bindToPreference(preferences.alwaysShowChapterTransition())
|
||||
binding.cropBorders.bindToPreference(preferences.cropBorders())
|
||||
binding.pageTransitions.bindToPreference(preferences.pageTransitions())
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the preferences for the pager reader.
|
||||
*/
|
||||
private fun initPagerPreferences() {
|
||||
webtoon_prefs_group.invisible()
|
||||
pager_prefs_group.visible()
|
||||
binding.webtoonPrefsGroup.invisible()
|
||||
binding.pagerPrefsGroup.visible()
|
||||
|
||||
scale_type.bindToPreference(preferences.imageScaleType(), 1)
|
||||
zoom_start.bindToPreference(preferences.zoomStart(), 1)
|
||||
binding.scaleType.bindToPreference(preferences.imageScaleType(), 1)
|
||||
binding.zoomStart.bindToPreference(preferences.zoomStart(), 1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Init the preferences for the webtoon reader.
|
||||
*/
|
||||
private fun initWebtoonPreferences() {
|
||||
pager_prefs_group.invisible()
|
||||
webtoon_prefs_group.visible()
|
||||
binding.pagerPrefsGroup.invisible()
|
||||
binding.webtoonPrefsGroup.visible()
|
||||
|
||||
webtoon_side_padding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
||||
binding.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -119,10 +102,10 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
|
||||
*/
|
||||
private fun initNavigationPreferences() {
|
||||
if (!preferences.readWithTapping().get()) {
|
||||
navigation_prefs_group.gone()
|
||||
binding.navigationPrefsGroup.gone()
|
||||
}
|
||||
|
||||
tapping_inverted.bindToPreference(preferences.readWithTappingInverted())
|
||||
binding.tappingInverted.bindToPreference(preferences.readWithTappingInverted())
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -244,8 +244,8 @@
|
||||
<string name="pref_true_color">32-bit color</string>
|
||||
<string name="pref_true_color_summary">Reduces banding, but impacts performance</string>
|
||||
<string name="pref_crop_borders">Crop borders</string>
|
||||
<string name="pref_custom_brightness">Use custom brightness</string>
|
||||
<string name="pref_custom_color_filter">Use custom color filter</string>
|
||||
<string name="pref_custom_brightness">Custom brightness</string>
|
||||
<string name="pref_custom_color_filter">Custom color filter</string>
|
||||
<string name="pref_color_filter_mode">Color filter blend mode</string>
|
||||
<string name="filter_mode_default">Default</string>
|
||||
<string name="filter_mode_overlay">Overlay</string>
|
||||
|
Loading…
Reference in New Issue
Block a user