mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
removed light theme; added dynamic theme (cf. #75)
This commit is contained in:
parent
06777a4d34
commit
3c59ad4c41
6 changed files with 63 additions and 6 deletions
|
@ -19,6 +19,9 @@ class Application : android.app.Application() {
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
// TODO Error: Invalid resource ID 0x00000000.
|
||||||
|
// DynamicColors.applyToActivitiesIfAvailable(this)
|
||||||
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= VERSION_CODES.M) {
|
||||||
torchManager = TorchManager(this)
|
torchManager = TorchManager(this)
|
||||||
|
|
|
@ -1,20 +1,49 @@
|
||||||
package de.jrpie.android.launcher.preferences.theme
|
package de.jrpie.android.launcher.preferences.theme
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import de.jrpie.android.launcher.R
|
import de.jrpie.android.launcher.R
|
||||||
|
import com.google.android.material.color.DynamicColors
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
enum class ColorTheme(private val id: Int, private val shadowId: Int) {
|
enum class ColorTheme(
|
||||||
DEFAULT(R.style.colorThemeDefault, R.style.textShadow),
|
private val id: Int,
|
||||||
DARK(R.style.colorThemeDark, R.style.textShadow),
|
private val labelResource: Int,
|
||||||
LIGHT(R.style.colorThemeLight, R.style.textShadowLight),
|
private val shadowId: Int,
|
||||||
|
val isAvailable: () -> Boolean
|
||||||
|
) {
|
||||||
|
DEFAULT(
|
||||||
|
R.style.colorThemeDefault,
|
||||||
|
R.string.settings_theme_color_theme_item_default,
|
||||||
|
R.style.textShadow,
|
||||||
|
{ true }),
|
||||||
|
DARK(
|
||||||
|
R.style.colorThemeDark,
|
||||||
|
R.string.settings_theme_color_theme_item_dark,
|
||||||
|
R.style.textShadow,
|
||||||
|
{ true }),
|
||||||
|
LIGHT(
|
||||||
|
R.style.colorThemeLight,
|
||||||
|
R.string.settings_theme_color_theme_item_light,
|
||||||
|
R.style.textShadowLight,
|
||||||
|
{ false }),
|
||||||
|
DYNAMIC(
|
||||||
|
R.style.colorThemeDynamic,
|
||||||
|
R.string.settings_theme_color_theme_item_dynamic,
|
||||||
|
R.style.textShadow,
|
||||||
|
{ DynamicColors.isDynamicColorAvailable() }),
|
||||||
;
|
;
|
||||||
|
|
||||||
fun applyToTheme(theme: Resources.Theme, shadow: Boolean) {
|
fun applyToTheme(theme: Resources.Theme, shadow: Boolean) {
|
||||||
theme.applyStyle(id, true)
|
val colorTheme = if (this.isAvailable()) this else DEFAULT
|
||||||
|
theme.applyStyle(colorTheme.id, true)
|
||||||
|
|
||||||
if (shadow) {
|
if (shadow) {
|
||||||
theme.applyStyle(shadowId, true)
|
theme.applyStyle(colorTheme.shadowId, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getLabel(context: Context): String {
|
||||||
|
return context.getString(labelResource)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@ import de.jrpie.android.launcher.R
|
||||||
import de.jrpie.android.launcher.actions.lock.LockMethod
|
import de.jrpie.android.launcher.actions.lock.LockMethod
|
||||||
import de.jrpie.android.launcher.actions.openAppsList
|
import de.jrpie.android.launcher.actions.openAppsList
|
||||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||||
|
import de.jrpie.android.launcher.preferences.theme.ColorTheme
|
||||||
import de.jrpie.android.launcher.setDefaultHomeScreen
|
import de.jrpie.android.launcher.setDefaultHomeScreen
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,6 +87,16 @@ class SettingsFragmentLauncher : PreferenceFragmentCompat() {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findPreference<androidx.preference.DropDownPreference>(
|
||||||
|
LauncherPreferences.theme().keys().colorTheme()
|
||||||
|
)?.apply {
|
||||||
|
entries = ColorTheme.entries.filter { x -> x.isAvailable() }
|
||||||
|
.map { x -> x.getLabel(requireContext()) }.toTypedArray()
|
||||||
|
entryValues = ColorTheme.entries.filter { x -> x.isAvailable() }
|
||||||
|
.map { x -> x.name }.toTypedArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||||
lockMethod?.isVisible = false
|
lockMethod?.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,11 +66,13 @@
|
||||||
<item>DEFAULT</item>
|
<item>DEFAULT</item>
|
||||||
<item>DARK</item>
|
<item>DARK</item>
|
||||||
<item>LIGHT</item>
|
<item>LIGHT</item>
|
||||||
|
<item>DYNAMIC</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="settings_theme_color_theme_items" translatable="false">
|
<string-array name="settings_theme_color_theme_items" translatable="false">
|
||||||
<item>@string/settings_theme_color_theme_item_default</item>
|
<item>@string/settings_theme_color_theme_item_default</item>
|
||||||
<item>@string/settings_theme_color_theme_item_dark</item>
|
<item>@string/settings_theme_color_theme_item_dark</item>
|
||||||
<item>@string/settings_theme_color_theme_item_light</item>
|
<item>@string/settings_theme_color_theme_item_light</item>
|
||||||
|
<item>@string/settings_theme_color_theme_item_dynamic</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string name="settings_theme_text_shadow_key" translatable="false">theme.text_shadow</string>
|
<string name="settings_theme_text_shadow_key" translatable="false">theme.text_shadow</string>
|
||||||
|
|
|
@ -90,6 +90,7 @@
|
||||||
<string name="settings_theme_color_theme_item_default">Default</string>
|
<string name="settings_theme_color_theme_item_default">Default</string>
|
||||||
<string name="settings_theme_color_theme_item_dark">Dark</string>
|
<string name="settings_theme_color_theme_item_dark">Dark</string>
|
||||||
<string name="settings_theme_color_theme_item_light">Light</string>
|
<string name="settings_theme_color_theme_item_light">Light</string>
|
||||||
|
<string name="settings_theme_color_theme_item_dynamic">Dynamic</string>
|
||||||
|
|
||||||
<string name="settings_theme_text_shadow">Text shadow</string>
|
<string name="settings_theme_text_shadow">Text shadow</string>
|
||||||
<string name="settings_theme_background">Background (app list and setting)</string>
|
<string name="settings_theme_background">Background (app list and setting)</string>
|
||||||
|
|
|
@ -51,6 +51,15 @@
|
||||||
<item name="android:textColor">@color/lightTheme_text_color</item>
|
<item name="android:textColor">@color/lightTheme_text_color</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="colorThemeDynamic">
|
||||||
|
<!--parent="Theme.Material3.Dark.NoActionBar"-->
|
||||||
|
<item name="colorPrimary">@color/material_dynamic_primary70</item>
|
||||||
|
<item name="colorPrimaryDark">@color/material_dynamic_primary50</item>
|
||||||
|
<item name="colorAccent">@color/material_dynamic_tertiary50</item>
|
||||||
|
<item name="android:colorBackground">@color/material_dynamic_neutral10</item>
|
||||||
|
<item name="android:textColor">@color/material_dynamic_neutral_variant90</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="textShadow">
|
<style name="textShadow">
|
||||||
<item name="android:shadowColor">#000</item>
|
<item name="android:shadowColor">#000</item>
|
||||||
<item name="android:shadowDx">0</item>
|
<item name="android:shadowDx">0</item>
|
||||||
|
@ -118,6 +127,8 @@
|
||||||
|
|
||||||
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
|
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
|
||||||
<item name="android:textColor">#000000</item>
|
<item name="android:textColor">#000000</item>
|
||||||
|
<item name="android:background">#ffffff</item>
|
||||||
|
<item name="android:color">#000000</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Set the fade in animation on all activities by default -->
|
<!-- Set the fade in animation on all activities by default -->
|
||||||
|
|
Loading…
Add table
Reference in a new issue