mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-22 00:42:38 +00:00
prompt user to view crash in error dialog
This commit is contained in:
4 files changed
+55
-10
No files matched your search
@@ -55,11 +55,14 @@ import com.geode.launcher.preferences.ApplicationLogsActivity
|
|||||||
import com.geode.launcher.BuildConfig
|
import com.geode.launcher.BuildConfig
|
||||||
import com.geode.launcher.R
|
import com.geode.launcher.R
|
||||||
import com.geode.launcher.UserDirectoryProvider
|
import com.geode.launcher.UserDirectoryProvider
|
||||||
|
import com.geode.launcher.preferences.GeodeLogsListingActivity
|
||||||
|
import com.geode.launcher.preferences.TextViewActivity
|
||||||
import com.geode.launcher.ui.theme.Typography
|
import com.geode.launcher.ui.theme.Typography
|
||||||
import com.geode.launcher.utils.GamePackageUtils
|
import com.geode.launcher.utils.GamePackageUtils
|
||||||
import com.geode.launcher.utils.LaunchUtils
|
import com.geode.launcher.utils.LaunchUtils
|
||||||
import com.geode.launcher.utils.PreferenceUtils
|
import com.geode.launcher.utils.PreferenceUtils
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
data class LoadFailureInfo(
|
data class LoadFailureInfo(
|
||||||
val title: LaunchUtils.LauncherError,
|
val title: LaunchUtils.LauncherError,
|
||||||
@@ -137,14 +140,28 @@ fun ErrorInfoTitle(failureReason: LaunchUtils.LauncherError) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onShareCrash(context: Context) {
|
fun findSomethingForCrash(context: Context): File? {
|
||||||
val lastCrash = LaunchUtils.getLastCrash(context)
|
val lastCrash = LaunchUtils.getLastCrash(context)
|
||||||
|
if (lastCrash != null) {
|
||||||
|
return lastCrash
|
||||||
|
}
|
||||||
|
|
||||||
|
val logsDirectory = LaunchUtils.getGeodeLogsDirectory(context)
|
||||||
|
if (!logsDirectory.exists()) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return logsDirectory.listFiles()?.maxByOrNull { it.lastModified() }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onShareCrash(context: Context) {
|
||||||
|
val lastCrash = findSomethingForCrash(context)
|
||||||
if (lastCrash == null) {
|
if (lastCrash == null) {
|
||||||
Toast.makeText(context, R.string.launcher_error_export_missing, Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, R.string.launcher_error_export_missing, Toast.LENGTH_SHORT).show()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val baseDirectory = LaunchUtils.getBaseDirectory(context)
|
val baseDirectory = LaunchUtils.getBaseDirectory(context, true)
|
||||||
|
|
||||||
val providerLocation = lastCrash.toRelativeString(baseDirectory)
|
val providerLocation = lastCrash.toRelativeString(baseDirectory)
|
||||||
val documentsPath = "${UserDirectoryProvider.ROOT}${providerLocation}"
|
val documentsPath = "${UserDirectoryProvider.ROOT}${providerLocation}"
|
||||||
@@ -163,6 +180,19 @@ fun onShareCrash(context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openLastCrash(context: Context) {
|
||||||
|
val lastCrash = findSomethingForCrash(context)
|
||||||
|
if (lastCrash == null) {
|
||||||
|
Toast.makeText(context, R.string.launcher_error_export_missing, Toast.LENGTH_SHORT).show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val launchIntent = Intent(context, TextViewActivity::class.java).run {
|
||||||
|
putExtra(TextViewActivity.EXTRA_LOG_VIEW_FILENAME, lastCrash.path)
|
||||||
|
}
|
||||||
|
context.startActivity(launchIntent)
|
||||||
|
}
|
||||||
|
|
||||||
fun onShowLogs(context: Context) {
|
fun onShowLogs(context: Context) {
|
||||||
val launchIntent = Intent(context, ApplicationLogsActivity::class.java)
|
val launchIntent = Intent(context, ApplicationLogsActivity::class.java)
|
||||||
context.startActivity(launchIntent)
|
context.startActivity(launchIntent)
|
||||||
@@ -255,6 +285,10 @@ fun ErrorInfoActions(extraDetails: String?, modifier: Modifier = Modifier) {
|
|||||||
Text(stringResource(R.string.launcher_error_copy))
|
Text(stringResource(R.string.launcher_error_copy))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
val crashFile = remember { findSomethingForCrash(context) }
|
||||||
|
val readableCrash = remember { crashFile?.extension == "log" }
|
||||||
|
|
||||||
|
if (crashFile != null) {
|
||||||
Button(onClick = { onShareCrash(context) }) {
|
Button(onClick = { onShareCrash(context) }) {
|
||||||
Icon(
|
Icon(
|
||||||
painterResource(R.drawable.icon_share),
|
painterResource(R.drawable.icon_share),
|
||||||
@@ -264,11 +298,21 @@ fun ErrorInfoActions(extraDetails: String?, modifier: Modifier = Modifier) {
|
|||||||
Text(stringResource(R.string.launcher_error_export_crash))
|
Text(stringResource(R.string.launcher_error_export_crash))
|
||||||
}
|
}
|
||||||
|
|
||||||
val developerSettingsEnabled = remember {
|
if (readableCrash) {
|
||||||
PreferenceUtils.get(context).getBoolean(PreferenceUtils.Key.DEVELOPER_MODE)
|
FilledTonalButton(onClick = { openLastCrash(context) }) {
|
||||||
|
Icon(
|
||||||
|
painterResource(R.drawable.icon_description),
|
||||||
|
contentDescription = null
|
||||||
|
)
|
||||||
|
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
|
||||||
|
Text(stringResource(R.string.launcher_error_view_details))
|
||||||
}
|
}
|
||||||
if (developerSettingsEnabled) {
|
}
|
||||||
FilledTonalButton(onClick = { onShowLogs(context) }) {
|
} else {
|
||||||
|
Button(onClick = {
|
||||||
|
val launchIntent = Intent(context, GeodeLogsListingActivity::class.java)
|
||||||
|
context.startActivity(launchIntent)
|
||||||
|
}) {
|
||||||
Icon(
|
Icon(
|
||||||
painterResource(R.drawable.icon_description),
|
painterResource(R.drawable.icon_description),
|
||||||
contentDescription = null
|
contentDescription = null
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class CrashLogsActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun shareCrash(context: Context, filename: String) {
|
fun shareCrash(context: Context, filename: String) {
|
||||||
val baseDirectory = LaunchUtils.getBaseDirectory(context)
|
val baseDirectory = LaunchUtils.getBaseDirectory(context, true)
|
||||||
val crashPath = File(LaunchUtils.getCrashDirectory(context), filename)
|
val crashPath = File(LaunchUtils.getCrashDirectory(context), filename)
|
||||||
|
|
||||||
if (!crashPath.exists()) {
|
if (!crashPath.exists()) {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class GeodeLogsListingActivity : ComponentActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun shareLog(context: Context, filename: String) {
|
fun shareLog(context: Context, filename: String) {
|
||||||
val baseDirectory = LaunchUtils.getBaseDirectory(context)
|
val baseDirectory = LaunchUtils.getBaseDirectory(context, true)
|
||||||
val crashPath = File(LaunchUtils.getGeodeLogsDirectory(context), filename)
|
val crashPath = File(LaunchUtils.getGeodeLogsDirectory(context), filename)
|
||||||
|
|
||||||
if (!crashPath.exists()) {
|
if (!crashPath.exists()) {
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
<string name="launcher_error_view_logs">View logs</string>
|
<string name="launcher_error_view_logs">View logs</string>
|
||||||
<string name="launcher_error_copy_error_alt">Copy</string>
|
<string name="launcher_error_copy_error_alt">Copy</string>
|
||||||
<string name="launcher_error_copy">Copy details</string>
|
<string name="launcher_error_copy">Copy details</string>
|
||||||
|
<string name="launcher_error_view_details">View details</string>
|
||||||
<string name="launcher_error_export_crash">Share crash</string>
|
<string name="launcher_error_export_crash">Share crash</string>
|
||||||
<string name="launcher_error_export_missing">No crash dump was found!</string>
|
<string name="launcher_error_export_missing">No crash dump was found!</string>
|
||||||
<string name="launcher_error_device_info">Android %2$s, %1$s (%5$s)\nGD %4$s, Geode %3$s + v%6$s</string>
|
<string name="launcher_error_device_info">Android %2$s, %1$s (%5$s)\nGD %4$s, Geode %3$s + v%6$s</string>
|
||||||
@@ -118,10 +119,10 @@
|
|||||||
<string name="load_failed_crashed_description">A crash was reported during the last session. Try to:</string>
|
<string name="load_failed_crashed_description">A crash was reported during the last session. Try to:</string>
|
||||||
<string name="load_failed_recommendation_reinstall">Reinstall Geometry Dash.</string>
|
<string name="load_failed_recommendation_reinstall">Reinstall Geometry Dash.</string>
|
||||||
<string name="load_failed_recommendation_switch_32bit_abi">Install the 32-bit version of the launcher.</string>
|
<string name="load_failed_recommendation_switch_32bit_abi">Install the 32-bit version of the launcher.</string>
|
||||||
<string name="load_failed_recommendation_switch_64bit_abi">Install the non 32-bit version of the launcher.</string>
|
<string name="load_failed_recommendation_switch_64bit_abi">Install the non-32-bit version of the launcher.</string>
|
||||||
<string name="load_failed_recommendation_update">Verify that the latest versions of the launcher and Geometry Dash are installed.</string>
|
<string name="load_failed_recommendation_update">Verify that the latest versions of the launcher and Geometry Dash are installed.</string>
|
||||||
<string name="load_failed_recommendation_report">Report this issue to the developers.</string>
|
<string name="load_failed_recommendation_report">Report this issue to the developers.</string>
|
||||||
<string name="load_failed_recommendation_safe_mode">Enable the safe mode button in Settings.</string>
|
<string name="load_failed_recommendation_safe_mode">Use the safe mode button in Settings.</string>
|
||||||
<string name="load_failed_recommendation_dev_stl">Devs: If this is a locally built Geode version, please use the c++_shared ANDROID_STL!</string>
|
<string name="load_failed_recommendation_dev_stl">Devs: If this is a locally built Geode version, please use the c++_shared ANDROID_STL!</string>
|
||||||
|
|
||||||
<string name="message_box_cancel">Cancel</string>
|
<string name="message_box_cancel">Cancel</string>
|
||||||
|
|||||||
Reference in new issue
Block a user