From 5c6e6ddfb7f93d74fe4e3c772a9a10ef03526f29 Mon Sep 17 00:00:00 2001 From: Jeff Boek Date: Tue, 18 Feb 2020 12:50:29 -0800 Subject: [PATCH] For #4807 - Always navigate to settings after deleting data --- .../DeleteBrowsingDataFragment.kt | 40 +------------------ app/src/main/res/navigation/nav_graph.xml | 7 +++- docs/metrics.md | 13 ++++++ 3 files changed, 21 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/settings/deletebrowsingdata/DeleteBrowsingDataFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/deletebrowsingdata/DeleteBrowsingDataFragment.kt index 1165e6bef7..00327859a8 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/deletebrowsingdata/DeleteBrowsingDataFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/deletebrowsingdata/DeleteBrowsingDataFragment.kt @@ -210,45 +210,9 @@ class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_da ) } - // If coming from Open Tab -> Settings, pop back to Home - // If coming from Home -> Settings, pop back to Settings private fun returnToDeletionOrigin() { - // If Delete browsing data fragment isn't in the backstack - // then Android may have changed their naming convention - // and we want to prevent a crash by defaulting to pop home behavior - if (checkIfFragmentInBackStack(R.id.deleteBrowsingDataFragment)) { - // If Settings is in the backstack then we can continue with intended behavior - if (checkIfFragmentInBackStack(R.id.browserFragment)) findNavController().popBackStack( - R.id.homeFragment, - false - ) - else findNavController().popBackStack() - } else { - findNavController().popBackStack( - R.id.homeFragment, - false - ) - } - } - - // For some reason, the only way you can tell if you came from - // BrowserFrag -> Settings OR BrowserFrag -> HomeFrag -> Settings is to check whether - // there is a browser fragment entry in the back stack. If there is, it means you came from BrowserFrag -> Settings - // if there isn't, it means you came from HomeFrag -> Settings - private fun checkIfFragmentInBackStack(res: Int): Boolean { - val backStackEntryCount = parentFragmentManager.backStackEntryCount - for (i in 0 until backStackEntryCount) { - if (getResIdFromBackstack(parentFragmentManager.getBackStackEntryAt(i).name) == res) { - return true - } - } - - return false - } - - private fun getResIdFromBackstack(name: String?): Int { - val idString = name?.split("-") - return idString!![1].toInt() + val directions = DeleteBrowsingDataFragmentDirections.actionDeleteBrowsingDataFragmentToSettingsFragment() + findNavController().navigate(directions) } companion object { diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 5b736e426a..f1dc0026ff 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -525,7 +525,12 @@ + android:label="@string/preferences_delete_browsing_data" > + + .`. If the search engine is bundled with Fenix `search-engine-name` will be the name of the search engine. If it's a custom search engine (defined: https://github.com/mozilla-mobile/fenix/issues/1607) the value will be `custom`. `source` will be: `action`, `suggestion`, `widget` or `shortcut` (depending on the source from which the search started). Also added the `other` option for the source but it should never enter on this case. |[1](https://github.com/mozilla-mobile/fenix/pull/1677), [2](https://github.com/mozilla-mobile/fenix/pull/5216), [3](https://github.com/mozilla-mobile/fenix/pull/7310)||2020-09-01 | ## events + This is a built-in ping that is assembled out of the box by the Glean SDK. + See the Glean SDK documentation for the [`events` ping](https://mozilla.github.io/glean/book/user/pings/events.html). + The following metrics are added to the ping: | Name | Type | Description | Data reviews | Extras | Expiration | @@ -171,8 +179,10 @@ The following metrics are added to the ping: | user_specified_search_engines.custom_engine_deleted |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user deleted a custom search engine |[1](https://github.com/mozilla-mobile/fenix/pull/6918)||2020-09-01 | ## installation + This ping is intended to capture the source of the installation + The following metrics are added to the ping: | Name | Type | Description | Data reviews | Extras | Expiration | @@ -184,8 +194,11 @@ The following metrics are added to the ping: | installation.timestamp |[datetime](https://mozilla.github.io/glean/book/user/metrics/datetime.html) |The date and time of the installation. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202)||2020-09-01 | ## metrics + This is a built-in ping that is assembled out of the box by the Glean SDK. + See the Glean SDK documentation for the [`metrics` ping](https://mozilla.github.io/glean/book/user/pings/metrics.html). + The following metrics are added to the ping: | Name | Type | Description | Data reviews | Extras | Expiration |