mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 23:15:09 +01:00
Added tabletUI option: "Automatic" (#6208)
* added automatic tablet ui option; useful for foldables * set automatic as default, rename setting * remove redundant checks Co-authored-by: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> * remove redundant checks Co-authored-by: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com> * fix defaultValue Co-authored-by: Ivan Iskandar <12537387+ivaniskandar@users.noreply.github.com>
This commit is contained in:
parent
bfcc883f01
commit
41952f0215
@ -53,6 +53,7 @@ object PreferenceValues {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum class TabletUiMode {
|
enum class TabletUiMode {
|
||||||
|
AUTOMATIC,
|
||||||
ALWAYS,
|
ALWAYS,
|
||||||
LANDSCAPE,
|
LANDSCAPE,
|
||||||
NEVER,
|
NEVER,
|
||||||
|
@ -326,10 +326,7 @@ class PreferencesHelper(val context: Context) {
|
|||||||
|
|
||||||
fun incognitoMode() = flowPrefs.getBoolean(Keys.incognitoMode, false)
|
fun incognitoMode() = flowPrefs.getBoolean(Keys.incognitoMode, false)
|
||||||
|
|
||||||
fun tabletUiMode() = flowPrefs.getEnum(
|
fun tabletUiMode() = flowPrefs.getEnum(Keys.tabletUiMode, Values.TabletUiMode.AUTOMATIC)
|
||||||
Keys.tabletUiMode,
|
|
||||||
if (context.applicationContext.isTablet()) Values.TabletUiMode.ALWAYS else Values.TabletUiMode.NEVER
|
|
||||||
)
|
|
||||||
|
|
||||||
fun extensionInstaller() = flowPrefs.getEnum(
|
fun extensionInstaller() = flowPrefs.getEnum(
|
||||||
Keys.extensionInstaller,
|
Keys.extensionInstaller,
|
||||||
|
@ -247,13 +247,9 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
key = Keys.tabletUiMode
|
key = Keys.tabletUiMode
|
||||||
titleRes = R.string.pref_tablet_ui_mode
|
titleRes = R.string.pref_tablet_ui_mode
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
entriesRes = arrayOf(R.string.lock_always, R.string.landscape, R.string.lock_never)
|
entriesRes = arrayOf(R.string.automatic_background, R.string.lock_always, R.string.landscape, R.string.lock_never)
|
||||||
entryValues = PreferenceValues.TabletUiMode.values().map { it.name }.toTypedArray()
|
entryValues = PreferenceValues.TabletUiMode.values().map { it.name }.toTypedArray()
|
||||||
defaultValue = if (context.isTablet()) {
|
defaultValue = PreferenceValues.TabletUiMode.AUTOMATIC.name
|
||||||
PreferenceValues.TabletUiMode.ALWAYS
|
|
||||||
} else {
|
|
||||||
PreferenceValues.TabletUiMode.NEVER
|
|
||||||
}.name
|
|
||||||
|
|
||||||
onChange {
|
onChange {
|
||||||
activity?.toast(R.string.requires_app_restart)
|
activity?.toast(R.string.requires_app_restart)
|
||||||
|
@ -316,6 +316,7 @@ fun Context.isTablet(): Boolean {
|
|||||||
fun Context.prepareTabletUiContext(): Context {
|
fun Context.prepareTabletUiContext(): Context {
|
||||||
val configuration = resources.configuration
|
val configuration = resources.configuration
|
||||||
val expected = when (Injekt.get<PreferencesHelper>().tabletUiMode().get()) {
|
val expected = when (Injekt.get<PreferencesHelper>().tabletUiMode().get()) {
|
||||||
|
PreferenceValues.TabletUiMode.AUTOMATIC -> isTablet()
|
||||||
PreferenceValues.TabletUiMode.ALWAYS -> true
|
PreferenceValues.TabletUiMode.ALWAYS -> true
|
||||||
PreferenceValues.TabletUiMode.LANDSCAPE -> configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
|
PreferenceValues.TabletUiMode.LANDSCAPE -> configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||||
PreferenceValues.TabletUiMode.NEVER -> false
|
PreferenceValues.TabletUiMode.NEVER -> false
|
||||||
|
@ -476,7 +476,7 @@
|
|||||||
<string name="battery_optimization_disabled">Battery optimization is already disabled</string>
|
<string name="battery_optimization_disabled">Battery optimization is already disabled</string>
|
||||||
<string name="battery_optimization_setting_activity_not_found">Couldn\'t open device settings</string>
|
<string name="battery_optimization_setting_activity_not_found">Couldn\'t open device settings</string>
|
||||||
<string name="about_dont_kill_my_app">Some manufacturers have additional app restrictions that kill background services. This website has more info on how to fix it.</string>
|
<string name="about_dont_kill_my_app">Some manufacturers have additional app restrictions that kill background services. This website has more info on how to fix it.</string>
|
||||||
<string name="pref_tablet_ui_mode">Force tablet UI</string>
|
<string name="pref_tablet_ui_mode">Tablet UI</string>
|
||||||
<string name="pref_verbose_logging">Verbose logging</string>
|
<string name="pref_verbose_logging">Verbose logging</string>
|
||||||
<string name="pref_verbose_logging_summary">Print verbose logs to system log (reduces app performance)</string>
|
<string name="pref_verbose_logging_summary">Print verbose logs to system log (reduces app performance)</string>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user