From 3d9e9349c71c9acee5cc04bfbc677d555b63116d Mon Sep 17 00:00:00 2001 From: sarah541 Date: Thu, 14 Mar 2024 17:54:22 -0400 Subject: [PATCH] Bug 1877526 - Add Share and Reload icons on toolbar in the right order --- .../browser/toolbar/internal/ActionContainer.kt | 2 ++ .../java/mozilla/components/concept/toolbar/Toolbar.kt | 2 ++ .../feature/CustomTabSessionTitleObserverTest.kt | 2 ++ .../feature/toolbar/ToolbarAutocompleteFeatureTest.kt | 8 ++++++++ .../components/feature/toolbar/ToolbarInteractorTest.kt | 8 ++++++++ .../java/org/mozilla/fenix/browser/BrowserFragment.kt | 4 ++-- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/android-components/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/internal/ActionContainer.kt b/android-components/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/internal/ActionContainer.kt index efc94447ba02..71de22f30656 100644 --- a/android-components/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/internal/ActionContainer.kt +++ b/android-components/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/internal/ActionContainer.kt @@ -33,6 +33,8 @@ internal class ActionContainer @JvmOverloads constructor( ToolbarActionIdentifier.READER_MODE, ToolbarActionIdentifier.TRANSLATION, ToolbarActionIdentifier.REVIEW_QUALITY_CHECK, + ToolbarActionIdentifier.SHARE, + ToolbarActionIdentifier.RELOAD, ) init { diff --git a/android-components/components/concept/toolbar/src/main/java/mozilla/components/concept/toolbar/Toolbar.kt b/android-components/components/concept/toolbar/src/main/java/mozilla/components/concept/toolbar/Toolbar.kt index e196d54e4f94..e50a8a1ec91e 100644 --- a/android-components/components/concept/toolbar/src/main/java/mozilla/components/concept/toolbar/Toolbar.kt +++ b/android-components/components/concept/toolbar/src/main/java/mozilla/components/concept/toolbar/Toolbar.kt @@ -561,4 +561,6 @@ enum class ToolbarActionIdentifier { READER_MODE, TRANSLATION, REVIEW_QUALITY_CHECK, + SHARE, + RELOAD, } diff --git a/android-components/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/feature/CustomTabSessionTitleObserverTest.kt b/android-components/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/feature/CustomTabSessionTitleObserverTest.kt index 024180ffb8e7..56f0d073bdfe 100644 --- a/android-components/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/feature/CustomTabSessionTitleObserverTest.kt +++ b/android-components/components/feature/customtabs/src/test/java/mozilla/components/feature/customtabs/feature/CustomTabSessionTitleObserverTest.kt @@ -8,6 +8,7 @@ import mozilla.components.browser.state.state.CustomTabSessionState import mozilla.components.browser.state.state.createCustomTab import mozilla.components.concept.toolbar.AutocompleteDelegate import mozilla.components.concept.toolbar.Toolbar +import mozilla.components.concept.toolbar.ToolbarActionIdentifier import mozilla.components.support.test.ThrowProperty import mozilla.components.support.test.mock import org.junit.Assert.assertEquals @@ -82,6 +83,7 @@ class CustomTabSessionTitleObserverTest { override fun removeBrowserAction(action: Toolbar.Action) = Unit override fun invalidateActions() = Unit override fun addPageAction(action: Toolbar.Action) = Unit + override fun addPageActionInOrder(action: Toolbar.Action, identifier: ToolbarActionIdentifier) = Unit override fun removePageAction(action: Toolbar.Action) = Unit override fun addNavigationAction(action: Toolbar.Action) = Unit override fun removeNavigationAction(action: Toolbar.Action) = Unit diff --git a/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarAutocompleteFeatureTest.kt b/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarAutocompleteFeatureTest.kt index 22130d1ac6c5..20535fea2341 100644 --- a/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarAutocompleteFeatureTest.kt +++ b/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarAutocompleteFeatureTest.kt @@ -13,6 +13,7 @@ import mozilla.components.concept.toolbar.AutocompleteDelegate import mozilla.components.concept.toolbar.AutocompleteProvider import mozilla.components.concept.toolbar.AutocompleteResult import mozilla.components.concept.toolbar.Toolbar +import mozilla.components.concept.toolbar.ToolbarActionIdentifier import mozilla.components.support.test.any import mozilla.components.support.test.argumentCaptor import mozilla.components.support.test.eq @@ -83,6 +84,13 @@ class ToolbarAutocompleteFeatureTest { fail() } + override fun addPageActionInOrder( + action: Toolbar.Action, + identifier: ToolbarActionIdentifier, + ) { + fail() + } + override fun addNavigationAction(action: Toolbar.Action) { fail() } diff --git a/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarInteractorTest.kt b/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarInteractorTest.kt index 3a0f5f5a5acc..38d638bafcf3 100644 --- a/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarInteractorTest.kt +++ b/android-components/components/feature/toolbar/src/test/java/mozilla/components/feature/toolbar/ToolbarInteractorTest.kt @@ -7,6 +7,7 @@ package mozilla.components.feature.toolbar import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.toolbar.AutocompleteDelegate import mozilla.components.concept.toolbar.Toolbar +import mozilla.components.concept.toolbar.ToolbarActionIdentifier import mozilla.components.feature.session.SessionUseCases import org.junit.Assert.assertEquals import org.junit.Assert.fail @@ -66,6 +67,13 @@ class ToolbarInteractorTest { fail() } + override fun addPageActionInOrder( + action: Toolbar.Action, + identifier: ToolbarActionIdentifier, + ) { + fail() + } + override fun addNavigationAction(action: Toolbar.Action) { fail() } diff --git a/fenix/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt b/fenix/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt index 4b94bd376d56..86afa05f3aab 100644 --- a/fenix/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt +++ b/fenix/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt @@ -307,7 +307,7 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler { listener = { browserToolbarInteractor.onShareActionClicked() }, ) - browserToolbarView.view.addPageAction(sharePageAction) + browserToolbarView.view.addPageActionInOrder(sharePageAction, ToolbarActionIdentifier.SHARE) } private fun initTranslationsAction(context: Context, view: View) { @@ -410,7 +410,7 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler { ) refreshAction?.let { - browserToolbarView.view.addPageAction(it) + browserToolbarView.view.addPageActionInOrder(it, ToolbarActionIdentifier.RELOAD) } }