1
0
Fork 0

For #5334: fix ETP shield coloring on custom private tabs

master
Severin Rudie 2019-12-06 11:28:52 -08:00 committed by Emily Kager
parent 45ae8cb35a
commit 957ed8aa88
1 changed files with 22 additions and 32 deletions

View File

@ -8,8 +8,6 @@ import android.app.Activity
import android.view.View
import android.view.ViewGroup.MarginLayoutParams
import androidx.appcompat.content.res.AppCompatResources
import com.airbnb.lottie.LottieCompositionFactory
import com.airbnb.lottie.LottieDrawable
import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.toolbar.BrowserToolbar
import mozilla.components.browser.toolbar.display.DisplayToolbar
@ -19,7 +17,6 @@ import mozilla.components.support.base.feature.UserInteractionHandler
import org.mozilla.fenix.R
import org.mozilla.fenix.components.toolbar.ToolbarMenu
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.theme.ThemeManager
class CustomTabsIntegration(
sessionManager: SessionManager,
@ -43,14 +40,20 @@ class CustomTabsIntegration(
}
}
val task = LottieCompositionFactory
.fromRawRes(
val uncoloredEtpShield = AppCompatResources.getDrawable(
activity,
ThemeManager.resolveAttribute(R.attr.shieldLottieFile, activity)
R.drawable.ic_tracking_protection_enabled
)!!
toolbar.display.icons = toolbar.display.icons.copy(
// Custom private tab backgrounds have bad contrast against the colored shield
trackingProtectionTrackersBlocked = uncoloredEtpShield,
trackingProtectionNothingBlocked = uncoloredEtpShield,
trackingProtectionException = AppCompatResources.getDrawable(
activity,
R.drawable.ic_tracking_protection_disabled
)!!
)
task.addListener { result ->
val lottieDrawable = LottieDrawable()
lottieDrawable.composition = result
toolbar.display.displayIndicatorSeparator = false
if (activity.settings().shouldUseTrackingProtection) {
@ -64,19 +67,6 @@ class CustomTabsIntegration(
)
}
toolbar.display.icons = toolbar.display.icons.copy(
trackingProtectionTrackersBlocked = lottieDrawable,
trackingProtectionNothingBlocked = AppCompatResources.getDrawable(
activity,
R.drawable.ic_tracking_protection_enabled
)!!,
trackingProtectionException = AppCompatResources.getDrawable(
activity,
R.drawable.ic_tracking_protection_disabled
)!!
)
}
// If in private mode, override toolbar background to use private color
// See #5334
if (isPrivate) {