Hide irrelevant settings on tablets

(cherry picked from commit 1b52acdad7)
This commit is contained in:
arkon
2021-05-23 13:05:45 -04:00
committed by Jobobby04
parent 3419bebb70
commit 43555b3b1a
4 changed files with 36 additions and 23 deletions
@@ -330,6 +330,18 @@ class MangaController :
it.scrollEvents()
.onEach { updateToolbarTitleAlpha() }
.launchIn(viewScope)
// Skips directly to chapters list if navigated to from the library
it.post {
if (!fromSource && preferences.jumpToChapters()) {
(it.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(1, 0)
}
// Delayed in case we need to jump to chapters
it.post {
updateToolbarTitleAlpha()
}
}
}
// Tablet layout
binding.infoRecycler?.let {
@@ -348,19 +360,7 @@ class MangaController :
chaptersAdapter?.fastScroller = binding.fastScroller
actionFabScrollListener = actionFab?.shrinkOnScroll(chaptersRecycler)
// Skips directly to chapters list if navigated to from the library
chaptersRecycler.post {
if (!fromSource && preferences.jumpToChapters()) {
(chaptersRecycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(1, 0)
}
// Delayed in case we need to jump to chapters
binding.fullRecycler?.post {
updateToolbarTitleAlpha()
}
}
actionFabScrollListener = actionFab?.shrinkOnScroll(chapterRecycler)
binding.swipeRefresh.refreshes()
.onEach {
@@ -448,7 +448,7 @@ class MangaController :
override fun cleanupFab(fab: ExtendedFloatingActionButton) {
fab.setOnClickListener(null)
actionFabScrollListener?.let { binding.fullRecycler?.removeOnScrollListener(it) }
actionFabScrollListener?.let { chapterRecycler.removeOnScrollListener(it) }
actionFab = null
}
@@ -1517,7 +1517,7 @@ class MangaController :
// Tracker sheet - end
private val chaptersRecycler: RecyclerView
private val chapterRecycler: RecyclerView
get() = binding.fullRecycler ?: binding.chaptersRecycler!!
companion object {
@@ -18,6 +18,7 @@ import eu.kanade.tachiyomi.util.preference.summaryRes
import eu.kanade.tachiyomi.util.preference.switchPreference
import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.system.LocaleHelper
import eu.kanade.tachiyomi.util.system.isTablet
import kotlinx.coroutines.flow.launchIn
import java.util.Date
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
@@ -46,10 +47,12 @@ class SettingsGeneralController : SettingsController() {
titleRes = R.string.pref_confirm_exit
defaultValue = false
}
switchPreference {
key = Keys.hideBottomBar
titleRes = R.string.pref_hide_bottom_bar_on_scroll
defaultValue = true
if (!context.isTablet()) {
switchPreference {
key = Keys.hideBottomBar
titleRes = R.string.pref_hide_bottom_bar_on_scroll
defaultValue = true
}
}
switchPreference {
key = Keys.hideUpdatesButton
@@ -32,6 +32,7 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory
import eu.kanade.tachiyomi.util.preference.summaryRes
import eu.kanade.tachiyomi.util.preference.switchPreference
import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.system.isTablet
import eu.kanade.tachiyomi.widget.MinMaxNumberPicker
import eu.kanade.tachiyomi.widget.materialdialogs.QuadStateCheckBox
import eu.kanade.tachiyomi.widget.materialdialogs.listItemsQuadStateMultiChoice
@@ -84,10 +85,12 @@ class SettingsLibraryController : SettingsController() {
}
.launchIn(viewScope)
}
switchPreference {
key = Keys.jumpToChapters
titleRes = R.string.pref_jump_to_chapters
defaultValue = false
if (!context.isTablet()) {
switchPreference {
key = Keys.jumpToChapters
titleRes = R.string.pref_jump_to_chapters
defaultValue = false
}
}
// SY -->
preference {
@@ -258,3 +258,10 @@ fun Context.createFileInCacheDir(name: String): File {
file.createNewFile()
return file
}
/**
* We consider anything with a width of >= 600dp as a tablet, i.e. with layouts in layout-sw600dp.
*/
fun Context.isTablet(): Boolean {
return resources.configuration.screenWidthDp >= 600
}