Text and bg colors can now be material you

This commit is contained in:
ottoptj 2024-08-16 16:44:29 +03:00
commit 28af7ab6c5
3 changed files with 29 additions and 4 deletions

View file

@ -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 {

View file

@ -6,6 +6,8 @@
<item>Black</item>
<item>Grey</item>
<item>White</item>
<item>Material</item>
</string-array>
<string-array name="bg_values">
@ -13,16 +15,20 @@
<item>#FF000000</item>
<item>#FF1B1B1B</item>
<item>#FFD6D6D6</item>
<item>material</item>
</string-array>
<string-array name="color_options">
<item>Light</item>
<item>Dark</item>
<item>Material</item>
</string-array>
<string-array name="color_values">
<item>#FFF3F3F3</item>
<item>#FF0C0C0C</item>
<item>material</item>
</string-array>
<string-array name="animation_options">

View file

@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.YamLauncher" parent="Theme.AppCompat.NoActionBar">
<style name="Base.Theme.YamLauncher" parent="Theme.Material3.DynamicColors.DayNight.NoActionBar">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@android:color/transparent</item>
<item name="android:windowShowWallpaper">true</item>