diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-09-13 10:41:17 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-09-13 10:41:17 -0700 |
commit | a3d2ba2009f61869762c655b3ab6f46b414b0b35 (patch) | |
tree | b05c4470752762901e706762fed64abe47d32e18 | |
parent | b2f01a9fd963d8f096dcfe68af842df3084bb22c (diff) | |
download | dsub-a3d2ba2009f61869762c655b3ab6f46b414b0b35.tar.gz dsub-a3d2ba2009f61869762c655b3ab6f46b414b0b35.tar.bz2 dsub-a3d2ba2009f61869762c655b3ab6f46b414b0b35.zip |
Closes #150 Add notification while background downloading
-rw-r--r-- | res/drawable-hdpi-v11/stat_notify_download.png | bin | 0 -> 300 bytes | |||
-rw-r--r-- | res/drawable-hdpi/stat_notify_download.png | bin | 0 -> 350 bytes | |||
-rw-r--r-- | res/drawable-mdpi-v11/stat_notify_download.png | bin | 0 -> 234 bytes | |||
-rw-r--r-- | res/drawable-mdpi/stat_notify_download.png | bin | 0 -> 272 bytes | |||
-rw-r--r-- | res/drawable-xhdpi-v11/stat_notify_download.png | bin | 0 -> 379 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/stat_notify_download.png | bin | 0 -> 404 bytes | |||
-rw-r--r-- | res/drawable-xxhdpi-v11/stat_notify_download.png | bin | 0 -> 531 bytes | |||
-rw-r--r-- | res/drawable-xxhdpi/stat_notify_download.png | bin | 0 -> 558 bytes | |||
-rw-r--r-- | src/github/daneren2005/dsub/activity/DownloadActivity.java | 6 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/activity/MainActivity.java | 3 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/fragments/DownloadFragment.java | 7 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadServiceImpl.java | 11 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/Util.java | 2 |
13 files changed, 28 insertions, 1 deletions
diff --git a/res/drawable-hdpi-v11/stat_notify_download.png b/res/drawable-hdpi-v11/stat_notify_download.png Binary files differnew file mode 100644 index 00000000..48ca6924 --- /dev/null +++ b/res/drawable-hdpi-v11/stat_notify_download.png diff --git a/res/drawable-hdpi/stat_notify_download.png b/res/drawable-hdpi/stat_notify_download.png Binary files differnew file mode 100644 index 00000000..aa1b6c92 --- /dev/null +++ b/res/drawable-hdpi/stat_notify_download.png diff --git a/res/drawable-mdpi-v11/stat_notify_download.png b/res/drawable-mdpi-v11/stat_notify_download.png Binary files differnew file mode 100644 index 00000000..4164e0fa --- /dev/null +++ b/res/drawable-mdpi-v11/stat_notify_download.png diff --git a/res/drawable-mdpi/stat_notify_download.png b/res/drawable-mdpi/stat_notify_download.png Binary files differnew file mode 100644 index 00000000..4c2a22de --- /dev/null +++ b/res/drawable-mdpi/stat_notify_download.png diff --git a/res/drawable-xhdpi-v11/stat_notify_download.png b/res/drawable-xhdpi-v11/stat_notify_download.png Binary files differnew file mode 100644 index 00000000..96ceb383 --- /dev/null +++ b/res/drawable-xhdpi-v11/stat_notify_download.png diff --git a/res/drawable-xhdpi/stat_notify_download.png b/res/drawable-xhdpi/stat_notify_download.png Binary files differnew file mode 100644 index 00000000..bd4cb567 --- /dev/null +++ b/res/drawable-xhdpi/stat_notify_download.png diff --git a/res/drawable-xxhdpi-v11/stat_notify_download.png b/res/drawable-xxhdpi-v11/stat_notify_download.png Binary files differnew file mode 100644 index 00000000..b2dc5651 --- /dev/null +++ b/res/drawable-xxhdpi-v11/stat_notify_download.png diff --git a/res/drawable-xxhdpi/stat_notify_download.png b/res/drawable-xxhdpi/stat_notify_download.png Binary files differnew file mode 100644 index 00000000..9d9a7f3e --- /dev/null +++ b/res/drawable-xxhdpi/stat_notify_download.png diff --git a/src/github/daneren2005/dsub/activity/DownloadActivity.java b/src/github/daneren2005/dsub/activity/DownloadActivity.java index 447bbb34..d8ebb98a 100644 --- a/src/github/daneren2005/dsub/activity/DownloadActivity.java +++ b/src/github/daneren2005/dsub/activity/DownloadActivity.java @@ -38,6 +38,7 @@ import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.service.DownloadFile; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; +import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.Util; import java.util.LinkedList; @@ -57,6 +58,11 @@ public class DownloadActivity extends SubsonicActivity { if (findViewById(R.id.download_container) != null && savedInstanceState == null) { currentFragment = new DownloadFragment(); + if(getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW)) { + Bundle args = new Bundle(); + args.putBoolean(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW, true); + currentFragment.setArguments(args); + } currentFragment.setPrimaryFragment(true); getSupportFragmentManager().beginTransaction().add(R.id.download_container, currentFragment, currentFragment.getSupportTag() + "").commit(); } diff --git a/src/github/daneren2005/dsub/activity/MainActivity.java b/src/github/daneren2005/dsub/activity/MainActivity.java index 8aa68b3d..9dbc2b5e 100644 --- a/src/github/daneren2005/dsub/activity/MainActivity.java +++ b/src/github/daneren2005/dsub/activity/MainActivity.java @@ -57,6 +57,9 @@ public class MainActivity extends SubsonicActivity { getIntent().removeExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD); Intent intent = new Intent(); intent.setClass(this, DownloadActivity.class); + if(getIntent().hasExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW)) { + intent.putExtra(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW, true); + } startActivity(intent); } setContentView(R.layout.main); diff --git a/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/src/github/daneren2005/dsub/fragments/DownloadFragment.java index 72186ff1..bf47e95e 100644 --- a/src/github/daneren2005/dsub/fragments/DownloadFragment.java +++ b/src/github/daneren2005/dsub/fragments/DownloadFragment.java @@ -120,6 +120,13 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe startFlipped = true;
}
}
+ Bundle args = getArguments();
+ if(args != null) {
+ if(args.getBoolean(Constants.INTENT_EXTRA_NAME_DOWNLOAD_VIEW)) {
+ startFlipped = true;
+ nowPlaying = false;
+ }
+ }
}
@Override
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 26ca7f11..2df1f30a 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -115,6 +115,8 @@ public class DownloadServiceImpl extends Service implements DownloadService { private PowerManager.WakeLock wakeLock; private boolean keepScreenOn; private int cachedPosition = 0; + private long downloadRevision; + private boolean downloadOngoing = false; private static boolean equalizerAvailable; private static boolean visualizerAvailable; @@ -1423,6 +1425,15 @@ public class DownloadServiceImpl extends Service implements DownloadService { } } + if(!backgroundDownloadList.isEmpty() && downloadRevision != revision) { + Util.showDownloadingNotification(this, this, currentDownloading, backgroundDownloadList.size(), handler); + downloadRevision = revision; + downloadOngoing = true; + } else if(backgroundDownloadList.isEmpty() && downloadOngoing) { + Util.hideDownloadingNotification(this, this, handler); + downloadOngoing = false; + } + // Delete obsolete .partial and .complete files. cleanup(); } diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index ce3621fb..f5638110 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -936,7 +936,7 @@ public final class Util { public static void showDownloadingNotification(final Context context, final DownloadServiceImpl downloadService, DownloadFile file, int size, Handler handler) { NotificationCompat.Builder builder; builder = new NotificationCompat.Builder(context) - .setSmallIcon(R.drawable.downloading) + .setSmallIcon(R.drawable.stat_notify_download) .setContentTitle("Downloading " + size + " songs") .setContentText("Current: " + file.getSong().getTitle()) .setProgress(10, 5, true); |