Skip to content

Commit

Permalink
feat: hide scrollBar toggle (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
sneazy-ibo authored Mar 13, 2024
1 parent 6e8bd08 commit 291f615
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<ViewGroup.MarginLayoutParams> {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_round_no_scroll_bar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M4,16h3c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L4,14c-0.55,0 -1,0.45 -1,1s0.45,1 1,1zM10.5,16h3c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1h-3c-0.55,0 -1,0.45 -1,1s0.45,1 1,1zM17,16h3c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1h-3c-0.55,0 -1,0.45 -1,1s0.45,1 1,1zM4,20c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1 -1,0.45 -1,1 0.45,1 1,1zM8,20c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1 -1,0.45 -1,1 0.45,1 1,1zM12,20c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1 -1,0.45 -1,1 0.45,1 1,1zM16,20c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1 -1,0.45 -1,1 0.45,1 1,1zM20,20c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1 -1,0.45 -1,1 0.45,1 1,1zM4,12h6c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L4,10c-0.55,0 -1,0.45 -1,1s0.45,1 1,1zM14,12h6c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1h-6c-0.55,0 -1,0.45 -1,1s0.45,1 1,1zM3,5v2c0,0.55 0.45,1 1,1h16c0.55,0 1,-0.45 1,-1L21,5c0,-0.55 -0.45,-1 -1,-1L4,4c-0.55,0 -1,0.45 -1,1z"/>

</vector>
20 changes: 20 additions & 0 deletions app/src/main/res/layout/activity_reader_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,26 @@
app:showText="false"
app:thumbTint="@color/button_switch_track" />

<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/readerSettingsHideScrollBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="false"
android:drawableStart="@drawable/ic_round_no_scroll_bar"
android:drawablePadding="16dp"
android:elegantTextHeight="true"
android:fontFamily="@font/poppins_bold"
android:minHeight="64dp"
android:paddingStart="32dp"
android:paddingEnd="32dp"
android:text="@string/hide_scroll_bar"
android:textAlignment="viewStart"
android:textColor="?attr/colorOnBackground"
app:cornerRadius="0dp"
app:drawableTint="?attr/colorPrimary"
app:showText="false"
app:thumbTint="@color/button_switch_track" />

<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/readerSettingsHidePageNumbers"
android:layout_width="match_parent"
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/res/layout/bottom_sheet_current_reader_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,24 @@
app:showText="false"
app:thumbTint="@color/button_switch_track" />

<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/readerHideScrollBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="false"
android:drawableStart="@drawable/ic_round_no_scroll_bar"
android:drawablePadding="16dp"
android:elegantTextHeight="true"
android:fontFamily="@font/poppins_bold"
android:minHeight="64dp"
android:text="@string/hide_scroll_bar"
android:textAlignment="viewStart"
android:textColor="?attr/colorOnBackground"
app:cornerRadius="0dp"
app:drawableTint="?attr/colorPrimary"
app:showText="false"
app:thumbTint="@color/button_switch_track" />

<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/readerHidePageNumbers"
android:layout_width="match_parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -698,4 +698,5 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
<string name="sampling">Sampling</string>
<string name="blur_banners">Blur Banners</string>
<string name="blur">Blur</string>
<string name="hide_scroll_bar">Hide Scroll Bar</string>
</resources>

0 comments on commit 291f615

Please sign in to comment.