diff --git a/app/src/main/java/com/aliernfrog/pftool/ui/screen/settings/AboutPage.kt b/app/src/main/java/com/aliernfrog/pftool/ui/screen/settings/AboutPage.kt index e20c5527..8cbcd2ab 100644 --- a/app/src/main/java/com/aliernfrog/pftool/ui/screen/settings/AboutPage.kt +++ b/app/src/main/java/com/aliernfrog/pftool/ui/screen/settings/AboutPage.kt @@ -14,9 +14,11 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Book +import androidx.compose.material.icons.filled.CopyAll import androidx.compose.material.icons.filled.Description import androidx.compose.material.icons.filled.Face import androidx.compose.material.icons.filled.Update +import androidx.compose.material.icons.outlined.CopyAll import androidx.compose.material3.ElevatedButton import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon @@ -35,11 +37,13 @@ import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.rememberVectorPainter +import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import androidx.core.graphics.drawable.toBitmap @@ -69,6 +73,7 @@ fun AboutPage( ) { val context = LocalContext.current val uriHandler = LocalUriHandler.current + val clipboardManager = LocalClipboardManager.current val scope = rememberCoroutineScope() val appIcon = remember { context.packageManager.getApplicationIcon(context.packageName).toBitmap().asImageBitmap() @@ -163,7 +168,7 @@ fun AboutPage( FormSection( title = stringResource(R.string.settings_about_credits), topDivider = true, - bottomDivider = false + bottomDivider = true ) { LaunchedEffect(Unit) { SettingsConstant.credits.forEach { @@ -213,6 +218,23 @@ fun AboutPage( onClick = onNavigateLibsRequest ) } + + FormSection( + title = stringResource(R.string.settings_about_other), + bottomDivider = false + ) { + ButtonRow( + title = stringResource(R.string.settings_about_other_copyDebugInfo), + description = stringResource(R.string.settings_about_other_copyDebugInfo_description), + painter = rememberVectorPainter(Icons.Outlined.CopyAll) + ) { + clipboardManager.setText(AnnotatedString(mainViewModel.debugInfo)) + settingsViewModel.topToastState.showToast( + text = R.string.settings_about_other_copyDebugInfo_copied, + icon = Icons.Default.CopyAll + ) + } + } } } diff --git a/app/src/main/java/com/aliernfrog/pftool/ui/viewmodel/MainViewModel.kt b/app/src/main/java/com/aliernfrog/pftool/ui/viewmodel/MainViewModel.kt index f53b6f14..709a985d 100644 --- a/app/src/main/java/com/aliernfrog/pftool/ui/viewmodel/MainViewModel.kt +++ b/app/src/main/java/com/aliernfrog/pftool/ui/viewmodel/MainViewModel.kt @@ -3,6 +3,7 @@ package com.aliernfrog.pftool.ui.viewmodel import android.content.Context import android.content.Intent import android.net.Uri +import android.os.Build import android.util.Log import androidx.appcompat.app.AppCompatDelegate import androidx.compose.material.icons.Icons @@ -21,6 +22,7 @@ import androidx.core.os.LocaleListCompat import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.aliernfrog.pftool.R +import com.aliernfrog.pftool.SettingsConstant import com.aliernfrog.pftool.TAG import com.aliernfrog.pftool.data.Language import com.aliernfrog.pftool.data.ReleaseInfo @@ -36,6 +38,7 @@ import com.aliernfrog.pftool.util.extension.cacheFile import com.aliernfrog.pftool.util.extension.getAvailableLanguage import com.aliernfrog.pftool.util.extension.showErrorToast import com.aliernfrog.pftool.util.extension.toLanguage +import com.aliernfrog.pftool.util.manager.ContextUtils import com.aliernfrog.pftool.util.manager.PreferenceManager import com.aliernfrog.pftool.util.staticutil.GeneralUtil import com.aliernfrog.toptoast.enum.TopToastColor @@ -55,7 +58,8 @@ class MainViewModel( context: Context, val prefs: PreferenceManager, val topToastState: TopToastState, - val progressState: ProgressState + val progressState: ProgressState, + private val contextUtils: ContextUtils ) : ViewModel() { lateinit var scope: CoroutineScope val updateSheetState = SheetState(skipPartiallyExpanded = false, Density(context)) @@ -90,6 +94,16 @@ class MainViewModel( var updateAvailable by mutableStateOf(false) private set + val debugInfo: String + get() = arrayOf( + "PF Tool $applicationVersionName ($applicationVersionCode)", + "Android API ${Build.VERSION.SDK_INT}", + "Storage access type ${prefs.storageAccessType}", + SettingsConstant.experimentalPrefOptions.joinToString("\n") { + "${contextUtils.getString(it.labelResourceId)}: ${it.getValue(prefs)}" + } + ).joinToString("\n") + init { if (!supportsPerAppLanguagePreferences && prefs.language.isNotBlank()) runBlocking { appLanguage = GeneralUtil.getLanguageFromCode(prefs.language)?.getAvailableLanguage() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 73ebd07c..5d5ffbd0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -178,6 +178,10 @@ Crowdin members Translations Inspiration + Other + Copy debug information + Includes information useful for debugging. Including this in bug reports is recommended + Copied debug information Experimental settings Experimental settings enabled! Not intended for normal usage, might break the app when misused