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

staging
Severin Rudie 5 years ago committed by Emily Kager
parent 45ae8cb35a
commit 957ed8aa88

@ -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,37 +40,30 @@ class CustomTabsIntegration(
} }
} }
val task = LottieCompositionFactory val uncoloredEtpShield = AppCompatResources.getDrawable(
.fromRawRes( activity,
activity, R.drawable.ic_tracking_protection_enabled
ThemeManager.resolveAttribute(R.attr.shieldLottieFile, activity) )!!
)
task.addListener { result ->
val lottieDrawable = LottieDrawable()
lottieDrawable.composition = result
toolbar.display.displayIndicatorSeparator = false toolbar.display.icons = toolbar.display.icons.copy(
if (activity.settings().shouldUseTrackingProtection) { // Custom private tab backgrounds have bad contrast against the colored shield
toolbar.display.indicators = listOf( trackingProtectionTrackersBlocked = uncoloredEtpShield,
DisplayToolbar.Indicators.SECURITY, trackingProtectionNothingBlocked = uncoloredEtpShield,
DisplayToolbar.Indicators.TRACKING_PROTECTION trackingProtectionException = AppCompatResources.getDrawable(
) activity,
} else { R.drawable.ic_tracking_protection_disabled
toolbar.display.indicators = listOf( )!!
DisplayToolbar.Indicators.SECURITY )
)
}
toolbar.display.icons = toolbar.display.icons.copy( toolbar.display.displayIndicatorSeparator = false
trackingProtectionTrackersBlocked = lottieDrawable, if (activity.settings().shouldUseTrackingProtection) {
trackingProtectionNothingBlocked = AppCompatResources.getDrawable( toolbar.display.indicators = listOf(
activity, DisplayToolbar.Indicators.SECURITY,
R.drawable.ic_tracking_protection_enabled DisplayToolbar.Indicators.TRACKING_PROTECTION
)!!, )
trackingProtectionException = AppCompatResources.getDrawable( } else {
activity, toolbar.display.indicators = listOf(
R.drawable.ic_tracking_protection_disabled DisplayToolbar.Indicators.SECURITY
)!!
) )
} }

Loading…
Cancel
Save