diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt index 397f202..00ab8af 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt @@ -328,6 +328,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh uiUtils.setFont(binding.menuTitle) uiUtils.setTextColors(binding.homeView) + uiUtils.setStatusBarColor(window) uiUtils.setMenuItemColors(binding.menuTitle, "A9") @@ -472,6 +473,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh "textColor" -> { uiUtils.setTextColors(binding.homeView) + uiUtils.setStatusBarColor(window) uiUtils.setMenuItemColors(searchView) uiUtils.setMenuItemColors(binding.menuTitle, "A9") uiUtils.setImageColor(searchSwitcher) 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 542f78a..23f096e 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt @@ -22,13 +22,17 @@ class SharedPreferenceManager (private val context: Context) { } fun getTextColor(): Int { - val textColor = preferences.getString("textColor", "#FFF3F3F3") + val textColor = getTextString() if(textColor == "material") { return getThemeColor(com.google.android.material.R.attr.colorPrimary) } return Color.parseColor(textColor) } + fun getTextString(): String? { + return preferences.getString("textColor", "#FFF3F3F3") + } + private fun getThemeColor(attr: Int): Int { val typedValue = TypedValue() val theme = context.theme diff --git a/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt b/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt index 1ca01d6..d3fee45 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/utils/UIUtils.kt @@ -1,6 +1,7 @@ package eu.ottop.yamlauncher.utils import android.content.Context +import android.content.res.Configuration import android.graphics.BlendMode import android.graphics.BlendModeColorFilter 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 { return try { view.javaClass.getMethod(methodName, Int::class.java)