aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-11-20 20:23:17 +0100
committerChristian Schneppe <christian@pix-art.de>2017-11-20 20:23:17 +0100
commit7381f906130403d0e9b60cab70673d246206d8fa (patch)
tree1d8c919576f2c3766c1cfd9528feae681a7538de /src/main/java/de/pixart
parent243facb0d2acc8b0d22b14a6390990a845db3207 (diff)
ExceptionHelper: code clean up
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/utils/ExceptionHelper.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java b/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java
index 7ed5e4804..efec5098b 100644
--- a/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java
+++ b/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java
@@ -19,6 +19,7 @@ import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
+import java.util.Locale;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
@@ -31,7 +32,8 @@ import de.pixart.messenger.xmpp.jid.InvalidJidException;
import de.pixart.messenger.xmpp.jid.Jid;
public class ExceptionHelper {
- private static SimpleDateFormat DATE_FORMATs = new SimpleDateFormat("yyyy-MM-dd");
+ private static final String FILENAME = "stacktrace.txt";
+ private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
public static void init(Context context) {
if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof ExceptionHandler)) {
@@ -60,7 +62,7 @@ public class ExceptionHelper {
return false;
}
final Account finalAccount = account;
- FileInputStream file = activity.openFileInput("stacktrace.txt");
+ FileInputStream file = activity.openFileInput(FILENAME);
InputStreamReader inputStreamReader = new InputStreamReader(file);
BufferedReader stacktrace = new BufferedReader(inputStreamReader);
final StringBuilder report = new StringBuilder();
@@ -68,11 +70,11 @@ public class ExceptionHelper {
PackageInfo packageInfo;
try {
packageInfo = pm.getPackageInfo(activity.getPackageName(), PackageManager.GET_SIGNATURES);
- report.append("Version: " + packageInfo.versionName + '\n');
- report.append("Last Update: " + DATE_FORMATs.format(new Date(packageInfo.lastUpdateTime)) + '\n');
+ report.append("Version: ").append(packageInfo.versionName).append('\n');
+ report.append("Last Update: ").append(DATE_FORMAT.format(new Date(packageInfo.lastUpdateTime))).append('\n');
Signature[] signatures = packageInfo.signatures;
if (signatures != null && signatures.length >= 1) {
- report.append("SHA-1: " + CryptoHelper.getFingerprintCert(packageInfo.signatures[0].toByteArray()) + "\n");
+ report.append("SHA-1: ").append(CryptoHelper.getFingerprintCert(packageInfo.signatures[0].toByteArray())).append('\n');
}
report.append('\n');
} catch (Exception e) {
@@ -85,7 +87,7 @@ public class ExceptionHelper {
report.append('\n');
}
file.close();
- activity.deleteFile("stacktrace.txt");
+ activity.deleteFile(FILENAME);
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(activity.getString(R.string.crash_report_title));
builder.setMessage(activity.getText(R.string.crash_report_message));
@@ -128,7 +130,7 @@ public class ExceptionHelper {
public static void writeToStacktraceFile(Context context, String msg) {
try {
- OutputStream os = context.openFileOutput("stacktrace.txt", Context.MODE_PRIVATE);
+ OutputStream os = context.openFileOutput(FILENAME, Context.MODE_PRIVATE);
os.write(msg.getBytes());
os.flush();
os.close();