forked from mozilla-mobile/android-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue mozilla-mobile#3647 - Bring back siteSecurityColor
- Loading branch information
Showing
14 changed files
with
195 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
.../toolbar/src/main/java/mozilla/components/browser/toolbar/display/SiteSecurityIconView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package mozilla.components.browser.toolbar.display | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.View | ||
import androidx.appcompat.widget.AppCompatImageView | ||
import mozilla.components.browser.toolbar.R | ||
import mozilla.components.concept.toolbar.Toolbar.SiteSecurity | ||
|
||
/** | ||
* Internal widget to display the different icons of site security, relies on the | ||
* [SiteSecurity] state of each page. | ||
*/ | ||
internal class SiteSecurityIconView @JvmOverloads constructor( | ||
context: Context, | ||
attrs: AttributeSet? = null, | ||
defStyleAttr: Int = 0 | ||
) : AppCompatImageView(context, attrs, defStyleAttr) { | ||
|
||
// We allow null here because in some situations, onCreateDrawableState is getting called from | ||
// the super() constructor on the View class, way before this class properties get | ||
// initialized causing a null pointer exception. | ||
// See for more details: https://github.com/mozilla-mobile/android-components/issues/4058 | ||
var siteSecurity: SiteSecurity? = SiteSecurity.INSECURE | ||
set(value) { | ||
if (value != field) { | ||
field = value | ||
refreshDrawableState() | ||
} | ||
|
||
field = value | ||
} | ||
|
||
override fun onCreateDrawableState(extraSpace: Int): IntArray { | ||
return when (siteSecurity) { | ||
SiteSecurity.INSECURE, null -> super.onCreateDrawableState(extraSpace) | ||
SiteSecurity.SECURE -> { | ||
val drawableState = super.onCreateDrawableState(extraSpace + 1) | ||
View.mergeDrawableStates(drawableState, intArrayOf(R.attr.state_site_secure)) | ||
drawableState | ||
} | ||
} | ||
} | ||
} |
67 changes: 0 additions & 67 deletions
67
...ser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/SiteSecurityIcons.kt
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
components/browser/toolbar/src/main/res/drawable/mozac_ic_site_security.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- This Source Code Form is subject to the terms of the Mozilla Public | ||
- License, v. 2.0. If a copy of the MPL was not distributed with this | ||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ac="http://schemas.android.com/apk/res-auto"> | ||
<item android:drawable="@drawable/mozac_ic_lock" ac:state_site_secure="true" /> | ||
<item android:drawable="@drawable/mozac_ic_globe" /> | ||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.