Bug 1912288 - Add an about:glean page to fenix r=android-reviewers,007
Differential Revision: https://phabricator.services.mozilla.com/D225081
This commit is contained in:
@@ -42,4 +42,5 @@ enum class BrowserDirection(@IdRes val fragmentId: Int) {
|
||||
FromDownloadLanguagesPreferenceFragment(R.id.downloadLanguagesPreferenceFragment),
|
||||
FromMenuDialogFragment(R.id.menuDialogFragment),
|
||||
FromWebCompatReporterFragment(R.id.webCompatReporterFragment),
|
||||
FromGleanDebugToolsFragment(R.id.gleanDebugToolsFragment),
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/* 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.debugsettings.gleandebugtools
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.widget.Toast
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.IconButton
|
||||
import androidx.compose.material.Scaffold
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import mozilla.telemetry.glean.Glean
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.lazyStore
|
||||
import org.mozilla.fenix.compose.ComposeFragment
|
||||
import org.mozilla.fenix.debugsettings.gleandebugtools.ui.GleanDebugToolsScreen
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
import org.mozilla.fenix.theme.FirefoxTheme
|
||||
|
||||
/**
|
||||
* [ComposeFragment] for displaying the Glean Debug Tools in the about:glean page.
|
||||
*/
|
||||
class GleanDebugToolsFragment : ComposeFragment() {
|
||||
|
||||
private val store by lazyStore {
|
||||
GleanDebugToolsStore(
|
||||
initialState = GleanDebugToolsState(
|
||||
logPingsToConsoleEnabled = Glean.getLogPings(),
|
||||
debugViewTag = Glean.getDebugViewTag() ?: "",
|
||||
),
|
||||
middlewares = listOf(
|
||||
GleanDebugToolsMiddleware(
|
||||
gleanDebugToolsStorage = DefaultGleanDebugToolsStorage(),
|
||||
clipboardHandler = requireComponents.clipboardHandler,
|
||||
openDebugView = { debugViewLink ->
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
intent.data = Uri.parse(debugViewLink)
|
||||
requireContext().startActivity(intent)
|
||||
},
|
||||
showToast = { pingType ->
|
||||
val toast = Toast.makeText(
|
||||
requireContext(),
|
||||
requireContext().getString(
|
||||
R.string.glean_debug_tools_send_ping_toast_message,
|
||||
pingType,
|
||||
),
|
||||
Toast.LENGTH_LONG,
|
||||
)
|
||||
toast.show()
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
|
||||
override fun UI() {
|
||||
FirefoxTheme {
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = {
|
||||
Text(
|
||||
text = stringResource(R.string.glean_debug_tools_title),
|
||||
color = FirefoxTheme.colors.textPrimary,
|
||||
style = FirefoxTheme.typography.headline6,
|
||||
)
|
||||
},
|
||||
navigationIcon = {
|
||||
val directions = GleanDebugToolsFragmentDirections.actionGlobalBrowser()
|
||||
IconButton(onClick = { findNavController().navigate(directions) }) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.mozac_ic_back_24),
|
||||
contentDescription = stringResource(
|
||||
R.string.bookmark_navigate_back_button_content_description,
|
||||
),
|
||||
tint = FirefoxTheme.colors.iconPrimary,
|
||||
)
|
||||
}
|
||||
},
|
||||
backgroundColor = FirefoxTheme.colors.layer1,
|
||||
)
|
||||
},
|
||||
backgroundColor = FirefoxTheme.colors.layer1,
|
||||
) {
|
||||
GleanDebugToolsScreen(
|
||||
gleanDebugToolsStore = store,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import org.mozilla.fenix.addons.AddonsManagementFragmentDirections
|
||||
import org.mozilla.fenix.components.menu.MenuDialogFragmentDirections
|
||||
import org.mozilla.fenix.customtabs.EXTRA_IS_SANDBOX_CUSTOM_TAB
|
||||
import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity
|
||||
import org.mozilla.fenix.debugsettings.gleandebugtools.GleanDebugToolsFragmentDirections
|
||||
import org.mozilla.fenix.exceptions.trackingprotection.TrackingProtectionExceptionsFragmentDirections
|
||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||
import org.mozilla.fenix.library.bookmarks.BookmarkFragmentDirections
|
||||
@@ -285,6 +286,8 @@ private fun getHomeNavDirections(
|
||||
|
||||
BrowserDirection.FromHistory -> HistoryFragmentDirections.actionGlobalBrowser()
|
||||
|
||||
BrowserDirection.FromGleanDebugToolsFragment -> GleanDebugToolsFragmentDirections.actionGlobalBrowser()
|
||||
|
||||
BrowserDirection.FromHistoryMetadataGroup -> HistoryMetadataGroupFragmentDirections.actionGlobalBrowser()
|
||||
|
||||
BrowserDirection.FromTrackingProtectionExceptions ->
|
||||
|
||||
@@ -93,6 +93,10 @@ class SearchDialogController(
|
||||
navController.navigateSafe(R.id.searchDialogFragment, directions)
|
||||
store.dispatch(AwesomeBarAction.EngagementFinished(abandoned = false))
|
||||
}
|
||||
"about:glean" -> {
|
||||
val directions = SearchDialogFragmentDirections.actionGleanDebugToolsFragment()
|
||||
navController.navigate(directions)
|
||||
}
|
||||
"moz://a" -> openSearchOrUrl(
|
||||
SupportUtils.getMozillaPageUrl(SupportUtils.MozillaPage.MANIFESTO),
|
||||
)
|
||||
|
||||
@@ -288,6 +288,9 @@
|
||||
android:defaultValue="@null"
|
||||
app:argType="string"
|
||||
app:nullable="true" />
|
||||
<action
|
||||
android:id="@+id/action_gleanDebugToolsFragment"
|
||||
app:destination="@id/gleanDebugToolsFragment" />
|
||||
</dialog>
|
||||
|
||||
<fragment
|
||||
@@ -1160,6 +1163,10 @@
|
||||
app:argType="mozilla.components.feature.addons.Addon" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/gleanDebugToolsFragment"
|
||||
android:name="org.mozilla.fenix.debugsettings.gleandebugtools.GleanDebugToolsFragment" />
|
||||
|
||||
<navigation
|
||||
android:id="@+id/site_permissions_exceptions_graph"
|
||||
app:startDestination="@id/sitePermissionsExceptionsFragment">
|
||||
|
||||
@@ -50,6 +50,7 @@ import org.mozilla.fenix.components.metrics.MetricsUtils
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.helpers.FenixGleanTestRule
|
||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||
import org.mozilla.fenix.search.SearchDialogFragmentDirections.Companion.actionGleanDebugToolsFragment
|
||||
import org.mozilla.fenix.search.SearchDialogFragmentDirections.Companion.actionGlobalAddonsManagementFragment
|
||||
import org.mozilla.fenix.search.SearchDialogFragmentDirections.Companion.actionGlobalSearchEngineFragment
|
||||
import org.mozilla.fenix.search.toolbar.SearchSelectorMenu
|
||||
@@ -329,6 +330,18 @@ class SearchDialogControllerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun handleGleanUrlCommitted() {
|
||||
val url = "about:glean"
|
||||
val directions = actionGleanDebugToolsFragment()
|
||||
|
||||
createController().handleUrlCommitted(url)
|
||||
|
||||
browserStore.waitUntilIdle()
|
||||
|
||||
verify { navController.navigate(directions) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun handleMozillaUrlCommitted() {
|
||||
val url = "moz://a"
|
||||
|
||||
Reference in New Issue
Block a user