2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-09 19:10:42 +00:00

For #4807 - Always navigate to settings after deleting data

This commit is contained in:
Jeff Boek 2020-02-18 12:50:29 -08:00
parent 8939358f40
commit 5c6e6ddfb7
3 changed files with 21 additions and 39 deletions

View File

@ -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() { private fun returnToDeletionOrigin() {
// If Delete browsing data fragment isn't in the backstack val directions = DeleteBrowsingDataFragmentDirections.actionDeleteBrowsingDataFragmentToSettingsFragment()
// then Android may have changed their naming convention findNavController().navigate(directions)
// 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()
} }
companion object { companion object {

View File

@ -525,7 +525,12 @@
<fragment <fragment
android:id="@+id/deleteBrowsingDataFragment" android:id="@+id/deleteBrowsingDataFragment"
android:name="org.mozilla.fenix.settings.deletebrowsingdata.DeleteBrowsingDataFragment" android:name="org.mozilla.fenix.settings.deletebrowsingdata.DeleteBrowsingDataFragment"
android:label="@string/preferences_delete_browsing_data" /> android:label="@string/preferences_delete_browsing_data" >
<action
android:id="@+id/action_deleteBrowsingDataFragment_to_settingsFragment"
app:destination="@id/settingsFragment"
app:popUpTo="@id/homeFragment" />
</fragment>
<fragment <fragment
android:id="@+id/exceptionsFragment" android:id="@+id/exceptionsFragment"
android:name="org.mozilla.fenix.exceptions.ExceptionsFragment" android:name="org.mozilla.fenix.exceptions.ExceptionsFragment"

View File

@ -15,8 +15,10 @@ This means you might have to go searching through the dependency tree to get a f
## activation ## activation
This ping is intended to provide a measure of the activation of mobile products. It's generated when Fenix starts, right after Glean is initialized. It doesn't include the client_id, since it might be reporting an hashed version of the Google Advertising ID. This ping is intended to provide a measure of the activation of mobile products. It's generated when Fenix starts, right after Glean is initialized. It doesn't include the client_id, since it might be reporting an hashed version of the Google Advertising ID.
The following metrics are added to the ping: The following metrics are added to the ping:
| Name | Type | Description | Data reviews | Extras | Expiration | | Name | Type | Description | Data reviews | Extras | Expiration |
@ -25,8 +27,11 @@ The following metrics are added to the ping:
| activation.identifier |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A hashed and salted version of the Google Advertising ID from the device. This will never be sent in a ping that also contains the client_id. |[1](https://github.com/mozilla-mobile/fenix/pull/1707#issuecomment-486972209)||2020-09-01 | | activation.identifier |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A hashed and salted version of the Google Advertising ID from the device. This will never be sent in a ping that also contains the client_id. |[1](https://github.com/mozilla-mobile/fenix/pull/1707#issuecomment-486972209)||2020-09-01 |
## baseline ## baseline
This is a built-in ping that is assembled out of the box by the Glean SDK. This is a built-in ping that is assembled out of the box by the Glean SDK.
See the Glean SDK documentation for the [`baseline` ping](https://mozilla.github.io/glean/book/user/pings/baseline.html). See the Glean SDK documentation for the [`baseline` ping](https://mozilla.github.io/glean/book/user/pings/baseline.html).
The following metrics are added to the ping: The following metrics are added to the ping:
| Name | Type | Description | Data reviews | Extras | Expiration | | Name | Type | Description | Data reviews | Extras | Expiration |
@ -35,8 +40,11 @@ The following metrics are added to the ping:
| metrics.search_count |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |The labels for this counter are `<search-engine-name>.<source>`. 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 | | metrics.search_count |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |The labels for this counter are `<search-engine-name>.<source>`. 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 ## events
This is a built-in ping that is assembled out of the box by the Glean SDK. 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). 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: The following metrics are added to the ping:
| Name | Type | Description | Data reviews | Extras | Expiration | | 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 | | 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 ## installation
This ping is intended to capture the source of the installation This ping is intended to capture the source of the installation
The following metrics are added to the ping: The following metrics are added to the ping:
| Name | Type | Description | Data reviews | Extras | Expiration | | 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 | | 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 ## metrics
This is a built-in ping that is assembled out of the box by the Glean SDK. 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). 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: The following metrics are added to the ping:
| Name | Type | Description | Data reviews | Extras | Expiration | | Name | Type | Description | Data reviews | Extras | Expiration |