diff options
Diffstat (limited to 'src/github')
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); |