add a button just for me

This commit is contained in:
Chloe committed 2026-02-01 22:52:43 -07:00
1 parent 3a54c34580
commit 5edd63f78f
4 files changed
+43 -1

No files matched your search

@@ -45,7 +45,8 @@ class CrashViewModel(private val application: Application) : ViewModel() {
private var logJob: Job? = null
@OptIn(ExperimentalTime::class)
var hasIndicator = false
private fun getCrashList(): List<CrashDump> {
val crashDirectory = LaunchUtils.getCrashDirectory(application)
if (!crashDirectory.exists()) {
@@ -57,6 +58,8 @@ class CrashViewModel(private val application: Application) : ViewModel() {
_, name -> name != LaunchUtils.CRASH_INDICATOR_NAME && name != "last-pid"
} ?: return emptyList()
hasIndicator = File(crashDirectory, LaunchUtils.CRASH_INDICATOR_NAME).exists()
return children
.map {
CrashDump(
@@ -67,6 +70,15 @@ class CrashViewModel(private val application: Application) : ViewModel() {
.sortedByDescending { it.lastModified }
}
fun clearIndicator() {
viewModelScope.launch(Dispatchers.IO) {
val crashDirectory = LaunchUtils.getCrashDirectory(application)
File(crashDirectory, LaunchUtils.CRASH_INDICATOR_NAME).delete()
hasIndicator = false
}
}
fun clearCrashes() {
logJob?.cancel()
@@ -232,6 +232,25 @@ fun CrashLogsScreen(
showMoreOptions = false
}
)
val developerMode by PreferenceUtils.useBooleanPreference(PreferenceUtils.Key.DEVELOPER_MODE)
if (developerMode) {
DropdownMenuItem(
leadingIcon = {
Icon(
painterResource(R.drawable.icon_remove_selection),
contentDescription = null
)
},
text = {
Text(stringResource(R.string.application_crashes_clear_indicator))
}, onClick = {
crashViewModel.clearIndicator()
showMoreOptions = false
},
enabled = crashViewModel.hasIndicator
)
}
}
},
title = {