mirror of
https://github.com/dzeiocom/crashhandler.git
synced 2025-04-22 10:52:16 +00:00
parent
64d9b25883
commit
06777bfef1
@ -16,3 +16,5 @@ kotlin.code.style=official
|
|||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
android.enableJetifier=false
|
android.enableJetifier=false
|
||||||
org.gradle.unsafe.configuration-cache=true
|
org.gradle.unsafe.configuration-cache=true
|
||||||
|
org.gradle.caching=true
|
||||||
|
org.gradle.configureondemand=true
|
@ -181,7 +181,7 @@ class CrashHandler private constructor(
|
|||||||
val now = Date().time
|
val now = Date().time
|
||||||
|
|
||||||
// prepare to build debug string
|
// 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 ?: ""
|
data += prefix ?: ""
|
||||||
|
|
||||||
@ -193,10 +193,19 @@ class CrashHandler private constructor(
|
|||||||
"${Build.MANUFACTURER} ${Build.DEVICE}"
|
"${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
|
// 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 lib as access to the preferences store
|
||||||
if (prefs != null && prefsKey != null) {
|
if (prefs != null && prefsKey != null) {
|
||||||
@ -204,7 +213,10 @@ class CrashHandler private constructor(
|
|||||||
val lastCrash = prefs.getLong(prefsKey, 0L)
|
val lastCrash = prefs.getLong(prefsKey, 0L)
|
||||||
|
|
||||||
// then add it to the logs :D
|
// 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 a crash already happened just before it means the Error Activity crashed lul
|
||||||
if (lastCrash >= now - 1000) {
|
if (lastCrash >= now - 1000) {
|
||||||
@ -217,7 +229,7 @@ class CrashHandler private constructor(
|
|||||||
// try to send a toast indicating it
|
// try to send a toast indicating it
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
application,
|
application,
|
||||||
errorReporterCrashKey ?: R.string.error_reporter_crash,
|
errorReporterCrashKey ?: R.string.crash_handler_reporter_crash,
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
|
|
||||||
@ -233,10 +245,14 @@ class CrashHandler private constructor(
|
|||||||
Log.i(TAG, "Collecting Error")
|
Log.i(TAG, "Collecting Error")
|
||||||
|
|
||||||
// get Thread name and ID
|
// 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
|
// 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 ?: ""
|
data += suffix ?: ""
|
||||||
|
|
||||||
|
@ -11,11 +11,12 @@
|
|||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
style="?textAppearanceHeadline5"
|
style="?textAppearanceHeadline5"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
android:textAlignment="center"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="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_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
@ -27,7 +28,8 @@
|
|||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_marginEnd="8dp"
|
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_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/title" />
|
app:layout_constraintTop_toBottomOf="@+id/title" />
|
||||||
@ -48,7 +50,8 @@
|
|||||||
android:id="@+id/error_text"
|
android:id="@+id/error_text"
|
||||||
style="?textAppearanceCaption"
|
style="?textAppearanceCaption"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:textIsSelectable="true" />
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
@ -59,7 +62,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginBottom="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_constraintBottom_toTopOf="@+id/error_quit"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/error_quit"
|
app:layout_constraintEnd_toEndOf="@+id/error_quit"
|
||||||
app:layout_constraintStart_toStartOf="@+id/error_quit" />
|
app:layout_constraintStart_toStartOf="@+id/error_quit" />
|
||||||
@ -69,7 +72,7 @@
|
|||||||
android:id="@+id/error_quit"
|
android:id="@+id/error_quit"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:text="@string/quit"
|
android:text="@string/crash_handler_quit"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<!-- Error Activity Translations -->
|
<!-- Error Activity Translations -->
|
||||||
<string name="error_app_crash">Une Erreur est survenu lors de l\'utilisation de l\'application</string>
|
<string name="crash_handler_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="crash_handler_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="crash_handler_copy_to_clipboard">Copier dans le presse papier</string>
|
||||||
<string name="quit">Quitter</string>
|
<string name="crash_handler_quit">Quitter</string>
|
||||||
<string name="error_reporter_crash">Erreur lors de la géneration d\'un rapport d\'erreur</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>
|
</resources>
|
@ -2,10 +2,16 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<!-- Error Activity Translations -->
|
<!-- Error Activity Translations -->
|
||||||
<string name="error_app_crash">An Error Occurred in the application forcing it to close down</string>
|
<string name="crash_handler_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="crash_handler_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="crash_handler_copy_to_clipboard">Copy to clipboard</string>
|
||||||
<string name="quit">Quit</string>
|
<string name="crash_handler_quit">Quit</string>
|
||||||
<string name="error_reporter_crash">An error occurred while making the error report</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>
|
</resources>
|
@ -22,10 +22,10 @@ class Application : android.app.Application() {
|
|||||||
.withPrefsKey("com.dzeio.crashhandler.key")
|
.withPrefsKey("com.dzeio.crashhandler.key")
|
||||||
// a Prefix to add at the beginning the crash message
|
// a Prefix to add at the beginning the crash message
|
||||||
.withPrefix(
|
.withPrefix(
|
||||||
"POKEMON"
|
"Pokémon"
|
||||||
)
|
)
|
||||||
// a Suffix to add at the end of the crash message
|
// a Suffix to add at the end of the crash message
|
||||||
.withSuffix("WHYYYYY")
|
.withSuffix("Suffix")
|
||||||
// build & start the module
|
// build & start the module
|
||||||
.build().setup()
|
.build().setup()
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import android.os.Process
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
|
import com.dzeio.crashhandlertest.R
|
||||||
import com.dzeio.crashhandlertest.databinding.ActivityErrorBinding
|
import com.dzeio.crashhandlertest.databinding.ActivityErrorBinding
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
@ -48,14 +49,26 @@ class ErrorActivity : AppCompatActivity() {
|
|||||||
val intent = Intent(Intent.ACTION_SEND)
|
val intent = Intent(Intent.ACTION_SEND)
|
||||||
intent.setDataAndType(Uri.parse("mailto:"), "text/plain")
|
intent.setDataAndType(Uri.parse("mailto:"), "text/plain")
|
||||||
intent.putExtra(Intent.EXTRA_EMAIL, arrayOf("report.openhealth@dzeio.com"))
|
intent.putExtra(Intent.EXTRA_EMAIL, arrayOf("report.openhealth@dzeio.com"))
|
||||||
intent.putExtra(Intent.EXTRA_SUBJECT, "Error report for application crash")
|
intent.putExtra(
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, "Send Report Email\n$data")
|
Intent.EXTRA_SUBJECT,
|
||||||
|
getString(R.string.error_report_application_crash)
|
||||||
|
)
|
||||||
|
intent.putExtra(Intent.EXTRA_TEXT, "${getString(R.string.send_email_report)}\n$data")
|
||||||
|
|
||||||
// send intent
|
// send intent
|
||||||
try {
|
try {
|
||||||
startActivity(Intent.createChooser(intent, "Send Report Email..."))
|
startActivity(
|
||||||
|
Intent.createChooser(
|
||||||
|
intent,
|
||||||
|
getString(R.string.send_email_report)
|
||||||
|
)
|
||||||
|
)
|
||||||
} catch (e: ActivityNotFoundException) {
|
} catch (e: ActivityNotFoundException) {
|
||||||
Toast.makeText(this, "Not Email client found :(", Toast.LENGTH_LONG).show()
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
getString(R.string.no_email_client_found),
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
sample/src/main/res/values-fr/strings.xml
Normal file
12
sample/src/main/res/values-fr/strings.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="crash_app">Faire Planter l\'application</string>
|
||||||
|
<string name="error_message">Je suis une erreur</string>
|
||||||
|
<string name="crash_handler_page_title">Crash Handler Titre de page</string>
|
||||||
|
<string name="crash_handler_page_subtitle">Crash Handler sous-titre de page</string>
|
||||||
|
<string name="e_mail">E-Mail</string>
|
||||||
|
<string name="quit">Quitter</string>
|
||||||
|
<string name="no_email_client_found">Aucun client E-Mail trouvé!</string>
|
||||||
|
<string name="send_email_report">Envoyer le rapport de crash par E-Mail</string>
|
||||||
|
<string name="error_report_application_crash">Rapport d\'erreur pour le crash d\'application</string>
|
||||||
|
</resources>
|
@ -1,10 +1,13 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name" translatable="false">Crash Handler</string>
|
<string name="app_name" translatable="false">Crash Handler</string>
|
||||||
<string name="crash_app" translatable="false">Crash app</string>
|
<string name="crash_app">Crash app</string>
|
||||||
<string name="error_message" translatable="false">I am an error</string>
|
<string name="error_message">I am an error</string>
|
||||||
<string name="crash_handler_page_title" translatable="false">Crash Handler page title</string>
|
<string name="crash_handler_page_title">Crash Handler page title</string>
|
||||||
<string name="crash_handler_page_subtitle" translatable="false">crash handler page subtitle</string>
|
<string name="crash_handler_page_subtitle">crash handler page subtitle</string>
|
||||||
<string name="github" translatable="false">Github</string>
|
<string name="github" translatable="false">Github</string>
|
||||||
<string name="e_mail" translatable="false">E-Mail</string>
|
<string name="e_mail">E-Mail</string>
|
||||||
<string name="quit" translatable="false">Quit</string>
|
<string name="quit">Quit</string>
|
||||||
|
<string name="no_email_client_found">No E-Mail client found!</string>
|
||||||
|
<string name="send_email_report">Send a Report E-Mail</string>
|
||||||
|
<string name="error_report_application_crash">Error report for the application crash</string>
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user