diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-12-18 06:53:50 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-12-18 06:53:50 -0800 |
commit | cc7f871520dbe03009748436759ed7987dc9e0df (patch) | |
tree | d197cf339be8d16bd684a67c9f9b766ceefe4096 /src | |
parent | 33baa6e2493183f8669ccf6bf5490147f7dd5f64 (diff) | |
download | dsub-cc7f871520dbe03009748436759ed7987dc9e0df.tar.gz dsub-cc7f871520dbe03009748436759ed7987dc9e0df.tar.bz2 dsub-cc7f871520dbe03009748436759ed7987dc9e0df.zip |
#214 Add a option to not display notification
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/util/Constants.java | 1 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/SyncUtil.java | 26 |
2 files changed, 15 insertions, 12 deletions
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index a720d21f..c539b45a 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -122,6 +122,7 @@ public final class Constants { public static final String PREFERENCES_KEY_SYNC_ENABLED = "syncEnabled"; public static final String PREFERENCES_KEY_SYNC_INTERVAL = "syncInterval"; public static final String PREFERENCES_KEY_SYNC_WIFI = "syncWifi"; + public static final String PREFERENCES_KEY_SYNC_NOTIFICATION = "syncNotification"; public static final String PREFERENCES_KEY_SYNC_STARRED = "syncStarred"; public static final String PREFERENCES_KEY_SYNC_MOST_RECENT = "syncMostRecent"; public static final String PREFERENCES_KEY_PAUSE_DISCONNECT = "pauseOnDisconnect"; diff --git a/src/github/daneren2005/dsub/util/SyncUtil.java b/src/github/daneren2005/dsub/util/SyncUtil.java index 4fb639a5..f595ff27 100644 --- a/src/github/daneren2005/dsub/util/SyncUtil.java +++ b/src/github/daneren2005/dsub/util/SyncUtil.java @@ -142,21 +142,23 @@ public final class SyncUtil { }
public static void showSyncNotification(final Context context, int stringId, String extra) {
- String content = (extra != null) ? context.getResources().getString(stringId, extra) : context.getResources().getString(stringId);
+ if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_SYNC_NOTIFICATION, true)) {
+ String content = (extra != null) ? context.getResources().getString(stringId, extra) : context.getResources().getString(stringId);
- NotificationCompat.Builder builder;
- builder = new NotificationCompat.Builder(context)
- .setSmallIcon(R.drawable.stat_notify_download)
- .setContentTitle(context.getResources().getString(R.string.sync_title))
- .setContentText(content)
- .setOngoing(false);
+ NotificationCompat.Builder builder;
+ builder = new NotificationCompat.Builder(context)
+ .setSmallIcon(R.drawable.stat_notify_download)
+ .setContentTitle(context.getResources().getString(R.string.sync_title))
+ .setContentText(content)
+ .setOngoing(false);
- Intent notificationIntent = new Intent(context, SubsonicFragmentActivity.class);
- notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- builder.setContentIntent(PendingIntent.getActivity(context, 0, notificationIntent, 0));
+ Intent notificationIntent = new Intent(context, SubsonicFragmentActivity.class);
+ notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ builder.setContentIntent(PendingIntent.getActivity(context, 0, notificationIntent, 0));
- NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.notify(stringId, builder.build());
+ NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.notify(stringId, builder.build());
+ }
}
public static String joinNames(List<String> names) {
|