mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-22 19:29:20 +01:00
Implement Material You theming support
Material You is disabled by default, it can be toggled in settings.
This commit is contained in:
parent
d3d22670f9
commit
236b754559
@ -7,6 +7,8 @@ package emu.skyline
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import com.google.android.material.color.DynamicColorsOptions
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import emu.skyline.di.getSettings
|
||||
import java.io.File
|
||||
@ -39,5 +41,8 @@ class SkylineApplication : Application() {
|
||||
val publicAppFilesPath = applicationContext.getPublicFilesDir().canonicalPath
|
||||
File("$publicAppFilesPath/logs/").mkdirs()
|
||||
initializeLog("$publicAppFilesPath/", getSettings().logLevel)
|
||||
|
||||
val dynamicColorsOptions = DynamicColorsOptions.Builder().setPrecondition { _, _ -> getSettings().useMaterialYou }.build()
|
||||
DynamicColors.applyToActivitiesIfAvailable(this, dynamicColorsOptions)
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ class AppSettings @Inject constructor(@ApplicationContext private val context :
|
||||
|
||||
// Appearance
|
||||
var appTheme by sharedPreferences(context, 2)
|
||||
var useMaterialYou by sharedPreferences(context, false)
|
||||
var layoutType by sharedPreferences(context, 1)
|
||||
var sortAppsBy by sharedPreferences(context, 0)
|
||||
var groupByFormat by sharedPreferences(context, true)
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
package emu.skyline.settings
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.preference.Preference
|
||||
@ -12,6 +13,7 @@ import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.TwoStatePreference
|
||||
import emu.skyline.BuildConfig
|
||||
import emu.skyline.MainActivity
|
||||
import emu.skyline.R
|
||||
import emu.skyline.utils.GpuDriverHelper
|
||||
import emu.skyline.utils.WindowInsetsHelper
|
||||
@ -35,6 +37,13 @@ class GlobalSettingsFragment : PreferenceFragmentCompat() {
|
||||
addPreferencesFromResource(R.xml.input_preferences)
|
||||
addPreferencesFromResource(R.xml.credits_preferences)
|
||||
|
||||
// Re-launch the app if Material You is toggled
|
||||
findPreference<Preference>("use_material_you")?.setOnPreferenceChangeListener { _, _ ->
|
||||
requireActivity().finishAffinity()
|
||||
startActivity(Intent(requireContext(), MainActivity::class.java))
|
||||
true
|
||||
}
|
||||
|
||||
// Uncheck `disable_frame_throttling` if `force_triple_buffering` gets disabled
|
||||
val disableFrameThrottlingPref = findPreference<TwoStatePreference>("disable_frame_throttling")!!
|
||||
findPreference<TwoStatePreference>("force_triple_buffering")?.setOnPreferenceChangeListener { _, newValue ->
|
||||
|
@ -44,6 +44,9 @@
|
||||
<!-- Settings - Appearance -->
|
||||
<string name="appearance">Appearance</string>
|
||||
<string name="theme">Theme</string>
|
||||
<string name="use_material_you">Use Material You</string>
|
||||
<string name="use_material_you_desc_off">Skyline colors will be used</string>
|
||||
<string name="use_material_you_desc_on">Material You will be used</string>
|
||||
<string name="app_language">App Language</string>
|
||||
<string name="app_language_default">Use System Default</string>
|
||||
<string name="layout_type">Game Display Layout</string>
|
||||
|
@ -28,6 +28,12 @@
|
||||
app:key="app_theme"
|
||||
app:title="@string/theme"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
app:key="use_material_you"
|
||||
app:summaryOff="@string/use_material_you_desc_off"
|
||||
app:summaryOn="@string/use_material_you_desc_on"
|
||||
app:title="@string/use_material_you" />
|
||||
<emu.skyline.preference.LanguagePreference
|
||||
app:key="app_language"
|
||||
app:persistent="false"
|
||||
|
Loading…
Reference in New Issue
Block a user