aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/values/strings.xml2
-rw-r--r--res/xml/settings.xml6
-rw-r--r--src/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--src/github/daneren2005/dsub/util/SyncUtil.java26
4 files changed, 23 insertions, 12 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 17b54c87..8bd333bc 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -369,6 +369,8 @@
<string name="settings.sync_most_recent_summary">Automatically cache newly added albums</string>
<string name="settings.sync_starred">Sync Starred</string>
<string name="settings.sync_starred_summary">Automatically cache songs, albums, and artists which are starred</string>
+ <string name="settings.sync_notification">Show Sync Notification</string>
+ <string name="settings.sync_notification_summary">Show a notification after new media has been synced</string>
<string name="shuffle.title">Shuffle By</string>
<string name="shuffle.startYear">Start Year:</string>
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
index 4355d890..7234d246 100644
--- a/res/xml/settings.xml
+++ b/res/xml/settings.xml
@@ -194,6 +194,12 @@
android:defaultValue="true"/>
<CheckBoxPreference
+ android:title="@string/settings.sync_notification"
+ android:summary="@string/settings.sync_notification_summary"
+ android:key="syncNotification"
+ android:defaultValue="true"/>
+
+ <CheckBoxPreference
android:title="@string/settings.sync_starred"
android:summary="@string/settings.sync_starred_summary"
android:key="syncStarred"
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) {