From 79a92bd6f401aef9095b48e5e47570b7c1b1159e Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 24 Mar 2016 17:56:38 -0700 Subject: Fixes #554: Add option for heads up notifications --- app/src/main/java/github/daneren2005/dsub/util/Constants.java | 1 + app/src/main/java/github/daneren2005/dsub/util/Notifications.java | 4 ++++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/settings_playback.xml | 6 ++++++ 4 files changed, 13 insertions(+) (limited to 'app') diff --git a/app/src/main/java/github/daneren2005/dsub/util/Constants.java b/app/src/main/java/github/daneren2005/dsub/util/Constants.java index 9aebef83..541f342e 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Constants.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Constants.java @@ -172,6 +172,7 @@ public final class Constants { public static final String PREFERENCES_KEY_BATCH_MODE = "batchMode"; public static final String PREFERENCES_KEY_CAST_GAPLESS_PLAYBACK = "castingGaplessPlayback"; public static final String PREFERENCES_KEY_CAST_STREAM_ORIGINAL = "castStreamOriginal"; + public static final String PREFERENCES_KEY_HEADS_UP_NOTIFICATION = "headsUpNotification"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; diff --git a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java index 356ec552..a59a9766 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java @@ -74,6 +74,10 @@ public final class Notifications { } if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { notification.visibility = Notification.VISIBILITY_PUBLIC; + + if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_HEADS_UP_NOTIFICATION, false)) { + notification.vibrate = new long[0]; + } } RemoteViews smallContentView = new RemoteViews(context.getPackageName(), R.layout.notification); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6b38f337..ee4af53c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -470,6 +470,8 @@ Shuffle all songs together Stream original Stream original files where supported by cast device + Heads Up Notifications (5.0+) + Show playing notifications as Heads Up notifications (Android Lollipop+ only) Shuffle By Start Year: diff --git a/app/src/main/res/xml/settings_playback.xml b/app/src/main/res/xml/settings_playback.xml index a4ea443e..91b0435b 100644 --- a/app/src/main/res/xml/settings_playback.xml +++ b/app/src/main/res/xml/settings_playback.xml @@ -40,6 +40,12 @@ android:key="persistentNotification" android:defaultValue="false"/> + +