feat: change to use strings (#9)
Some checks failed
build

This commit is contained in:
2023-03-22 14:32:17 +01:00
committed by GitHub
parent 64d9b25883
commit 06777bfef1
9 changed files with 96 additions and 34 deletions

View File

@ -181,7 +181,7 @@ class CrashHandler private constructor(
val now = Date().time
// prepare to build debug string
var data = "Crash report:\n\n"
var data = "${application.getString(R.string.crash_handler_crash_report)}\n\n"
data += prefix ?: ""
@ -193,10 +193,19 @@ class CrashHandler private constructor(
"${Build.MANUFACTURER} ${Build.DEVICE}"
}
data += "\n\non $deviceToReport (${Build.MODEL}) running Android ${Build.VERSION.RELEASE} (${Build.VERSION.SDK_INT})"
data += "\n\n${application.getString(
R.string.crash_handler_hard_soft_infos,
deviceToReport,
Build.MODEL,
Build.VERSION.RELEASE,
Build.VERSION.SDK_INT
)}"
// add the current time to it
data += "\n\nCrash happened at ${Date(now)}"
data += "\n\n${application.getString(
R.string.crash_handler_crash_happened,
Date(now).toString()
)}"
// if lib as access to the preferences store
if (prefs != null && prefsKey != null) {
@ -204,7 +213,10 @@ class CrashHandler private constructor(
val lastCrash = prefs.getLong(prefsKey, 0L)
// then add it to the logs :D
data += "\nLast crash happened at ${Date(lastCrash)}"
data += "\n${application.getString(
R.string.crash_handler_previous_crash,
Date(lastCrash).toString()
)}"
// if a crash already happened just before it means the Error Activity crashed lul
if (lastCrash >= now - 1000) {
@ -217,7 +229,7 @@ class CrashHandler private constructor(
// try to send a toast indicating it
Toast.makeText(
application,
errorReporterCrashKey ?: R.string.error_reporter_crash,
errorReporterCrashKey ?: R.string.crash_handler_reporter_crash,
Toast.LENGTH_LONG
).show()
@ -233,10 +245,14 @@ class CrashHandler private constructor(
Log.i(TAG, "Collecting Error")
// get Thread name and ID
data += "\n\nHappened on Thread \"${paramThread.name}\" (${paramThread.id})"
data += "\n\n${application.getString(
R.string.crash_handler_thread_infos,
paramThread.name,
paramThread.id
)}"
// print exception backtrace
data += "\n\nException:\n${paramThrowable.stackTraceToString()}\n\n"
data += "\n\n${application.getString(R.string.crash_handler_error)}\n${paramThrowable.stackTraceToString()}\n\n"
data += suffix ?: ""

View File

@ -11,11 +11,12 @@
android:id="@+id/title"
style="?textAppearanceHeadline5"
android:layout_width="0dp"
android:textAlignment="center"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="@string/error_app_crash"
android:text="@string/crash_handler_error_app_crash"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
@ -27,7 +28,8 @@
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:text="@string/error_app_report"
android:textAlignment="center"
android:text="@string/crash_handler_error_app_report"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title" />
@ -48,7 +50,8 @@
android:id="@+id/error_text"
style="?textAppearanceCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:textIsSelectable="true" />
</ScrollView>
@ -59,7 +62,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginBottom="16dp"
android:text="@string/copy_to_clipboard"
android:text="@string/crash_handler_copy_to_clipboard"
app:layout_constraintBottom_toTopOf="@+id/error_quit"
app:layout_constraintEnd_toEndOf="@+id/error_quit"
app:layout_constraintStart_toStartOf="@+id/error_quit" />
@ -69,7 +72,7 @@
android:id="@+id/error_quit"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="@string/quit"
android:text="@string/crash_handler_quit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

View File

@ -1,9 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Error Activity Translations -->
<string name="error_app_crash">Une Erreur est survenu lors de l\'utilisation de l\'application</string>
<string name="error_app_report">Merci d\'envoyer le rapport d\'erreur afin que nous puissions améliorer votre experience</string>
<string name="copy_to_clipboard">Copier dans le presse papier</string>
<string name="quit">Quitter</string>
<string name="error_reporter_crash">Erreur lors de la géneration d\'un rapport d\'erreur</string>
<string name="crash_handler_error_app_crash">Une Erreur est survenu lors de l\'utilisation de l\'application</string>
<string name="crash_handler_error_app_report">Merci d\'envoyer le rapport d\'erreur afin que nous puissions améliorer votre experience</string>
<string name="crash_handler_copy_to_clipboard">Copier dans le presse papier</string>
<string name="crash_handler_quit">Quitter</string>
<string name="crash_handler_reporter_crash">Erreur lors de la géneration d\'un rapport d\'erreur</string>
<string name="crash_handler_hard_soft_infos">sur %1$s (%2$s) avec Android %3$s (%4$d)</string>
<string name="crash_handler_crash_happened">Plantage arrivé à %1$s</string>
<string name="crash_handler_previous_crash">Plantage précédent arrivé à %1$s</string>
<string name="crash_handler_thread_infos">Arrivé sur le thread "%1$s" (%2$d)</string>
<string name="crash_handler_error">Erreur :</string>
<string name="crash_handler_crash_report">Rapport d\'erreur :</string>
</resources>

View File

@ -2,10 +2,16 @@
<resources>
<!-- Error Activity Translations -->
<string name="error_app_crash">An Error Occurred in the application forcing it to close down</string>
<string name="error_app_report">Please report it so we can enhance you\'re Android OpenHealth experience</string>
<string name="copy_to_clipboard">Copy to clipboard</string>
<string name="quit">Quit</string>
<string name="error_reporter_crash">An error occurred while making the error report</string>
<string name="crash_handler_error_app_crash">An Error Occurred in the application forcing it to close down</string>
<string name="crash_handler_error_app_report">Please report it so we can enhance you\'re Android OpenHealth experience</string>
<string name="crash_handler_copy_to_clipboard">Copy to clipboard</string>
<string name="crash_handler_quit">Quit</string>
<string name="crash_handler_reporter_crash">An error occurred while making the error report</string>
<string name="crash_handler_hard_soft_infos">on%1$s (%2$s) running Android %3$s (%4$d)</string>
<string name="crash_handler_crash_happened">Crash happened at %1$s</string>
<string name="crash_handler_previous_crash">Previous crash happened at %1$s</string>
<string name="crash_handler_thread_infos">Happened on Thread "%1$s" (%2$d)</string>
<string name="crash_handler_error">Exception:</string>
<string name="crash_handler_crash_report">Crash Report:</string>
</resources>