1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-22 20:31:16 +00:00

Don't show notification when syncthing binary crashes, just log.

This commit is contained in:
Felix Ableitner 2014-12-10 19:21:47 +02:00
parent e5209066ee
commit c903d9d1d0
2 changed files with 1 additions and 27 deletions

View file

@ -1,17 +1,11 @@
package com.nutomic.syncthingandroid.syncthing; package com.nutomic.syncthingandroid.syncthing;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.util.Log; import android.util.Log;
import com.nutomic.syncthingandroid.R;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
@ -27,8 +21,6 @@ public class SyncthingRunnable implements Runnable {
private static final String TAG_NATIVE = "SyncthingNativeCode"; private static final String TAG_NATIVE = "SyncthingNativeCode";
private static final int NOTIFICATION_CRASHED = 3;
private final Context mContext; private final Context mContext;
private String mCommand; private String mCommand;
@ -84,21 +76,8 @@ public class SyncthingRunnable implements Runnable {
} }
process.destroy(); process.destroy();
if (ret != 0) { if (ret != 0) {
Log.w(TAG_NATIVE, "Syncthing binary crashed with error code " + Log.e(TAG_NATIVE, "Syncthing binary crashed with error code " +
Integer.toString(ret)); Integer.toString(ret));
NotificationCompat.Builder b = new NotificationCompat.Builder(mContext)
.setContentTitle(mContext.getString(R.string.binary_crashed_title))
.setContentText(mContext.getString(R.string.binary_crashed_message, ret))
.setContentIntent(PendingIntent.getActivity(mContext, 0, new Intent(), 0))
.setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true)
.setOnlyAlertOnce(true);
Notification n = new NotificationCompat.BigTextStyle(b)
.bigText(mContext.getString(R.string.binary_crashed_message, ret))
.build();
NotificationManager nm = (NotificationManager)
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(NOTIFICATION_CRASHED, n);
} }
} }
} }

View file

@ -286,12 +286,7 @@ Please report any problems you encounter via Github.</string>
<!-- SyncthingService --> <!-- SyncthingService -->
<!-- Title of the dialog shown when the syncthing binary returns an error -->
<string name="binary_crashed_title">Syncthing Binary Crashed</string>
<!-- Message of the dialog shown when the syncthing binary returns an error -->
<string name="binary_crashed_message">The syncthing binary has exited with error code %1$d.\n\n
If this error persists, try restarting your device.</string>
<!-- Title of the "syncthing disabled" dialog --> <!-- Title of the "syncthing disabled" dialog -->
<string name="syncthing_disabled_title">Syncthing is disabled</string> <string name="syncthing_disabled_title">Syncthing is disabled</string>