Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

For #7503 - Show Start browsing cfr at fresh install #7705

Merged
merged 1 commit into from Oct 26, 2022

Conversation

iorgamgabriel
Copy link
Collaborator

@iorgamgabriel iorgamgabriel commented Sep 21, 2022

Pull Request checklist

  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not
  • Accessibility: The code in this PR follows accessibility best practices or does not include any user facing features. In addition, it includes a screenshot of a successful accessibility scan to ensure no new defects are added to the product.

QA

  • QA Needed

To download an APK when reviewing a PR:

  1. click on Show All Checks,
  2. click Details next to build-focus-debug or build-klar-debug for changes targeting Klar,
  3. click View task in Taskcluster,
  4. click the Artifacts row,
  5. click to download any of the apks listed here which use an appropriate name for each CPU architecture.

GitHub Automation

Fixes #7503

fun `GIVEN app fresh install WHEN input toolbar integration is starting THEN start browsing scope is populated`() {
inputToolbarIntegration.start()

assertNotEquals(null, inputToolbarIntegration.startBrowsingCfrScope)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertNotEquals(null, inputToolbarIntegration.startBrowsingCfrScope)
assertNotNull(inputToolbarIntegration.startBrowsingCfrScope)

nit: We could verify that the scope was null before the inputToolbarIntegration.start() call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

fun `GIVEN app fresh install WHEN input toolbar integration is stoping THEN start browsing scope is canceled`() {
inputToolbarIntegration.stop()

assertEquals(null, inputToolbarIntegration.startBrowsingCfrScope?.cancel())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it looks like we are asserting that startBrowsingCfrScope?.cancel() returns null.
If we need to test that inputToolbarIntegration.stop() stopped the scope we could use something similar to

assertFalse(inputToolbarIntegration.startBrowsingCfrScope?.isActive ?: true)

in which case a previous

assertTrue(inputToolbarIntegration.startBrowsingCfrScope?.isActive ?: false)

would also help adding mroe confidence in the assert.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 61 to 62
shippedDomainsProvider,
customDomainProviderResult,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Seems like these are simple mocks needed just to be able to build InputToolbarIntegration. They could be initialized in place with mock() calls.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


@Before
fun setUp() {
Dispatchers.setMain(testDispatcher)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this is needed (together with UnconfinedTestDispatcher and code from onAfter)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -964,6 +964,9 @@
!-- This is the title of promote search widget dialog. -->
<string name="promote_search_widget_dialog_title">Browsing history cleared! 🎉</string>

<!-- CFR for Start your private browsing session-->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally it is preferred to avoid acronyms. Maybe localizers don't know these internal namings.
Would be useful to reformulate this to avoid the CFR or at least offer more context. I see for other such strings that the comment contains (Banner Info Message).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -187,6 +188,13 @@ private fun showEraseTabsCfrChanged(state: AppState, action: AppAction.ShowErase
return state.copy(showEraseTabsCfr = action.value)
}

/**
* The state of start browsing CFR changed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This comment provides little useful info. If a comment is really needed "Update whether the start browsing CFR should be shown or not" may be just a little bit better.
I see that there are many comments which follow this structure so maybe a separate ticket to update the documentation for all these methods would be nice for a good first issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -105,9 +123,60 @@ class InputToolbarIntegration(
override fun start() {
useCustomDomainProvider = settings.shouldAutocompleteFromCustomDomainList()
useShippedDomainProvider = settings.shouldAutocompleteFromShippedDomainList()
observeStartBrowserCfrVisibility()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Since the new CFR is to be shown just once we could avoid always observing the store with another if (showStartBrowsingCfr) check here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 321 to 323
fontSize = 16.sp,
letterSpacing = 0.5.sp,
lineHeight = 24.sp,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this configuration is common to all CFRs.
Could it be extracted in a new typography?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@Mugurell Mugurell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one question about the dismiss behavior and a few proposed changes about the cfr text typographies.

onDismiss = { onDismissStartBrowsingCfr() },
text = {
Text(
style = focusTypography.cfrTextStyle,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This style should be applied to all CFRs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/* 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 org.mozilla.focus.browser.integration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing newline between this and the license text.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -121,4 +122,10 @@ val focusTypography: FocusTypography
fontSize = 14.sp,
color = PhotonColors.LightGrey05,
),
cfrTextStyle = TextStyle(
fontFamily = metropolis,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this font should be removed. The other CFRs which don't yet use this typography don't have it declared.
After applying the new patch this start browsing CFR looks different than expected.

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

),
popupVerticalOffset = 0.dp,
),
onDismiss = { onDismissStartBrowsingCfr() },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onDismiss callback informs of the user taped on the X button or not - maybe the CFR was dismissed by pressing outside of it.
Do we need to consider these separate scenarios?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done . Based on this bug #7653 cfrs should not be dismissed if the users taps anywhere on the screen.

@iorgamgabriel iorgamgabriel added 🛬 needs landing PRs that are ready to land and removed 🛬 needs landing PRs that are ready to land labels Oct 25, 2022
@iorgamgabriel iorgamgabriel added the 🛬 needs landing PRs that are ready to land label Oct 26, 2022
@mergify mergify bot merged commit a0a0916 into mozilla-mobile:main Oct 26, 2022
@lobontiumira
Copy link

Verified as implemented on a local Focus Nightly build 108.0a1 with the following devices:

  • Google Pixel 6 (Android 13),
  • Lenovo tablet M10 (Android 10),
  • Oppo Reno 6 (Android 12),
  • Samsung Galaxy Note 8 (Android 9), and
  • Xiaomi mi4i (Android 5.0.2).

After dismissing the new onboarding, the start browsing CFR is displayed.
Rotating the device, dismisses the CFR. But, after sending the app in the background, and re-opening it, the CFR is displayed again.
Tapping the "X" button from the top-right corner of the CFR, dismisses the CFR.

CFR

@iorgamgabriel
Copy link
Collaborator Author

@Mergifyio backport releases_v107.0

@mergify
Copy link
Contributor

mergify bot commented Oct 27, 2022

backport releases_v107.0

✅ Backports have been created

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🛬 needs landing PRs that are ready to land QAVerified
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace "Go to Settings" CFR with "Start your private browsing session" CFR
3 participants