Feat: Added crash report system.
Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
This commit is contained in:
@@ -141,6 +141,10 @@ dependencies {
|
||||
implementation(libs.androidx.runtime.android)
|
||||
implementation(libs.androidx.ui.android)
|
||||
|
||||
implementation(libs.acra.core)
|
||||
implementation(libs.acra.dialog)
|
||||
implementation(libs.acra.mail)
|
||||
|
||||
//noinspection KaptUsageInsteadOfKsp
|
||||
kapt(libs.room.compiler)
|
||||
implementation(libs.dagger.hilt.android)
|
||||
|
||||
@@ -1,12 +1,72 @@
|
||||
package com.github.droidworksstudio.launcher
|
||||
|
||||
import android.app.Application
|
||||
import com.github.droidworksstudio.launcher.helper.PreferenceHelper
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import org.acra.ACRA
|
||||
import org.acra.ReportField
|
||||
import org.acra.config.dialog
|
||||
import org.acra.config.mailSender
|
||||
import org.acra.data.StringFormat
|
||||
import org.acra.ktx.initAcra
|
||||
|
||||
|
||||
@HiltAndroidApp
|
||||
class Application: Application() {
|
||||
class Application : Application() {
|
||||
private lateinit var preferenceHelper: PreferenceHelper
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
// Initialize prefs here
|
||||
preferenceHelper = PreferenceHelper(this)
|
||||
|
||||
val pkgName = getString(R.string.app_name)
|
||||
val pkgVersion = this.packageManager.getPackageInfo(
|
||||
this.packageName,
|
||||
0
|
||||
).versionName
|
||||
|
||||
ACRA.DEV_LOGGING = true
|
||||
|
||||
initAcra {
|
||||
//core configuration:
|
||||
buildConfigClass = BuildConfig::class.java
|
||||
reportFormat = StringFormat.KEY_VALUE_LIST
|
||||
reportContent = listOf(
|
||||
ReportField.APP_VERSION_CODE,
|
||||
ReportField.APP_VERSION_NAME,
|
||||
ReportField.ANDROID_VERSION,
|
||||
ReportField.PHONE_MODEL,
|
||||
ReportField.CUSTOM_DATA,
|
||||
ReportField.STACK_TRACE,
|
||||
ReportField.LOGCAT
|
||||
)
|
||||
//each plugin you chose above can be configured in a block like this:
|
||||
dialog {
|
||||
//required
|
||||
text = getString(R.string.acra_dialog_text).format(pkgName)
|
||||
//optional, enables the dialog title
|
||||
title = getString(R.string.acra_crash)
|
||||
//defaults to android.R.string.ok
|
||||
positiveButtonText = getString(R.string.acra_send_report)
|
||||
//defaults to android.R.string.cancel
|
||||
negativeButtonText = getString(R.string.acra_dont_send)
|
||||
//optional, defaults to @android:style/Theme.Dialog
|
||||
resTheme = R.style.MaterialDialogTheme
|
||||
}
|
||||
|
||||
mailSender {
|
||||
//required
|
||||
mailTo = getString(R.string.acra_email)
|
||||
//defaults to true
|
||||
reportAsFile = true
|
||||
//defaults to ACRA-report.stacktrace
|
||||
reportFileName = "$pkgName-$pkgVersion-crash-report.ini"
|
||||
//defaults to "<applicationId> Crash Report"
|
||||
subject = "$pkgName $pkgVersion Crash Report"
|
||||
//defaults to empty
|
||||
body = getString(R.string.acra_mail_body)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,8 +49,6 @@
|
||||
<item name="materialAlertDialogTheme">@style/CustomAlertDialog</item>
|
||||
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
@@ -78,4 +76,8 @@
|
||||
<item name="android:shadowDy">1</item>
|
||||
<item name="android:shadowRadius">2</item>
|
||||
</style>
|
||||
|
||||
<style name="MaterialDialogTheme" parent="Theme.AppCompat.DayNight.Dialog">
|
||||
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -22,4 +22,6 @@
|
||||
<string name="widget_weather_wind" translatable="false">Wind : %1$.2f %2$s</string>
|
||||
<string name="widget_weather_humidity" translatable="false">Humidity : %d %%</string>
|
||||
<string name="widget_weather_pressure" translatable="false">Pressure : %d hPa</string>
|
||||
|
||||
<string name="acra_email" translatable="false">droidworksstudio@063240.xyz</string>
|
||||
</resources>
|
||||
@@ -608,4 +608,10 @@
|
||||
<string name="widgets_settings_display_battery">Battery Widget</string>
|
||||
<string name="widgets_settings_display">Display</string>
|
||||
<string name="widgets_settings_select_order">Select Order</string>
|
||||
|
||||
<string name="acra_crash">Crash</string>
|
||||
<string name="acra_dialog_text">We\'re sorry, but %1$s has encountered an unexpected issue and needs to close. Please help us improve by sending a crash report.\n\n%1$s values your privacy and the data collected is solely used for improving app stability. No personal information is collected. Thank you for your support!</string>
|
||||
<string name="acra_send_report">Send Report</string>
|
||||
<string name="acra_dont_send">Don\'t Send</string>
|
||||
<string name="acra_mail_body">Please describe the issue you encountered:</string>
|
||||
</resources>
|
||||
@@ -49,13 +49,11 @@
|
||||
<item name="materialAlertDialogTheme">@style/CustomAlertDialog</item>
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
|
||||
<style name="AppBottomSheetDialogTheme"
|
||||
parent="Theme.Design.Light.BottomSheetDialog">
|
||||
<style name="AppBottomSheetDialogTheme" parent="Theme.Design.Light.BottomSheetDialog">
|
||||
<item name="bottomSheetStyle">@style/AppModalStyle</item>
|
||||
</style>
|
||||
|
||||
@@ -78,4 +76,8 @@
|
||||
<item name="android:shadowDy">1</item>
|
||||
<item name="android:shadowRadius">2</item>
|
||||
</style>
|
||||
|
||||
<style name="MaterialDialogTheme" parent="Theme.AppCompat.DayNight.Dialog">
|
||||
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
|
||||
</style>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user