Enable Material You Dynamic colors (#138)
This commit is contained in:
parent
3c9d1dda73
commit
5eb101323b
10 changed files with 25 additions and 22 deletions
|
@ -59,7 +59,6 @@ dependencies {
|
|||
implementation("androidx.leanback:leanback:1.2.0-alpha02")
|
||||
|
||||
implementation("androidx.core:core-ktx:1.8.0")
|
||||
implementation("androidx.core:core-splashscreen:1.0.0")
|
||||
implementation("androidx.appcompat:appcompat:1.4.2")
|
||||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.FindroidSplashScreen"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
|
||||
<intent-filter>
|
||||
|
|
|
@ -3,23 +3,28 @@ package dev.jdtech.jellyfin
|
|||
import android.app.Application
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import dev.jdtech.jellyfin.utils.AppPreferences
|
||||
import timber.log.Timber
|
||||
|
||||
@HiltAndroidApp
|
||||
class BaseApplication : Application() {
|
||||
override fun onCreate() {
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
super.onCreate()
|
||||
|
||||
when (sharedPreferences.getString("theme", null)) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Timber.plant(Timber.DebugTree())
|
||||
}
|
||||
|
||||
val appPreferences = AppPreferences(PreferenceManager.getDefaultSharedPreferences(this))
|
||||
|
||||
when (appPreferences.theme) {
|
||||
"system" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
"light" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||
"dark" -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||
}
|
||||
|
||||
super.onCreate()
|
||||
if (BuildConfig.DEBUG) {
|
||||
Timber.plant(Timber.DebugTree())
|
||||
}
|
||||
if (appPreferences.dynamicColors) DynamicColors.applyToActivitiesIfAvailable(this)
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ package dev.jdtech.jellyfin
|
|||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.NavigationUI
|
||||
|
@ -23,7 +22,6 @@ class MainActivity : AppCompatActivity() {
|
|||
lateinit var database: ServerDatabaseDao
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
installSplashScreen()
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = ActivityMainAppBinding.inflate(layoutInflater)
|
||||
|
|
|
@ -12,6 +12,11 @@ class AppPreferences
|
|||
constructor(
|
||||
private val sharedPreferences: SharedPreferences
|
||||
) {
|
||||
// Appearance
|
||||
val theme = sharedPreferences.getString(Constants.PREF_THEME, null)
|
||||
val dynamicColors = sharedPreferences.getBoolean(Constants.PREF_DYNAMIC_COLORS, true)
|
||||
|
||||
// Player
|
||||
val playerGestures = sharedPreferences.getBoolean(Constants.PREF_PLAYER_GESTURES, true)
|
||||
val playerGesturesVB = sharedPreferences.getBoolean(Constants.PREF_PLAYER_GESTURES_VB, true)
|
||||
val playerGesturesZoom = sharedPreferences.getBoolean(Constants.PREF_PLAYER_GESTURES_ZOOM, true)
|
||||
|
|
|
@ -17,6 +17,8 @@ object Constants {
|
|||
const val PREF_PLAYER_SEEK_FORWARD_INC = "pref_player_seek_forward_inc"
|
||||
const val PREF_IMAGE_CACHE = "pref_image_cache"
|
||||
const val PREF_IMAGE_CACHE_SIZE = "pref_image_cache_size"
|
||||
const val PREF_THEME = "theme"
|
||||
const val PREF_DYNAMIC_COLORS = "dynamic_colors"
|
||||
|
||||
// caching
|
||||
const val DEFAULT_CACHE_SIZE = 20
|
||||
|
|
|
@ -16,10 +16,4 @@
|
|||
<item name="android:colorBackground">@color/neutral_1000</item>
|
||||
<item name="colorSurface">@color/neutral_900</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.FindroidSplashScreen" parent="Theme.SplashScreen">
|
||||
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
|
||||
<item name="windowSplashScreenBackground">@color/black</item>
|
||||
<item name="postSplashScreenTheme">@style/Theme.Findroid</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -128,4 +128,6 @@
|
|||
<string name="seeking">Seeking</string>
|
||||
<string name="seek_back_increment">Seek back increment (ms)</string>
|
||||
<string name="seek_forward_increment">Seek forward increment (ms)</string>
|
||||
<string name="dynamic_colors">Dynamic colors</string>
|
||||
<string name="dynamic_colors_summary">Use Material You Dynamic colors (only available on Android 12+)</string>
|
||||
</resources>
|
|
@ -39,12 +39,6 @@
|
|||
<item name="elevationOverlayEnabled">false</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.FindroidSplashScreen" parent="Theme.SplashScreen">
|
||||
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
|
||||
<item name="windowSplashScreenBackground">@color/white</item>
|
||||
<item name="postSplashScreenTheme">@style/Theme.Findroid</item>
|
||||
</style>
|
||||
|
||||
<string-array name="themes">
|
||||
<item>Follow system</item>
|
||||
<item>Light</item>
|
||||
|
|
|
@ -7,4 +7,9 @@
|
|||
app:key="theme"
|
||||
app:title="@string/theme"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<SwitchPreference
|
||||
app:defaultValue="true"
|
||||
app:key="dynamic_colors"
|
||||
app:summary="@string/dynamic_colors_summary"
|
||||
app:title="@string/dynamic_colors" />
|
||||
</PreferenceScreen>
|
Loading…
Reference in a new issue