From 3fbfdac129510e1edd1668cef7d8ed0e34f39516 Mon Sep 17 00:00:00 2001 From: Vlad Filippov Date: Thu, 23 Jan 2020 17:10:26 -0500 Subject: [PATCH 001/226] Changelog: https://github.com/mozilla/application-services/releases/tag/v0.48.3 Ref: mozilla-mobile/android-components#5703 @grigoryk @ekager r? --- buildSrc/src/main/java/Dependencies.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 3636b2640..736c02380 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -39,7 +39,7 @@ object Versions { // that we depend on directly for the fenix-megazord (and for it's // forUnitTest variant), and it's important that it be kept in // sync with the version used by android-components above. - const val mozilla_appservices = "0.48.2" + const val mozilla_appservices = "0.48.3" const val mozilla_glean = "23.0.0" From 24396d174f9ba7ef8fd70cd5f111529a495b4450 Mon Sep 17 00:00:00 2001 From: Mihai Adrian <48995920+mcarare@users.noreply.github.com> Date: Wed, 29 Jan 2020 18:50:11 +0200 Subject: [PATCH 002/226] For #6980: Add What's new card (#7952) --- .../sessioncontrol/SessionControlAdapter.kt | 4 ++ .../home/sessioncontrol/SessionControlView.kt | 1 + .../viewholders/onboarding/OnboardingIcon.kt | 8 ++- .../OnboardingWhatsNewViewHolder.kt | 40 +++++++++++++++ .../main/res/layout/onboarding_whats_new.xml | 50 +++++++++++++++++++ 5 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/onboarding/OnboardingWhatsNewViewHolder.kt create mode 100644 app/src/main/res/layout/onboarding_whats_new.xml diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt index bbfa546ba..37edda17b 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt @@ -38,6 +38,8 @@ import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingPr import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingSectionHeaderViewHolder import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingThemePickerViewHolder import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingTrackingProtectionViewHolder +import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.OnboardingWhatsNewViewHolder + import mozilla.components.feature.tab.collections.Tab as ComponentTab sealed class AdapterItem(@LayoutRes val viewType: Int) { @@ -109,6 +111,7 @@ sealed class AdapterItem(@LayoutRes val viewType: Int) { object OnboardingPrivateBrowsing : AdapterItem(OnboardingPrivateBrowsingViewHolder.LAYOUT_ID) object OnboardingPrivacyNotice : AdapterItem(OnboardingPrivacyNoticeViewHolder.LAYOUT_ID) object OnboardingFinish : AdapterItem(OnboardingFinishViewHolder.LAYOUT_ID) + object OnboardingWhatsNew : AdapterItem(OnboardingWhatsNewViewHolder.LAYOUT_ID) /** * True if this item represents the same value as other. Used by [AdapterItemDiffCallback]. @@ -168,6 +171,7 @@ class SessionControlAdapter( OnboardingPrivateBrowsingViewHolder.LAYOUT_ID -> OnboardingPrivateBrowsingViewHolder(view) OnboardingPrivacyNoticeViewHolder.LAYOUT_ID -> OnboardingPrivacyNoticeViewHolder(view) OnboardingFinishViewHolder.LAYOUT_ID -> OnboardingFinishViewHolder(view, interactor) + OnboardingWhatsNewViewHolder.LAYOUT_ID -> OnboardingWhatsNewViewHolder(view) else -> throw IllegalStateException() } } diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt index cdfc6510f..82cbc5725 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt @@ -111,6 +111,7 @@ private fun onboardingAdapterItems(onboardingState: OnboardingState): List + + + + + + + From 94447657c4833b993441eb523561f8aa3a6d8218 Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Wed, 29 Jan 2020 09:34:41 +0100 Subject: [PATCH 003/226] No issue: Fixes strings for data migration --- .../toolbar/BrowserToolbarController.kt | 7 ++++- .../migration/MigrationProgressActivity.kt | 15 ++++++++--- .../fenix/settings/logins/SavedLoginsView.kt | 8 ++++++ .../main/res/layout/activity_migration.xml | 2 +- app/src/main/res/values/strings.xml | 26 +++++++++---------- 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarController.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarController.kt index 152bcbb08..77ad05f06 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarController.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarController.kt @@ -148,8 +148,13 @@ class DefaultBrowserToolbarController( } activity.getRootView()?.let { + + val appName = it.context.getString(R.string.app_name) FenixSnackbar.makeWithToolbarPadding(it, Snackbar.LENGTH_SHORT) - .setText(it.context.getString(R.string.snackbar_added_to_firefox_home)) + .setText(it.context.getString( + R.string.snackbar_added_to_firefox_home, + appName + )) .show() } } diff --git a/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt b/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt index 76819d6b2..ca2da1fab 100644 --- a/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt @@ -40,11 +40,21 @@ class MigrationProgressActivity : AbstractMigrationProgressActivity() { } fun init() { + val appName = migration_description.context.getString(R.string.app_name) + + migration_description.apply { + text = context.getString(R.string.migration_description, appName) + } + migration_status_list.apply { layoutManager = LinearLayoutManager(this@MigrationProgressActivity) adapter = statusAdapter } + migration_welcome_title.apply { + text = context.getString(R.string.migration_title, appName) + } + migration_button.apply { setOnClickListener { finish() @@ -56,10 +66,7 @@ class MigrationProgressActivity : AbstractMigrationProgressActivity() { startActivity(intent) } } - text = getString( - R.string.migration_updating_app_button_text, - getString(R.string.app_name) - ) + text = getString(R.string.migration_updating_app_button_text, appName) } } diff --git a/app/src/main/java/org/mozilla/fenix/settings/logins/SavedLoginsView.kt b/app/src/main/java/org/mozilla/fenix/settings/logins/SavedLoginsView.kt index 5835d0044..b19eafab5 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/logins/SavedLoginsView.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/logins/SavedLoginsView.kt @@ -58,6 +58,14 @@ class SavedLoginsView( text = textWithLink setOnClickListener { interactor.onLearnMore() } } + + with(view.saved_passwords_empty_message) { + val appName = context.getString(R.string.app_name) + text = context.getString( + R.string.preferences_passwords_saved_logins_description_empty_text, + appName + ) + } } fun update(state: SavedLoginsFragmentState) { diff --git a/app/src/main/res/layout/activity_migration.xml b/app/src/main/res/layout/activity_migration.xml index 5aa10192c..8df5caede 100644 --- a/app/src/main/res/layout/activity_migration.xml +++ b/app/src/main/res/layout/activity_migration.xml @@ -21,7 +21,7 @@ android:id="@+id/migration_firefox_logo" android:layout_width="67dp" android:layout_height="67dp" - android:contentDescription="@string/firefox_logo_description" + android:importantForAccessibility="no" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:srcCompat="@drawable/ic_firefox" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 272fc04aa..7688faf4f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -702,8 +702,8 @@ Tab closed Tabs closed - - Added to Firefox home! + + Added to %s home! Private tab closed @@ -1046,8 +1046,8 @@ Sign in to Sync Saved logins - - The logins you save or sync to Firefox will show up here. + + The logins you save or sync to %s will show up here. Learn more about Sync. @@ -1156,17 +1156,15 @@ Deleted %s - - Firefox logo - - Welcome to an all-new Firefox - - A completely redesigned browser awaits, with improved performance and features to help you do more online.\n\nPlease wait while we update Firefox with your - + + Welcome to an all-new %s + + A completely redesigned browser awaits, with improved performance and features to help you do more online.\n\nPlease wait while we update %s with your + Updating %s… - + Start %s - + Migration status: %s @@ -1191,7 +1189,7 @@ Phone Feature No Decision - +
1. Go to Android Settings

2. Tap Permissions

3. Toggle %1$s to ON ]]>
From d272623c3dbd3a15210bd0b9d97ceb6577dd3e4c Mon Sep 17 00:00:00 2001 From: Emily Kager Date: Thu, 30 Jan 2020 15:57:40 +0100 Subject: [PATCH 004/226] No issue: Add idle for create folder UI test --- app/src/androidTest/java/org/mozilla/fenix/ui/BookmarksTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/BookmarksTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/BookmarksTest.kt index 83cc370d3..b4940e389 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/BookmarksTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/BookmarksTest.kt @@ -103,6 +103,7 @@ class BookmarksTest { verifyKeyboardVisible() addNewFolderName(bookmarksFolderName) saveNewFolder() + getInstrumentation().waitForIdleSync() verifyFolderTitle(bookmarksFolderName) verifyKeyboardHidden() } From db34700e3aab160764beb8d3fd62823917f100da Mon Sep 17 00:00:00 2001 From: Simon Chae Date: Thu, 30 Jan 2020 16:55:06 +0100 Subject: [PATCH 005/226] Update a-c snapshot version to 30.0.0 (#8003) --- buildSrc/src/main/java/Dependencies.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 736c02380..768b8f853 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -32,7 +32,7 @@ object Versions { const val androidx_work = "2.2.0" const val google_material = "1.1.0-beta01" - const val mozilla_android_components = "29.0.0-SNAPSHOT" + const val mozilla_android_components = "30.0.0-SNAPSHOT" // Note that android-components also depends on application-services, // and in fact is our main source of appservices-related functionality. // The version number below tracks the application-services version From f728cdaf053e0e879b4125c9dd3604c1d0c43441 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Thu, 30 Jan 2020 20:24:53 +0100 Subject: [PATCH 006/226] Bug 7189 - Provide page title in website information dialog (#7255) * Bug 7189 - Provide page title in website information dialog * Update QSFS test * Fix Tiger's nits --- .../org/mozilla/fenix/browser/BrowserFragment.kt | 1 + .../customtabs/ExternalAppBrowserFragment.kt | 1 + .../quicksettings/QuickSettingsFragmentStore.kt | 9 +++++++-- .../QuickSettingsSheetDialogFragment.kt | 1 + .../settings/quicksettings/WebsiteInfoView.kt | 5 +++++ .../res/layout/quicksettings_website_info.xml | 15 +++++++++------ app/src/main/res/navigation/nav_graph.xml | 3 +++ .../QuickSettingsFragmentStoreTest.kt | 10 +++++++--- 8 files changed, 34 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt index 1aa5c5a6e..09aa67a5f 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt @@ -155,6 +155,7 @@ class BrowserFragment : BaseBrowserFragment(), UserInteractionHandler { BrowserFragmentDirections.actionBrowserFragmentToQuickSettingsSheetDialogFragment( sessionId = session.id, url = session.url, + title = session.title, isSecured = session.securityInfo.secure, sitePermissions = sitePermissions, gravity = getAppropriateLayoutGravity() diff --git a/app/src/main/java/org/mozilla/fenix/customtabs/ExternalAppBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/customtabs/ExternalAppBrowserFragment.kt index f7c81714b..a3e234e77 100644 --- a/app/src/main/java/org/mozilla/fenix/customtabs/ExternalAppBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/customtabs/ExternalAppBrowserFragment.kt @@ -161,6 +161,7 @@ class ExternalAppBrowserFragment : BaseBrowserFragment(), UserInteractionHandler .actionExternalAppBrowserFragmentToQuickSettingsSheetDialogFragment( sessionId = session.id, url = session.url, + title = session.title, isSecured = session.securityInfo.secure, sitePermissions = sitePermissions, gravity = getAppropriateLayoutGravity() diff --git a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStore.kt b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStore.kt index 5ced2fde5..fb0923002 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStore.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStore.kt @@ -67,6 +67,7 @@ class QuickSettingsFragmentStore( * * @param context [Context] used for access to various Android resources. * @param websiteUrl [String] the URL of the current web page. + * @param websiteTitle [String] the title of the current web page. * @param isSecured [Boolean] whether the connection is secured (TLS) or not. * @param permissions [SitePermissions]? list of website permissions and their status. * @param settings [Settings] application settings. @@ -75,12 +76,13 @@ class QuickSettingsFragmentStore( fun createStore( context: Context, websiteUrl: String, + websiteTitle: String, isSecured: Boolean, permissions: SitePermissions?, settings: Settings ) = QuickSettingsFragmentStore( QuickSettingsFragmentState( - webInfoState = createWebsiteInfoState(websiteUrl, isSecured), + webInfoState = createWebsiteInfoState(websiteUrl, websiteTitle, isSecured), websitePermissionsState = createWebsitePermissionState( context, permissions, @@ -101,13 +103,14 @@ class QuickSettingsFragmentStore( @VisibleForTesting fun createWebsiteInfoState( websiteUrl: String, + websiteTitle: String, isSecured: Boolean ): WebsiteInfoState { val (stringRes, iconRes, colorRes) = when (isSecured) { true -> getSecuredWebsiteUiValues false -> getInsecureWebsiteUiValues } - return WebsiteInfoState(websiteUrl, stringRes, iconRes, colorRes) + return WebsiteInfoState(websiteUrl, websiteTitle, stringRes, iconRes, colorRes) } /** @@ -217,12 +220,14 @@ data class QuickSettingsFragmentState( * [State] to be rendered by [WebsiteInfoView] indicating whether the connection is secure or not. * * @param websiteUrl [String] the URL of the current web page. + * @param websiteTitle [String] the title of the current web page. * @param securityInfoRes [StringRes] for the connection description. * @param iconRes [DrawableRes] image indicating the connection status. * @param iconTintRes [ColorRes] icon color. */ data class WebsiteInfoState( val websiteUrl: String, + val websiteTitle: String, @StringRes val securityInfoRes: Int, @DrawableRes val iconRes: Int, @ColorRes val iconTintRes: Int diff --git a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsSheetDialogFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsSheetDialogFragment.kt index 148ca4f0b..f30c5d899 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsSheetDialogFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsSheetDialogFragment.kt @@ -67,6 +67,7 @@ class QuickSettingsSheetDialogFragment : AppCompatDialogFragment() { quickSettingsStore = QuickSettingsFragmentStore.createStore( context = context, websiteUrl = args.url, + websiteTitle = args.title, isSecured = args.isSecured, permissions = args.sitePermissions, settings = Settings.getInstance(context) diff --git a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/WebsiteInfoView.kt b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/WebsiteInfoView.kt index 914933659..4190f29f7 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/quicksettings/WebsiteInfoView.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/quicksettings/WebsiteInfoView.kt @@ -37,6 +37,7 @@ class WebsiteInfoView( */ fun update(state: WebsiteInfoState) { bindUrl(state.websiteUrl) + bindTitle(state.websiteTitle) bindSecurityInfo(state.securityInfoRes, state.iconRes, state.iconTintRes) } @@ -44,6 +45,10 @@ class WebsiteInfoView( view.url.text = url } + private fun bindTitle(title: String) { + view.title.text = title + } + private fun bindSecurityInfo( @StringRes securityInfoRes: Int, @DrawableRes iconRes: Int, diff --git a/app/src/main/res/layout/quicksettings_website_info.xml b/app/src/main/res/layout/quicksettings_website_info.xml index a1f5eef58..1c1976a3d 100644 --- a/app/src/main/res/layout/quicksettings_website_info.xml +++ b/app/src/main/res/layout/quicksettings_website_info.xml @@ -12,15 +12,21 @@ android:layout_height="wrap_content" android:orientation="vertical"> + + diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 4d798eec2..71447aaf2 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -582,6 +582,9 @@ + diff --git a/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStoreTest.kt b/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStoreTest.kt index 47ad85d9c..003acc020 100644 --- a/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStoreTest.kt +++ b/app/src/test/java/org/mozilla/fenix/settings/quicksettings/QuickSettingsFragmentStoreTest.kt @@ -57,7 +57,7 @@ class QuickSettingsFragmentStoreTest { val permissions = mockk(relaxed = true) val store = QuickSettingsFragmentStore.createStore( - context, "url", true, permissions, settings + context, "url", "Hello", true, permissions, settings ) assertAll { @@ -71,13 +71,15 @@ class QuickSettingsFragmentStoreTest { @Test fun `createWebsiteInfoState constructs a WebsiteInfoState with the right values for a secure connection`() { val websiteUrl = "https://host.com/page1" + val websiteTitle = "Hello" val securedStatus = true - val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, securedStatus) + val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus) assertAll { assertThat(state).isNotNull() assertThat(state.websiteUrl).isSameAs(websiteUrl) + assertThat(state.websiteTitle).isSameAs(websiteTitle) assertThat(state.securityInfoRes).isEqualTo(secureStringRes) assertThat(state.iconRes).isEqualTo(secureDrawableRes) assertThat(state.iconTintRes).isEqualTo(secureColorRes) @@ -87,13 +89,15 @@ class QuickSettingsFragmentStoreTest { @Test fun `createWebsiteInfoState constructs a WebsiteInfoState with the right values for an insecure connection`() { val websiteUrl = "https://host.com/page1" + val websiteTitle = "Hello" val securedStatus = false - val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, securedStatus) + val state = QuickSettingsFragmentStore.createWebsiteInfoState(websiteUrl, websiteTitle, securedStatus) assertAll { assertThat(state).isNotNull() assertThat(state.websiteUrl).isSameAs(websiteUrl) + assertThat(state.websiteTitle).isSameAs(websiteTitle) assertThat(state.securityInfoRes).isEqualTo(insecureStringRes) assertThat(state.iconRes).isEqualTo(insecureDrawableRes) assertThat(state.iconTintRes).isEqualTo(insecureColorRes) From 89cc5657ce65da82f643edd8eb5a62ecf06d78e3 Mon Sep 17 00:00:00 2001 From: Aaron Train Date: Thu, 30 Jan 2020 16:15:40 -0500 Subject: [PATCH 007/226] Closes #8006: Add Close/Undo UI tests (#8007) --- .../org/mozilla/fenix/ui/HomeScreenTest.kt | 2 - .../mozilla/fenix/ui/TabbedBrowsingTest.kt | 75 ++++++++++- .../java/org/mozilla/fenix/ui/TabsTest.kt | 122 ------------------ .../fenix/ui/robots/HomeScreenRobot.kt | 90 ++++++++++--- 4 files changed, 144 insertions(+), 145 deletions(-) delete mode 100644 app/src/androidTest/java/org/mozilla/fenix/ui/TabsTest.kt diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt index 6f802bb60..d0b47eb89 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/HomeScreenTest.kt @@ -110,7 +110,6 @@ class HomeScreenTest { verifyHomeWordmark() verifyAddTabButton() verifyShareTabsButton(visible = false) - verifyCloseTabsButton(visible = false) verifyPrivateSessionHeader() verifyPrivateSessionMessage(visible = true) verifyHomeToolbar() @@ -130,7 +129,6 @@ class HomeScreenTest { verifyHomeWordmark() verifyAddTabButton() verifyShareTabsButton(visible = true) - verifyCloseTabsButton(visible = true) verifyPrivateSessionHeader() verifyPrivateSessionMessage(visible = false) verifyHomeToolbar() diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt index ced946432..4675da8fb 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt @@ -28,8 +28,10 @@ import org.mozilla.fenix.ui.robots.navigationToolbar * - Opening a private tab * - Verifying tab list * - Closing all tabs + * - Close tab + * - Swipe to close tab + * - Undo close tab * - * TODO: Tab Collections */ class TabbedBrowsingTest { @@ -76,7 +78,10 @@ class TabbedBrowsingTest { homeScreen { // Timing issue on slow devices on Firebase - mDevice.waitNotNull(Until.findObjects(By.res("org.mozilla.fenix.debug:id/item_tab")), TestAssetHelper.waitingTime) + mDevice.waitNotNull( + Until.findObjects(By.res("org.mozilla.fenix.debug:id/item_tab")), + TestAssetHelper.waitingTime + ) verifyExistingTabList() }.openTabsListThreeDotMenu { @@ -106,10 +111,13 @@ class TabbedBrowsingTest { verifyTabCounter("1") }.openHomeScreen { // Timing issue on slow devices on Firebase - mDevice.waitNotNull(Until.findObjects(By.res("org.mozilla.fenix.debug:id/item_tab")), TestAssetHelper.waitingTime) + mDevice.waitNotNull( + Until.findObjects(By.res("org.mozilla.fenix.debug:id/item_tab")), + TestAssetHelper.waitingTime + ) verifyExistingTabList() verifyShareTabsButton(true) - verifyCloseTabsButton(true) + verifyCloseTabsButton("Test_Page_1") }.togglePrivateBrowsingMode() // Verify private tabs remain in private browsing mode @@ -135,7 +143,10 @@ class TabbedBrowsingTest { homeScreen { // Timing issue on slow devices on Firebase - mDevice.waitNotNull(Until.findObjects(By.res("org.mozilla.fenix.debug:id/item_tab")), TestAssetHelper.waitingTime) + mDevice.waitNotNull( + Until.findObjects(By.res("org.mozilla.fenix.debug:id/item_tab")), + TestAssetHelper.waitingTime + ) verifyExistingTabList() }.openTabsListThreeDotMenu { verifyCloseAllTabsButton() @@ -147,5 +158,59 @@ class TabbedBrowsingTest { verifyNoTabsOpenedHeader() verifyNoTabsOpenedText() } + + // Repeat for Private Tabs + homeScreen { + }.togglePrivateBrowsingMode() + + navigationToolbar { + }.enterURLAndEnterToBrowser(defaultWebPage.url) { + verifyPageContent(defaultWebPage.content) + }.openHomeScreen { } + + homeScreen { + // Timing issue on slow devices on Firebase + mDevice.waitNotNull( + Until.findObjects(By.res("org.mozilla.fenix.debug:id/item_tab")), + TestAssetHelper.waitingTime + ) + verifyExistingTabList() + verifyPrivateTabsCloseTabsButton() + }.closeAllPrivateTabs { + verifyPrivateSessionHeader() + verifyPrivateSessionMessage(true) + } + } + + @Test + fun closeTabTest() { + var genericURLS = TestAssetHelper.getGenericAssets(mockWebServer) + + genericURLS.forEachIndexed { index, element -> + navigationToolbar { + }.openNewTabAndEnterToBrowser(element.url) { + verifyPageContent(element.content) + }.openHomeScreen { } + + homeScreen { + verifyExistingOpenTabs("Test_Page_${index + 1}") + verifyCloseTabsButton("Test_Page_${index + 1}") + closeTabViaXButton("Test_Page_${index + 1}") + verifySnackBarText("Tab closed") + snackBarButtonClick("UNDO") + verifyExistingOpenTabs("Test_Page_${index + 1}") + verifyCloseTabsButton("Test_Page_${index + 1}") + swipeTabRight("Test_Page_${index + 1}") + verifySnackBarText("Tab closed") + snackBarButtonClick("UNDO") + verifyExistingOpenTabs("Test_Page_${index + 1}") + verifyCloseTabsButton("Test_Page_${index + 1}") + swipeTabLeft("Test_Page_${index + 1}") + verifySnackBarText("Tab closed") + snackBarButtonClick("UNDO") + verifyExistingOpenTabs("Test_Page_${index + 1}") + verifyCloseTabsButton("Test_Page_${index + 1}") + } + } } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/TabsTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/TabsTest.kt deleted file mode 100644 index d8607363c..000000000 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/TabsTest.kt +++ /dev/null @@ -1,122 +0,0 @@ -/* 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.fenix.ui - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.uiautomator.UiDevice -import okhttp3.mockwebserver.MockWebServer -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.junit.Before -import org.junit.After -import org.mozilla.fenix.helpers.AndroidAssetDispatcher -import org.mozilla.fenix.helpers.HomeActivityTestRule -import org.mozilla.fenix.helpers.TestAssetHelper -import org.mozilla.fenix.ui.robots.homeScreen -import org.mozilla.fenix.ui.robots.navigationToolbar - -/** - * Tests for verifying basic functionality of tabs - * - */ - -class TabsTest { - /* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping. - - private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) - private lateinit var mockWebServer: MockWebServer - - @get:Rule - val activityTestRule = HomeActivityTestRule() - - @Before - fun setUp() { - mockWebServer = MockWebServer().apply { - setDispatcher(AndroidAssetDispatcher()) - start() - } - } - - @After - fun tearDown() { - mockWebServer.shutdown() - } - - @Ignore("This is a stub test, ignore for now") - @Test - fun tabsItemsTest() { - homeScreen { }.dismissOnboarding() - - // Setup browser so that tabs are visible in UI - // Verify all tabs elements are visible: - // "open tabs header, + button, etc. - // Verify tabs 3-dot menu elements - } - - @Ignore("This is a stub test, ignore for now") - @Test - fun noTabsInCacheTest() { - // Verify open tabs header and text exists (when no previous browsing) - // Verify + button redirects to navigation bar UI - // Verify "Collections" header exists - // Verify "No collections" text (when no previous browsing) - } - - @Ignore("This is a stub test, ignore for now") - @Test - fun browsingWithTabsTest() { - // Setup: - // - Verify + button redirects to navigation bar UI - // - Enter mock website via navigation bar - // Verify "Open tabs" header exits - // Verify Collections header exits - // Verify that tabs counter is augmented by 1 count - // Click on tabs counter - // Verify that new page is listed in "Open tabs" - // Repeat for several sites - - } - - @Ignore("This is a stub test, ignore for now") - @Test - fun tabsThreeDotMenuTest() { - // short 3-dot menu setup: - // - create multiple tabs (using mock web server) for the following... - // Verify tabs 3-dot menu functions: - // 1. "Close all tabs" - // 2. "Share tabs" - opens share sub-menu - // 3. "Save to collection" - verify saved to collection - - // NOTE: extended 3 dot menu test is verified in a separate class - } - - @Ignore("This is a stub test, ignore for now") - @Test - fun collectionsTest() { - // Setup: - // - create multiple tabs (using mock web server) for the following... - // Verify collections header exits - // Verify multiple collections can be saved, named - // Verify "Select tabs to save" - // Verify collections dropdown toggle - // Verify send and share button works - opens share menu - - // Verify collections 3-dot menu functions: - // 1. Delete collection - // 2. Rename collection - // 3. Open tabs - } - - @Ignore("This is a sample test, ignore") - @Test - fun sampleTest() { - val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) - - navigationToolbar { - }.enterURLAndEnterToBrowser(defaultWebPage.url) { - } - } -} diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt index aa2f264fe..835e0f5a0 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt @@ -14,23 +14,25 @@ import androidx.test.espresso.assertion.ViewAssertions.doesNotExist import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.contrib.RecyclerViewActions import androidx.test.espresso.matcher.ViewMatchers -import androidx.test.espresso.matcher.ViewMatchers.Visibility import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.withContentDescription +import androidx.test.espresso.matcher.ViewMatchers.Visibility import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility -import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.uiautomator.Until import androidx.test.uiautomator.By import androidx.test.uiautomator.UiDevice import androidx.test.uiautomator.UiScrollable import androidx.test.uiautomator.UiSelector +import androidx.test.uiautomator.Until import org.hamcrest.CoreMatchers import org.hamcrest.Matchers.allOf import org.hamcrest.Matchers.containsString import org.mozilla.fenix.R -import org.mozilla.fenix.helpers.click +import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime +import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.ext.waitNotNull /** @@ -80,8 +82,11 @@ class HomeScreenRobot { // Private mode elements fun verifyPrivateSessionHeader() = assertPrivateSessionHeader() fun verifyPrivateSessionMessage(visible: Boolean = true) = assertPrivateSessionMessage(visible) + fun verifyPrivateTabsCloseTabsButton() = assertPrivateTabsCloseTabsButton() + fun verifyShareTabsButton(visible: Boolean = true) = assertShareTabsButton(visible) - fun verifyCloseTabsButton(visible: Boolean = true) = assertCloseTabsButton(visible) + fun verifyCloseTabsButton(title: String) = + assertCloseTabsButton(title) fun verifyExistingTabList() = assertExistingTabList() fun verifyExistingOpenTabs(title: String) = assertExistingOpenTabs(title) @@ -91,29 +96,35 @@ class HomeScreenRobot { collectionThreeDotButton().click() mDevice.waitNotNull(Until.findObject(By.text("Delete collection")), waitingTime) } + fun selectRenameCollection() { onView(allOf(ViewMatchers.withText("Rename collection"))).click() mDevice.waitNotNull(Until.findObject(By.res("name_collection_edittext"))) } + fun selectDeleteCollection() { onView(allOf(ViewMatchers.withText("Delete collection"))).click() mDevice.waitNotNull(Until.findObject(By.res("message")), waitingTime) } + fun confirmDeleteCollection() { onView(allOf(ViewMatchers.withText("DELETE"))).click() mDevice.waitNotNull(Until.findObject(By.res("collections_header")), waitingTime) } + fun typeCollectionName(name: String) { mDevice.wait(Until.findObject(By.res("name_collection_edittext")), waitingTime) collectionNameTextField().perform(ViewActions.replaceText(name)) collectionNameTextField().perform(ViewActions.pressImeActionButton()) } + fun scrollToElementByText(text: String): UiScrollable { val appView = UiScrollable(UiSelector().scrollable(true)) appView.scrollTextIntoView(text) return appView } + fun swipeUpToDismissFirstRun() { scrollToElementByText("Start browsing") } @@ -124,12 +135,31 @@ class HomeScreenRobot { fun togglePrivateBrowsingModeOnOff() { onView(ViewMatchers.withResourceName("privateBrowsingButton")) - .perform(click()) + .perform(click()) } - fun swipeToBottom() = onView(ViewMatchers.withId(R.id.home_component)).perform(ViewActions.swipeUp()) + fun swipeToBottom() = onView(withId(R.id.home_component)).perform(ViewActions.swipeUp()) - fun swipeToTop() = onView(ViewMatchers.withId(R.id.home_component)).perform(ViewActions.swipeDown()) + fun swipeToTop() = onView(withId(R.id.home_component)).perform(ViewActions.swipeDown()) + + fun swipeTabRight(title: String) = + onView(allOf(withId(R.id.tab_title), withText(title))).perform(ViewActions.swipeRight()) + + fun swipeTabLeft(title: String) = + onView(allOf(withId(R.id.tab_title), withText(title))).perform(ViewActions.swipeLeft()) + + fun closeTabViaXButton(title: String) = closeTabViaX(title) + + fun verifySnackBarText(expectedText: String) { + val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) + mDevice.waitNotNull(Until.findObject(By.text(expectedText)), TestAssetHelper.waitingTime) + } + + fun snackBarButtonClick(expectedText: String) { + onView(CoreMatchers.allOf(withId(R.id.snackbar_btn), withText(expectedText))).check( + matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)) + ).perform(ViewActions.click()) + } class Transition { val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) @@ -167,6 +197,15 @@ class HomeScreenRobot { ThreeDotMenuMainRobot().interact() return ThreeDotMenuMainRobot.Transition() } + + fun closeAllPrivateTabs(interact: HomeScreenRobot.() -> Unit): Transition { + onView(withId(R.id.close_tabs_button)) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) + .perform(click()) + + HomeScreenRobot().interact() + return Transition() + } } } @@ -322,8 +361,13 @@ private fun assertYourPrivacyHeader() = .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun assertYourPrivacyText() = - onView(CoreMatchers.allOf(withText( - "We’ve designed Firefox Preview to give you control over what you share online and what you share with us."))) + onView( + CoreMatchers.allOf( + withText( + "We’ve designed Firefox Preview to give you control over what you share online and what you share with us." + ) + ) + ) .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) private fun assertPrivacyNoticeButton() = @@ -337,7 +381,7 @@ private fun assertStartBrowsingButton() = // Private mode elements private fun assertPrivateSessionHeader() = onView(CoreMatchers.allOf(withText("Private tabs"))) - .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) + .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) const val PRIVATE_SESSION_MESSAGE = "Firefox Preview clears your search and browsing history " + "when you quit the app or close all private tabs. While this doesn’t make you anonymous to websites or " + @@ -354,11 +398,12 @@ private fun assertShareTabsButton(visible: Boolean) = onView(CoreMatchers.allOf(withId(R.id.share_tabs_button), isDisplayed())) .check(matches(withEffectiveVisibility(visibleOrGone(visible)))) -private fun assertCloseTabsButton(visible: Boolean) = - onView(CoreMatchers.allOf(withId(R.id.close_tab_button), isDisplayed())) - .check(matches(withEffectiveVisibility(visibleOrGone(visible)))) +private fun assertCloseTabsButton(title: String) = + onView(allOf(withId(R.id.close_tab_button), withContentDescription("Close tab $title"))) + .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) -private fun visibleOrGone(visibility: Boolean) = if (visibility) Visibility.VISIBLE else Visibility.GONE +private fun visibleOrGone(visibility: Boolean) = + if (visibility) Visibility.VISIBLE else Visibility.GONE private fun assertExistingTabList() = onView(CoreMatchers.allOf(withId(R.id.item_tab))) @@ -375,4 +420,17 @@ private fun tabsListThreeDotButton() = onView(allOf(withId(R.id.tabs_overflow_bu private fun collectionThreeDotButton() = onView(allOf(withId(R.id.collection_overflow_button))) -private fun collectionNameTextField() = onView(allOf(ViewMatchers.withResourceName("name_collection_edittext"))) +private fun collectionNameTextField() = + onView(allOf(ViewMatchers.withResourceName("name_collection_edittext"))) + +private fun closeTabViaX(title: String) { + val closeButton = onView( + allOf( + withId(R.id.close_tab_button), + withContentDescription("Close tab $title") + ) + ) + closeButton.perform(click()) +} + +private fun assertPrivateTabsCloseTabsButton() = onView(allOf(withId(R.id.close_tabs_button))) From 82c698c818790b8be77a60c13b3f087348c8b97e Mon Sep 17 00:00:00 2001 From: David Walsh Date: Wed, 15 Jan 2020 13:26:12 -0600 Subject: [PATCH 008/226] Fix 5727 - History to browser navigation should go back to history --- app/src/main/res/navigation/nav_graph.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 71447aaf2..0fb506505 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -246,7 +246,9 @@ tools:layout="@layout/fragment_history"> + app:destination="@id/browserFragment" + app:popUpToInclusive="true" + /> @@ -264,7 +266,8 @@ app:argType="string" /> + app:destination="@id/browserFragment" + app:popUpToInclusive="true"/> From 1372ed58371dd8ae02978715341c4eac698aceab Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Thu, 30 Jan 2020 11:27:16 +0100 Subject: [PATCH 009/226] For #7970: Updates snackbars for accessibility --- .../mozilla/fenix/components/FenixSnackbar.kt | 13 +++++- .../java/org/mozilla/fenix/utils/Settings.kt | 3 ++ .../main/java/org/mozilla/fenix/utils/Undo.kt | 43 +++++-------------- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/FenixSnackbar.kt b/app/src/main/java/org/mozilla/fenix/components/FenixSnackbar.kt index f044af1ac..5eba2275e 100644 --- a/app/src/main/java/org/mozilla/fenix/components/FenixSnackbar.kt +++ b/app/src/main/java/org/mozilla/fenix/components/FenixSnackbar.kt @@ -75,6 +75,7 @@ class FenixSnackbar private constructor( companion object { const val LENGTH_LONG = Snackbar.LENGTH_LONG const val LENGTH_SHORT = Snackbar.LENGTH_SHORT + const val LENGTH_ACCESSIBLE = 15000 /* 15 seconds in ms */ const val LENGTH_INDEFINITE = Snackbar.LENGTH_INDEFINITE private const val minTextSize = 12 @@ -82,6 +83,10 @@ class FenixSnackbar private constructor( private const val actionButtonIncreaseDps = 16 private const val stepGranularity = 1 + /** + * Display a snackbar in the given view with duration and proper normal/error styling. + * Note: Duration is overriden for users with accessibility settings enabled + */ fun make(view: View, duration: Int, isError: Boolean = false): FenixSnackbar { val parent = findSuitableParent(view) ?: run { throw IllegalArgumentException( @@ -92,9 +97,15 @@ class FenixSnackbar private constructor( val inflater = LayoutInflater.from(parent.context) val content = inflater.inflate(R.layout.fenix_snackbar, parent, false) + val durationOrAccessibleDuration = if (parent.context.settings().accessibilityServicesEnabled) { + LENGTH_ACCESSIBLE + } else { + duration + } + val callback = FenixSnackbarCallback(content) return FenixSnackbar(parent, content, callback, isError).also { - it.duration = duration + it.duration = durationOrAccessibleDuration } } diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index a731423d7..48a5ee50a 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -274,6 +274,9 @@ class Settings private constructor( return accessibilityManager?.isTouchExplorationEnabled ?: false } + val accessibilityServicesEnabled: Boolean + get() { return touchExplorationIsEnabled || switchServiceIsEnabled } + val toolbarSettingString: String get() = when { shouldUseBottomToolbar -> appContext.getString(R.string.preference_bottom_toolbar) diff --git a/app/src/main/java/org/mozilla/fenix/utils/Undo.kt b/app/src/main/java/org/mozilla/fenix/utils/Undo.kt index f9512be2c..97812918d 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Undo.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Undo.kt @@ -10,13 +10,11 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.launch import org.mozilla.fenix.components.FenixSnackbar -import android.app.AlertDialog -import org.mozilla.fenix.R -import android.content.Context -import android.view.accessibility.AccessibilityManager +import org.mozilla.fenix.ext.settings import java.util.concurrent.atomic.AtomicBoolean internal const val UNDO_DELAY = 3000L +internal const val ACCESSIBLE_UNDO_DELAY = 15000L /** * Runs [operation] after giving user time (see [UNDO_DELAY]) to cancel it. @@ -44,22 +42,6 @@ fun CoroutineScope.allowUndo( // writing a volatile variable. val requestedUndo = AtomicBoolean(false) - fun showUndoDialog() { - val dialogBuilder = AlertDialog.Builder(view.context) - dialogBuilder.setMessage(message).setCancelable(false) - .setPositiveButton(R.string.a11y_dialog_deleted_confirm) { _, _ -> - launch { - operation.invoke() - } - }.setNegativeButton(R.string.a11y_dialog_deleted_undo) { _, _ -> - launch { - onCancel.invoke() - } - } - val alert = dialogBuilder.create() - alert.show() - } - fun showUndoSnackbar() { val snackbar = FenixSnackbar .make(view, FenixSnackbar.LENGTH_INDEFINITE) @@ -77,7 +59,13 @@ fun CoroutineScope.allowUndo( // Wait a bit, and if user didn't request cancellation, proceed with // requested operation and hide the snackbar. launch { - delay(UNDO_DELAY) + val lengthToDelay = if (view.context.settings().accessibilityServicesEnabled) { + ACCESSIBLE_UNDO_DELAY + } else { + UNDO_DELAY + } + + delay(lengthToDelay) if (!requestedUndo.get()) { snackbar.dismiss() @@ -86,16 +74,5 @@ fun CoroutineScope.allowUndo( } } - // It is difficult to use our Snackbars quickly enough with - // Talkback enabled, so in that case we show a dialog instead - if (touchExplorationEnabled(view)) { - showUndoDialog() - } else { - showUndoSnackbar() - } -} - -fun touchExplorationEnabled(view: View): Boolean { - val am = view.context.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager - return am.isTouchExplorationEnabled + showUndoSnackbar() } From eb2eed1c9c027884ddfa2e8b7eb2d25aea5e8239 Mon Sep 17 00:00:00 2001 From: Aaron Train Date: Fri, 31 Jan 2020 14:58:02 -0500 Subject: [PATCH 010/226] Closes #8015: fix UI test verifyContextCopyLink (#8026) --- .../java/org/mozilla/fenix/ui/ContextMenusTest.kt | 4 ++-- .../java/org/mozilla/fenix/ui/robots/BrowserRobot.kt | 4 ++-- .../mozilla/fenix/ui/robots/NavigationToolbarRobot.kt | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt index 78b24b1e1..a9510416d 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt @@ -112,7 +112,7 @@ class ContextMenusTest { clickContextCopyLink() verifySnackBarText("Link copied to clipboard") }.openNavigationToolbar { - }.visitLinkFromClipboard(genericURL.url) { + }.visitLinkFromClipboard { verifyUrl(genericURL.url.toString()) } } @@ -169,7 +169,7 @@ class ContextMenusTest { clickContextCopyImageLocation() verifySnackBarText("Link copied to clipboard") }.openNavigationToolbar { - }.visitLinkFromClipboard(imageResource.url) { + }.visitLinkFromClipboard { verifyUrl(imageResource.url.toString()) } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt index b0964dea3..bd80a3277 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt @@ -38,14 +38,14 @@ class BrowserRobot { .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) } - fun verifyUrl(redirectUrl: String) { + fun verifyUrl(url: String) { val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) mDevice.waitNotNull( Until.findObject(By.res("org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view")), TestAssetHelper.waitingTime ) onView(withId(R.id.mozac_browser_toolbar_url_view)) - .check(matches(withText(containsString(redirectUrl)))) + .check(matches(withText(containsString(url)))) } fun verifyHelpUrl() { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt index 4f5e6f400..454eecd12 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt @@ -54,7 +54,7 @@ class NavigationToolbarRobot { return BrowserRobot.Transition() } - fun visitLinkFromClipboard(url: Uri, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { + fun visitLinkFromClipboard(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { mDevice.waitNotNull( Until.findObject(By.res("org.mozilla.fenix.debug:id/mozac_browser_toolbar_clear_view")), waitingTime @@ -62,11 +62,12 @@ class NavigationToolbarRobot { clearAddressBar().click() mDevice.waitNotNull( - Until.findObject(By.text(url.toString())), waitingTime + Until.findObject(By.res("org.mozilla.fenix.debug:id/clipboard_title")), + waitingTime ) mDevice.waitNotNull( - Until.findObject(By.res("org.mozilla.fenix.debug:id/fill_link_from_clipboard")), + Until.findObject(By.res("org.mozilla.fenix.debug:id/clipboard_url")), waitingTime ) fillLinkButton().click() @@ -87,5 +88,5 @@ private fun urlBar() = onView(ViewMatchers.withId(R.id.toolbar)) private fun awesomeBar() = onView(ViewMatchers.withId(R.id.mozac_browser_toolbar_edit_url_view)) private fun threeDotButton() = onView(ViewMatchers.withContentDescription("Menu")) private fun newTab() = onView(ViewMatchers.withContentDescription("Add tab")) -private fun fillLinkButton() = onView(ViewMatchers.withId(R.id.fill_link_from_clipboard)) +private fun fillLinkButton() = onView(ViewMatchers.withId(R.id.clipboard_url)) private fun clearAddressBar() = onView(ViewMatchers.withId(R.id.mozac_browser_toolbar_clear_view)) From 1b7cb117cade9500e0130d7f3177b115ae7bb626 Mon Sep 17 00:00:00 2001 From: Mihai Branescu Date: Mon, 27 Jan 2020 15:33:57 +0200 Subject: [PATCH 011/226] For #7559 - allows changing locale even after setting theme with AppCompatDelegate.setDefaultNightMode(mode). The override is necessary because the uiMode needs to be manually updated after changing theme --- app/src/main/java/org/mozilla/fenix/HomeActivity.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt index 838de0432..d70a110b0 100644 --- a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt @@ -6,6 +6,7 @@ package org.mozilla.fenix import android.content.Context import android.content.Intent +import android.content.res.Configuration import android.os.Bundle import android.util.AttributeSet import android.view.View @@ -21,7 +22,7 @@ import androidx.navigation.NavDirections import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.NavigationUI -import kotlinx.android.synthetic.main.activity_home.* +import kotlinx.android.synthetic.main.activity_home.navigationToolbarStub import kotlinx.coroutines.launch import mozilla.components.browser.search.SearchEngine import mozilla.components.browser.session.Session @@ -91,6 +92,15 @@ open class HomeActivity : LocaleAwareAppCompatActivity() { ) } + override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) { + if (overrideConfiguration != null) { + val uiMode = overrideConfiguration.uiMode + overrideConfiguration.setTo(baseContext.resources.configuration) + overrideConfiguration.uiMode = uiMode + } + super.applyOverrideConfiguration(overrideConfiguration) + } + final override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) From 2a876d5e0f9a3c615cb95dc01180b9db114d7972 Mon Sep 17 00:00:00 2001 From: Mihai Branescu Date: Mon, 27 Jan 2020 15:41:30 +0200 Subject: [PATCH 012/226] For #7559 - fixes 2 issues: - The same item now doesn't recreate the activity - The app context now contains the right locale --- .../advanced/DefaultLocaleSettingsController.kt | 8 +++++++- .../settings/advanced/LocaleManagerExtension.kt | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/settings/advanced/DefaultLocaleSettingsController.kt b/app/src/main/java/org/mozilla/fenix/settings/advanced/DefaultLocaleSettingsController.kt index 2bd481c84..43f532861 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/advanced/DefaultLocaleSettingsController.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/advanced/DefaultLocaleSettingsController.kt @@ -21,17 +21,23 @@ class DefaultLocaleSettingsController( ) : LocaleSettingsController { override fun handleLocaleSelected(locale: Locale) { - if (localeSettingsStore.state.selectedLocale == locale) { + if (localeSettingsStore.state.selectedLocale == locale && + !LocaleManager.isDefaultLocaleSelected(context)) { return } localeSettingsStore.dispatch(LocaleSettingsAction.Select(locale)) LocaleManager.setNewLocale(context, locale.toLanguageTag()) + LocaleManager.updateBaseConfiguration(context, locale) (context as Activity).recreate() } override fun handleDefaultLocaleSelected() { + if (LocaleManager.isDefaultLocaleSelected(context)) { + return + } localeSettingsStore.dispatch(LocaleSettingsAction.Select(localeSettingsStore.state.localeList[0])) LocaleManager.resetToSystemDefault(context) + LocaleManager.updateBaseConfiguration(context, localeSettingsStore.state.localeList[0]) (context as Activity).recreate() } diff --git a/app/src/main/java/org/mozilla/fenix/settings/advanced/LocaleManagerExtension.kt b/app/src/main/java/org/mozilla/fenix/settings/advanced/LocaleManagerExtension.kt index aea61b51c..a2e68e7c4 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/advanced/LocaleManagerExtension.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/advanced/LocaleManagerExtension.kt @@ -51,3 +51,15 @@ fun LocaleManager.getSelectedLocale( fun LocaleManager.isDefaultLocaleSelected(context: Context): Boolean { return getCurrentLocale(context) == null } + +/** + * Update the locale for the configuration of the app context's resources + */ +@Suppress("DEPRECATION") +fun LocaleManager.updateBaseConfiguration(context: Context, locale: Locale) { + val resources = context.applicationContext.resources + val config = resources.configuration + config.setLocale(locale) + config.setLayoutDirection(locale) + resources.updateConfiguration(config, resources.displayMetrics) +} From 7b9f74138c3132ac70f8b0884cb79b75287bd9aa Mon Sep 17 00:00:00 2001 From: Mihai Branescu Date: Mon, 27 Jan 2020 15:42:28 +0200 Subject: [PATCH 013/226] For #7559 - added unit test for same locale selected --- .../advanced/LocaleSettingsControllerTest.kt | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/app/src/test/java/org/mozilla/fenix/settings/advanced/LocaleSettingsControllerTest.kt b/app/src/test/java/org/mozilla/fenix/settings/advanced/LocaleSettingsControllerTest.kt index cc5b0110b..ebe78b5a6 100644 --- a/app/src/test/java/org/mozilla/fenix/settings/advanced/LocaleSettingsControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/settings/advanced/LocaleSettingsControllerTest.kt @@ -11,6 +11,7 @@ import io.mockk.every import io.mockk.just import io.mockk.mockk import io.mockk.mockkObject +import io.mockk.mockkStatic import io.mockk.verify import mozilla.components.support.locale.LocaleManager import mozilla.components.support.test.mock @@ -30,6 +31,33 @@ class LocaleSettingsControllerTest { controller = DefaultLocaleSettingsController(context, localeSettingsStore) } + @Test + fun `don't set locale if same locale is chosen`() { + val selectedLocale = Locale("en", "UK") + every { localeSettingsStore.state } returns LocaleSettingsState( + mockk(), + mockk(), + selectedLocale + ) + mockkObject(LocaleManager) + mockkStatic("org.mozilla.fenix.settings.advanced.LocaleManagerExtensionKt") + every { LocaleManager.getCurrentLocale(context) } returns mockk() + every { LocaleManager.isDefaultLocaleSelected(context) } returns false + + controller.handleLocaleSelected(selectedLocale) + + verify( + inverse = true, + verifyBlock = { localeSettingsStore.dispatch(LocaleSettingsAction.Select(selectedLocale)) }) + verify( + inverse = true, + verifyBlock = { LocaleManager.setNewLocale(context, selectedLocale.toLanguageTag()) }) + verify( + inverse = true, + verifyBlock = { LocaleManager.updateBaseConfiguration(context, selectedLocale) }) + verify(inverse = true, verifyBlock = { (context as Activity).recreate() }) + } + @Test fun `set a new locale from the list`() { val selectedLocale = Locale("en", "UK") @@ -40,6 +68,8 @@ class LocaleSettingsControllerTest { otherLocale ) mockkObject(LocaleManager) + mockkStatic("org.mozilla.fenix.settings.advanced.LocaleManagerExtensionKt") + every { LocaleManager.updateBaseConfiguration(context, selectedLocale) } just Runs every { LocaleManager.setNewLocale( context, @@ -51,9 +81,37 @@ class LocaleSettingsControllerTest { verify { localeSettingsStore.dispatch(LocaleSettingsAction.Select(selectedLocale)) } verify { LocaleManager.setNewLocale(context, selectedLocale.toLanguageTag()) } + verify { LocaleManager.updateBaseConfiguration(context, selectedLocale) } verify { (context as Activity).recreate() } } + @Test + fun `don't set default locale if default locale is already chosen`() { + val selectedLocale = Locale("en", "UK") + val localeList = ArrayList() + localeList.add(selectedLocale) + every { localeSettingsStore.state } returns LocaleSettingsState( + localeList, + mockk(), + mockk() + ) + mockkStatic("org.mozilla.fenix.settings.advanced.LocaleManagerExtensionKt") + every { LocaleManager.isDefaultLocaleSelected(context) } returns true + + controller.handleDefaultLocaleSelected() + + verify( + inverse = true, + verifyBlock = { localeSettingsStore.dispatch(LocaleSettingsAction.Select(selectedLocale)) }) + verify( + inverse = true, + verifyBlock = { LocaleManager.resetToSystemDefault(context) }) + verify( + inverse = true, + verifyBlock = { LocaleManager.updateBaseConfiguration(context, selectedLocale) }) + verify(inverse = true, verifyBlock = { (context as Activity).recreate() }) + } + @Test fun `set the default locale as the new locale`() { val selectedLocale = Locale("en", "UK") @@ -65,12 +123,15 @@ class LocaleSettingsControllerTest { mockk() ) mockkObject(LocaleManager) + mockkStatic("org.mozilla.fenix.settings.advanced.LocaleManagerExtensionKt") every { LocaleManager.resetToSystemDefault(context) } just Runs + every { LocaleManager.updateBaseConfiguration(context, selectedLocale) } just Runs controller.handleDefaultLocaleSelected() verify { localeSettingsStore.dispatch(LocaleSettingsAction.Select(selectedLocale)) } verify { LocaleManager.resetToSystemDefault(context) } + verify { LocaleManager.updateBaseConfiguration(context, selectedLocale) } verify { (context as Activity).recreate() } } From 2026c60136df18626aa3e45c6a1d84fc112fa479 Mon Sep 17 00:00:00 2001 From: ValentinTimisica Date: Mon, 3 Feb 2020 15:17:49 +0200 Subject: [PATCH 014/226] For #6834: Adds telemetry for About page items Didn't change the existing probe for 'whats new' item because we're already collecting that info. --- app/metrics.yaml | 57 +++++++++++++++++++ .../components/metrics/GleanMetricsService.kt | 16 ++++++ .../fenix/components/metrics/Metrics.kt | 5 ++ .../fenix/settings/about/AboutFragment.kt | 21 ++++++- docs/metrics.md | 5 ++ 5 files changed, 101 insertions(+), 3 deletions(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index 5073eece1..9566559eb 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1703,3 +1703,60 @@ top_sites: notification_emails: - fenix-core@mozilla.com expires: "2020-09-01" + +about_page: + support_tapped: + type: event + description: > + A user tapped on "Support" item from About page + bugs: + - https://github.com/mozilla-mobile/fenix/issues/6834 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/8047 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" + privacy_notice_tapped: + type: event + description: > + A user tapped on "Privacy notice" item from About page + bugs: + - https://github.com/mozilla-mobile/fenix/issues/6834 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/8047 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" + rights_tapped: + type: event + description: > + A user tapped on "Know your rights" item from About page + bugs: + - https://github.com/mozilla-mobile/fenix/issues/6834 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/8047 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" + licensing_tapped: + type: event + description: > + A user tapped on "Licensing information" item from About page + bugs: + - https://github.com/mozilla-mobile/fenix/issues/6834 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/8047 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" + libraries_tapped: + type: event + description: > + A user tapped on "Libraries that we use" item from About page + bugs: + - https://github.com/mozilla-mobile/fenix/issues/6834 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/8047 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index 7183394db..0bcd5c8c5 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -11,6 +11,7 @@ import kotlinx.coroutines.MainScope import mozilla.components.service.glean.Glean import mozilla.components.service.glean.private.NoExtraKeys import mozilla.components.support.base.log.logger.Logger +import org.mozilla.fenix.GleanMetrics.AboutPage import org.mozilla.fenix.GleanMetrics.BookmarksManagement import org.mozilla.fenix.GleanMetrics.Collections import org.mozilla.fenix.GleanMetrics.ContextMenu @@ -466,6 +467,21 @@ private val Event.wrapper: EventWrapper<*>? is Event.TopSiteRemoved -> EventWrapper( { TopSites.remove.record(it) } ) + is Event.SupportTapped -> EventWrapper( + { AboutPage.supportTapped.record(it) } + ) + is Event.PrivacyNoticeTapped -> EventWrapper( + { AboutPage.privacyNoticeTapped.record(it) } + ) + is Event.RightsTapped -> EventWrapper( + { AboutPage.rightsTapped.record(it) } + ) + is Event.LicensingTapped -> EventWrapper( + { AboutPage.licensingTapped.record(it) } + ) + is Event.LibrariesThatWeUseTapped -> EventWrapper( + { AboutPage.librariesTapped.record(it) } + ) // Don't record other events in Glean: is Event.AddBookmark -> null is Event.OpenedBookmark -> null diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt index 28800a588..484d42cba 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt @@ -143,6 +143,11 @@ sealed class Event { object CustomEngineDeleted : Event() object PrivateBrowsingShowSearchSuggestions : Event() object WhatsNewTapped : Event() + object SupportTapped : Event() + object PrivacyNoticeTapped : Event() + object RightsTapped : Event() + object LicensingTapped : Event() + object LibrariesThatWeUseTapped : Event() // Interaction events with extras diff --git a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt index 1bfb180f7..0d7f08db8 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/about/AboutFragment.kt @@ -149,14 +149,29 @@ class AboutFragment : Fragment(), AboutPageListener { override fun onAboutItemClicked(item: AboutItem) { Do exhaustive when (item) { is AboutItem.ExternalLink -> { - if (item.type == WHATS_NEW) { - WhatsNew.userViewedWhatsNew(requireContext()) - requireComponents.analytics.metrics.track(Event.WhatsNewTapped) + when (item.type) { + WHATS_NEW -> { + WhatsNew.userViewedWhatsNew(requireContext()) + requireComponents.analytics.metrics.track(Event.WhatsNewTapped) + } + SUPPORT -> { + requireComponents.analytics.metrics.track(Event.SupportTapped) + } + PRIVACY_NOTICE -> { + requireComponents.analytics.metrics.track(Event.PrivacyNoticeTapped) + } + RIGHTS -> { + requireComponents.analytics.metrics.track(Event.RightsTapped) + } + LICENSING_INFO -> { + requireComponents.analytics.metrics.track(Event.LicensingTapped) + } } openLinkInCustomTab(item.url) } is AboutItem.Libraries -> { + requireComponents.analytics.metrics.track(Event.LibrariesThatWeUseTapped) openLibrariesPage() } } diff --git a/docs/metrics.md b/docs/metrics.md index b07b21ff0..019fd9174 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -40,6 +40,11 @@ The following metrics are added to the ping: | Name | Type | Description | Data reviews | Extras | Expiration | | --- | --- | --- | --- | --- | --- | +| about_page.libraries_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Libraries that we use" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 | +| about_page.licensing_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Licensing information" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 | +| about_page.privacy_notice_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Privacy notice" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 | +| about_page.rights_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Know your rights" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 | +| about_page.support_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Support" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 | | bookmarks_management.copied |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user copied a bookmark. |[1](https://github.com/mozilla-mobile/fenix/pull/1708)||2020-09-01 | | bookmarks_management.edited |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user edited the title and/or URL of an existing bookmark. |[1](https://github.com/mozilla-mobile/fenix/pull/1708)||2020-09-01 | | bookmarks_management.folder_add |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user added a new bookmark folder. |[1](https://github.com/mozilla-mobile/fenix/pull/1708)||2020-09-01 | From 030f75b4df13e47300339709bd45972361846584 Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Wed, 22 Jan 2020 12:53:26 -0800 Subject: [PATCH 015/226] For #5892 & #6380: Updates error page template and allows SSL bypassing --- .../main/assets/high_risk_error_pages.html | 53 ++++ app/src/main/assets/high_risk_error_style.css | 120 +++++++++ .../low_and_medium_risk_error_pages.html | 83 +++++++ .../low_and_medium_risk_error_style.css | 133 ++++++++++ .../mozilla/fenix/AppRequestInterceptor.kt | 36 +-- .../java/org/mozilla/fenix/HomeActivity.kt | 1 + .../main/res/layout/fragment_turn_on_sync.xml | 2 + .../main/res/raw/high_risk_error_style.css | 227 ------------------ .../raw/low_and_medium_risk_error_style.css | 220 ----------------- .../main/res/raw/low_risk_error_pages.html | 40 --- .../raw/medium_and_high_risk_error_pages.html | 45 ---- .../fenix/AppRequestInterceptorTest.kt | 24 +- 12 files changed, 426 insertions(+), 558 deletions(-) create mode 100644 app/src/main/assets/high_risk_error_pages.html create mode 100644 app/src/main/assets/high_risk_error_style.css create mode 100644 app/src/main/assets/low_and_medium_risk_error_pages.html create mode 100644 app/src/main/assets/low_and_medium_risk_error_style.css delete mode 100644 app/src/main/res/raw/high_risk_error_style.css delete mode 100644 app/src/main/res/raw/low_and_medium_risk_error_style.css delete mode 100644 app/src/main/res/raw/low_risk_error_pages.html delete mode 100644 app/src/main/res/raw/medium_and_high_risk_error_pages.html diff --git a/app/src/main/assets/high_risk_error_pages.html b/app/src/main/assets/high_risk_error_pages.html new file mode 100644 index 000000000..c1eb16e2d --- /dev/null +++ b/app/src/main/assets/high_risk_error_pages.html @@ -0,0 +1,53 @@ + + + + + + + + + + + + + +
+ + + + + +
+

+
+ + +
+
+
+ + + + + + + +
+ +
+
+ + + + + diff --git a/app/src/main/assets/high_risk_error_style.css b/app/src/main/assets/high_risk_error_style.css new file mode 100644 index 000000000..1a8563114 --- /dev/null +++ b/app/src/main/assets/high_risk_error_style.css @@ -0,0 +1,120 @@ +/* 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/. */ + +html, +body { + margin: 0; + padding: 0; + height: 100%; + --moz-vertical-spacing: 10px; + --moz-background-height: 32px; +} + +body { + background-size: 64px var(--moz-background-height); + background-repeat: repeat-x; + background-color: #c50042; + color: #ffffff; + padding: 0 40px; + font-size: 14px; + -moz-text-size-adjust: none; + font-family: sharp-sans; +} + +ul { + /* Shove the list indicator so that its left aligned, but use outside so that text + * doesn't don't wrap the text around it */ + padding: 0 1em; + margin: 0; + list-style-type: disc; +} + +#errorShortDesc, +li:not(:last-of-type) { + /* Margins between the li and buttons below it won't be collapsed. Remove the bottom margin here. */ + margin: var(--moz-vertical-spacing) 0; +} + +h1 { + margin: 0; + padding: 0; + margin: var(--moz-vertical-spacing) 0; + color: #ffffff; + font-family: sharp-sans; + font-weight: bold; + font-size: 20px; + line-height: 24px; +} + +p { + line-height: 20px; + margin: var(--moz-vertical-spacing) 0; + color: #ffffff; +} + +button { + display: block; + height: 36px; + width: 100%; + border-radius: 5px; + border-color: #e3e3e7; + font-family: sans-serif; + background-color: #e6e6eb; + color: #2f2c61; + font-size: 14px; + font-weight: bold; + margin: var(--moz-vertical-spacing) auto; + text-aligned:center; + vertical-aligned:center; + background-image: none; +} + +button.inProgress { + background-image: linear-gradient(-45deg, #dfe8ee, #dfe8ee 33%, + #ecf0f3 33%, #ecf0f3 66%, + #dfe8ee 66%, #dfe8ee); + background-size: 37px 5px; + background-repeat: repeat-x; + animation: progress 6s linear infinite; +} + +@keyframes progress { + from { background-position: 0 100%; } + to { background-position: 100% 100%; } +} + +#errorPageContainer { + /* If the page is greater than 550px center the content. + * This number should be kept in sync with the media query for tablets below */ + max-width: 550px; + margin: 0 auto; + transform: translateY(var(--moz-background-height)); + padding-bottom: var(--moz-vertical-spacing); + + min-height: calc(100% - var(--moz-background-height) - var(--moz-vertical-spacing)); + display: flex; + flex-direction: column; +} + +/* On large width devices, apply specific styles here. Often triggered by landscape mode or tablets */ +@media (min-width: 550px) { + button { + margin: var(--moz-vertical-spacing) var(--moz-vertical-spacing); + min-width: 400px; + width: auto; + } + + /* If the device is tall as well, add some padding to make content feel a bit more centered */ + @media (min-height: 550px) { + #errorPageContainer { + padding-top: 64px; + min-height: calc(100% - 64px); + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + } + } +} + + diff --git a/app/src/main/assets/low_and_medium_risk_error_pages.html b/app/src/main/assets/low_and_medium_risk_error_pages.html new file mode 100644 index 000000000..67ab3a284 --- /dev/null +++ b/app/src/main/assets/low_and_medium_risk_error_pages.html @@ -0,0 +1,83 @@ + + + + + + + + + + + + + +
+ + + + + +
+

+
+ + +
+
+
+ + + + + + + + +
+ +
+
+ + + + + + + diff --git a/app/src/main/assets/low_and_medium_risk_error_style.css b/app/src/main/assets/low_and_medium_risk_error_style.css new file mode 100644 index 000000000..f4d0de178 --- /dev/null +++ b/app/src/main/assets/low_and_medium_risk_error_style.css @@ -0,0 +1,133 @@ +/* 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/. */ + +html, +body { + margin: 0; + padding: 0; + height: 100%; + --moz-vertical-spacing: 10px; + --moz-background-height: 32px; +} + +body { + background-size: 64px var(--moz-background-height); + background-repeat: repeat-x; + background-color: #f9f9fb; + color: #15141A; + padding: 0 40px; + font-size: 14px; + -moz-text-size-adjust: none; + font-family: sans-serif; +} + +ul { + /* Shove the list indicator so that its left aligned, but use outside so that text + * doesn't don't wrap the text around it */ + padding: 0 1em; + margin: 0; + list-style-type: disc; +} + +#errorShortDesc, +li:not(:last-of-type) { + /* Margins between the li and buttons below it won't be collapsed. Remove the bottom margin here. */ + margin: var(--moz-vertical-spacing) 0; +} + +h1 { + margin: 0; + padding: 0; + margin: var(--moz-vertical-spacing) 0; + color: #312a65; + font-family: sans-serif; + font-weight: bold; + font-size: 20px; + line-height: 24px; +} + +p { + line-height: 20px; + margin: var(--moz-vertical-spacing) 0; +} + + +button { + display: block; + height: 36px; + width: 100%; + border-radius: 5px; + border-color: #312A65; + font-family: sans-serif; + background-color: #312A65; + color: #FFFFFF; + font-size: 14px; + font-weight: bold; + margin: var(--moz-vertical-spacing) auto; + text-aligned:center; + vertical-aligned:center; +} + +hr { + color: #EDEDF0; + margin-left: -40px; + margin-right: -40px; +} + +.buttonSecondary { + display: block; + width: 100%; + height: 36px; + border-radius: 5px; + border-color: #E0E0E6; + font-family: sans-serif; + font-weight: bold; + background-color: #E0E0E6; + color: #20123A; + text-aligned:center; + vertical-aligned:center; + margin: var(--moz-vertical-spacing) auto; +} + +#errorPageContainer { + /* If the page is greater than 550px center the content. + * This number should be kept in sync with the media query for tablets below */ + max-width: 550px; + margin: 0 auto; + min-height: 100%; +} + +/* On large width devices, apply specific styles here. Often triggered by landscape mode or tablets */ +@media (min-width: 550px) { + button { + margin: var(--moz-vertical-spacing) auto; + min-width: 400px; + width: auto; + } + + .buttonSecondary { + margin: var(--moz-vertical-spacing) auto; + min-width: 400px; + width: auto; + } + + /* If the device is tall as well, add some padding to make content feel a bit more centered */ + @media (min-height: 550px) { + #errorPageContainer { + padding-top: 64px; + min-height: calc(100% - 64px); + } + } +} + +#badCertTechnicalInfo { + overflow: auto; + white-space: pre-line; +} + +#advancedPanelButtonContainer { + display: flex; + justify-content: center; +} + diff --git a/app/src/main/java/org/mozilla/fenix/AppRequestInterceptor.kt b/app/src/main/java/org/mozilla/fenix/AppRequestInterceptor.kt index 783211e9e..260525fbb 100644 --- a/app/src/main/java/org/mozilla/fenix/AppRequestInterceptor.kt +++ b/app/src/main/java/org/mozilla/fenix/AppRequestInterceptor.kt @@ -6,7 +6,7 @@ package org.mozilla.fenix import android.content.Context import android.net.ConnectivityManager -import androidx.annotation.RawRes +import androidx.annotation.StringRes import androidx.core.content.getSystemService import mozilla.components.browser.errorpages.ErrorPages import mozilla.components.browser.errorpages.ErrorType @@ -14,8 +14,8 @@ import mozilla.components.concept.engine.EngineSession import mozilla.components.concept.engine.request.RequestInterceptor import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.components -import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.isOnline +import org.mozilla.fenix.ext.settings class AppRequestInterceptor(private val context: Context) : RequestInterceptor { override fun onLoadRequest( @@ -60,20 +60,18 @@ class AppRequestInterceptor(private val context: Context) : RequestInterceptor { uri: String? ): RequestInterceptor.ErrorResponse? { val improvedErrorType = improveErrorType(errorType) - val riskLevel = getRiskLevel(improvedErrorType) context.components.analytics.metrics.track(Event.ErrorPageVisited(improvedErrorType)) - return RequestInterceptor.ErrorResponse.Content( - ErrorPages.createErrorPage( - context, - improvedErrorType, - uri = uri, - htmlResource = riskLevel.htmlRes, - cssResource = riskLevel.cssRes - ) + val errorPageUri = ErrorPages.createUrlEncodedErrorPage( + context = context, + errorType = improvedErrorType, + uri = uri, + htmlResource = riskLevel.htmlRes ) + + return RequestInterceptor.ErrorResponse.Uri(errorPageUri) } /** @@ -124,9 +122,17 @@ class AppRequestInterceptor(private val context: Context) : RequestInterceptor { ErrorType.ERROR_SAFEBROWSING_UNWANTED_URI -> RiskLevel.High } - private enum class RiskLevel(@RawRes val htmlRes: Int, @RawRes val cssRes: Int) { - Low(R.raw.low_risk_error_pages, R.raw.low_and_medium_risk_error_style), - Medium(R.raw.medium_and_high_risk_error_pages, R.raw.low_and_medium_risk_error_style), - High(R.raw.medium_and_high_risk_error_pages, R.raw.high_risk_error_style), + internal enum class RiskLevel(val htmlRes: String) { + + Low(LOW_AND_MEDIUM_RISK_ERROR_PAGES), + Medium(LOW_AND_MEDIUM_RISK_ERROR_PAGES), + High(HIGH_RISK_ERROR_PAGES), + } + + + companion object { + internal const val LOW_AND_MEDIUM_RISK_ERROR_PAGES = "low_and_medium_risk_error_pages.html" + internal const val HIGH_RISK_ERROR_PAGES = "high_risk_error_pages.html" } } + diff --git a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt index d70a110b0..4df8affcd 100644 --- a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt @@ -164,6 +164,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity() { // NB: There are ways for the user to install new products without leaving the browser. BrowsersCache.resetAll() } + /** * Handles intents received when the activity is open. */ diff --git a/app/src/main/res/layout/fragment_turn_on_sync.xml b/app/src/main/res/layout/fragment_turn_on_sync.xml index 384496443..f8578da03 100644 --- a/app/src/main/res/layout/fragment_turn_on_sync.xml +++ b/app/src/main/res/layout/fragment_turn_on_sync.xml @@ -59,6 +59,7 @@ style="@style/Widget.MaterialComponents.Button.TextButton" android:layout_width="0dp" android:layout_height="wrap_content" + android:minHeight="48dp" android:layout_marginTop="16dp" android:letterSpacing="0" android:text="@string/sign_in_ready_for_scan" @@ -79,6 +80,7 @@ style="@style/ThemeIndependentMaterialGreyButton" android:layout_width="0dp" android:layout_height="wrap_content" + android:minHeight="48dp" android:layout_marginTop="8dp" android:text="@string/sign_in_with_email" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/raw/high_risk_error_style.css b/app/src/main/res/raw/high_risk_error_style.css deleted file mode 100644 index a84513735..000000000 --- a/app/src/main/res/raw/high_risk_error_style.css +++ /dev/null @@ -1,227 +0,0 @@ -/* 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/. */ - -html, -body { - margin: 0; - padding: 0; - height: 100%; - --moz-vertical-spacing: 10px; - --moz-background-height: 32px; -} - -body { - background-size: 64px var(--moz-background-height); - background-repeat: repeat-x; - background-color: #c50042; - color: #ffffff; - padding: 0 40px; - font-size: 14px; - -moz-text-size-adjust: none; - font-family: sharp-sans; -} - -ul { - /* Shove the list indicator so that its left aligned, but use outside so that text - * doesn't don't wrap the text around it */ - padding: 0 1em; - margin: 0; - list-style-type: disc; -} - -#errorShortDesc, -li:not(:last-of-type) { - /* Margins between the li and buttons below it won't be collapsed. Remove the bottom margin here. */ - margin: var(--moz-vertical-spacing) 0; -} - -li > button { - /* Removing the normal padding on the li so this stretched edge to edge. */ - margin-left: -1em; - margin-right: -1em; - width: calc(100% + 2em); -} - -/* Push the #ignoreWarningButton to the bottom on the blocked site page */ -.blockedsite > #errorPageContainer > #errorLongContent { - flex: 1; -} - -h1 { - margin: 0; - padding: 0; - margin: var(--moz-vertical-spacing) 0; - color: #ffffff; - font-family: sharp-sans; - font-weight: bold; - font-size: 20px; - line-height: 24px; -} - -p { - line-height: 20px; - margin: var(--moz-vertical-spacing) 0; - color: #ffffff; -} - -button { - /* Force buttons to display: block here to try and enforce collapsing margins */ - display: block; - height: 36px; - width: 100%; - border-radius: 5px; - border-color: #e3e3e7; - font-family: sharp-sans; - background-color: #e6e6eb; - color: #2f2c61; - font-size: 14px; - font-weight: bold; - position: fixed; - bottom: 20px; - text-aligned:center; - vertical-aligned:center; - background-image: none; -} - -button.inProgress { - background-image: linear-gradient(-45deg, #dfe8ee, #dfe8ee 33%, - #ecf0f3 33%, #ecf0f3 66%, - #dfe8ee 66%, #dfe8ee); - background-size: 37px 5px; - background-repeat: repeat-x; - animation: progress 6s linear infinite; -} - -@keyframes progress { - from { background-position: 0 100%; } - to { background-position: 100% 100%; } -} - -.certerror { - background-image: linear-gradient(-45deg, #f0d000, #f0d000 33%, - #fedc00 33%, #fedc00 66%, - #f0d000 66%, #f0d000); -} - -.blockedsite { - background-image: linear-gradient(-45deg, #9b2e2e, #9b2e2e 33%, - #a83232 33%, #a83232 66%, - #9b2e2e 66%, #9b2e2e); - background-color: #b14646; - color: white; -} - -#errorPageContainer { - /* If the page is greater than 550px center the content. - * This number should be kept in sync with the media query for tablets below */ - max-width: 550px; - margin: 0 auto; - transform: translateY(var(--moz-background-height)); - padding-bottom: var(--moz-vertical-spacing); - - min-height: calc(100% - var(--moz-background-height) - var(--moz-vertical-spacing)); - display: flex; - flex-direction: column; -} - -/* Expanders have a structure of - *
- *

Title

- *

Content

- *
- * - * This shows an arrow to the right of the h2 element, and hides the content when collapsed="true". */ -.expander { - margin: var(--moz-vertical-spacing) 0; - background-image: url("chrome://browser/skin/images/dropmarker.svg"); - background-repeat: no-repeat; - /* dropmarker.svg is 10x7. Ensure that its centered in the middle of an 18x18 box */ - background-position: 3px 5.5px; - background-size: 10px 7px; - padding-left: 18px; -} - -div[collapsed="true"] > .expander { - background-image: url("chrome://browser/skin/images/dropmarker-right.svg"); - /* dropmarker.svg is 7x10. Ensure that its centered in the middle of an 18x18 box */ - background-size: 7px 10px; - background-position: 5.5px 4px; -} - -div[hidden] > .expander, -div[hidden] > .expander + *, -div[collapsed="true"] > .expander + * { - display: none; -} - -.blockedsite h1 { - border-bottom-color: #9b2e2e; -} - -.blockedsite button { - background-color: #9b2e2e; - color: white; -} - -/* Style warning button to look like a small text link in the - bottom. This is preferable to just using a text link - since there is already a mechanism in browser.js for trapping - oncommand events from unprivileged chrome pages (ErrorPageEventHandler).*/ -#ignoreWarningButton { - width: calc(100% + 40px); - -moz-appearance: none; - background: #b14646; - border: none; - text-decoration: underline; - margin: 0; - margin-inline-start: -20px; - font-size: smaller; - border-radius: 0; -} - -/* On large screen devices (hopefully a 7+ inch tablet, we already center content (see #errorPageContainer above). - Apply tablet specific styles here */ -@media (min-width: 550px) { - button { - min-width: 160px; - width: auto; - } - - /* If the tablet is tall as well, add some padding to make content feel a bit more centered - border-box value of box-sizing property makes height property include both content and padding */ - @media (min-height: 550px) { - #errorPageContainer { - padding-top: 64px; - min-height: calc(100% - 64px); - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - } - } -} - -#searchbox { - padding: 0; - display: flex; - margin: var(--moz-vertical-spacing) -1em; -} - -#searchbox > input { - flex: 3; - padding: 0em 3em 0em 1em; - width: 100%; - border: none; - font-family: sans-serif; - background-image: none; - background-color: white; - border-radius-top-right: none; - border-radius-bottom-right: none; -} - -#searchbox > button { - flex: 1; - margin: 0; - width: auto; -} - diff --git a/app/src/main/res/raw/low_and_medium_risk_error_style.css b/app/src/main/res/raw/low_and_medium_risk_error_style.css deleted file mode 100644 index 3486910e7..000000000 --- a/app/src/main/res/raw/low_and_medium_risk_error_style.css +++ /dev/null @@ -1,220 +0,0 @@ -/* 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/. */ - -html, -body { - margin: 0; - padding: 0; - height: 100%; - --moz-vertical-spacing: 10px; - --moz-background-height: 32px; -} - -body { - background-size: 64px var(--moz-background-height); - background-repeat: repeat-x; - background-color: #f9f9fb; - color: #15141A; - padding: 0 40px; - font-size: 14px; - -moz-text-size-adjust: none; - font-family: sharp-sans; -} - -ul { - /* Shove the list indicator so that its left aligned, but use outside so that text - * doesn't don't wrap the text around it */ - padding: 0 1em; - margin: 0; - list-style-type: disc; -} - -#errorShortDesc, -li:not(:last-of-type) { - /* Margins between the li and buttons below it won't be collapsed. Remove the bottom margin here. */ - margin: var(--moz-vertical-spacing) 0; -} - -li > button { - /* Removing the normal padding on the li so this stretched edge to edge. */ - margin-left: -1em; - margin-right: -1em; - width: calc(100% + 2em); -} - -/* Push the #ignoreWarningButton to the bottom on the blocked site page */ -#errorLongContent { - flex: 1; -} - -h1 { - margin: 0; - padding: 0; - margin: var(--moz-vertical-spacing) 0; - color: #312a65; - font-family: sharp-sans; - font-weight: bold; - font-size: 20px; - line-height: 24px; -} - -p { - line-height: 20px; - margin: var(--moz-vertical-spacing) 0; -} - -button { - /* Force buttons to display: block here to try and enforce collapsing margins */ - display: block; - flex: 0; - height: 36px; - width: 100%; - border-radius: 5px; - border-color: #312a65; - font-family: sharp-sans; - background-color: #312a65; - color: #FFFFFF; - line-height:16px; - font-size: 14px; - font-weight: bold; - text-aligned:center; - vertical-aligned:center; - background-image: none; - margin-bottom: 20px; -} - -button.inProgress { - background-image: linear-gradient(-45deg, #dfe8ee, #dfe8ee 33%, - #ecf0f3 33%, #ecf0f3 66%, - #dfe8ee 66%, #dfe8ee); - background-size: 37px 5px; - background-repeat: repeat-x; - animation: progress 6s linear infinite; -} - -@keyframes progress { - from { background-position: 0 100%; } - to { background-position: 100% 100%; } -} - -.certerror { - background-image: linear-gradient(-45deg, #f0d000, #f0d000 33%, - #fedc00 33%, #fedc00 66%, - #f0d000 66%, #f0d000); -} - -.blockedsite { - background-image: linear-gradient(-45deg, #9b2e2e, #9b2e2e 33%, - #a83232 33%, #a83232 66%, - #9b2e2e 66%, #9b2e2e); - background-color: #b14646; - color: white; -} - -#errorPageContainer { - /* If the page is greater than 550px center the content. - * This number should be kept in sync with the media query for tablets below */ - max-width: 550px; - margin: 0 auto; - min-height: 100%; - display: flex; - flex-direction: column; -} - -/* Expanders have a structure of - *
- *

Title

- *

Content

- *
- * - * This shows an arrow to the right of the h2 element, and hides the content when collapsed="true". */ -.expander { - margin: var(--moz-vertical-spacing) 0; - background-image: url("chrome://browser/skin/images/dropmarker.svg"); - background-repeat: no-repeat; - /* dropmarker.svg is 10x7. Ensure that its centered in the middle of an 18x18 box */ - background-position: 3px 5.5px; - background-size: 10px 7px; - padding-left: 18px; -} - -div[collapsed="true"] > .expander { - background-image: url("chrome://browser/skin/images/dropmarker-right.svg"); - /* dropmarker.svg is 7x10. Ensure that its centered in the middle of an 18x18 box */ - background-size: 7px 10px; - background-position: 5.5px 4px; -} - -div[hidden] > .expander, -div[hidden] > .expander + *, -div[collapsed="true"] > .expander + * { - display: none; -} - -.blockedsite h1 { - border-bottom-color: #9b2e2e; -} - -.blockedsite button { - background-color: #9b2e2e; - color: white; -} - -/* Style warning button to look like a small text link in the - bottom. This is preferable to just using a text link - since there is already a mechanism in browser.js for trapping - oncommand events from unprivileged chrome pages (ErrorPageEventHandler).*/ -#ignoreWarningButton { - width: calc(100% + 40px); - -moz-appearance: none; - background: #b14646; - border: none; - text-decoration: underline; - margin: 0; - margin-inline-start: -20px; - font-size: smaller; - border-radius: 0; -} - -/* On large screen devices (hopefully a 7+ inch tablet, we already center content (see #errorPageContainer above). - Apply tablet specific styles here */ -@media (min-width: 550px) { - button { - min-width: 160px; - width: auto; - } - - /* If the tablet is tall as well, add some padding to make content feel a bit more centered */ - @media (min-height: 550px) { - #errorPageContainer { - padding-top: 64px; - min-height: calc(100% - 64px); - } - } -} - -#searchbox { - padding: 0; - display: flex; - margin: var(--moz-vertical-spacing) -1em; -} - -#searchbox > input { - flex: 3; - padding: 0em 3em 0em 1em; - width: 100%; - border: none; - font-family: sans-serif; - background-image: none; - background-color: white; - border-radius-top-right: none; - border-radius-bottom-right: none; -} - -#searchbox > button { - flex: 1; - margin: 0; - width: auto; -} - diff --git a/app/src/main/res/raw/low_risk_error_pages.html b/app/src/main/res/raw/low_risk_error_pages.html deleted file mode 100644 index 27b70ccee..000000000 --- a/app/src/main/res/raw/low_risk_error_pages.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - %pageTitle% - - - - - -
- - -
-

%messageShort%

-
- - -
- - -
-

%messageLong%

-
- -
- - -
- -
-
- - diff --git a/app/src/main/res/raw/medium_and_high_risk_error_pages.html b/app/src/main/res/raw/medium_and_high_risk_error_pages.html deleted file mode 100644 index dd741e5db..000000000 --- a/app/src/main/res/raw/medium_and_high_risk_error_pages.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - %pageTitle% - - - - - -
- - -
-

%messageShort%

-
- - -
- - -
-

%messageLong%

-
- -
- - -
- -
-
- - - diff --git a/app/src/test/java/org/mozilla/fenix/AppRequestInterceptorTest.kt b/app/src/test/java/org/mozilla/fenix/AppRequestInterceptorTest.kt index 7755d9290..294fc1a69 100644 --- a/app/src/test/java/org/mozilla/fenix/AppRequestInterceptorTest.kt +++ b/app/src/test/java/org/mozilla/fenix/AppRequestInterceptorTest.kt @@ -5,7 +5,6 @@ package org.mozilla.fenix import android.net.ConnectivityManager -import androidx.annotation.RawRes import androidx.core.content.getSystemService import assertk.assertThat import assertk.assertions.isEqualTo @@ -20,6 +19,8 @@ import mozilla.components.support.test.robolectric.testContext import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import org.mozilla.fenix.AppRequestInterceptor.Companion.HIGH_RISK_ERROR_PAGES +import org.mozilla.fenix.AppRequestInterceptor.Companion.LOW_AND_MEDIUM_RISK_ERROR_PAGES import org.mozilla.fenix.ext.isOnline import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config @@ -67,8 +68,7 @@ class AppRequestInterceptorTest { val actualPage = createActualErrorPage(error) val expectedPage = createExpectedErrorPage( error = error, - html = R.raw.low_risk_error_pages, - css = R.raw.low_and_medium_risk_error_style + html = LOW_AND_MEDIUM_RISK_ERROR_PAGES ) assertThat(actualPage).isEqualTo(expectedPage) @@ -85,8 +85,7 @@ class AppRequestInterceptorTest { val actualPage = createActualErrorPage(error) val expectedPage = createExpectedErrorPage( error = error, - html = R.raw.medium_and_high_risk_error_pages, - css = R.raw.low_and_medium_risk_error_style + html = LOW_AND_MEDIUM_RISK_ERROR_PAGES ) assertThat(actualPage).isEqualTo(expectedPage) @@ -104,8 +103,7 @@ class AppRequestInterceptorTest { val actualPage = createActualErrorPage(error) val expectedPage = createExpectedErrorPage( error = error, - html = R.raw.medium_and_high_risk_error_pages, - css = R.raw.high_risk_error_style + html = HIGH_RISK_ERROR_PAGES ) assertThat(actualPage).isEqualTo(expectedPage) @@ -114,11 +112,15 @@ class AppRequestInterceptorTest { private fun createActualErrorPage(error: ErrorType): String { val errorPage = interceptor.onErrorRequest(session = mockk(), errorType = error, uri = null) - as RequestInterceptor.ErrorResponse.Content - return errorPage.data + as RequestInterceptor.ErrorResponse.Uri + return errorPage.uri } - private fun createExpectedErrorPage(error: ErrorType, @RawRes html: Int, @RawRes css: Int): String { - return ErrorPages.createErrorPage(testContext, error, null, html, css) + private fun createExpectedErrorPage(error: ErrorType, html: String): String { + return ErrorPages.createUrlEncodedErrorPage( + context = testContext, + errorType = error, + htmlResource = html + ) } } From ae445abff398a3b8273d6dfd5468b75815cd62b8 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Mon, 3 Feb 2020 11:22:57 -0600 Subject: [PATCH 016/226] Small improvements, lint fixes --- .../main/assets/high_risk_error_pages.html | 15 ----------- app/src/main/assets/high_risk_error_style.css | 26 ++----------------- .../low_and_medium_risk_error_pages.html | 25 +++++------------- .../low_and_medium_risk_error_style.css | 4 +++ .../mozilla/fenix/AppRequestInterceptor.kt | 4 --- 5 files changed, 13 insertions(+), 61 deletions(-) diff --git a/app/src/main/assets/high_risk_error_pages.html b/app/src/main/assets/high_risk_error_pages.html index c1eb16e2d..aec567697 100644 --- a/app/src/main/assets/high_risk_error_pages.html +++ b/app/src/main/assets/high_risk_error_pages.html @@ -30,21 +30,6 @@ - - - - -
- -
diff --git a/app/src/main/assets/high_risk_error_style.css b/app/src/main/assets/high_risk_error_style.css index 1a8563114..41d1bf4a9 100644 --- a/app/src/main/assets/high_risk_error_style.css +++ b/app/src/main/assets/high_risk_error_style.css @@ -70,31 +70,9 @@ button { background-image: none; } -button.inProgress { - background-image: linear-gradient(-45deg, #dfe8ee, #dfe8ee 33%, - #ecf0f3 33%, #ecf0f3 66%, - #dfe8ee 66%, #dfe8ee); - background-size: 37px 5px; - background-repeat: repeat-x; - animation: progress 6s linear infinite; -} -@keyframes progress { - from { background-position: 0 100%; } - to { background-position: 100% 100%; } -} - -#errorPageContainer { - /* If the page is greater than 550px center the content. - * This number should be kept in sync with the media query for tablets below */ - max-width: 550px; - margin: 0 auto; - transform: translateY(var(--moz-background-height)); - padding-bottom: var(--moz-vertical-spacing); - - min-height: calc(100% - var(--moz-background-height) - var(--moz-vertical-spacing)); - display: flex; - flex-direction: column; +.hidden { + display: none; } /* On large width devices, apply specific styles here. Often triggered by landscape mode or tablets */ diff --git a/app/src/main/assets/low_and_medium_risk_error_pages.html b/app/src/main/assets/low_and_medium_risk_error_pages.html index 67ab3a284..5262f925a 100644 --- a/app/src/main/assets/low_and_medium_risk_error_pages.html +++ b/app/src/main/assets/low_and_medium_risk_error_pages.html @@ -32,11 +32,11 @@ - + - +
-