diff --git a/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt b/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt
index 945177d..1b9a7a3 100644
--- a/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt
+++ b/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt
@@ -2,20 +2,39 @@ package eu.ottop.yamlauncher.settings
import android.content.Context
import android.graphics.Color
+import android.util.TypedValue
import android.widget.TextView
+import androidx.core.graphics.toColor
import androidx.preference.PreferenceManager
+import eu.ottop.yamlauncher.R
-class SharedPreferenceManager (context: Context) {
+class SharedPreferenceManager (private val context: Context) {
private val preferences = PreferenceManager.getDefaultSharedPreferences(context)
// General UI
fun getBgColor(): Int {
- return Color.parseColor(preferences.getString("bgColor", "#00000000"))
+ val bgColor = preferences.getString("bgColor", "#00000000")
+ if(bgColor == "material") {
+ return getThemeColor(com.google.android.material.R.attr.colorOnPrimary)
+ }
+ return Color.parseColor(bgColor)
}
fun getTextColor(): Int {
- return Color.parseColor(preferences.getString("textColor", "#FFF3F3F3"))
+ val textColor = preferences.getString("textColor", "#FFF3F3F3")
+ if(textColor == "material") {
+ return getThemeColor(com.google.android.material.R.attr.colorPrimary)
+ }
+ return Color.parseColor(textColor)
+ }
+
+
+ private fun getThemeColor(attr: Int): Int {
+ val typedValue = TypedValue()
+ val theme = context.theme
+ theme.resolveAttribute(attr, typedValue, true)
+ return typedValue.data
}
fun isBarVisible(): Boolean {
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index e4b1e2f..d67f170 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -6,6 +6,8 @@
- Black
- Grey
- White
+ - Material
+
@@ -13,16 +15,20 @@
- #FF000000
- #FF1B1B1B
- #FFD6D6D6
+ - material
+
- Light
- Dark
+ - Material
- #FFF3F3F3
- #FF0C0C0C
+ - material
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 86285c3..d9d3c7b 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -1,6 +1,6 @@
-