mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-26 07:34:19 +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.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import com.google.android.material.color.DynamicColors
|
||||||
|
import com.google.android.material.color.DynamicColorsOptions
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
import emu.skyline.di.getSettings
|
import emu.skyline.di.getSettings
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@ -39,5 +41,8 @@ class SkylineApplication : Application() {
|
|||||||
val publicAppFilesPath = applicationContext.getPublicFilesDir().canonicalPath
|
val publicAppFilesPath = applicationContext.getPublicFilesDir().canonicalPath
|
||||||
File("$publicAppFilesPath/logs/").mkdirs()
|
File("$publicAppFilesPath/logs/").mkdirs()
|
||||||
initializeLog("$publicAppFilesPath/", getSettings().logLevel)
|
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
|
// Appearance
|
||||||
var appTheme by sharedPreferences(context, 2)
|
var appTheme by sharedPreferences(context, 2)
|
||||||
|
var useMaterialYou by sharedPreferences(context, false)
|
||||||
var layoutType by sharedPreferences(context, 1)
|
var layoutType by sharedPreferences(context, 1)
|
||||||
var sortAppsBy by sharedPreferences(context, 0)
|
var sortAppsBy by sharedPreferences(context, 0)
|
||||||
var groupByFormat by sharedPreferences(context, true)
|
var groupByFormat by sharedPreferences(context, true)
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package emu.skyline.settings
|
package emu.skyline.settings
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
@ -12,6 +13,7 @@ import androidx.preference.PreferenceCategory
|
|||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.preference.TwoStatePreference
|
import androidx.preference.TwoStatePreference
|
||||||
import emu.skyline.BuildConfig
|
import emu.skyline.BuildConfig
|
||||||
|
import emu.skyline.MainActivity
|
||||||
import emu.skyline.R
|
import emu.skyline.R
|
||||||
import emu.skyline.utils.GpuDriverHelper
|
import emu.skyline.utils.GpuDriverHelper
|
||||||
import emu.skyline.utils.WindowInsetsHelper
|
import emu.skyline.utils.WindowInsetsHelper
|
||||||
@ -35,6 +37,13 @@ class GlobalSettingsFragment : PreferenceFragmentCompat() {
|
|||||||
addPreferencesFromResource(R.xml.input_preferences)
|
addPreferencesFromResource(R.xml.input_preferences)
|
||||||
addPreferencesFromResource(R.xml.credits_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
|
// Uncheck `disable_frame_throttling` if `force_triple_buffering` gets disabled
|
||||||
val disableFrameThrottlingPref = findPreference<TwoStatePreference>("disable_frame_throttling")!!
|
val disableFrameThrottlingPref = findPreference<TwoStatePreference>("disable_frame_throttling")!!
|
||||||
findPreference<TwoStatePreference>("force_triple_buffering")?.setOnPreferenceChangeListener { _, newValue ->
|
findPreference<TwoStatePreference>("force_triple_buffering")?.setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
@ -44,6 +44,9 @@
|
|||||||
<!-- Settings - Appearance -->
|
<!-- Settings - Appearance -->
|
||||||
<string name="appearance">Appearance</string>
|
<string name="appearance">Appearance</string>
|
||||||
<string name="theme">Theme</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">App Language</string>
|
||||||
<string name="app_language_default">Use System Default</string>
|
<string name="app_language_default">Use System Default</string>
|
||||||
<string name="layout_type">Game Display Layout</string>
|
<string name="layout_type">Game Display Layout</string>
|
||||||
|
@ -28,6 +28,12 @@
|
|||||||
app:key="app_theme"
|
app:key="app_theme"
|
||||||
app:title="@string/theme"
|
app:title="@string/theme"
|
||||||
app:useSimpleSummaryProvider="true" />
|
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
|
<emu.skyline.preference.LanguagePreference
|
||||||
app:key="app_language"
|
app:key="app_language"
|
||||||
app:persistent="false"
|
app:persistent="false"
|
||||||
|
Loading…
Reference in New Issue
Block a user