[Android] button for bug report on fatal error

Signed-off-by: Harry Bond <me@hbond.xyz>
This commit is contained in:
Harry Bond 2024-07-28 01:57:46 +01:00 committed by Alexander Borsuk
parent 29c91f244a
commit 3eae1ff9f1

View file

@ -7,6 +7,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
@ -21,6 +22,7 @@ import app.organicmaps.location.LocationHelper;
import app.organicmaps.util.Config;
import app.organicmaps.util.LocationUtils;
import app.organicmaps.util.ThemeUtils;
import app.organicmaps.util.Utils;
import app.organicmaps.util.concurrency.UiThread;
import app.organicmaps.util.log.Logger;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
@ -103,13 +105,20 @@ public class SplashActivity extends AppCompatActivity
mPermissionRequest = null;
}
private void showFatalErrorDialog(@StringRes int titleId, @StringRes int messageId)
private void showFatalErrorDialog(@StringRes int titleId, @StringRes int messageId, Exception error)
{
mCanceled = true;
new MaterialAlertDialogBuilder(this, R.style.MwmTheme_AlertDialog)
.setTitle(titleId)
.setMessage(messageId)
.setNegativeButton(R.string.ok, (dialog, which) -> SplashActivity.this.finish())
.setPositiveButton(
R.string.report_a_bug,
(dialog, which) -> Utils.sendBugReport(
this,
"Fatal Error",
Log.getStackTraceString(error)
)
)
.setCancelable(false)
.show();
}
@ -121,9 +130,9 @@ public class SplashActivity extends AppCompatActivity
try
{
asyncContinue = app.init(this::processNavigation);
} catch (IOException e)
} catch (IOException error)
{
showFatalErrorDialog(R.string.dialog_error_storage_title, R.string.dialog_error_storage_message);
showFatalErrorDialog(R.string.dialog_error_storage_title, R.string.dialog_error_storage_message, error);
return;
}