mirror of
https://github.com/mihonapp/mihon.git
synced 2024-10-31 21:20:59 -04:00
29fa93e829
* Split the reset of the preferences in PreferencesHelper * Capitalize ThemeMode
45 lines
1.6 KiB
Kotlin
45 lines
1.6 KiB
Kotlin
package eu.kanade.domain.ui
|
|
|
|
import android.os.Build
|
|
import eu.kanade.domain.ui.model.AppTheme
|
|
import eu.kanade.domain.ui.model.TabletUiMode
|
|
import eu.kanade.domain.ui.model.ThemeMode
|
|
import eu.kanade.tachiyomi.core.preference.PreferenceStore
|
|
import eu.kanade.tachiyomi.core.preference.getEnum
|
|
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
|
import eu.kanade.tachiyomi.util.system.isDynamicColorAvailable
|
|
import java.text.DateFormat
|
|
import java.text.SimpleDateFormat
|
|
import java.util.Locale
|
|
|
|
class UiPreferences(
|
|
private val preferenceStore: PreferenceStore,
|
|
) {
|
|
|
|
fun sideNavIconAlignment() = preferenceStore.getInt("pref_side_nav_icon_alignment", 0)
|
|
|
|
fun themeMode() = preferenceStore.getEnum(
|
|
"pref_theme_mode_key",
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { ThemeMode.SYSTEM } else { ThemeMode.LIGHT },
|
|
)
|
|
|
|
fun appTheme() = preferenceStore.getEnum(
|
|
"pref_app_theme",
|
|
if (DeviceUtil.isDynamicColorAvailable) { AppTheme.MONET } else { AppTheme.DEFAULT },
|
|
)
|
|
|
|
fun themeDarkAmoled() = preferenceStore.getBoolean("pref_theme_dark_amoled_key", false)
|
|
|
|
fun relativeTime() = preferenceStore.getInt("relative_time", 7)
|
|
|
|
fun dateFormat() = preferenceStore.getString("app_date_format", "")
|
|
|
|
fun tabletUiMode() = preferenceStore.getEnum("tablet_ui_mode", TabletUiMode.AUTOMATIC)
|
|
|
|
companion object {
|
|
fun dateFormat(format: String): DateFormat = when (format) {
|
|
"" -> DateFormat.getDateInstance(DateFormat.SHORT)
|
|
else -> SimpleDateFormat(format, Locale.getDefault())
|
|
}
|
|
}
|
|
}
|