mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +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:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user