Render debug info screen with Jetpack Compose.
This commit is contained in:
parent
84fdf62240
commit
1cd04cd05e
|
@ -217,6 +217,14 @@ android {
|
|||
minHeapSize = "1024m"
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
compose true
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = Versions.androidx_compose
|
||||
}
|
||||
}
|
||||
|
||||
android.applicationVariants.all { variant ->
|
||||
|
@ -496,6 +504,10 @@ dependencies {
|
|||
implementation Deps.mozilla_lib_dataprotect
|
||||
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_biometric
|
||||
implementation Deps.androidx_paging
|
||||
|
|
|
@ -7,6 +7,8 @@ package org.mozilla.fenix.components
|
|||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.core.net.toUri
|
||||
import com.google.android.play.core.review.ReviewManagerFactory
|
||||
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.AutofillSearchActivity
|
||||
import org.mozilla.fenix.autofill.AutofillUnlockActivity
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.perf.AppStartReasonProvider
|
||||
import org.mozilla.fenix.perf.StartupActivityLog
|
||||
|
@ -173,3 +176,10 @@ class Components(private val context: Context) {
|
|||
val startupActivityLog by lazyMonitored { StartupActivityLog() }
|
||||
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
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import android.view.LayoutInflater
|
||||
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.ext.requireComponents
|
||||
import org.mozilla.fenix.components.components
|
||||
import org.mozilla.fenix.ext.showToolbar
|
||||
|
||||
class SecretDebugSettingsFragment : PreferenceFragmentCompat() {
|
||||
class SecretDebugSettingsFragment : Fragment() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
showToolbar(getString(R.string.preferences_debug_info))
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.secret_info_settings_preferences, rootKey)
|
||||
|
||||
val store = requireComponents.core.store
|
||||
|
||||
requirePreference<Preference>(R.string.pref_key_search_region_home).apply {
|
||||
summary = store.state.search.region?.home ?: "Unknown"
|
||||
}
|
||||
|
||||
requirePreference<Preference>(R.string.pref_key_search_region_current).apply {
|
||||
summary = store.state.search.region?.current ?: "Unknown"
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
return ComposeView(requireContext()).apply {
|
||||
setContent { DebugInfo() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
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 -->
|
||||
<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 -->
|
||||
<string name="pref_key_show_address_feature" translatable="false">pref_key_show_address_feature</string>
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
|
||||
<!-- Secret debug info strings -->
|
||||
<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_current" translatable="false">Current region</string>
|
||||
</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/. */
|
||||
|
||||
object Versions {
|
||||
const val kotlin = "1.5.20"
|
||||
const val kotlin = "1.5.10"
|
||||
const val coroutines = "1.5.0"
|
||||
|
||||
// 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 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_benchmark = "1.0.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 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_benchmark_junit4 = "androidx.benchmark:benchmark-junit4:${Versions.androidx_benchmark}"
|
||||
const val androidx_biometric = "androidx.biometric:biometric:${Versions.androidx_biometric}"
|
||||
|
|
Loading…
Reference in New Issue
Block a user