Skip to content

Commit

Permalink
For mozilla-mobile#11545 - Replace clearColorFilter with setColorFilt…
Browse files Browse the repository at this point in the history
…er for security icon

Clear color filter doesn't work on Api 21, 22
Even if we invalidate the view after clearColorFilter the filter is not removed, so to fix the bug
we need to use setColorFilter with color Color.Transparent
  • Loading branch information
Ionut Cristian Bedregeanu committed Jan 14, 2022
1 parent 84a50a6 commit d42bd3a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package mozilla.components.browser.toolbar.display

import android.content.Context
import android.graphics.Color
import android.graphics.Typeface
import android.graphics.drawable.Drawable
import android.util.TypedValue
Expand Down Expand Up @@ -500,12 +499,7 @@ class DisplayToolbar internal constructor(
Toolbar.SiteSecurity.INSECURE -> colors.securityIconInsecure
Toolbar.SiteSecurity.SECURE -> colors.securityIconSecure
}
if (color == Color.TRANSPARENT) {
views.securityIndicator.clearColorFilter()
} else {
views.securityIndicator.setColorFilter(color)
}

views.securityIndicator.setColorFilter(color)
views.securityIndicator.siteSecurity = siteSecurity
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,13 +648,6 @@ class DisplayToolbarTest {

assertNull(displayToolbar.views.securityIndicator.colorFilter)

displayToolbar.colors = displayToolbar.colors.copy(
securityIconSecure = Color.TRANSPARENT,
securityIconInsecure = Color.TRANSPARENT
)

assertNull(displayToolbar.views.securityIndicator.colorFilter)

displayToolbar.colors = displayToolbar.colors.copy(
securityIconSecure = Color.BLUE,
securityIconInsecure = Color.BLUE
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ permalink: /changelog/
* [Gecko](https://github.com/mozilla-mobile/android-components/blob/main/buildSrc/src/main/java/Gecko.kt)
* [Configuration](https://github.com/mozilla-mobile/android-components/blob/main/.config.yml)

* **browser-toolbar**
* 🚒 Bug fixed [issue #11545](https://github.com/mozilla-mobile/android-components/issues/11545) - `clearColorFilter` doesn't work on Api 21, 22, so the default white filter remains set.Use `setColorFilter` method for all scenarios

* **lib/publicsuffixlist**
* ⚠️ **This is a breaking change**: Removed `String.urlToTrimmedHost` extension method.

Expand Down

0 comments on commit d42bd3a

Please sign in to comment.