mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-15 12:57:27 -04:00
Set up ACRA with email crash alerts for foss build
This commit is contained in:
@@ -29,6 +29,7 @@ android {
|
||||
|
||||
buildConfigField("boolean", "showDonate", "true")
|
||||
buildConfigField("boolean", "showRateOnGooglePlay", "false")
|
||||
buildConfigField("boolean", "useAcraCrashReporter", "true")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -61,6 +62,9 @@ android {
|
||||
// Google doesn't allow donation links
|
||||
buildConfigField("boolean", "showDonate", "false")
|
||||
buildConfigField("boolean", "showRateOnGooglePlay", "true")
|
||||
|
||||
// Google Play already sends crashes to the Google Play Console
|
||||
buildConfigField("boolean", "useAcraCrashReporter", "false")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,6 +132,11 @@ dependencies {
|
||||
implementation("com.jaredrummler:colorpicker:1.1.0")
|
||||
implementation("net.lingala.zip4j:zip4j:2.11.5")
|
||||
|
||||
// Crash reporting
|
||||
val acraVersion = "5.12.0"
|
||||
implementation("ch.acra:acra-mail:$acraVersion")
|
||||
implementation("ch.acra:acra-dialog:$acraVersion")
|
||||
|
||||
// Testing
|
||||
val androidXTestVersion = "1.7.0"
|
||||
val junitVersion = "4.13.2"
|
||||
|
||||
@@ -4,6 +4,12 @@ import android.app.Application;
|
||||
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import org.acra.ACRA;
|
||||
import org.acra.config.CoreConfigurationBuilder;
|
||||
import org.acra.config.DialogConfigurationBuilder;
|
||||
import org.acra.config.MailSenderConfigurationBuilder;
|
||||
import org.acra.data.StringFormat;
|
||||
|
||||
import protect.card_locker.preferences.Settings;
|
||||
|
||||
public class LoyaltyCardLockerApplication extends Application {
|
||||
@@ -12,6 +18,27 @@ public class LoyaltyCardLockerApplication extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
// Initialize crash reporter (if enabled)
|
||||
if (BuildConfig.useAcraCrashReporter) {
|
||||
ACRA.init(this, new CoreConfigurationBuilder()
|
||||
//core configuration:
|
||||
.withBuildConfigClass(BuildConfig.class)
|
||||
.withReportFormat(StringFormat.KEY_VALUE_LIST)
|
||||
.withPluginConfigurations(
|
||||
new DialogConfigurationBuilder()
|
||||
.withText(String.format(getString(R.string.acra_catima_has_crashed), getString(R.string.app_name)))
|
||||
.withCommentPrompt(getString(R.string.acra_explain_crash))
|
||||
.withResTheme(R.style.AppTheme)
|
||||
.build(),
|
||||
new MailSenderConfigurationBuilder()
|
||||
.withMailTo("acra-crash@catima.app")
|
||||
.withSubject(String.format(getString(R.string.acra_crash_email_subject), getString(R.string.app_name)))
|
||||
.build()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Set theme
|
||||
Settings settings = new Settings(this);
|
||||
AppCompatDelegate.setDefaultNightMode(settings.getTheme());
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import protect.card_locker.BuildConfig;
|
||||
import protect.card_locker.CatimaAppCompatActivity;
|
||||
import protect.card_locker.MainActivity;
|
||||
import protect.card_locker.R;
|
||||
@@ -193,6 +194,11 @@ public class SettingsActivity extends CatimaAppCompatActivity {
|
||||
Preference contentProviderReadPreference = findPreference(getResources().getString(R.string.settings_key_allow_content_provider_read));
|
||||
assert contentProviderReadPreference != null;
|
||||
contentProviderReadPreference.setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
|
||||
|
||||
// Hide crash reporter settings on builds it's not enabled on
|
||||
Preference crashReporterPreference = findPreference("acra.enable");
|
||||
assert crashReporterPreference != null;
|
||||
crashReporterPreference.setVisible(BuildConfig.useAcraCrashReporter);
|
||||
}
|
||||
|
||||
private void refreshActivity(boolean reloadMain) {
|
||||
|
||||
@@ -353,4 +353,9 @@
|
||||
<string name="cardWithNumber">Card <xliff:g>%d</xliff:g></string>
|
||||
<string name="cardWithNumberAndLocale">Card <xliff:g>%d</xliff:g> (<xliff:g>%s</xliff:g>)</string>
|
||||
<string name="pleaseDoNotRotateTheDevice">Please do not rotate the device, as this will cancel the action</string>
|
||||
<string name="acra_catima_has_crashed">We\'re sorry, but <xliff:g id="app_name">%s</xliff:g> has crashed. Please help us fix this issue by sending us an error report.</string>
|
||||
<string name="acra_explain_crash">If possible, please add more details on what you were doing here:</string>
|
||||
<string name="acra_crash_email_subject"><xliff:g id="app_name">%s</xliff:g> crash report</string>
|
||||
<string name="pref_enable_acra">Ask to send crash reports</string>
|
||||
<string name="pref_enable_acra_summary">When enabled, you will be asked to report a crash when it happens. Crash reports are never sent automatically.</string>
|
||||
</resources>
|
||||
|
||||
@@ -44,6 +44,15 @@
|
||||
app:iconSpaceReserved="false"
|
||||
app:singleLineTitle="false"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:widgetLayout="@layout/preference_material_switch"
|
||||
android:defaultValue="true"
|
||||
android:key="acra.enable"
|
||||
android:title="@string/pref_enable_acra"
|
||||
android:summary="@string/pref_enable_acra_summary"
|
||||
app:iconSpaceReserved="false"
|
||||
app:singleLineTitle="false"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
@@ -124,7 +133,6 @@
|
||||
android:title="@string/settings_allow_content_provider_read_title"
|
||||
app:iconSpaceReserved="false"
|
||||
app:singleLineTitle="false" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
Reference in New Issue
Block a user