Simplify theme color application logic
This commit is contained in:
parent
cb72b9180f
commit
9ebac9684b
@ -37,7 +37,7 @@
|
|||||||
android:requestLegacyExternalStorage="true"
|
android:requestLegacyExternalStorage="true"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/LauncherTheme.DefaultColors"
|
android:theme="@style/LauncherTheme"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
tools:ignore="GoogleAppIndexingWarning">
|
tools:ignore="GoogleAppIndexingWarning">
|
||||||
|
|
||||||
@ -51,7 +51,7 @@
|
|||||||
android:parentActivityName=".ui.legacy.activity.LauncherActivity"
|
android:parentActivityName=".ui.legacy.activity.LauncherActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:taskAffinity="de.mm20.launcher2.settings"
|
android:taskAffinity="de.mm20.launcher2.settings"
|
||||||
android:theme="@style/SettingsTheme.DefaultColors">
|
android:theme="@style/SettingsTheme">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
|
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
|||||||
@ -3,26 +3,22 @@ package de.mm20.launcher2.activity
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import de.mm20.launcher2.R
|
|
||||||
import de.mm20.launcher2.fragment.PreferencesCalendarFragment
|
import de.mm20.launcher2.fragment.PreferencesCalendarFragment
|
||||||
import de.mm20.launcher2.fragment.PreferencesMainFragment
|
import de.mm20.launcher2.fragment.PreferencesMainFragment
|
||||||
import de.mm20.launcher2.fragment.PreferencesServicesFragment
|
import de.mm20.launcher2.fragment.PreferencesServicesFragment
|
||||||
import de.mm20.launcher2.fragment.PreferencesWeatherFragment
|
import de.mm20.launcher2.fragment.PreferencesWeatherFragment
|
||||||
import de.mm20.launcher2.preferences.ColorSchemes
|
|
||||||
import de.mm20.launcher2.preferences.LauncherPreferences
|
|
||||||
import de.mm20.launcher2.ui.legacy.activity.LauncherActivity
|
import de.mm20.launcher2.ui.legacy.activity.LauncherActivity
|
||||||
|
import de.mm20.launcher2.ui.legacy.helper.ThemeHelper
|
||||||
|
|
||||||
class SettingsActivity : AppCompatActivity() {
|
class SettingsActivity : AppCompatActivity() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
when(LauncherPreferences.instance.colorScheme) {
|
|
||||||
ColorSchemes.BLACK -> setTheme(R.style.SettingsTheme_BlackWhiteColors)
|
ThemeHelper.applyTheme(theme)
|
||||||
else -> setTheme(R.style.SettingsTheme_DefaultColors)
|
|
||||||
}
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
val fragment = getStartFragment()
|
val fragment = getStartFragment()
|
||||||
setupActionBar()
|
setupActionBar()
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<style name="DefaultColors" parent="BaseTheme">
|
<style name="DefaultColors">
|
||||||
<item name="colorPrimary">@android:color/system_accent1_200</item>
|
<item name="colorPrimary">@android:color/system_accent1_200</item>
|
||||||
<item name="colorOnPrimary">@android:color/system_accent1_800</item>
|
<item name="colorOnPrimary">@android:color/system_accent1_800</item>
|
||||||
<item name="colorPrimaryContainer">@android:color/system_accent1_700</item>
|
<item name="colorPrimaryContainer">@android:color/system_accent1_700</item>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<style name="DefaultColors" parent="BaseTheme">
|
<style name="DefaultColors">
|
||||||
<item name="colorPrimary">#72D1FF</item>
|
<item name="colorPrimary">#72D1FF</item>
|
||||||
<item name="colorOnPrimary">#003549</item>
|
<item name="colorOnPrimary">#003549</item>
|
||||||
<item name="colorPrimaryContainer">#004D68</item>
|
<item name="colorPrimaryContainer">#004D68</item>
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<item name="elevationOverlayEnabled">true</item>
|
<item name="elevationOverlayEnabled">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="BlackWhiteColors" parent="BaseTheme">
|
<style name="BlackWhiteColors">
|
||||||
<item name="colorPrimary">@android:color/white</item>
|
<item name="colorPrimary">@android:color/white</item>
|
||||||
<item name="colorOnPrimary">@android:color/black</item>
|
<item name="colorOnPrimary">@android:color/black</item>
|
||||||
<item name="colorPrimaryContainer">@android:color/black</item>
|
<item name="colorPrimaryContainer">@android:color/black</item>
|
||||||
|
|||||||
@ -1,12 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="SettingsTheme.DefaultColors" parent="DefaultColors">
|
<style name="SettingsTheme" parent="BaseTheme">
|
||||||
<item name="android:statusBarColor">?colorSurface</item>
|
|
||||||
<item name="android:windowLightStatusBar">false</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="SettingsTheme.BlackWhiteColors" parent="BlackWhiteColors">
|
|
||||||
<item name="android:statusBarColor">?colorSurface</item>
|
<item name="android:statusBarColor">?colorSurface</item>
|
||||||
<item name="android:windowLightStatusBar">false</item>
|
<item name="android:windowLightStatusBar">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<style name="DefaultColors" parent="BaseTheme">
|
<style name="DefaultColors">
|
||||||
<item name="colorPrimary">@android:color/system_accent1_600</item>
|
<item name="colorPrimary">@android:color/system_accent1_600</item>
|
||||||
<item name="colorOnPrimary">@android:color/system_accent1_0</item>
|
<item name="colorOnPrimary">@android:color/system_accent1_0</item>
|
||||||
<item name="colorPrimaryContainer">@android:color/system_accent1_100</item>
|
<item name="colorPrimaryContainer">@android:color/system_accent1_100</item>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<style name="DefaultColors" parent="BaseTheme">
|
<style name="DefaultColors">
|
||||||
<item name="colorPrimary">#006689</item>
|
<item name="colorPrimary">#006689</item>
|
||||||
<item name="colorOnPrimary">@android:color/white</item>
|
<item name="colorOnPrimary">@android:color/white</item>
|
||||||
<item name="colorPrimaryContainer">#BFE8FF</item>
|
<item name="colorPrimaryContainer">#BFE8FF</item>
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<item name="elevationOverlayEnabled">false</item>
|
<item name="elevationOverlayEnabled">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="BlackWhiteColors" parent="BaseTheme">
|
<style name="BlackWhiteColors">
|
||||||
<item name="colorPrimary">@android:color/black</item>
|
<item name="colorPrimary">@android:color/black</item>
|
||||||
<item name="colorOnPrimary">@android:color/white</item>
|
<item name="colorOnPrimary">@android:color/white</item>
|
||||||
<item name="colorPrimaryContainer">@android:color/white</item>
|
<item name="colorPrimaryContainer">@android:color/white</item>
|
||||||
|
|||||||
@ -21,31 +21,6 @@
|
|||||||
<item name="alertDialogTheme">@style/AlertDialogTheme</item>
|
<item name="alertDialogTheme">@style/AlertDialogTheme</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Main theme. -->
|
|
||||||
<style name="LauncherTheme" parent="BaseLauncherTheme">
|
|
||||||
<item name="android:windowBackground">@android:color/transparent</item>
|
|
||||||
<item name="android:windowShowWallpaper">true</item>
|
|
||||||
<item name="android:colorPrimaryDark">#0000</item>
|
|
||||||
<item name="android:statusBarColor">#00000000</item>
|
|
||||||
<item name="android:navigationBarColor">#00000000</item>
|
|
||||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
|
||||||
<item name="android:windowTranslucentStatus">false</item>
|
|
||||||
<item name="android:windowTranslucentNavigation">false</item>
|
|
||||||
<item name="android:enforceStatusBarContrast">false</item>
|
|
||||||
<item name="android:enforceNavigationBarContrast">false</item>
|
|
||||||
<item name="windowActionBar">false</item>
|
|
||||||
<item name="windowNoTitle">true</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="SettingsTheme" parent="BaseLauncherTheme.Settings">
|
|
||||||
<item name="android:colorAccent">@color/blue</item>
|
|
||||||
<item name="colorAccent">@color/blue</item>
|
|
||||||
<item name="colorPrimary">@color/settings_color_primary</item>
|
|
||||||
<item name="colorPrimaryDark">@color/settings_color_primary_dark</item>
|
|
||||||
<item name="android:windowBackground">@android:color/transparent</item>
|
|
||||||
<item name="android:windowShowWallpaper">true</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="AlertDialogTheme" parent="ThemeOverlay.Material3.Dialog.Alert">
|
<style name="AlertDialogTheme" parent="ThemeOverlay.Material3.Dialog.Alert">
|
||||||
<item name="buttonBarButtonStyle">@style/AlertDialogButtonStyle</item>
|
<item name="buttonBarButtonStyle">@style/AlertDialogButtonStyle</item>
|
||||||
<item name="dialogCornerRadius">8dp</item>
|
<item name="dialogCornerRadius">8dp</item>
|
||||||
@ -96,10 +71,6 @@
|
|||||||
<item name="android:textColor">@color/chip_textcolor</item>
|
<item name="android:textColor">@color/chip_textcolor</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="BaseLauncherTheme.Settings">
|
|
||||||
<item name="android:windowLightStatusBar">true</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="LauncherTheme.IconStyle">
|
<style name="LauncherTheme.IconStyle">
|
||||||
<item name="android:alpha">0.87</item>
|
<item name="android:alpha">0.87</item>
|
||||||
<item name="android:tint">@color/icon_color</item>
|
<item name="android:tint">@color/icon_color</item>
|
||||||
|
|||||||
@ -19,32 +19,12 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<style name="SettingsTheme.DefaultColors" parent="DefaultColors">
|
<style name="SettingsTheme" parent="BaseTheme">
|
||||||
<item name="android:statusBarColor">?colorSurface</item>
|
<item name="android:statusBarColor">?colorSurface</item>
|
||||||
<item name="android:windowLightStatusBar">true</item>
|
<item name="android:windowLightStatusBar">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="SettingsTheme.BlackWhiteColors" parent="BlackWhiteColors">
|
<style name="LauncherTheme" parent="BaseTheme">
|
||||||
<item name="android:statusBarColor">?colorSurface</item>
|
|
||||||
<item name="android:windowLightStatusBar">true</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="LauncherTheme.DefaultColors" parent="DefaultColors">
|
|
||||||
<item name="android:windowBackground">@android:color/transparent</item>
|
|
||||||
<item name="android:windowShowWallpaper">true</item>
|
|
||||||
<item name="android:colorPrimaryDark">#0000</item>
|
|
||||||
<item name="android:statusBarColor">#00000000</item>
|
|
||||||
<item name="android:navigationBarColor">#00000000</item>
|
|
||||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
|
||||||
<item name="android:windowTranslucentStatus">false</item>
|
|
||||||
<item name="android:windowTranslucentNavigation">false</item>
|
|
||||||
<item name="android:enforceStatusBarContrast">false</item>
|
|
||||||
<item name="android:enforceNavigationBarContrast">false</item>
|
|
||||||
<item name="windowActionBar">false</item>
|
|
||||||
<item name="windowNoTitle">true</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="LauncherTheme.BlackWhiteColors" parent="BlackWhiteColors">
|
|
||||||
<item name="android:windowBackground">@android:color/transparent</item>
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
<item name="android:windowShowWallpaper">true</item>
|
<item name="android:windowShowWallpaper">true</item>
|
||||||
<item name="android:colorPrimaryDark">#0000</item>
|
<item name="android:colorPrimaryDark">#0000</item>
|
||||||
|
|||||||
@ -48,6 +48,7 @@ public class CrashReporterActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
getTheme().applyStyle(R.style.DefaultColors, true);
|
||||||
setContentView(R.layout.crash_reporter_activity);
|
setContentView(R.layout.crash_reporter_activity);
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="CrashReporter.Theme" parent="SettingsTheme.DefaultColors">
|
<style name="CrashReporter.Theme" parent="SettingsTheme">
|
||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -50,7 +50,6 @@ import de.mm20.launcher2.ktx.dp
|
|||||||
import de.mm20.launcher2.ktx.isBrightColor
|
import de.mm20.launcher2.ktx.isBrightColor
|
||||||
import de.mm20.launcher2.legacy.helper.ActivityStarter
|
import de.mm20.launcher2.legacy.helper.ActivityStarter
|
||||||
import de.mm20.launcher2.permissions.PermissionsManager
|
import de.mm20.launcher2.permissions.PermissionsManager
|
||||||
import de.mm20.launcher2.preferences.ColorSchemes
|
|
||||||
import de.mm20.launcher2.preferences.LauncherPreferences
|
import de.mm20.launcher2.preferences.LauncherPreferences
|
||||||
import de.mm20.launcher2.search.SearchViewModel
|
import de.mm20.launcher2.search.SearchViewModel
|
||||||
import de.mm20.launcher2.transition.ChangingLayoutTransition
|
import de.mm20.launcher2.transition.ChangingLayoutTransition
|
||||||
@ -59,6 +58,7 @@ import de.mm20.launcher2.ui.R
|
|||||||
import de.mm20.launcher2.ui.databinding.ActivityLauncherBinding
|
import de.mm20.launcher2.ui.databinding.ActivityLauncherBinding
|
||||||
import de.mm20.launcher2.ui.legacy.component.EditFavoritesView
|
import de.mm20.launcher2.ui.legacy.component.EditFavoritesView
|
||||||
import de.mm20.launcher2.ui.legacy.component.WidgetView
|
import de.mm20.launcher2.ui.legacy.component.WidgetView
|
||||||
|
import de.mm20.launcher2.ui.legacy.helper.ThemeHelper
|
||||||
import de.mm20.launcher2.ui.legacy.search.SearchGridView
|
import de.mm20.launcher2.ui.legacy.search.SearchGridView
|
||||||
import de.mm20.launcher2.ui.legacy.widget.LauncherWidget
|
import de.mm20.launcher2.ui.legacy.widget.LauncherWidget
|
||||||
import de.mm20.launcher2.weather.WeatherViewModel
|
import de.mm20.launcher2.weather.WeatherViewModel
|
||||||
@ -191,11 +191,8 @@ class LauncherActivity : AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
val iconRepository: IconRepository by inject()
|
val iconRepository: IconRepository by inject()
|
||||||
iconRepository.recreate()
|
iconRepository.recreate()
|
||||||
|
ThemeHelper.applyTheme(theme)
|
||||||
|
|
||||||
when(LauncherPreferences.instance.colorScheme) {
|
|
||||||
ColorSchemes.BLACK -> setTheme(R.style.LauncherTheme_BlackWhiteColors)
|
|
||||||
else -> setTheme(R.style.LauncherTheme_DefaultColors)
|
|
||||||
}
|
|
||||||
if (LauncherPreferences.instance.firstRunVersion < 1) {
|
if (LauncherPreferences.instance.firstRunVersion < 1) {
|
||||||
ActivityCompat.requestPermissions(
|
ActivityCompat.requestPermissions(
|
||||||
this, arrayOf(
|
this, arrayOf(
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
package de.mm20.launcher2.ui.legacy.helper
|
||||||
|
|
||||||
|
import android.content.res.Resources
|
||||||
|
import de.mm20.launcher2.preferences.ColorSchemes
|
||||||
|
import de.mm20.launcher2.preferences.LauncherPreferences
|
||||||
|
import de.mm20.launcher2.ui.R
|
||||||
|
|
||||||
|
object ThemeHelper {
|
||||||
|
fun applyTheme(theme: Resources.Theme) {
|
||||||
|
val colorScheme = when(LauncherPreferences.instance.colorScheme) {
|
||||||
|
ColorSchemes.BLACK -> R.style.BlackWhiteColors
|
||||||
|
else -> R.style.DefaultColors
|
||||||
|
}
|
||||||
|
theme.applyStyle(colorScheme, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user