mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Made the status bar colors change according to the text color
This commit is contained in:
parent
d490a46a3a
commit
0130708468
3 changed files with 23 additions and 1 deletions
|
|
@ -328,6 +328,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
uiUtils.setFont(binding.menuTitle)
|
uiUtils.setFont(binding.menuTitle)
|
||||||
|
|
||||||
uiUtils.setTextColors(binding.homeView)
|
uiUtils.setTextColors(binding.homeView)
|
||||||
|
uiUtils.setStatusBarColor(window)
|
||||||
|
|
||||||
uiUtils.setMenuItemColors(binding.menuTitle, "A9")
|
uiUtils.setMenuItemColors(binding.menuTitle, "A9")
|
||||||
|
|
||||||
|
|
@ -472,6 +473,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
|
|
||||||
"textColor" -> {
|
"textColor" -> {
|
||||||
uiUtils.setTextColors(binding.homeView)
|
uiUtils.setTextColors(binding.homeView)
|
||||||
|
uiUtils.setStatusBarColor(window)
|
||||||
uiUtils.setMenuItemColors(searchView)
|
uiUtils.setMenuItemColors(searchView)
|
||||||
uiUtils.setMenuItemColors(binding.menuTitle, "A9")
|
uiUtils.setMenuItemColors(binding.menuTitle, "A9")
|
||||||
uiUtils.setImageColor(searchSwitcher)
|
uiUtils.setImageColor(searchSwitcher)
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,17 @@ class SharedPreferenceManager (private val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTextColor(): Int {
|
fun getTextColor(): Int {
|
||||||
val textColor = preferences.getString("textColor", "#FFF3F3F3")
|
val textColor = getTextString()
|
||||||
if(textColor == "material") {
|
if(textColor == "material") {
|
||||||
return getThemeColor(com.google.android.material.R.attr.colorPrimary)
|
return getThemeColor(com.google.android.material.R.attr.colorPrimary)
|
||||||
}
|
}
|
||||||
return Color.parseColor(textColor)
|
return Color.parseColor(textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getTextString(): String? {
|
||||||
|
return preferences.getString("textColor", "#FFF3F3F3")
|
||||||
|
}
|
||||||
|
|
||||||
private fun getThemeColor(attr: Int): Int {
|
private fun getThemeColor(attr: Int): Int {
|
||||||
val typedValue = TypedValue()
|
val typedValue = TypedValue()
|
||||||
val theme = context.theme
|
val theme = context.theme
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.ottop.yamlauncher.utils
|
package eu.ottop.yamlauncher.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.Configuration
|
||||||
import android.graphics.BlendMode
|
import android.graphics.BlendMode
|
||||||
import android.graphics.BlendModeColorFilter
|
import android.graphics.BlendModeColorFilter
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
|
@ -63,6 +64,21 @@ class UIUtils(private val context: Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setStatusBarColor(window: Window) {
|
||||||
|
val insetController = window.insetsController
|
||||||
|
when (sharedPreferenceManager.getTextString()) {
|
||||||
|
"#FFF3F3F3" -> insetController?.setSystemBarsAppearance(0, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS)
|
||||||
|
"#FF0C0C0C" -> insetController?.setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS)
|
||||||
|
"material" -> {
|
||||||
|
val currentNightMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||||
|
when (currentNightMode) {
|
||||||
|
Configuration.UI_MODE_NIGHT_YES -> insetController?.setSystemBarsAppearance(0, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS)
|
||||||
|
Configuration.UI_MODE_NIGHT_NO -> insetController?.setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun hasMethod(view: View, methodName: String): Boolean {
|
private fun hasMethod(view: View, methodName: String): Boolean {
|
||||||
return try {
|
return try {
|
||||||
view.javaClass.getMethod(methodName, Int::class.java)
|
view.javaClass.getMethod(methodName, Int::class.java)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue