From 291f61551a4f9103d2cf2976c85b545fff9e2e93 Mon Sep 17 00:00:00 2001 From: ibo <41344259+sneazy-ibo@users.noreply.github.com> Date: Wed, 13 Mar 2024 13:57:40 +0100 Subject: [PATCH] feat: hide scrollBar toggle (#238) --- .../manga/mangareader/MangaReaderActivity.kt | 33 +++++++++++++++++++ .../ReaderSettingsDialogFragment.kt | 6 ++++ .../settings/CurrentReaderSettings.kt | 1 + .../settings/ReaderSettingsActivity.kt | 6 ++++ .../dantotsu/settings/saving/Preferences.kt | 1 + .../res/drawable/ic_round_no_scroll_bar.xml | 5 +++ .../res/layout/activity_reader_settings.xml | 20 +++++++++++ .../bottom_sheet_current_reader_settings.xml | 18 ++++++++++ app/src/main/res/values/strings.xml | 1 + 9 files changed, 91 insertions(+) create mode 100644 app/src/main/res/drawable/ic_round_no_scroll_bar.xml diff --git a/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt b/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt index 3665eb3e7d3..d74959f949f 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/mangareader/MangaReaderActivity.kt @@ -88,6 +88,7 @@ class MangaReaderActivity : AppCompatActivity() { private var isContVisible = false private var showProgressDialog = true + private var hidescrollbar = false private var maxChapterPage = 0L private var currentChapterPage = 0L @@ -781,6 +782,38 @@ class MangaReaderActivity : AppCompatActivity() { hideBars() checkNotch() } + // Hide the scrollbar completely + if (defaultSettings.hideScrollBar) { + binding.mangaReaderSliderContainer.visibility = View.GONE + } else { + if (defaultSettings.horizontalScrollBar) { + binding.mangaReaderSliderContainer.updateLayoutParams { + height = ViewGroup.LayoutParams.WRAP_CONTENT + width = ViewGroup.LayoutParams.WRAP_CONTENT + } + + binding.mangaReaderSlider.apply { + updateLayoutParams { + width = ViewGroup.LayoutParams.MATCH_PARENT + } + rotation = 0f + } + + } else { + binding.mangaReaderSliderContainer.updateLayoutParams { + height = ViewGroup.LayoutParams.MATCH_PARENT + width = 48f.px + } + + binding.mangaReaderSlider.apply { + updateLayoutParams { + width = binding.mangaReaderSliderContainer.height - 16f.px + } + rotation = 90f + } + } + binding.mangaReaderSliderContainer.visibility = View.VISIBLE + } //horizontal scrollbar if (defaultSettings.horizontalScrollBar) { binding.mangaReaderSliderContainer.updateLayoutParams { diff --git a/app/src/main/java/ani/dantotsu/media/manga/mangareader/ReaderSettingsDialogFragment.kt b/app/src/main/java/ani/dantotsu/media/manga/mangareader/ReaderSettingsDialogFragment.kt index c9c42aab025..de69d399e7d 100644 --- a/app/src/main/java/ani/dantotsu/media/manga/mangareader/ReaderSettingsDialogFragment.kt +++ b/app/src/main/java/ani/dantotsu/media/manga/mangareader/ReaderSettingsDialogFragment.kt @@ -127,6 +127,12 @@ class ReaderSettingsDialogFragment : BottomSheetDialogFragment() { activity.applySettings() } + binding.readerHideScrollBar.isChecked = settings.hideScrollBar + binding.readerHideScrollBar.setOnCheckedChangeListener { _, isChecked -> + settings.hideScrollBar = isChecked + activity.applySettings() + } + binding.readerHidePageNumbers.isChecked = settings.hidePageNumbers binding.readerHidePageNumbers.setOnCheckedChangeListener { _, isChecked -> settings.hidePageNumbers = isChecked diff --git a/app/src/main/java/ani/dantotsu/settings/CurrentReaderSettings.kt b/app/src/main/java/ani/dantotsu/settings/CurrentReaderSettings.kt index 2aca1b3e93a..be076fbdedc 100644 --- a/app/src/main/java/ani/dantotsu/settings/CurrentReaderSettings.kt +++ b/app/src/main/java/ani/dantotsu/settings/CurrentReaderSettings.kt @@ -15,6 +15,7 @@ data class CurrentReaderSettings( var trueColors: Boolean = PrefManager.getVal(PrefName.TrueColors), var rotation: Boolean = PrefManager.getVal(PrefName.Rotation), var padding: Boolean = PrefManager.getVal(PrefName.Padding), + var hideScrollBar: Boolean = PrefManager.getVal(PrefName.HideScrollBar), var hidePageNumbers: Boolean = PrefManager.getVal(PrefName.HidePageNumbers), var horizontalScrollBar: Boolean = PrefManager.getVal(PrefName.HorizontalScrollBar), var keepScreenOn: Boolean = PrefManager.getVal(PrefName.KeepScreenOn), diff --git a/app/src/main/java/ani/dantotsu/settings/ReaderSettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/ReaderSettingsActivity.kt index f3846245f0f..8cbdac58cef 100644 --- a/app/src/main/java/ani/dantotsu/settings/ReaderSettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/ReaderSettingsActivity.kt @@ -148,6 +148,12 @@ class ReaderSettingsActivity : AppCompatActivity() { PrefManager.setVal(PrefName.KeepScreenOn, isChecked) } + binding.readerSettingsHideScrollBar.isChecked = defaultSettings.hideScrollBar + binding.readerSettingsHideScrollBar.setOnCheckedChangeListener { _, isChecked -> + defaultSettings.hideScrollBar = isChecked + PrefManager.setVal(PrefName.HideScrollBar, isChecked) + } + binding.readerSettingsHidePageNumbers.isChecked = defaultSettings.hidePageNumbers binding.readerSettingsHidePageNumbers.setOnCheckedChangeListener { _, isChecked -> defaultSettings.hidePageNumbers = isChecked diff --git a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt index b33ed1689fe..0e0a6a2250a 100644 --- a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt +++ b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt @@ -119,6 +119,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files TrueColors(Pref(Location.Reader, Boolean::class, false)), Rotation(Pref(Location.Reader, Boolean::class, true)), Padding(Pref(Location.Reader, Boolean::class, true)), + HideScrollBar(Pref(Location.Reader, Boolean::class, false)), HidePageNumbers(Pref(Location.Reader, Boolean::class, false)), HorizontalScrollBar(Pref(Location.Reader, Boolean::class, true)), KeepScreenOn(Pref(Location.Reader, Boolean::class, false)), diff --git a/app/src/main/res/drawable/ic_round_no_scroll_bar.xml b/app/src/main/res/drawable/ic_round_no_scroll_bar.xml new file mode 100644 index 00000000000..c11b94ee6af --- /dev/null +++ b/app/src/main/res/drawable/ic_round_no_scroll_bar.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/layout/activity_reader_settings.xml b/app/src/main/res/layout/activity_reader_settings.xml index be259b9622e..1b0706019da 100644 --- a/app/src/main/res/layout/activity_reader_settings.xml +++ b/app/src/main/res/layout/activity_reader_settings.xml @@ -484,6 +484,26 @@ app:showText="false" app:thumbTint="@color/button_switch_track" /> + + + + Sampling Blur Banners Blur + Hide Scroll Bar