commit b0df215ddeb23e304f8678f53572b79851251b23
parent eb94f1f7c52ef462ca06fc12c51990919e5a9d9c
Author: Gabriel Luong <gabriel.luong@gmail.com>
Date: Tue, 18 Nov 2025 21:46:22 +0000
Bug 2000090 - Part 3: Migrate CrashTools to use M3 color tokens r=android-reviewers,007
Differential Revision: https://phabricator.services.mozilla.com/D272570
Diffstat:
1 file changed, 62 insertions(+), 47 deletions(-)
diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/debugsettings/crashtools/CrashTools.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/debugsettings/crashtools/CrashTools.kt
@@ -12,6 +12,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@@ -22,6 +24,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.delay
import mozilla.components.compose.base.annotation.FlexibleWindowLightDarkPreview
@@ -30,6 +33,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.components.components
import org.mozilla.fenix.startupCrash.StartupCrashActivity
import org.mozilla.fenix.theme.FirefoxTheme
+import org.mozilla.fenix.theme.Theme
import org.mozilla.fenix.utils.Settings
private const val SECOND_IN_MILLISECOND = 1000L
@@ -49,54 +53,57 @@ internal fun CrashTools(
delay(SECOND_IN_MILLISECOND)
}
}
- Column(
- modifier = Modifier
- .padding(all = 16.dp)
- .verticalScroll(state = rememberScrollState()),
- ) {
- Text(
- text = stringResource(
- R.string.crash_debug_deferral_timer,
- convertMillisToDHMS(maxOf(genericDeferPeriod, 0)),
- ),
- style = FirefoxTheme.typography.body2,
- )
- FilledButton(
- text = stringResource(R.string.crash_debug_deferral_button),
- modifier = Modifier.fillMaxWidth(),
- onClick = {
- settings.crashReportDeferredUntil = 0L
- genericDeferPeriod = 0L
- },
- )
- Text(
- text = stringResource(R.string.crash_debug_crash_app_warning),
- color = FirefoxTheme.colors.actionCritical,
- style = FirefoxTheme.typography.subtitle2,
- )
- FilledButton(
- text = stringResource(R.string.crash_debug_generic_crash_trigger),
- modifier = Modifier.fillMaxWidth(),
- onClick = {
- throw ArithmeticException("Debug drawer triggered exception.")
- },
- )
- Text(
- text = stringResource(R.string.crash_debug_startup_crash_warning),
- color = FirefoxTheme.colors.actionCritical,
- style = FirefoxTheme.typography.subtitle2,
- )
- FilledButton(
- text = stringResource(R.string.crash_debug_show_startup_crash_screen),
- modifier = Modifier.fillMaxWidth(),
- onClick = {
- val intent = Intent(appContext, StartupCrashActivity::class.java)
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- appContext.startActivity(intent)
- Process.killProcess(Process.myPid())
- },
- )
+ Surface {
+ Column(
+ modifier = Modifier
+ .padding(all = 16.dp)
+ .verticalScroll(state = rememberScrollState()),
+ ) {
+ Text(
+ text = stringResource(
+ R.string.crash_debug_deferral_timer,
+ convertMillisToDHMS(maxOf(genericDeferPeriod, 0)),
+ ),
+ style = FirefoxTheme.typography.body2,
+ )
+ FilledButton(
+ text = stringResource(R.string.crash_debug_deferral_button),
+ modifier = Modifier.fillMaxWidth(),
+ onClick = {
+ settings.crashReportDeferredUntil = 0L
+ genericDeferPeriod = 0L
+ },
+ )
+ Text(
+ text = stringResource(R.string.crash_debug_crash_app_warning),
+ color = MaterialTheme.colorScheme.error,
+ style = FirefoxTheme.typography.subtitle2,
+ )
+ FilledButton(
+ text = stringResource(R.string.crash_debug_generic_crash_trigger),
+ modifier = Modifier.fillMaxWidth(),
+ onClick = {
+ throw ArithmeticException("Debug drawer triggered exception.")
+ },
+ )
+ Text(
+ text = stringResource(R.string.crash_debug_startup_crash_warning),
+ color = MaterialTheme.colorScheme.error,
+ style = FirefoxTheme.typography.subtitle2,
+ )
+ FilledButton(
+ text = stringResource(R.string.crash_debug_show_startup_crash_screen),
+ modifier = Modifier.fillMaxWidth(),
+ onClick = {
+ val intent = Intent(appContext, StartupCrashActivity::class.java)
+
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ appContext.startActivity(intent)
+ Process.killProcess(Process.myPid())
+ },
+ )
+ }
}
}
@@ -111,3 +118,11 @@ private fun CrashToolsPreview() {
CrashTools(Settings(LocalContext.current))
}
}
+
+@Preview
+@Composable
+private fun CrashToolsPrivatePreview() {
+ FirefoxTheme(theme = Theme.Private) {
+ CrashTools(Settings(LocalContext.current))
+ }
+}