From cf8afd541cb210810ef83bf74b445bc5e1489112 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Mar 2019 08:26:10 +0000 Subject: [PATCH] ACRA: switch to notification alerts on crashes. On some devices users weren't able to send stack traces because EteSync would restart and then hide/cancel the email app chooser. --- app/build.gradle | 2 +- .../java/com/etesync/syncadapter/AcraConfiguration.java | 9 +++++---- app/src/main/java/com/etesync/syncadapter/App.kt | 2 +- app/src/main/res/values/strings.xml | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ea00cee8..dc9d4e4c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -131,7 +131,7 @@ dependencies { def acraVersion = '5.2.1' implementation "ch.acra:acra-mail:$acraVersion" - implementation "ch.acra:acra-toast:$acraVersion" + implementation "ch.acra:acra-notification:$acraVersion" def supportVersion = '1.0.0' implementation "androidx.legacy:legacy-support-core-ui:$supportVersion" implementation "androidx.core:core:$supportVersion" diff --git a/app/src/main/java/com/etesync/syncadapter/AcraConfiguration.java b/app/src/main/java/com/etesync/syncadapter/AcraConfiguration.java index b3aecf2d..7d4528f4 100644 --- a/app/src/main/java/com/etesync/syncadapter/AcraConfiguration.java +++ b/app/src/main/java/com/etesync/syncadapter/AcraConfiguration.java @@ -1,11 +1,10 @@ package com.etesync.syncadapter; import android.content.Context; -import android.widget.Toast; import org.acra.config.CoreConfigurationBuilder; import org.acra.config.MailSenderConfigurationBuilder; -import org.acra.config.ToastConfigurationBuilder; +import org.acra.config.NotificationConfigurationBuilder; import org.acra.data.StringFormat; import static com.etesync.syncadapter.utils.EventEmailInvitationKt.emailSupportsAttachments; @@ -22,9 +21,11 @@ public class AcraConfiguration { .setReportFileName("ACRA-report.stacktrace.json") .setReportAsFile(emailSupportsAttachments(context)) .setEnabled(true); - builder.getPluginConfigurationBuilder(ToastConfigurationBuilder.class) + builder.getPluginConfigurationBuilder(NotificationConfigurationBuilder.class) + .setResTitle(R.string.crash_title) .setResText(R.string.crash_message) - .setLength(Toast.LENGTH_SHORT) + .setChannelName("crash-notification") + .setSendOnClick(true) .setEnabled(true); return builder; diff --git a/app/src/main/java/com/etesync/syncadapter/App.kt b/app/src/main/java/com/etesync/syncadapter/App.kt index 404eb232..24ae46bc 100644 --- a/app/src/main/java/com/etesync/syncadapter/App.kt +++ b/app/src/main/java/com/etesync/syncadapter/App.kt @@ -113,7 +113,7 @@ class App : Application() { // The following line triggers the initialization of ACRA ACRA.init(this, AcraConfiguration.getConfig(this)) val pm = base.packageManager - var installedFrom = pm.getInstallerPackageName(BuildConfig.APPLICATION_ID) + val installedFrom = pm.getInstallerPackageName(BuildConfig.APPLICATION_ID) ACRA.getErrorReporter().putCustomData("installedFrom", installedFrom); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c004205e..fab77a49 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -22,7 +22,8 @@ Send - EteSync has crashed, please send stack trace to developers. + EteSync has crashed! + Please send stack trace to developers. EteSync Debug Info