aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-02-06 15:22:48 -0800
committerScott Jackson <daneren2005@gmail.com>2014-02-06 15:22:48 -0800
commitf048ecd83239d40a17315524a2cbdd0e35678568 (patch)
tree9476c4fed10515f2f1b8b8c1668405b5f2764a64 /src/github/daneren2005
parent06d737a2f6c112e59c5969fe63fede9f4ae1d07a (diff)
downloaddsub-f048ecd83239d40a17315524a2cbdd0e35678568.tar.gz
dsub-f048ecd83239d40a17315524a2cbdd0e35678568.tar.bz2
dsub-f048ecd83239d40a17315524a2cbdd0e35678568.zip
#166 Add cancel button to download notification
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceImpl.java2
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java3
-rw-r--r--src/github/daneren2005/dsub/util/Util.java15
3 files changed, 17 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 4df94be3..d67d53bf 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -81,7 +81,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
public static final String CMD_STOP = "github.daneren2005.dsub.CMD_STOP";
public static final String CMD_PREVIOUS = "github.daneren2005.dsub.CMD_PREVIOUS";
public static final String CMD_NEXT = "github.daneren2005.dsub.CMD_NEXT";
-
+ public static final String CANCEL_DOWNLOADS = "github.daneren2005.dsub.CANCEL_DOWNLOADS";
private RemoteControlClientHelper mRemoteControl;
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index a5f1cff1..65320f84 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -92,6 +92,8 @@ public class DownloadServiceLifecycleSupport {
} else if (DownloadServiceImpl.CMD_STOP.equals(action)) {
downloadService.pause();
downloadService.seekTo(0);
+ } else if(DownloadServiceImpl.CANCEL_DOWNLOADS.equals(action)) {
+ downloadService.clearBackground();
}
}
});
@@ -195,6 +197,7 @@ public class DownloadServiceLifecycleSupport {
commandFilter.addAction(DownloadServiceImpl.CMD_STOP);
commandFilter.addAction(DownloadServiceImpl.CMD_PREVIOUS);
commandFilter.addAction(DownloadServiceImpl.CMD_NEXT);
+ commandFilter.addAction(DownloadServiceImpl.CANCEL_DOWNLOADS);
downloadService.registerReceiver(intentReceiver, commandFilter);
new CacheCleaner(downloadService, downloadService).clean();
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index 06c6a49d..fe8b6eae 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -1106,13 +1106,24 @@ public final class Util {
}
public static void showDownloadingNotification(final Context context, DownloadFile file, int size) {
+ Intent cancelIntent = new Intent(context, DownloadServiceImpl.class);
+ cancelIntent.setAction(DownloadServiceImpl.CANCEL_DOWNLOADS);
+ PendingIntent cancelPI = PendingIntent.getService(context, 0, cancelIntent, 0);
+
+ String currentDownloading = (file != null) ? file.getSong().getTitle() : "none";
+
NotificationCompat.Builder builder;
builder = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.stat_notify_download)
.setContentTitle(context.getResources().getString(R.string.download_downloading_title, size))
- .setContentText(context.getResources().getString(R.string.download_downloading_summary, (file != null ? file.getSong().getTitle() : "none")))
+ .setContentText(context.getResources().getString(R.string.download_downloading_summary, currentDownloading))
+ .setStyle(new NotificationCompat.BigTextStyle()
+ .bigText(context.getResources().getString(R.string.download_downloading_summary, currentDownloading)))
.setProgress(10, 5, true)
- .setOngoing(true);
+ .setOngoing(true)
+ .addAction(R.drawable.notification_close,
+ context.getResources().getString(R.string.common_cancel,
+ cancelPI);
Intent notificationIntent = new Intent(context, SubsonicFragmentActivity.class);
notificationIntent.putExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD, true);