mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-26 05:05:15 +00:00
Added support for theme recreation after application relaunch (untested)
This commit is contained in:
parent
5920139710
commit
0e554686e3
5 changed files with 8 additions and 20 deletions
|
@ -9,7 +9,8 @@
|
|||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true">
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
|
||||
<activity
|
||||
android:name=".SplashScreenActivity"
|
||||
|
@ -24,15 +25,13 @@
|
|||
|
||||
<activity
|
||||
android:name=".ui.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/LightTheme">
|
||||
android:label="@string/app_name">
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.AboutActivity"
|
||||
android:parentActivityName=".ui.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/LightTheme">
|
||||
android:label="@string/app_name">
|
||||
</activity>
|
||||
|
||||
<meta-data
|
||||
|
|
|
@ -19,15 +19,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
when (currentVal.toInt()){
|
||||
0 -> {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
activity?.recreate()
|
||||
}
|
||||
1 -> {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||
activity?.recreate()
|
||||
}
|
||||
else ->{
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||
activity?.recreate()
|
||||
}
|
||||
}
|
||||
true
|
||||
|
|
|
@ -22,16 +22,8 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
when (AppCompatDelegate.getDefaultNightMode()) {
|
||||
AppCompatDelegate.MODE_NIGHT_YES -> {
|
||||
setTheme(R.style.DarkTheme)
|
||||
}
|
||||
AppCompatDelegate.MODE_NIGHT_NO -> {
|
||||
setTheme(R.style.LightTheme)
|
||||
}
|
||||
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM -> {
|
||||
}
|
||||
}
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.getDefaultNightMode())
|
||||
|
||||
super.onCreate(null)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="DarkTheme" parent="Theme.MaterialComponents.NoActionBar">
|
||||
<style name="MainTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
|
||||
<item name="colorPrimary">#1490D7</item>
|
||||
<item name="colorPrimaryVariant">#804EAFF5</item>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="LightTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
|
||||
<style name="MainTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
|
||||
<item name="colorPrimary">#1490D7</item>
|
||||
<item name="colorPrimaryVariant">#2C7EB9</item>
|
||||
|
|
Loading…
Reference in a new issue