Render debug info screen with Jetpack Compose.

upstream-sync
Sebastian Kaspari 3 years ago committed by mergify[bot]
parent 84fdf62240
commit 1cd04cd05e

@ -217,6 +217,14 @@ android {
minHeapSize = "1024m" minHeapSize = "1024m"
} }
} }
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = Versions.androidx_compose
}
} }
android.applicationVariants.all { variant -> android.applicationVariants.all { variant ->
@ -496,6 +504,10 @@ dependencies {
implementation Deps.mozilla_lib_dataprotect implementation Deps.mozilla_lib_dataprotect
debugImplementation Deps.leakcanary debugImplementation Deps.leakcanary
implementation Deps.androidx_compose_ui
implementation Deps.androidx_compose_ui_tooling
implementation Deps.androidx_compose_foundation
implementation Deps.androidx_compose_material
implementation Deps.androidx_legacy implementation Deps.androidx_legacy
implementation Deps.androidx_biometric implementation Deps.androidx_biometric
implementation Deps.androidx_paging implementation Deps.androidx_paging

@ -7,6 +7,8 @@ package org.mozilla.fenix.components
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.core.net.toUri import androidx.core.net.toUri
import com.google.android.play.core.review.ReviewManagerFactory import com.google.android.play.core.review.ReviewManagerFactory
import mozilla.components.feature.addons.AddonManager import mozilla.components.feature.addons.AddonManager
@ -25,6 +27,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.autofill.AutofillConfirmActivity import org.mozilla.fenix.autofill.AutofillConfirmActivity
import org.mozilla.fenix.autofill.AutofillSearchActivity import org.mozilla.fenix.autofill.AutofillSearchActivity
import org.mozilla.fenix.autofill.AutofillUnlockActivity import org.mozilla.fenix.autofill.AutofillUnlockActivity
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.perf.AppStartReasonProvider import org.mozilla.fenix.perf.AppStartReasonProvider
import org.mozilla.fenix.perf.StartupActivityLog import org.mozilla.fenix.perf.StartupActivityLog
@ -173,3 +176,10 @@ class Components(private val context: Context) {
val startupActivityLog by lazyMonitored { StartupActivityLog() } val startupActivityLog by lazyMonitored { StartupActivityLog() }
val startupStateProvider by lazyMonitored { StartupStateProvider(startupActivityLog, appStartReasonProvider) } val startupStateProvider by lazyMonitored { StartupStateProvider(startupActivityLog, appStartReasonProvider) }
} }
/**
* Returns the [Components] object from within a [Composable].
*/
val components: Components
@Composable
get() = LocalContext.current.components

@ -5,30 +5,65 @@
package org.mozilla.fenix.settings package org.mozilla.fenix.settings
import android.os.Bundle import android.os.Bundle
import androidx.preference.Preference import android.view.LayoutInflater
import androidx.preference.PreferenceFragmentCompat import android.view.View
import android.view.ViewGroup
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.fragment.app.Fragment
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.components.components
import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.ext.showToolbar
class SecretDebugSettingsFragment : PreferenceFragmentCompat() { class SecretDebugSettingsFragment : Fragment() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
showToolbar(getString(R.string.preferences_debug_info)) showToolbar(getString(R.string.preferences_debug_info))
} }
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreateView(
setPreferencesFromResource(R.xml.secret_info_settings_preferences, rootKey) inflater: LayoutInflater,
container: ViewGroup?,
val store = requireComponents.core.store savedInstanceState: Bundle?
): View {
requirePreference<Preference>(R.string.pref_key_search_region_home).apply { return ComposeView(requireContext()).apply {
summary = store.state.search.region?.home ?: "Unknown" setContent { DebugInfo() }
} }
}
}
requirePreference<Preference>(R.string.pref_key_search_region_current).apply { @Composable
summary = store.state.search.region?.current ?: "Unknown" private fun DebugInfo() {
} val store = components.core.store
Column(
modifier = Modifier.padding(8.dp)
) {
Text(
text = stringResource(R.string.debug_info_region_home),
style = MaterialTheme.typography.h6,
modifier = Modifier.padding(4.dp)
)
Text(
text = store.state.search.region?.home ?: "Unknown",
modifier = Modifier.padding(4.dp))
Text(
text = stringResource(R.string.debug_info_region_current),
style = MaterialTheme.typography.h6,
modifier = Modifier.padding(4.dp)
)
Text(
text = store.state.search.region?.current ?: "Unknown",
modifier = Modifier.padding(4.dp)
)
} }
} }

@ -279,8 +279,6 @@
<!-- Secret Info Setting Keys --> <!-- Secret Info Setting Keys -->
<string name="pref_key_secret_debug_info" translatable="false">pref_key_secret_debug_info</string> <string name="pref_key_secret_debug_info" translatable="false">pref_key_secret_debug_info</string>
<string name="pref_key_search_region_home" translatable="false">pref_key_search_region_home</string>
<string name="pref_key_search_region_current" translatable="false">pref_key_search_region_current</string>
<!-- Secret Settings --> <!-- Secret Settings -->
<string name="pref_key_show_address_feature" translatable="false">pref_key_show_address_feature</string> <string name="pref_key_show_address_feature" translatable="false">pref_key_show_address_feature</string>

@ -73,7 +73,6 @@
<!-- Secret debug info strings --> <!-- Secret debug info strings -->
<string name="debug_info_telemetry_title" translatable="false">Telemetry</string> <string name="debug_info_telemetry_title" translatable="false">Telemetry</string>
<string name="debug_info_search_title" translatable="false">Search</string>
<string name="debug_info_region_home" translatable="false">Home region</string> <string name="debug_info_region_home" translatable="false">Home region</string>
<string name="debug_info_region_current" translatable="false">Current region</string> <string name="debug_info_region_current" translatable="false">Current region</string>
</resources> </resources>

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:title="@string/debug_info_search_title">
<Preference
android:key="@string/pref_key_search_region_home"
android:title="@string/debug_info_region_home"
android:enabled="false" />
<Preference
android:key="@string/pref_key_search_region_current"
android:title="@string/debug_info_region_current"
android:enabled="false" />
</PreferenceCategory>
</PreferenceScreen>

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
object Versions { object Versions {
const val kotlin = "1.5.20" const val kotlin = "1.5.10"
const val coroutines = "1.5.0" const val coroutines = "1.5.0"
// These versions are linked: lint should be X+23.Y.Z of gradle_plugin version, according to: // These versions are linked: lint should be X+23.Y.Z of gradle_plugin version, according to:
@ -17,6 +17,8 @@ object Versions {
const val detekt = "1.17.1" const val detekt = "1.17.1"
const val jna = "5.6.0" const val jna = "5.6.0"
const val androidx_activity_compose = "1.3.0-rc02"
const val androidx_compose = "1.0.0-rc02"
const val androidx_appcompat = "1.3.0" const val androidx_appcompat = "1.3.0"
const val androidx_benchmark = "1.0.0" const val androidx_benchmark = "1.0.0"
const val androidx_biometric = "1.1.0" const val androidx_biometric = "1.1.0"
@ -164,6 +166,12 @@ object Deps {
const val sentry = "io.sentry:sentry-android:${Versions.sentry}" const val sentry = "io.sentry:sentry-android:${Versions.sentry}"
const val leakcanary = "com.squareup.leakcanary:leakcanary-android:${Versions.leakcanary}" const val leakcanary = "com.squareup.leakcanary:leakcanary-android:${Versions.leakcanary}"
const val androidx_compose_ui = "androidx.compose.ui:ui:${Versions.androidx_compose}"
const val androidx_compose_ui_test = "androidx.compose.ui:ui-test-junit4:${Versions.androidx_compose}"
const val androidx_compose_ui_test_manifest = "androidx.compose.ui:ui-test-manifest:${Versions.androidx_compose}"
const val androidx_compose_ui_tooling = "androidx.compose.ui:ui-tooling:${Versions.androidx_compose}"
const val androidx_compose_foundation = "androidx.compose.foundation:foundation:${Versions.androidx_compose}"
const val androidx_compose_material = "androidx.compose.material:material:${Versions.androidx_compose}"
const val androidx_annotation = "androidx.annotation:annotation:${Versions.androidx_annotation}" const val androidx_annotation = "androidx.annotation:annotation:${Versions.androidx_annotation}"
const val androidx_benchmark_junit4 = "androidx.benchmark:benchmark-junit4:${Versions.androidx_benchmark}" const val androidx_benchmark_junit4 = "androidx.benchmark:benchmark-junit4:${Versions.androidx_benchmark}"
const val androidx_biometric = "androidx.biometric:biometric:${Versions.androidx_biometric}" const val androidx_biometric = "androidx.biometric:biometric:${Versions.androidx_biometric}"

Loading…
Cancel
Save