From 3d75d21bdf5584dbf44568f00e11d4109c7cde7a Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 29 Mar 2022 11:36:09 +0200 Subject: [PATCH] lets control the actionbar colors too to avoid surprises --- .../commons/activities/BaseSimpleActivity.kt | 10 +--------- .../commons/extensions/Activity.kt | 16 ++++++++++------ commons/src/main/res/values-v31/colors.xml | 2 +- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt index 38dfd2a3d..e8279c294 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/BaseSimpleActivity.kt @@ -22,7 +22,6 @@ import android.view.Menu import android.view.MenuItem import android.view.View import android.view.WindowManager -import android.widget.TextView import android.widget.Toast import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity @@ -202,14 +201,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() { var color = baseColor.getContrastColor() if (baseConfig.isUsingSystemTheme) { - val views = ArrayList() - try { - window.decorView.rootView.findViewsWithText(views, supportActionBar?.title, View.FIND_VIEWS_WITH_TEXT) - views.firstOrNull { it is TextView && it.id == -1 }?.apply { - color = (this as TextView).currentTextColor - } - } catch (ignored: Exception) { - } + color = getProperTextColor() } for (i in 0 until menu.size()) { diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt index d952c2843..77224e12d 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Activity.kt @@ -48,19 +48,23 @@ import java.io.OutputStream import java.util.* fun AppCompatActivity.updateActionBarTitle(text: String, color: Int = baseConfig.primaryColor) { - if (baseConfig.isUsingSystemTheme) { - supportActionBar?.title = text + val colorToUse = if (baseConfig.isUsingSystemTheme) { + getProperTextColor() } else { - supportActionBar?.title = Html.fromHtml("$text") + color.getContrastColor() } + + supportActionBar?.title = Html.fromHtml("$text") } fun AppCompatActivity.updateActionBarSubtitle(text: String) { - if (baseConfig.isUsingSystemTheme) { - supportActionBar?.subtitle = text + val colorToUse = if (baseConfig.isUsingSystemTheme) { + getProperTextColor() } else { - supportActionBar?.subtitle = Html.fromHtml("$text") + baseConfig.primaryColor.getContrastColor() } + + supportActionBar?.subtitle = Html.fromHtml("$text") } fun Activity.appLaunched(appId: String) { diff --git a/commons/src/main/res/values-v31/colors.xml b/commons/src/main/res/values-v31/colors.xml index 19f5520db..6a0d006f7 100644 --- a/commons/src/main/res/values-v31/colors.xml +++ b/commons/src/main/res/values-v31/colors.xml @@ -2,7 +2,7 @@ @android:color/system_accent2_50 @android:color/system_neutral1_10 - @android:color/system_accent1_800 + @android:color/system_accent1_900 @android:color/system_accent1_400 @android:color/system_accent1_600 @android:color/system_accent2_10