From bb8f80b86af049b104b625287a88e771f4b78614 Mon Sep 17 00:00:00 2001 From: Mugurell Date: Thu, 22 Sep 2022 17:11:28 +0300 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/26644 - Apply the new theme earlier to the private browsing button This will help avoid a race between the two layers of the svg, with previously only changing the color for just one. By applying the new theme to the button when needing to apply the textColor from wallpaper it will automatically use the right --- .../org/mozilla/fenix/home/HomeFragment.kt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index f8e8ff240e..7bdf823379 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -39,6 +39,7 @@ import androidx.navigation.fragment.navArgs import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearSmoothScroller import androidx.recyclerview.widget.RecyclerView.SmoothScroller +import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat import com.google.android.material.appbar.AppBarLayout import com.google.android.material.button.MaterialButton import com.google.android.material.snackbar.Snackbar @@ -993,7 +994,22 @@ class HomeFragment : Fragment() { } binding.wordmarkText.imageTintList = tintColor - binding.privateBrowsingButton.imageTintList = tintColor + + // Need to preemptively apply the new theme to the private browsing button drawable + // See https://github.com/mozilla-mobile/fenix/issues/26644#issuecomment-1254961616 + (activity as? HomeActivity)?.themeManager?.let { themeManager -> + with(binding.privateBrowsingButton) { + val drawable = VectorDrawableCompat.create( + resources, + R.drawable.private_browsing_button, + resources.newTheme().apply { + applyStyle(themeManager.currentThemeResource, true) + }, + ) + setImageDrawable(drawable) + imageTintList = tintColor + } + } } private fun observeWallpaperUpdates() {