From f85c418a0cd5e489f4468355d62aa9713a6ce7f1 Mon Sep 17 00:00:00 2001 From: CookieGamesOfficial Date: Sun, 6 Feb 2022 13:37:07 +0100 Subject: [PATCH] Fixed tab strip colours, ready for next release --- app/build.gradle | 4 ++-- .../smartcookie/browser/activity/BrowserActivity.kt | 2 +- .../smartcookie/browser/tabs/TabsDesktopAdapter.kt | 4 ++-- .../smartcookie/browser/tabs/TabsDesktopView.kt | 4 ++-- .../com/cookiegames/smartcookie/utils/ThemeUtils.java | 11 +++++++++++ 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 92f254e5..3076ca52 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,8 +22,8 @@ android { defaultConfig { minSdkVersion project.minSdkVersion targetSdkVersion project.targetSdkVersion - versionName "16.1" - versionCode 150 + versionName "16.2" + versionCode 151 vectorDrawables.useSupportLibrary = true testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } diff --git a/app/src/main/java/com/cookiegames/smartcookie/browser/activity/BrowserActivity.kt b/app/src/main/java/com/cookiegames/smartcookie/browser/activity/BrowserActivity.kt index 604559b4..e14f777d 100644 --- a/app/src/main/java/com/cookiegames/smartcookie/browser/activity/BrowserActivity.kt +++ b/app/src/main/java/com/cookiegames/smartcookie/browser/activity/BrowserActivity.kt @@ -1527,7 +1527,7 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr private fun loadState(above: Int) = tabsManager.currentTab?.let { it.progress >= above } ?: false override fun changeToolbarColor(tabBackground: Drawable?){ - val primaryColor = ThemeUtils.getPrimaryColor(this) + val primaryColor = ThemeUtils.getColorBackground(this) if(userPreferences.darkModeExtension) currentTabView?.setBackgroundColor(if (loadState(50)) Color.WHITE else primaryColor); currentTabView?.invalidate() diff --git a/app/src/main/java/com/cookiegames/smartcookie/browser/tabs/TabsDesktopAdapter.kt b/app/src/main/java/com/cookiegames/smartcookie/browser/tabs/TabsDesktopAdapter.kt index 64eefd70..2b8b3508 100644 --- a/app/src/main/java/com/cookiegames/smartcookie/browser/tabs/TabsDesktopAdapter.kt +++ b/app/src/main/java/com/cookiegames/smartcookie/browser/tabs/TabsDesktopAdapter.kt @@ -67,7 +67,7 @@ class TabsDesktopAdapter( private fun updateViewHolderAppearance(viewHolder: TabViewHolder, favicon: Bitmap?, isForeground: Boolean) { if (isForeground) { val foregroundDrawable = resources.getDrawable(R.drawable.desktop_tab_selected) - foregroundDrawable.tint(ThemeUtils.getPrimaryColor(uiController as Context)) + foregroundDrawable.tint(ThemeUtils.getColorBackground(uiController as Context)) if (uiController.isColorMode()) { foregroundDrawable.tint(uiController.getUiColor()) } @@ -76,7 +76,7 @@ class TabsDesktopAdapter( uiController.changeToolbarBackground(favicon, foregroundDrawable) } else { val backgroundDrawable = resources.getDrawable(R.drawable.desktop_tab) - backgroundDrawable.tint(Utils.mixTwoColors(ThemeUtils.getPrimaryColor(uiController as Context), Color.BLACK, 0.85f)) + backgroundDrawable.tint(Utils.mixTwoColors(ThemeUtils.getColorBackground(uiController as Context), Color.BLACK, 0.85f)) TextViewCompat.setTextAppearance(viewHolder.txtTitle, R.style.normalText) viewHolder.layout.background = backgroundDrawable } diff --git a/app/src/main/java/com/cookiegames/smartcookie/browser/tabs/TabsDesktopView.kt b/app/src/main/java/com/cookiegames/smartcookie/browser/tabs/TabsDesktopView.kt index 666af5e2..eab82c65 100644 --- a/app/src/main/java/com/cookiegames/smartcookie/browser/tabs/TabsDesktopView.kt +++ b/app/src/main/java/com/cookiegames/smartcookie/browser/tabs/TabsDesktopView.kt @@ -40,7 +40,7 @@ class TabsDesktopView @JvmOverloads constructor( private val tabList: RecyclerView init { - setBackgroundColor(Utils.mixTwoColors(ThemeUtils.getPrimaryColor(uiController as Context), Color.BLACK, 0.85f)) + setBackgroundColor(Utils.mixTwoColors(ThemeUtils.getColorBackground(uiController as Context), Color.BLACK, 0.85f)) context.inflater.inflate(R.layout.tab_strip, this, true) findViewById(R.id.new_tab_button).apply { setColorFilter(ThemeUtils.getTextColor(uiController as Context)) @@ -73,7 +73,7 @@ class TabsDesktopView @JvmOverloads constructor( setHasFixedSize(true) } - val backgroundColor = Utils.mixTwoColors(ThemeUtils.getPrimaryColor(uiController as Context), Color.BLACK, 0.85f) + val backgroundColor = Utils.mixTwoColors(ThemeUtils.getColorBackground(uiController as Context), Color.BLACK, 0.85f) tabList.setBackgroundColor(backgroundColor) } diff --git a/app/src/main/java/com/cookiegames/smartcookie/utils/ThemeUtils.java b/app/src/main/java/com/cookiegames/smartcookie/utils/ThemeUtils.java index f84ddef3..6587a182 100644 --- a/app/src/main/java/com/cookiegames/smartcookie/utils/ThemeUtils.java +++ b/app/src/main/java/com/cookiegames/smartcookie/utils/ThemeUtils.java @@ -186,4 +186,15 @@ public static Bitmap createThemedBitmap(@NonNull Context context, @DrawableRes i public static int getTextColor(@NonNull Context context) { return getColor(context, android.R.attr.editTextColor); } + + /** + * Gets the surface color for the current theme. + * + * @param context the context to use. + * @return a surface color. + */ + @ColorInt + public static int getColorBackground(@NonNull Context context) { + return getColor(context, android.R.attr.colorBackground); + } }