mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05: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
5 changed files with 6 additions and 11 deletions
|
@ -53,6 +53,7 @@ object PreferenceValues {
|
|||
}
|
||||
|
||||
enum class TabletUiMode {
|
||||
AUTOMATIC,
|
||||
ALWAYS,
|
||||
LANDSCAPE,
|
||||
NEVER,
|
||||
|
|
|
@ -326,10 +326,7 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun incognitoMode() = flowPrefs.getBoolean(Keys.incognitoMode, false)
|
||||
|
||||
fun tabletUiMode() = flowPrefs.getEnum(
|
||||
Keys.tabletUiMode,
|
||||
if (context.applicationContext.isTablet()) Values.TabletUiMode.ALWAYS else Values.TabletUiMode.NEVER
|
||||
)
|
||||
fun tabletUiMode() = flowPrefs.getEnum(Keys.tabletUiMode, Values.TabletUiMode.AUTOMATIC)
|
||||
|
||||
fun extensionInstaller() = flowPrefs.getEnum(
|
||||
Keys.extensionInstaller,
|
||||
|
|
|
@ -247,13 +247,9 @@ class SettingsAdvancedController : SettingsController() {
|
|||
key = Keys.tabletUiMode
|
||||
titleRes = R.string.pref_tablet_ui_mode
|
||||
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()
|
||||
defaultValue = if (context.isTablet()) {
|
||||
PreferenceValues.TabletUiMode.ALWAYS
|
||||
} else {
|
||||
PreferenceValues.TabletUiMode.NEVER
|
||||
}.name
|
||||
defaultValue = PreferenceValues.TabletUiMode.AUTOMATIC.name
|
||||
|
||||
onChange {
|
||||
activity?.toast(R.string.requires_app_restart)
|
||||
|
|
|
@ -316,6 +316,7 @@ fun Context.isTablet(): Boolean {
|
|||
fun Context.prepareTabletUiContext(): Context {
|
||||
val configuration = resources.configuration
|
||||
val expected = when (Injekt.get<PreferencesHelper>().tabletUiMode().get()) {
|
||||
PreferenceValues.TabletUiMode.AUTOMATIC -> isTablet()
|
||||
PreferenceValues.TabletUiMode.ALWAYS -> true
|
||||
PreferenceValues.TabletUiMode.LANDSCAPE -> configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
|
||||
PreferenceValues.TabletUiMode.NEVER -> false
|
||||
|
|
|
@ -476,7 +476,7 @@
|
|||
<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="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_summary">Print verbose logs to system log (reduces app performance)</string>
|
||||
|
||||
|
|
Loading…
Reference in a new issue