Add export log to debug settings screen

This commit is contained in:
MM20 2022-01-09 01:14:36 +01:00
parent ed11330674
commit ef01439ded
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
3 changed files with 32 additions and 0 deletions

View File

@ -440,6 +440,7 @@
<string name="preference_crash_reporter">Crash-Reporter</string>
<string name="preference_crash_reporter_summary">Fehler- und Absturzberichte</string>
<string name="preference_export_log">Log-Datei exportieren</string>
<string name="preference_music_filter_sources">Auf Musik-Apps begrenzen</string>
<string name="preference_music_filter_sources_summary">Mediensitzungen von Apps ignorieren, die keine Musik-Apps sind</string>

View File

@ -478,6 +478,7 @@
<string name="preference_crash_reporter">Crash reporter</string>
<string name="preference_crash_reporter_summary">Error and crash reports</string>
<string name="preference_export_log">Export log file</string>
<string name="preference_music_filter_sources">Restrict to music apps</string>
<string name="preference_music_filter_sources_summary">Ignore media sessions of apps that are not music apps</string>

View File

@ -1,16 +1,24 @@
package de.mm20.launcher2.ui.settings.debug
import android.content.Intent
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.core.content.FileProvider
import de.mm20.launcher2.crashreporter.CrashReporter
import de.mm20.launcher2.debug.DebugInformationDumper
import de.mm20.launcher2.ktx.tryStartActivity
import de.mm20.launcher2.ui.R
import de.mm20.launcher2.ui.component.preferences.Preference
import de.mm20.launcher2.ui.component.preferences.PreferenceScreen
import kotlinx.coroutines.launch
import java.io.File
@Composable
fun DebugSettingsScreen() {
val context = LocalContext.current
val scope = rememberCoroutineScope()
PreferenceScreen(
stringResource(R.string.preference_screen_debug)
) {
@ -21,6 +29,28 @@ fun DebugSettingsScreen() {
onClick = {
context.startActivity(CrashReporter.getLaunchIntent())
})
Preference(
title = stringResource(R.string.preference_export_log),
onClick = {
scope.launch {
val path = DebugInformationDumper().dump(context)
context.tryStartActivity(
Intent.createChooser(
Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
putExtra(
Intent.EXTRA_STREAM, FileProvider.getUriForFile(
context,
context.applicationContext.packageName + ".fileprovider",
File(path)
)
)
}, null
)
)
}
})
}
}
}