Skip to content

Commit ee19e02

Browse files
committed
upgrade ACRA (fixes #318)
1 parent 1c5d993 commit ee19e02

5 files changed

Lines changed: 54 additions & 55 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ buildscript {
1313
jcenter()
1414
}
1515
dependencies {
16-
classpath 'com.android.tools.build:gradle:3.1.3'
16+
classpath 'com.android.tools.build:gradle:3.1.4'
1717
}
1818
}

syncloud/build.gradle

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ android {
44
compileSdkVersion 26
55
buildToolsVersion '27.0.3'
66

7+
compileOptions {
8+
sourceCompatibility JavaVersion.VERSION_1_8
9+
targetCompatibility JavaVersion.VERSION_1_8
10+
}
11+
712
defaultConfig {
813
minSdkVersion 16
914
targetSdkVersion 26
10-
versionCode 18051
11-
versionName "18.08.01"
15+
versionCode 18082
16+
versionName "18.08.02"
1217
}
1318

1419
useLibrary 'org.apache.http.legacy'
@@ -71,14 +76,15 @@ android {
7176

7277
dependencies {
7378
implementation 'log4j:log4j:1.2.17'
74-
implementation 'ch.acra:acra:4.8.0'
79+
implementation 'ch.acra:acra-mail:5.1.3'
80+
implementation 'ch.acra:acra-dialog:5.1.3'
7581
implementation 'de.mindpipe.android:android-logging-log4j:1.0.3'
7682
implementation 'com.fasterxml.jackson.core:jackson-databind:2.3.3'
7783
implementation 'org.apache.commons:commons-lang3:3.3.2'
7884
implementation 'org.apache.httpcomponents:httpclient-android:4.3.3'
7985
implementation 'com.google.guava:guava:18.0'
80-
implementation 'com.android.support:design:26.1.0'
81-
implementation 'com.android.support:support-v4:26.1.0'
82-
implementation 'com.android.support:appcompat-v7:26.1.0'
86+
implementation 'com.android.support:design:27.0.2'
87+
implementation 'com.android.support:support-v4:27.0.2'
88+
implementation 'com.android.support:appcompat-v7:27.0.2'
8389
implementation 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
8490
}

syncloud/src/main/java/org/syncloud/android/AcraLogEmailer.java

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,33 @@
33
import android.content.Context;
44
import android.content.Intent;
55
import android.net.Uri;
6-
import android.os.Environment;
6+
import android.support.annotation.NonNull;
77

88
import org.acra.ReportField;
9-
import org.acra.collector.CrashReportData;
10-
import org.acra.config.ACRAConfig;
9+
import org.acra.collections.ImmutableSet;
10+
import org.acra.config.CoreConfiguration;
11+
import org.acra.data.CrashReportData;
1112
import org.acra.sender.ReportSender;
1213
import org.acra.sender.ReportSenderException;
1314

14-
import java.io.File;
15-
import java.io.FileOutputStream;
16-
import java.io.IOException;
17-
1815
import static org.acra.ReportField.ANDROID_VERSION;
1916
import static org.acra.ReportField.APP_VERSION_NAME;
2017
import static org.acra.ReportField.BRAND;
21-
import static org.acra.ReportField.ENVIRONMENT;
22-
import static org.acra.ReportField.LOGCAT;
2318
import static org.acra.ReportField.PHONE_MODEL;
2419
import static org.acra.ReportField.STACK_TRACE;
2520

2621
public class AcraLogEmailer implements ReportSender {
2722

2823
private final Context mContext;
29-
private final ACRAConfig config;
24+
private final CoreConfiguration config;
3025

31-
public AcraLogEmailer(Context ctx, ACRAConfig config) {
26+
public AcraLogEmailer(Context ctx, CoreConfiguration config) {
3227
this.mContext = ctx;
3328
this.config = config;
3429
}
3530

3631
@Override
37-
public void send(Context context, CrashReportData errorContent) throws ReportSenderException {
32+
public void send(@NonNull Context context, @NonNull CrashReportData errorContent) throws ReportSenderException {
3833
final String mailTo = "support@syncloud.it";
3934
final String subject = "Syncloud Android Report";
4035
final String body = buildBodyText(errorContent);
@@ -48,28 +43,28 @@ public void send(Context context, CrashReportData errorContent) throws ReportSen
4843
}
4944

5045
private String buildBodyText(CrashReportData errorContent) {
51-
ReportField[] fields = config.customReportContent();
52-
if(fields.length == 0) {
53-
fields = new ReportField[] {
54-
ANDROID_VERSION,
55-
APP_VERSION_NAME,
56-
BRAND,
57-
PHONE_MODEL,
58-
STACK_TRACE
59-
};
46+
ImmutableSet<ReportField> fields = config.reportContent();
47+
if(fields.isEmpty()) {
48+
fields = new ImmutableSet<>(
49+
ANDROID_VERSION,
50+
APP_VERSION_NAME,
51+
BRAND,
52+
PHONE_MODEL,
53+
STACK_TRACE
54+
);
6055
}
6156

6257
final StringBuilder builder = new StringBuilder();
6358
for (ReportField field : fields) {
6459
if (field != ReportField.LOGCAT) {
6560
builder.append(field.toString()).append("=");
66-
builder.append(errorContent.get(field));
61+
builder.append(errorContent.getString(field));
6762
builder.append('\n');
6863
}
6964
}
7065
builder.append("LOGCAT");
7166
builder.append('\n');
72-
builder.append(errorContent.get(ReportField.LOGCAT));
67+
builder.append(errorContent.getString(ReportField.LOGCAT));
7368
return builder.toString();
7469
}
7570
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.syncloud.android;
22

33
import android.content.Context;
4+
import android.support.annotation.NonNull;
45

5-
import org.acra.config.ACRAConfig;
6+
import org.acra.config.CoreConfiguration;
67
import org.acra.sender.ReportSender;
78
import org.acra.sender.ReportSenderFactory;
89

@@ -12,7 +13,7 @@ public AcraLogEmailerFactory() {
1213
}
1314

1415
@Override
15-
public ReportSender create(Context context, ACRAConfig config) {
16+
public ReportSender create(@NonNull Context context, @NonNull CoreConfiguration config) {
1617
return new AcraLogEmailer(context, config);
1718
}
1819
}

syncloud/src/main/java/org/syncloud/android/SyncloudApplication.java

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
import android.net.ConnectivityManager;
77
import android.net.NetworkInfo;
88
import android.preference.PreferenceManager;
9-
import android.util.Log;
109

1110
import org.acra.ACRA;
12-
import org.acra.ReportingInteractionMode;
13-
import org.acra.annotation.ReportsCrashes;
14-
import org.acra.collector.CrashReportData;
15-
import org.acra.sender.ReportSender;
16-
import org.acra.sender.ReportSenderException;
11+
import org.acra.annotation.AcraCore;
12+
import org.acra.annotation.AcraDialog;
13+
import org.acra.data.StringFormat;
1714
import org.apache.log4j.Logger;
1815
import org.syncloud.android.core.redirect.IUserService;
1916
import org.syncloud.android.core.redirect.RedirectService;
@@ -25,41 +22,41 @@
2522
import static org.acra.ReportField.*;
2623
import static org.syncloud.android.core.redirect.RedirectService.getApiUrl;
2724

28-
@ReportsCrashes(
29-
customReportContent = { APP_VERSION_CODE, ANDROID_VERSION, PHONE_MODEL, STACK_TRACE, LOGCAT },
30-
31-
mode = ReportingInteractionMode.DIALOG,
32-
resToastText = R.string.crash_toast_text, // optional, displayed as soon as the crash occurs, before collecting data which can take a few seconds
33-
resDialogText = R.string.crash_dialog_text,
34-
resDialogIcon = R.drawable.ic_launcher, //optional. default is a warning sign
35-
resDialogTitle = R.string.crash_dialog_title, // optional. default is your application name
36-
resDialogOkToast = R.string.crash_dialog_ok_toast, // optional. displays a Toast message when the user accepts to send a report.
25+
@AcraDialog(
26+
resText = R.string.crash_dialog_text,
27+
resIcon = R.drawable.ic_launcher, //optional. default is a warning sign
28+
resTitle = R.string.crash_dialog_title // optional. default is your application name
29+
)
30+
@AcraCore(
31+
buildConfigClass = BuildConfig.class,
32+
reportContent = { APP_VERSION_CODE, ANDROID_VERSION, PHONE_MODEL, STACK_TRACE, LOGCAT },
3733

3834
logcatArguments = { "-t", "500", "-v", "long", "*:D"},
3935
logcatFilterByPid = false,
4036

41-
reportSenderFactoryClasses = { AcraLogEmailerFactory.class }
37+
reportSenderFactoryClasses = { AcraLogEmailerFactory.class },
38+
reportFormat = StringFormat.KEY_VALUE_LIST
39+
4240
)
4341
public class SyncloudApplication extends Application {
4442

45-
private String TAG = SyncloudApplication.class.getSimpleName();
46-
47-
public static String DEVICE_ENDPOINT = "device_endpoint";
48-
4943
private Preferences preferences;
5044
private UserStorage userStorage;
5145

5246
@Override
53-
public void onCreate() {
54-
47+
protected void attachBaseContext(Context base) {
48+
super.attachBaseContext(base);
5549
ACRA.init(this);
50+
}
51+
52+
@Override
53+
public void onCreate() {
5654

5755
ConfigureLog4J.configure();
5856

5957
Logger logger = Logger.getLogger(SyncloudApplication.class);
6058
logger.info("Starting Syncloud App");
6159

62-
6360
super.onCreate();
6461
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
6562
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

0 commit comments

Comments
 (0)