aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005/dsub/service
diff options
context:
space:
mode:
authorGlenn Guy <glennguy83@gmail.com>2018-10-29 16:10:59 +1100
committerGlenn Guy <glennguy83@gmail.com>2018-10-29 16:10:59 +1100
commit5076b6753d33328d1e427d5daadbaebd199c795b (patch)
treef1d44fc70f4e9015b0fd330a37c3ec49d226ce0c /app/src/main/java/github/daneren2005/dsub/service
parente3e97a1fc61b6573520eb6ba4ed20fc6329b25c3 (diff)
downloaddsub-5076b6753d33328d1e427d5daadbaebd199c795b.tar.gz
dsub-5076b6753d33328d1e427d5daadbaebd199c795b.tar.bz2
dsub-5076b6753d33328d1e427d5daadbaebd199c795b.zip
Don't call shutGoogleUpNotification when service is already in foreground
Since adding the call to shutGoogleUpNotification to onStartCommand, using the controls on the notification would always remove the current notification which is pretty annoying. This fixes that unwanted behaviour and I think is much nicer than blindly calling it every time.
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/service')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
index 88c631f5..0fb5e9e5 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -170,6 +170,7 @@ public class DownloadService extends Service {
private boolean downloadOngoing = false;
private float volume = 1.0f;
private long delayUpdateProgress = DEFAULT_DELAY_UPDATE_PROGRESS;
+ private boolean foregroundService = false;
private AudioEffectsController effectsController;
private RemoteControlState remoteState = LOCAL;
@@ -309,7 +310,7 @@ public class DownloadService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
lifecycleSupport.onStart(intent);
- if(Build.VERSION.SDK_INT >= 26) {
+ if(Build.VERSION.SDK_INT >= 26 && !this.isForeground()) {
Notifications.shutGoogleUpNotification(this);
}
return START_NOT_STICKY;
@@ -1063,6 +1064,14 @@ public class DownloadService extends Service {
return size() == 1 || (currentPlaying != null && !currentPlaying.isSong());
}
+ public synchronized boolean isForeground() {
+ return this.foregroundService;
+ }
+
+ public synchronized void setIsForeground(boolean foreground) {
+ this.foregroundService = foreground;
+ }
+
public synchronized List<DownloadFile> getDownloads() {
List<DownloadFile> temp = new ArrayList<DownloadFile>();
temp.addAll(downloadList);