diff --git a/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/BrowserToolbar.kt b/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/BrowserToolbar.kt index 092ecd2a609..0510d94fcad 100644 --- a/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/BrowserToolbar.kt +++ b/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/BrowserToolbar.kt @@ -25,7 +25,7 @@ import mozilla.components.browser.toolbar.edit.EditToolbar import mozilla.components.concept.toolbar.AutocompleteDelegate import mozilla.components.concept.toolbar.AutocompleteResult import mozilla.components.concept.toolbar.Toolbar -import mozilla.components.concept.toolbar.Toolbar.PermissionHighlights +import mozilla.components.concept.toolbar.Toolbar.Highlight import mozilla.components.support.base.android.Padding import mozilla.components.support.base.log.logger.Logger import mozilla.components.ui.autocomplete.AutocompleteView @@ -112,10 +112,10 @@ class BrowserToolbar @JvmOverloads constructor( get() = display.siteSecurity set(value) { display.siteSecurity = value } - override var permissionHighlights: PermissionHighlights = PermissionHighlights.NONE + override var highlight: Highlight = Highlight.NONE set(value) { if (field != value) { - display.setPermissionIndicator(value) + display.setHighlight(value) field = value } } diff --git a/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/DisplayToolbar.kt b/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/DisplayToolbar.kt index fb28749a59a..915e5a33178 100644 --- a/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/DisplayToolbar.kt +++ b/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/DisplayToolbar.kt @@ -78,7 +78,7 @@ class DisplayToolbar internal constructor( SECURITY, TRACKING_PROTECTION, EMPTY, - PERMISSION_HIGHLIGHTS + HIGHLIGHT } /** @@ -93,7 +93,7 @@ class DisplayToolbar internal constructor( * @property text Text color of the URL. * @property trackingProtection Color tint for the tracking protection icons. * @property separator Color tint for the separator shown between indicators. - * @property permissionHighlights Color tint for the permission indicator. + * @property highlight Color tint for the highlight icon. * * Set/Get the site security icon colours. It uses a pair of color integers which represent the * insecure and secure colours respectively. @@ -108,7 +108,7 @@ class DisplayToolbar internal constructor( @ColorInt val text: Int, @ColorInt val trackingProtection: Int?, @ColorInt val separator: Int, - @ColorInt val permissionHighlights: Int? + @ColorInt val highlight: Int? ) /** @@ -121,23 +121,16 @@ class DisplayToolbar internal constructor( * enabled and no trackers have been blocked. * @property trackingProtectionException An icon that is shown if tracking protection is enabled * but the current page is in the "exception list". - * @property permissionHighlights An icon that is shown if any site permission needs to be brought - * to the user's attention. + * @property highlight An icon that is shown if any event needs to be brought + * to the user's attention. Like the autoplay permission been blocked. */ data class Icons( val emptyIcon: Drawable?, val trackingProtectionTrackersBlocked: Drawable, val trackingProtectionNothingBlocked: Drawable, val trackingProtectionException: Drawable, - val permissionHighlights: PermissionHighlights - ) { - /** - * Icons for site permission indicators. - */ - data class PermissionHighlights( - val autoPlayBlocked: Drawable - ) - } + val highlight: Drawable + ) /** * Gravity enum for positioning the progress bar. @@ -176,7 +169,7 @@ class DisplayToolbar internal constructor( } } }, - permissionIndicator = rootView.findViewById(R.id.mozac_browser_toolbar_permission_indicator) + highlight = rootView.findViewById(R.id.mozac_browser_toolbar_permission_indicator) ) /** @@ -192,7 +185,7 @@ class DisplayToolbar internal constructor( text = views.origin.textColor, trackingProtection = null, separator = ContextCompat.getColor(context, R.color.photonGrey80), - permissionHighlights = null + highlight = null ) set(value) { field = value @@ -210,8 +203,8 @@ class DisplayToolbar internal constructor( views.trackingProtectionIndicator.setColorFilter(value.trackingProtection) } - if (value.permissionHighlights != null) { - views.permissionIndicator.setTint(value.permissionHighlights) + if (value.highlight != null) { + views.highlight.setTint(value.highlight) } } @@ -229,9 +222,8 @@ class DisplayToolbar internal constructor( trackingProtectionException = requireNotNull( getDrawable(context, TrackingProtectionIconView.DEFAULT_ICON_OFF_FOR_A_SITE) ), - permissionHighlights = Icons.PermissionHighlights( - autoPlayBlocked = - requireNotNull(getDrawable(context, R.drawable.mozac_ic_autoplay_blocked)) + highlight = requireNotNull( + getDrawable(context, R.drawable.mozac_dot_notification) ) ) set(value) { @@ -244,7 +236,7 @@ class DisplayToolbar internal constructor( value.trackingProtectionTrackersBlocked, value.trackingProtectionException ) - views.permissionIndicator.setIcons(value.permissionHighlights) + views.highlight.setIcon(value.highlight) } /** @@ -298,29 +290,6 @@ class DisplayToolbar internal constructor( } } - /** - * Sets a listener to be invoked when the site permission indicator icon is clicked. - */ - fun setOnPermissionIndicatorClickedListener(listener: (() -> Unit)?) { - if (listener == null) { - views.permissionIndicator.setOnClickListener(null) - views.permissionIndicator.background = null - } else { - views.permissionIndicator.setOnClickListener { - listener.invoke() - } - - val outValue = TypedValue() - context.theme.resolveAttribute( - android.R.attr.selectableItemBackgroundBorderless, - outValue, - true - ) - - views.permissionIndicator.setBackgroundResource(outValue.resourceId) - } - } - /** * Sets a lambda to be invoked when the menu is dismissed */ @@ -470,8 +439,8 @@ class DisplayToolbar internal constructor( View.GONE } - views.permissionIndicator.visibility = if (!urlEmpty && indicators.contains(Indicators.PERMISSION_HIGHLIGHTS)) { - setPermissionIndicator(toolbar.permissionHighlights) + views.highlight.visibility = if (!urlEmpty && indicators.contains(Indicators.HIGHLIGHT)) { + setHighlight(toolbar.highlight) } else { View.GONE } @@ -549,14 +518,14 @@ class DisplayToolbar internal constructor( updateSeparatorVisibility() } - internal fun setPermissionIndicator(state: Toolbar.PermissionHighlights): Int { - if (!indicators.contains(Indicators.PERMISSION_HIGHLIGHTS)) { - return views.permissionIndicator.visibility + internal fun setHighlight(state: Toolbar.Highlight): Int { + if (!indicators.contains(Indicators.HIGHLIGHT)) { + return views.highlight.visibility } - views.permissionIndicator.permissionHighlights = state + views.highlight.state = state - return views.permissionIndicator.visibility + return views.highlight.visibility } internal fun onStop() { @@ -685,5 +654,5 @@ internal class DisplayToolbarViews( val trackingProtectionIndicator: TrackingProtectionIconView, val origin: OriginView, val progress: ProgressBar, - val permissionIndicator: PermissionHighlightsIconView + val highlight: HighlightView ) diff --git a/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/PermissionHighlightsIconView.kt b/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/HighlightView.kt similarity index 62% rename from components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/PermissionHighlightsIconView.kt rename to components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/HighlightView.kt index 89a6cc899fa..7064f75f280 100644 --- a/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/PermissionHighlightsIconView.kt +++ b/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/HighlightView.kt @@ -12,14 +12,14 @@ import androidx.appcompat.content.res.AppCompatResources import androidx.appcompat.widget.AppCompatImageView import androidx.core.view.isVisible import mozilla.components.browser.toolbar.R -import mozilla.components.concept.toolbar.Toolbar.PermissionHighlights -import mozilla.components.concept.toolbar.Toolbar.PermissionHighlights.AUTOPLAY_BLOCKED -import mozilla.components.concept.toolbar.Toolbar.PermissionHighlights.NONE +import mozilla.components.concept.toolbar.Toolbar.Highlight +import mozilla.components.concept.toolbar.Toolbar.Highlight.AUTOPLAY_BLOCKED +import mozilla.components.concept.toolbar.Toolbar.Highlight.NONE /** - * Internal widget to display the different icons of site permission. + * Internal widget to display a dot notification. */ -internal class PermissionHighlightsIconView @JvmOverloads constructor( +internal class HighlightView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 @@ -29,7 +29,7 @@ internal class PermissionHighlightsIconView @JvmOverloads constructor( visibility = GONE } - var permissionHighlights: PermissionHighlights = NONE + var state: Highlight = NONE set(value) { if (value != field) { field = value @@ -38,18 +38,18 @@ internal class PermissionHighlightsIconView @JvmOverloads constructor( } @VisibleForTesting - internal var permissionTint: Int? = null + internal var highlightTint: Int? = null - private var iconAutoplayBlocked: Drawable = - requireNotNull(AppCompatResources.getDrawable(context, DEFAULT_ICON_AUTOPLAY_BLOCKED)) + private var highlightIcon: Drawable = + requireNotNull(AppCompatResources.getDrawable(context, DEFAULT_ICON)) fun setTint(tint: Int) { - permissionTint = tint + highlightTint = tint setColorFilter(tint) } - fun setIcons(icons: DisplayToolbar.Icons.PermissionHighlights) { - this.iconAutoplayBlocked = icons.autoPlayBlocked + fun setIcon(icons: Drawable) { + this.highlightIcon = icons updateIcon() } @@ -57,7 +57,7 @@ internal class PermissionHighlightsIconView @JvmOverloads constructor( @Synchronized @VisibleForTesting internal fun updateIcon() { - val update = permissionHighlights.toUpdate() + val update = state.toUpdate() isVisible = update.visible @@ -67,18 +67,17 @@ internal class PermissionHighlightsIconView @JvmOverloads constructor( null } - permissionTint?.let { setColorFilter(it) } + highlightTint?.let { setColorFilter(it) } setImageDrawable(update.drawable) } companion object { - val DEFAULT_ICON_AUTOPLAY_BLOCKED = - R.drawable.mozac_ic_autoplay_blocked + val DEFAULT_ICON = R.drawable.mozac_dot_notification } - private fun PermissionHighlights.toUpdate(): Update = when (this) { + private fun Highlight.toUpdate(): Update = when (this) { AUTOPLAY_BLOCKED -> Update( - iconAutoplayBlocked, + highlightIcon, R.string.mozac_browser_toolbar_content_description_autoplay_blocked, true) diff --git a/components/browser/toolbar/src/main/res/drawable/mozac_dot_notification.xml b/components/browser/toolbar/src/main/res/drawable/mozac_dot_notification.xml new file mode 100644 index 00000000000..5469b822afc --- /dev/null +++ b/components/browser/toolbar/src/main/res/drawable/mozac_dot_notification.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/components/browser/toolbar/src/main/res/layout/mozac_browser_toolbar_displaytoolbar.xml b/components/browser/toolbar/src/main/res/layout/mozac_browser_toolbar_displaytoolbar.xml index ef0791a9796..f540eec2d00 100644 --- a/components/browser/toolbar/src/main/res/layout/mozac_browser_toolbar_displaytoolbar.xml +++ b/components/browser/toolbar/src/main/res/layout/mozac_browser_toolbar_displaytoolbar.xml @@ -83,20 +83,18 @@ app:layout_constraintTop_toTopOf="parent" app:srcCompat="@drawable/mozac_ic_site_security" /> - + android:tint="@color/photonBlue40" + app:srcCompat="@drawable/mozac_dot_notification" /> @@ -106,8 +104,9 @@ android:layout_height="40dp" android:layout_marginTop="8dp" app:layout_constraintEnd_toStartOf="@+id/mozac_browser_toolbar_page_actions" - app:layout_constraintStart_toEndOf="@+id/mozac_browser_toolbar_permission_indicator" + app:layout_constraintStart_toEndOf="@+id/mozac_browser_toolbar_security_indicator" app:layout_constraintTop_toTopOf="parent" + app:layout_goneMarginStart="8dp" app:layout_goneMarginTop="8dp" /> diff --git a/components/browser/toolbar/src/test/java/mozilla/components/browser/toolbar/display/DisplayToolbarTest.kt b/components/browser/toolbar/src/test/java/mozilla/components/browser/toolbar/display/DisplayToolbarTest.kt index 44b53c9762c..356d3f8be97 100644 --- a/components/browser/toolbar/src/test/java/mozilla/components/browser/toolbar/display/DisplayToolbarTest.kt +++ b/components/browser/toolbar/src/test/java/mozilla/components/browser/toolbar/display/DisplayToolbarTest.kt @@ -97,15 +97,15 @@ class DisplayToolbarTest { } @Test - fun `permissionViewColor will change the color of the permissionIconView`() { + fun `highlightView will change the color of the dot`() { val (_, displayToolbar) = createDisplayToolbar() - assertNull(displayToolbar.views.permissionIndicator.colorFilter) + assertNull(displayToolbar.views.highlight.colorFilter) - displayToolbar.colors = displayToolbar.colors.copy(permissionHighlights = Color.BLUE) + displayToolbar.colors = displayToolbar.colors.copy(highlight = Color.BLUE) - assertNotNull(displayToolbar.views.permissionIndicator.colorFilter) - assertNotNull(displayToolbar.views.permissionIndicator.permissionTint) + assertNotNull(displayToolbar.views.highlight.colorFilter) + assertNotNull(displayToolbar.views.highlight.highlightTint) } @Test @@ -182,29 +182,29 @@ class DisplayToolbarTest { } @Test - fun `setPermissionIcons will forward to PermissionHighlightsIconView`() { + fun `setHighlight will forward to HighlightView`() { val (_, displayToolbar) = createDisplayToolbar() - val oldPermissionIcon = displayToolbar.views.permissionIndicator.drawable + val oldPermissionIcon = displayToolbar.views.highlight.drawable assertNotNull(oldPermissionIcon) - val drawable1 = testContext.getDrawable(PermissionHighlightsIconView.DEFAULT_ICON_AUTOPLAY_BLOCKED)!! + val drawable1 = testContext.getDrawable(HighlightView.DEFAULT_ICON)!! - displayToolbar.indicators = listOf(DisplayToolbar.Indicators.PERMISSION_HIGHLIGHTS) + displayToolbar.indicators = listOf(DisplayToolbar.Indicators.HIGHLIGHT) displayToolbar.icons = displayToolbar.icons.copy( - permissionHighlights = DisplayToolbar.Icons.PermissionHighlights(drawable1) + highlight = drawable1 ) assertNotEquals( oldPermissionIcon, - displayToolbar.views.permissionIndicator.drawable + displayToolbar.views.highlight.drawable ) - displayToolbar.setPermissionIndicator(Toolbar.PermissionHighlights.AUTOPLAY_BLOCKED) + displayToolbar.setHighlight(Toolbar.Highlight.AUTOPLAY_BLOCKED) assertNotEquals( oldPermissionIcon, - displayToolbar.views.permissionIndicator.drawable + displayToolbar.views.highlight.drawable ) } @@ -704,39 +704,6 @@ class DisplayToolbarTest { assertNull(displayToolbar.views.securityIndicator.background) } - @Test - fun `clicking on permission indicator invokes listener`() { - var listenerInvoked = false - - val (_, displayToolbar) = createDisplayToolbar() - - assertNull(displayToolbar.views.permissionIndicator.background) - - displayToolbar.setOnPermissionIndicatorClickedListener { - listenerInvoked = true - } - - assertNotNull(displayToolbar.views.permissionIndicator.background) - - displayToolbar.views.permissionIndicator.performClick() - - assertTrue(listenerInvoked) - - listenerInvoked = false - - displayToolbar.setOnPermissionIndicatorClickedListener { } - - assertNotNull(displayToolbar.views.permissionIndicator.background) - - displayToolbar.views.permissionIndicator.performClick() - - assertFalse(listenerInvoked) - - displayToolbar.setOnPermissionIndicatorClickedListener(null) - - assertNull(displayToolbar.views.permissionIndicator.background) - } - @Test fun `Security icon has proper content description`() { val (_, displayToolbar) = createDisplayToolbar() diff --git a/components/browser/toolbar/src/test/java/mozilla/components/browser/toolbar/display/PermissionHighlightsIconViewTest.kt b/components/browser/toolbar/src/test/java/mozilla/components/browser/toolbar/display/HighlightViewTest.kt similarity index 64% rename from components/browser/toolbar/src/test/java/mozilla/components/browser/toolbar/display/PermissionHighlightsIconViewTest.kt rename to components/browser/toolbar/src/test/java/mozilla/components/browser/toolbar/display/HighlightViewTest.kt index 50aab0a1a48..9f2fb539c39 100644 --- a/components/browser/toolbar/src/test/java/mozilla/components/browser/toolbar/display/PermissionHighlightsIconViewTest.kt +++ b/components/browser/toolbar/src/test/java/mozilla/components/browser/toolbar/display/HighlightViewTest.kt @@ -7,8 +7,8 @@ package mozilla.components.browser.toolbar.display import androidx.core.view.isVisible import androidx.test.ext.junit.runners.AndroidJUnit4 import mozilla.components.browser.toolbar.R -import mozilla.components.concept.toolbar.Toolbar.PermissionHighlights.NONE -import mozilla.components.concept.toolbar.Toolbar.PermissionHighlights.AUTOPLAY_BLOCKED +import mozilla.components.concept.toolbar.Toolbar.Highlight.NONE +import mozilla.components.concept.toolbar.Toolbar.Highlight.AUTOPLAY_BLOCKED import mozilla.components.support.test.robolectric.testContext import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse @@ -21,22 +21,22 @@ import org.mockito.Mockito.spy import org.mockito.Mockito.verify @RunWith(AndroidJUnit4::class) -class PermissionHighlightsIconViewTest { +class HighlightViewTest { @Test fun `after setting tint, can get trackingProtectionTint`() { - val view = PermissionHighlightsIconView(testContext) + val view = HighlightView(testContext) view.setTint(android.R.color.black) - assertEquals(android.R.color.black, view.permissionTint) + assertEquals(android.R.color.black, view.highlightTint) } @Test - fun `setting permissionHighlights status will trigger an icon updated`() { - val view = PermissionHighlightsIconView(testContext) + fun `setting status will trigger an icon updated`() { + val view = HighlightView(testContext) - view.permissionHighlights = AUTOPLAY_BLOCKED + view.state = AUTOPLAY_BLOCKED - assertEquals(AUTOPLAY_BLOCKED, view.permissionHighlights) + assertEquals(AUTOPLAY_BLOCKED, view.state) assertTrue(view.isVisible) assertNotNull(view.drawable) assertEquals( @@ -44,9 +44,9 @@ class PermissionHighlightsIconViewTest { testContext.getString(R.string.mozac_browser_toolbar_content_description_autoplay_blocked) ) - view.permissionHighlights = NONE + view.state = NONE - assertEquals(NONE, view.permissionHighlights) + assertEquals(NONE, view.state) assertNull(view.drawable) assertFalse(view.isVisible) assertNull(view.contentDescription) @@ -54,12 +54,12 @@ class PermissionHighlightsIconViewTest { @Test fun `setIcons will trigger an icon updated`() { - val view = spy(PermissionHighlightsIconView(testContext)) + val view = spy(HighlightView(testContext)) - view.setIcons(DisplayToolbar.Icons.PermissionHighlights( + view.setIcon( testContext.getDrawable( TrackingProtectionIconView.DEFAULT_ICON_ON_NO_TRACKERS_BLOCKED - )!!)) + )!!) verify(view).updateIcon() } diff --git a/components/concept/toolbar/src/main/java/mozilla/components/concept/toolbar/Toolbar.kt b/components/concept/toolbar/src/main/java/mozilla/components/concept/toolbar/Toolbar.kt index 5cef141a280..b83711d2286 100644 --- a/components/concept/toolbar/src/main/java/mozilla/components/concept/toolbar/Toolbar.kt +++ b/components/concept/toolbar/src/main/java/mozilla/components/concept/toolbar/Toolbar.kt @@ -48,9 +48,9 @@ interface Toolbar { var siteSecure: SiteSecurity /** - * Sets/Gets the site site permission indicator to be displayed on the toolbar. + * Sets/Gets the highlight icon to be displayed on the toolbar. */ - var permissionHighlights: PermissionHighlights + var highlight: Highlight /** * Sets/Gets the site tracking protection state to be displayed on the toolbar. @@ -415,15 +415,15 @@ interface Toolbar { } /** - * Indicates which site permission indicator a site should show. + * Indicates the reason why a highlight icon is shown or hidden. */ - enum class PermissionHighlights { + enum class Highlight { /** * The site has autoplay blocked. */ AUTOPLAY_BLOCKED, /** - * The site does not have any permission indicator to show. + * The site does not show a dot indicator. */ NONE } diff --git a/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/feature/CustomTabSessionTitleObserverTest.kt b/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/feature/CustomTabSessionTitleObserverTest.kt index 54ab414a3c5..d6865f7e7ef 100644 --- a/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/feature/CustomTabSessionTitleObserverTest.kt +++ b/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/feature/CustomTabSessionTitleObserverTest.kt @@ -70,7 +70,7 @@ class CustomTabSessionTitleObserverTest { private class MockToolbar : Toolbar { override var title: String = "" - override var permissionHighlights: Toolbar.PermissionHighlights = Toolbar.PermissionHighlights.NONE + override var highlight: Toolbar.Highlight = Toolbar.Highlight.NONE override var url: CharSequence by ThrowProperty() override var private: Boolean by ThrowProperty() override var siteSecure: Toolbar.SiteSecurity by ThrowProperty() diff --git a/components/feature/toolbar/src/main/java/mozilla/components/feature/toolbar/ToolbarPresenter.kt b/components/feature/toolbar/src/main/java/mozilla/components/feature/toolbar/ToolbarPresenter.kt index 779b1f8e736..fe55778d658 100644 --- a/components/feature/toolbar/src/main/java/mozilla/components/feature/toolbar/ToolbarPresenter.kt +++ b/components/feature/toolbar/src/main/java/mozilla/components/feature/toolbar/ToolbarPresenter.kt @@ -14,7 +14,7 @@ import mozilla.components.browser.state.state.BrowserState import mozilla.components.browser.state.state.SessionState import mozilla.components.browser.state.store.BrowserStore import mozilla.components.concept.toolbar.Toolbar -import mozilla.components.concept.toolbar.Toolbar.PermissionHighlights +import mozilla.components.concept.toolbar.Toolbar.Highlight import mozilla.components.concept.toolbar.Toolbar.SiteTrackingProtection import mozilla.components.feature.toolbar.internal.URLRenderer import mozilla.components.lib.state.ext.flowScoped @@ -81,16 +81,16 @@ class ToolbarPresenter( else -> SiteTrackingProtection.OFF_GLOBALLY } - updatePermissionIndicator(tab) + updateHighlight(tab) } else { clear() } } - private fun updatePermissionIndicator(tab: SessionState) { - toolbar.permissionHighlights = when { - tab.content.permissionHighlights.isAutoPlayBlocking -> PermissionHighlights.AUTOPLAY_BLOCKED - else -> PermissionHighlights.NONE + private fun updateHighlight(tab: SessionState) { + toolbar.highlight = when { + tab.content.permissionHighlights.isAutoPlayBlocking -> Highlight.AUTOPLAY_BLOCKED + else -> Highlight.NONE } } @@ -104,6 +104,6 @@ class ToolbarPresenter( toolbar.siteSecure = Toolbar.SiteSecurity.INSECURE toolbar.siteTrackingProtection = SiteTrackingProtection.OFF_GLOBALLY - toolbar.permissionHighlights = PermissionHighlights.NONE + toolbar.highlight = Highlight.NONE } } diff --git a/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarAutocompleteFeatureTest.kt b/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarAutocompleteFeatureTest.kt index 0fc8c5f9f15..7e4fee840dd 100644 --- a/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarAutocompleteFeatureTest.kt +++ b/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarAutocompleteFeatureTest.kt @@ -35,7 +35,7 @@ import org.mockito.Mockito.verify class ToolbarAutocompleteFeatureTest { class TestToolbar : Toolbar { - override var permissionHighlights: Toolbar.PermissionHighlights = Toolbar.PermissionHighlights.NONE + override var highlight: Toolbar.Highlight = Toolbar.Highlight.NONE override var siteTrackingProtection: Toolbar.SiteTrackingProtection = Toolbar.SiteTrackingProtection.OFF_GLOBALLY override var title: String = "" diff --git a/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarInteractorTest.kt b/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarInteractorTest.kt index 7e3c96dde64..a3fffa67cc3 100644 --- a/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarInteractorTest.kt +++ b/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarInteractorTest.kt @@ -19,7 +19,7 @@ import org.mockito.Mockito.spy class ToolbarInteractorTest { class TestToolbar : Toolbar { - override var permissionHighlights: Toolbar.PermissionHighlights = Toolbar.PermissionHighlights.NONE + override var highlight: Toolbar.Highlight = Toolbar.Highlight.NONE override var url: CharSequence = "" override var siteSecure: Toolbar.SiteSecurity = Toolbar.SiteSecurity.INSECURE override var private: Boolean = false diff --git a/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarPresenterTest.kt b/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarPresenterTest.kt index 066bbde800f..042ad99133e 100644 --- a/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarPresenterTest.kt +++ b/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarPresenterTest.kt @@ -164,7 +164,7 @@ class ToolbarPresenterTest { verify(toolbar).displayProgress(60) verify(toolbar).siteSecure = Toolbar.SiteSecurity.SECURE verify(toolbar).siteTrackingProtection = Toolbar.SiteTrackingProtection.OFF_GLOBALLY - verify(toolbar).permissionHighlights = Toolbar.PermissionHighlights.NONE + verify(toolbar).highlight = Toolbar.Highlight.NONE verifyNoMoreInteractions(toolbarPresenter.renderer) verifyNoMoreInteractions(toolbar) @@ -279,7 +279,7 @@ class ToolbarPresenterTest { verify(toolbar).displayProgress(60) verify(toolbar).siteSecure = Toolbar.SiteSecurity.SECURE verify(toolbar).siteTrackingProtection = Toolbar.SiteTrackingProtection.OFF_GLOBALLY - verify(toolbar).permissionHighlights = Toolbar.PermissionHighlights.NONE + verify(toolbar).highlight = Toolbar.Highlight.NONE verifyNoMoreInteractions(toolbarPresenter.renderer) verifyNoMoreInteractions(toolbar) } @@ -326,7 +326,7 @@ class ToolbarPresenterTest { verify(toolbar).displayProgress(60) verify(toolbar).siteSecure = Toolbar.SiteSecurity.SECURE verify(toolbar).siteTrackingProtection = Toolbar.SiteTrackingProtection.OFF_GLOBALLY - verify(toolbar).permissionHighlights = Toolbar.PermissionHighlights.NONE + verify(toolbar).highlight = Toolbar.Highlight.NONE verifyNoMoreInteractions(toolbarPresenter.renderer) verifyNoMoreInteractions(toolbar) @@ -339,7 +339,7 @@ class ToolbarPresenterTest { verify(toolbar).displayProgress(90) verify(toolbar).siteSecure = Toolbar.SiteSecurity.INSECURE verify(toolbar).siteTrackingProtection = Toolbar.SiteTrackingProtection.ON_NO_TRACKERS_BLOCKED - verify(toolbar).permissionHighlights = Toolbar.PermissionHighlights.AUTOPLAY_BLOCKED + verify(toolbar).highlight = Toolbar.Highlight.AUTOPLAY_BLOCKED verifyNoMoreInteractions(toolbarPresenter.renderer) verifyNoMoreInteractions(toolbar) } @@ -394,7 +394,7 @@ class ToolbarPresenterTest { } @Test - fun `displaying different permissions highlights states`() { + fun `displaying different dot notification states`() { val toolbar: Toolbar = mock() val store = spy(BrowserStore( BrowserState( @@ -418,19 +418,19 @@ class ToolbarPresenterTest { testDispatcher.advanceUntilIdle() - verify(toolbar).permissionHighlights = Toolbar.PermissionHighlights.NONE + verify(toolbar).highlight = Toolbar.Highlight.NONE store.dispatch(UpdatePermissionHighlightsStateAction("tab", PermissionHighlightsState(true))).joinBlocking() testDispatcher.advanceUntilIdle() - verify(toolbar).permissionHighlights = Toolbar.PermissionHighlights.AUTOPLAY_BLOCKED + verify(toolbar).highlight = Toolbar.Highlight.AUTOPLAY_BLOCKED store.dispatch(UpdatePermissionHighlightsStateAction("tab", PermissionHighlightsState())).joinBlocking() testDispatcher.advanceUntilIdle() - verify(toolbar, times(2)).permissionHighlights = Toolbar.PermissionHighlights.NONE + verify(toolbar, times(2)).highlight = Toolbar.Highlight.NONE } @Test @@ -466,6 +466,6 @@ class ToolbarPresenterTest { verify(toolbar).displayProgress(0) verify(toolbar).siteSecure = Toolbar.SiteSecurity.INSECURE verify(toolbar).siteTrackingProtection = Toolbar.SiteTrackingProtection.OFF_GLOBALLY - verify(toolbar).permissionHighlights = Toolbar.PermissionHighlights.NONE + verify(toolbar).highlight = Toolbar.Highlight.NONE } } diff --git a/docs/changelog.md b/docs/changelog.md index 4651854e434..ac88c0524f8 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -43,15 +43,18 @@ permalink: /changelog/ * **feature-app-links** * ⚠️ **This is a breaking change**: Migrated this component to use `browser-state` instead of `browser-session`. It is now required to pass a `BrowserStore` instance (instead of `SessionManager`) to `AppLinksFeature`. +* **browser-toolbar** + * ⚠️ **This is a breaking change**: The API for showing the site permission indicators has been replaced to API to show an dot notification instead, for more information see [#9378](https://github.com/mozilla-mobile/android-components/issues/9378). + * **service-nimbus** * Added a `NimbusDisabled` class to provide implementers who are not able to use Nimbus yet. - + * **support-base** * 🌟 Add an `ActivityResultHandler` for features that want to consume the result. - + * **concept-engine** * 🌟 Added a new `ActivityDelegate` for handling intent requests from the engine. - + * **browser-engine-gecko(-nightly)** * Added `GeckoActivityDelegate` for the GeckoView `activityDelegate`. diff --git a/samples/browser/src/main/java/org/mozilla/samples/browser/BaseBrowserFragment.kt b/samples/browser/src/main/java/org/mozilla/samples/browser/BaseBrowserFragment.kt index 64fb1cde7d5..34498adb09b 100644 --- a/samples/browser/src/main/java/org/mozilla/samples/browser/BaseBrowserFragment.kt +++ b/samples/browser/src/main/java/org/mozilla/samples/browser/BaseBrowserFragment.kt @@ -88,18 +88,8 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler { owner = this, view = layout) - layout.toolbar.display.setOnPermissionIndicatorClickedListener { - sitePermissionsFeature.withFeature { feature -> - feature.sitePermissionsRules = feature.sitePermissionsRules?.copy( - autoplayAudible = AutoplayAction.ALLOWED, - autoplayInaudible = AutoplayAction.ALLOWED - ) - components.sessionUseCases.reload() - } - } - layout.toolbar.display.indicators += listOf( - DisplayToolbar.Indicators.TRACKING_PROTECTION + DisplayToolbar.Indicators.TRACKING_PROTECTION, DisplayToolbar.Indicators.HIGHLIGHT ) swipeRefreshFeature.set(