From 66eb7c123ec209458f66d1b42774f78ca32fd577 Mon Sep 17 00:00:00 2001 From: HeCodes2Much Date: Mon, 17 Jun 2024 12:34:32 +0100 Subject: [PATCH] Feat: Added crash report system. Signed-off-by: HeCodes2Much --- app/build.gradle.kts | 4 ++ .../droidworksstudio/launcher/Application.kt | 62 ++++++++++++++++++- app/src/main/res/values-night/styles.xml | 6 +- app/src/main/res/values/nontranslatable.xml | 2 + app/src/main/res/values/strings.xml | 6 ++ app/src/main/res/values/styles.xml | 8 ++- gradle/libs.versions.toml | 9 ++- 7 files changed, 89 insertions(+), 8 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c7670f0..2836a93 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -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) diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/Application.kt b/app/src/main/java/com/github/droidworksstudio/launcher/Application.kt index b4a062c..32ae3c4 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/Application.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/Application.kt @@ -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 " Crash Report" + subject = "$pkgName $pkgVersion Crash Report" + //defaults to empty + body = getString(R.string.acra_mail_body) + } + } } } \ No newline at end of file diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml index 8a73ddd..9427ff3 100644 --- a/app/src/main/res/values-night/styles.xml +++ b/app/src/main/res/values-night/styles.xml @@ -49,8 +49,6 @@ @style/CustomAlertDialog - - @@ -78,4 +76,8 @@ 1 2 + + \ No newline at end of file diff --git a/app/src/main/res/values/nontranslatable.xml b/app/src/main/res/values/nontranslatable.xml index 66952f0..88b1a1a 100644 --- a/app/src/main/res/values/nontranslatable.xml +++ b/app/src/main/res/values/nontranslatable.xml @@ -22,4 +22,6 @@ Wind : %1$.2f %2$s Humidity : %d %% Pressure : %d hPa + + droidworksstudio@063240.xyz \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2b9708e..f9ce97e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -608,4 +608,10 @@ Battery Widget Display Select Order + + Crash + 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! + Send Report + Don\'t Send + Please describe the issue you encountered: \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 3c34a13..9b3210d 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -49,13 +49,11 @@ @style/CustomAlertDialog - - @@ -78,4 +76,8 @@ 1 2 + + \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c0b06d9..3750adb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ appcompat = "1.7.0" material = "1.12.0" constraintlayout = "2.1.4" navigation = "2.7.7" -lifecycle = "2.8.1" +lifecycle = "2.8.2" dagger = "2.51.1" work = "2.9.0" recyclerview = "1.3.2" @@ -18,7 +18,8 @@ retrofit = "2.11.0" room = "2.6.1" biometric = "1.2.0-alpha05" color-chooser = "0.7.3" -composeAndroid = "1.6.7" +composeAndroid = "1.6.8" +acra = "5.11.3" [libraries] core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } @@ -54,6 +55,10 @@ androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-co androidx-runtime-android = { group = "androidx.compose.runtime", name = "runtime-android", version.ref = "composeAndroid" } androidx-ui-android = { group = "androidx.compose.ui", name = "ui-android", version.ref = "composeAndroid" } +acra-core = { group = "ch.acra", name = "acra-core", version.ref = "acra" } +acra-dialog = { group = "ch.acra", name = "acra-dialog", version.ref = "acra" } +acra-mail = { group = "ch.acra", name = "acra-mail", version.ref = "acra" } + [plugins] android-application = { id = "com.android.application", version.ref = "agp" }