Skip to content

Commit

Permalink
For mozilla-mobile#4807 - Always navigate to settings after deleting …
Browse files Browse the repository at this point in the history
…data
  • Loading branch information
boek committed Feb 18, 2020
1 parent 6150c6b commit 9c1e418
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 39 deletions.
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/res/navigation/nav_graph.xml
Expand Up @@ -525,7 +525,12 @@
<fragment
android:id="@+id/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
android:id="@+id/exceptionsFragment"
android:name="org.mozilla.fenix.exceptions.ExceptionsFragment"
Expand Down
13 changes: 13 additions & 0 deletions docs/metrics.md
Expand Up @@ -15,8 +15,10 @@ This means you might have to go searching through the dependency tree to get a f


## 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.


The following metrics are added to the ping:

| Name | Type | Description | Data reviews | Extras | Expiration |
Expand All @@ -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 |

## baseline

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).

The following metrics are added to the ping:

| Name | Type | Description | Data reviews | Extras | Expiration |
Expand All @@ -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 |

## 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 |
Expand Down Expand Up @@ -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 |
Expand All @@ -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 |
Expand Down

0 comments on commit 9c1e418

Please sign in to comment.