Reader PR (with vertical sidebar) (#216)
* Reader PR * Dealt with conflicts + updates * Adeed missing import
This commit is contained in:
@@ -25,6 +25,10 @@ object PreferenceKeys {
|
||||
|
||||
const val showPageNumber = "pref_show_page_number_key"
|
||||
|
||||
const val landscapeVerticalSeekbar = "pref_show_vert_seekbar_landscape"
|
||||
|
||||
const val leftVerticalSeekbar = "pref_left_handed_vertical_seekbar"
|
||||
|
||||
const val dualPageSplit = "pref_dual_page_split"
|
||||
|
||||
const val dualPageInvert = "pref_dual_page_invert"
|
||||
|
||||
@@ -460,4 +460,8 @@ class PreferencesHelper(val context: Context) {
|
||||
fun extensionRepos() = flowPrefs.getStringSet(Keys.extensionRepos, emptySet())
|
||||
|
||||
fun cropBordersContinuesVertical() = flowPrefs.getBoolean(Keys.cropBordersContinuesVertical, false)
|
||||
|
||||
fun landscapeVerticalSeekbar() = flowPrefs.getBoolean(Keys.landscapeVerticalSeekbar, false)
|
||||
|
||||
fun leftVerticalSeekbar() = flowPrefs.getBoolean(Keys.leftVerticalSeekbar, false)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.app.ProgressDialog
|
||||
import android.content.ClipData
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
@@ -17,6 +18,7 @@ import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.Animation
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.SeekBar
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.ViewCompat
|
||||
@@ -387,36 +389,81 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
}
|
||||
}
|
||||
|
||||
// SY -->
|
||||
// Init listeners on bottom menu
|
||||
binding.pageSeekbar.setOnSeekBarChangeListener(
|
||||
object : SimpleSeekBarListener() {
|
||||
override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
|
||||
if (viewer != null && fromUser) {
|
||||
moveToPageIndex(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// Extra menu buttons
|
||||
|
||||
binding.leftChapter.setOnClickListener {
|
||||
if (viewer != null) {
|
||||
if (viewer is R2LPagerViewer) {
|
||||
loadNextChapter()
|
||||
} else {
|
||||
loadPreviousChapter()
|
||||
val listener = object : SimpleSeekBarListener() {
|
||||
override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
|
||||
if (viewer != null && fromUser) {
|
||||
moveToPageIndex(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.rightChapter.setOnClickListener {
|
||||
if (viewer != null) {
|
||||
if (viewer is R2LPagerViewer) {
|
||||
loadPreviousChapter()
|
||||
} else {
|
||||
loadNextChapter()
|
||||
}
|
||||
listOf(binding.pageSeekbar, binding.pageSeekbarVert)
|
||||
.forEach {
|
||||
it.setOnSeekBarChangeListener(listener)
|
||||
}
|
||||
// SY <--
|
||||
|
||||
// Extra menu buttons
|
||||
|
||||
// SY -->
|
||||
listOf(binding.leftChapter, binding.aboveChapter).forEach {
|
||||
it.clicks()
|
||||
.onEach {
|
||||
if (viewer != null) {
|
||||
if (viewer is R2LPagerViewer) {
|
||||
loadNextChapter()
|
||||
} else {
|
||||
loadPreviousChapter()
|
||||
}
|
||||
}
|
||||
}
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
listOf(binding.rightChapter, binding.belowChapter).forEach {
|
||||
it.clicks()
|
||||
.onEach {
|
||||
if (viewer != null) {
|
||||
if (viewer is R2LPagerViewer) {
|
||||
loadPreviousChapter()
|
||||
} else {
|
||||
loadNextChapter()
|
||||
}
|
||||
}
|
||||
}
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
// SY <--
|
||||
|
||||
/*binding.actionRotation.setOnClickListener {
|
||||
val newOrientation = OrientationType.getNextOrientation(preferences.rotation().get(), resources)
|
||||
|
||||
preferences.rotation().set(newOrientation.prefValue)
|
||||
setOrientation(newOrientation.flag)
|
||||
|
||||
rotationToast?.cancel()
|
||||
rotationToast = toast(newOrientation.stringRes)
|
||||
}
|
||||
preferences.rotation().asImmediateFlow { updateRotationShortcut(it) }
|
||||
.onEach {
|
||||
updateRotationShortcut(it)
|
||||
}
|
||||
.launchIn(lifecycleScope)
|
||||
*/
|
||||
|
||||
binding.actionCustomFilter.setOnClickListener {
|
||||
val sheet = ReaderColorFilterSheet(this)
|
||||
// Remove dimmed backdrop so changes can be previewed
|
||||
.apply { window?.setDimAmount(0f) }
|
||||
|
||||
// Hide toolbars while sheet is open for better preview
|
||||
sheet.setOnDismissListener { setMenuVisibility(true) }
|
||||
setMenuVisibility(false)
|
||||
|
||||
sheet.show()
|
||||
}
|
||||
binding.actionSettings.setOnClickListener {
|
||||
ReaderSettingsSheet(this).show()
|
||||
}
|
||||
|
||||
/*binding.actionRotation.setOnClickListener {
|
||||
@@ -666,6 +713,14 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
binding.header.startAnimation(toolbarAnimation)
|
||||
// EXH <--
|
||||
|
||||
val vertAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_in_side)
|
||||
val vertAnimationLeft = AnimationUtils.loadAnimation(this, R.anim.fade_in_side_left)
|
||||
if (preferences.leftVerticalSeekbar().get() && binding.readerNavVert.isVisible) {
|
||||
binding.seekbarVertContainer.startAnimation(vertAnimationLeft)
|
||||
} else {
|
||||
binding.seekbarVertContainer.startAnimation(vertAnimation)
|
||||
}
|
||||
|
||||
val bottomAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_bottom)
|
||||
binding.readerMenuBottom.startAnimation(bottomAnimation)
|
||||
}
|
||||
@@ -693,6 +748,14 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
binding.header.startAnimation(toolbarAnimation)
|
||||
// EXH <--
|
||||
|
||||
val vertAnimation = AnimationUtils.loadAnimation(this, R.anim.fade_out_side)
|
||||
val vertAnimationLeft = AnimationUtils.loadAnimation(this, R.anim.fade_out_side_left)
|
||||
if (preferences.leftVerticalSeekbar().get() && binding.readerNavVert.isVisible) {
|
||||
binding.seekbarVertContainer.startAnimation(vertAnimationLeft)
|
||||
} else {
|
||||
binding.seekbarVertContainer.startAnimation(vertAnimation)
|
||||
}
|
||||
|
||||
val bottomAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_bottom)
|
||||
binding.readerMenuBottom.startAnimation(bottomAnimation)
|
||||
}
|
||||
@@ -765,6 +828,31 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
showReadingModeSnackbar(presenter.getMangaViewer())
|
||||
}
|
||||
|
||||
// SY -->
|
||||
|
||||
// --> Vertical seekbar hide on landscape
|
||||
|
||||
if (((resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE && preferences.landscapeVerticalSeekbar().get()) || resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) && (viewer is WebtoonViewer || viewer is VerticalPagerViewer)) {
|
||||
binding.readerNavVert.isVisible = true
|
||||
binding.readerNavHorz.isVisible = false
|
||||
} else {
|
||||
binding.readerNavVert.isVisible = false
|
||||
binding.readerNavHorz.isVisible = true
|
||||
}
|
||||
|
||||
// <-- Vertical seekbar hide on landscape
|
||||
|
||||
// --> Left-handed vertical seekbar
|
||||
|
||||
val params = binding.readerNavVert.layoutParams as RelativeLayout.LayoutParams
|
||||
if (preferences.leftVerticalSeekbar().get() && binding.readerNavVert.isVisible) {
|
||||
params.removeRule(RelativeLayout.ALIGN_PARENT_END)
|
||||
binding.readerNavVert.layoutParams = params
|
||||
}
|
||||
|
||||
// <-- Left-handed vertical seekbar
|
||||
|
||||
// SY <--
|
||||
binding.toolbar.title = manga.title
|
||||
|
||||
binding.pageSeekbar.isRTL = newViewer is R2LPagerViewer
|
||||
@@ -872,8 +960,18 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
binding.leftPageText.text = "${pages.size}"
|
||||
}
|
||||
|
||||
// SY -->
|
||||
binding.abovePageText.text = "${page.number}"
|
||||
binding.belowPageText.text = "${pages.size}"
|
||||
// SY <--
|
||||
|
||||
binding.pageSeekbar.max = pages.lastIndex
|
||||
binding.pageSeekbar.progress = page.index
|
||||
|
||||
// SY -->
|
||||
binding.pageSeekbarVert.max = pages.lastIndex
|
||||
binding.pageSeekbarVert.progress = page.index
|
||||
// SY <--
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,6 +67,8 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BaseBottomShee
|
||||
binding.rotationMode.bindToPreference(preferences.rotation(), 1)
|
||||
binding.backgroundColor.bindToIntPreference(preferences.readerTheme(), R.array.reader_themes_values)
|
||||
binding.showPageNumber.bindToPreference(preferences.showPageNumber())
|
||||
binding.landscapeVerticalSeekbar.bindToPreference(preferences.landscapeVerticalSeekbar())
|
||||
binding.leftVerticalSeekbar.bindToPreference(preferences.leftVerticalSeekbar())
|
||||
binding.fullscreen.bindToPreference(preferences.fullscreen())
|
||||
binding.dualPageSplit.bindToPreference(preferences.dualPageSplit())
|
||||
binding.keepscreen.bindToPreference(preferences.keepScreenOn())
|
||||
|
||||
@@ -50,6 +50,18 @@ class SettingsReaderController : SettingsController() {
|
||||
summaryRes = R.string.pref_show_reading_mode_summary
|
||||
defaultValue = true
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.landscapeVerticalSeekbar
|
||||
titleRes = R.string.pref_show_vert_seekbar_landscape
|
||||
summaryRes = R.string.pref_show_vert_seekbar_landscape_summary
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.leftVerticalSeekbar
|
||||
titleRes = R.string.pref_left_handed_vertical_seekbar
|
||||
summaryRes = R.string.pref_left_handed_vertical_seekbar_summary
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.dualPageSplit
|
||||
titleRes = R.string.pref_dual_page_split
|
||||
|
||||
Reference in New Issue
Block a user