[fenix] For https://github.com/mozilla-mobile/fenix/issues/5334: fix ETP shield coloring on custom private tabs

pull/600/head
Severin Rudie 5 years ago committed by Emily Kager
parent ab0bc61cb3
commit 9a0b3f6557

@ -8,8 +8,6 @@ import android.app.Activity
import android.view.View import android.view.View
import android.view.ViewGroup.MarginLayoutParams import android.view.ViewGroup.MarginLayoutParams
import androidx.appcompat.content.res.AppCompatResources 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.session.SessionManager
import mozilla.components.browser.toolbar.BrowserToolbar import mozilla.components.browser.toolbar.BrowserToolbar
import mozilla.components.browser.toolbar.display.DisplayToolbar 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.R
import org.mozilla.fenix.components.toolbar.ToolbarMenu import org.mozilla.fenix.components.toolbar.ToolbarMenu
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.theme.ThemeManager
class CustomTabsIntegration( class CustomTabsIntegration(
sessionManager: SessionManager, sessionManager: SessionManager,
@ -43,14 +40,20 @@ class CustomTabsIntegration(
} }
} }
val task = LottieCompositionFactory val uncoloredEtpShield = AppCompatResources.getDrawable(
.fromRawRes(
activity, 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 toolbar.display.displayIndicatorSeparator = false
if (activity.settings().shouldUseTrackingProtection) { 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 // If in private mode, override toolbar background to use private color
// See #5334 // See #5334
if (isPrivate) { if (isPrivate) {

Loading…
Cancel
Save