Skip to content

Commit 95aee5a

Browse files
Mugurellplingurar@mozilla.com
authored andcommitted
Bug 1977765 - Reuse existing navigation bar view id to anchor other popups r=android-reviewers,Roger
From the previous navigation bar implementation we had the `toolbar_navbar_container` view id still lingering in the application but unused. Since we saw that when using the new navigation bar it would be added in the layout with the same id as the composable toolbar we'll go with using the pre-existent navigation bar id to distinguish between the two and ensure application popups will be correctly anchored. Renamed the `toolbar_navbar_container` to `navigation_bar` because with the new implementation we don't have a container. Differential Revision: https://phabricator.services.mozilla.com/D259088
1 parent 39dc1d0 commit 95aee5a

File tree

9 files changed

+16
-13
lines changed

9 files changed

+16
-13
lines changed

mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ class HomeScreenRobot {
480480

481481
fun verifyNavigationToolbarIsSetToTheBottomOfTheHomeScreen() {
482482
Log.i(TAG, "verifyAddressBarPosition: Trying to verify that the navigation toolbar is set to bottom")
483-
onView(withId(R.id.toolbar_navbar_container)).check(isPartiallyBelow(withId(R.id.homepageView)))
483+
onView(withId(R.id.navigation_bar)).check(isPartiallyBelow(withId(R.id.homepageView)))
484484
Log.i(TAG, "verifyAddressBarPosition: Verified that the navigation toolbar is set to bottom")
485485
}
486486

mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class NavigationToolbarRobot {
222222
mDevice.findObject(
223223
By.desc(buttonDescription)
224224
.enabled(true)
225-
.hasAncestor(By.res("$packageName:id/toolbar_navbar_container")),
225+
.hasAncestor(By.res("$packageName:id/navigation_bar")),
226226
)
227227
.click(LONG_CLICK_DURATION)
228228
Log.i(TAG, "longTapNavButton: Long clicked the nav bar $buttonDescription button.")
@@ -245,7 +245,7 @@ class NavigationToolbarRobot {
245245
// Verifies that the address bar is displayed separately, or merged with the navbar in landscape mode.
246246
fun verifyAddressBarIsDisplayedSeparately(isSeparate: Boolean, isAtTop: Boolean) {
247247
val addressBar = "$packageName:id/toolbar"
248-
val navBar = "$packageName:id/toolbar_navbar_container"
248+
val navBar = "$packageName:id/navigation_bar"
249249

250250
if (isSeparate) {
251251
assertUIObjectExists(itemWithResId(addressBar), itemWithResId(navBar))
@@ -269,7 +269,7 @@ class NavigationToolbarRobot {
269269

270270
fun verifyNavBarBarPosition(isAtBottom: Boolean) {
271271
Log.i(TAG, "verifyNavBarBarPosition: Trying to verify the toolbar navbar position is at the bottom: $isAtBottom.")
272-
onView(allOf(withId(R.id.toolbar_navbar_container), isCompletelyDisplayed())).check(
272+
onView(allOf(withId(R.id.navigation_bar), isCompletelyDisplayed())).check(
273273
if (isAtBottom) {
274274
isPartiallyBelow(withId(R.id.engineView))
275275
} else {

mobile/android/fenix/app/src/main/java/org/mozilla/fenix/browser/AutofillSelectBarBehavior.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AutofillSelectBarBehavior<V : View>(
2323

2424
// Priority list of possible anchors for the autofill bars.
2525
private val dependenciesIds = buildList {
26-
add(R.id.toolbar_navbar_container)
26+
add(R.id.navigation_bar)
2727
if (toolbarPosition == ToolbarPosition.BOTTOM) {
2828
add(R.id.toolbar)
2929
add(R.id.composable_toolbar)

mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/SnackbarBehavior.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SnackbarBehavior<V : View>(
3535
add(R.id.suggestStrongPasswordBar)
3636
add(R.id.creditCardSelectBar)
3737
add(R.id.addressSelectBar)
38-
add(R.id.toolbar_navbar_container)
38+
add(R.id.navigation_bar)
3939
if (
4040
toolbarPosition == ToolbarPosition.BOTTOM ||
4141
(toolbarPosition == ToolbarPosition.TOP && shouldUseExpandedToolbar)

mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/BottomToolbarContainerView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class BottomToolbarContainerView(
3333
) {
3434

3535
val toolbarContainerView = ToolbarContainerView(context).apply {
36-
id = R.id.toolbar_navbar_container
36+
id = R.id.navigation_bar
3737
}
3838
private val composeView = ComposeView(context).apply {
3939
setContent {

mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserNavigationBar.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import mozilla.components.compose.browser.toolbar.store.ToolbarGravity.Bottom
2222
import mozilla.components.compose.browser.toolbar.store.ToolbarGravity.Top
2323
import mozilla.components.feature.toolbar.ToolbarBehaviorController
2424
import mozilla.components.lib.state.ext.observeAsState
25+
import org.mozilla.fenix.R
2526
import org.mozilla.fenix.compose.utils.KeyboardState
2627
import org.mozilla.fenix.compose.utils.keyboardAsState
2728
import org.mozilla.fenix.theme.FirefoxTheme
@@ -70,6 +71,8 @@ class BrowserNavigationBar(
7071

7172
DefaultNavigationBarContent()
7273
}.apply {
74+
id = R.id.navigation_bar
75+
7376
container.addView(
7477
this,
7578
LayoutParams(

mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/toolbar/HomeNavigationBar.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ import mozilla.components.compose.browser.toolbar.store.BrowserToolbarStore
1919
import mozilla.components.compose.browser.toolbar.store.ToolbarGravity.Bottom
2020
import mozilla.components.compose.browser.toolbar.store.ToolbarGravity.Top
2121
import mozilla.components.lib.state.ext.observeAsState
22-
import org.mozilla.fenix.components.AppStore
23-
import org.mozilla.fenix.components.StoreProvider
22+
import org.mozilla.fenix.R
2423
import org.mozilla.fenix.compose.utils.KeyboardState
2524
import org.mozilla.fenix.compose.utils.keyboardAsState
26-
import org.mozilla.fenix.ext.components
2725
import org.mozilla.fenix.theme.FirefoxTheme
2826
import org.mozilla.fenix.utils.Settings
2927

@@ -73,6 +71,8 @@ class HomeNavigationBar(
7371
}
7472

7573
override val layout = ComposeView(context).apply {
74+
id = R.id.navigation_bar
75+
7676
setContent {
7777
DefaultNavigationBarContent()
7878
}

mobile/android/fenix/app/src/main/res/values/ids.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
- License, v. 2.0. If a copy of the MPL was not distributed with this
44
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
55
<resources>
6-
<item name="toolbar_navbar_container" type="id"/>
6+
<item name="navigation_bar" type="id"/>
77
<item name="composable_toolbar" type="id"/>
88
</resources>

mobile/android/fenix/app/src/test/java/org/mozilla/fenix/browser/AutofillSelectBarBehaviorTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class AutofillSelectBarBehaviorTest {
6060

6161
@Test
6262
fun `GIVEN a toolbar shown at top and the navbar at the bottom WHEN the login bar is shown THEN anchor it to the navbar`() {
63-
dependency.id = R.id.toolbar_navbar_container
63+
dependency.id = R.id.navigation_bar
6464
val behavior = AutofillSelectBarBehavior<ViewGroup>(testContext, ToolbarPosition.TOP)
6565

6666
behavior.layoutDependsOn(parent, loginsBar, dependency)
@@ -127,7 +127,7 @@ class AutofillSelectBarBehaviorTest {
127127
@Test
128128
fun `GIVEN the login bar is anchored to the navbar WHEN the navbar is not shown anymore THEN place the login bar at the bottom`() {
129129
val navbar = View(testContext)
130-
.apply { id = R.id.toolbar_navbar_container }
130+
.apply { id = R.id.navigation_bar }
131131
.also { parent.addView(it) }
132132
val behavior = AutofillSelectBarBehavior<ViewGroup>(testContext, ToolbarPosition.BOTTOM)
133133

0 commit comments

Comments
 (0)