From 2292312f402048db15107bebb6c36236e5bcf591 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 24 Mar 2014 20:36:34 -0700 Subject: #313 Add x for remote, make it stop + disconnect --- src/github/daneren2005/dsub/service/DownloadService.java | 6 ++++++ src/github/daneren2005/dsub/util/Util.java | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'src/github/daneren2005') diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index a4d2c508..e2e664ac 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -900,6 +900,12 @@ public class DownloadService extends Service { if (playerState == STARTED) { if (remoteState != RemoteControlState.LOCAL) { remoteController.stop(); + handler.post(new Runnable() { + @Override + public void run() { + mediaRouter.setDefaultRoute(); + } + }); } else { mediaPlayer.pause(); } diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index 4243c853..5887b088 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -39,6 +39,7 @@ import android.media.AudioManager.OnAudioFocusChangeListener; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.wifi.WifiManager; +import android.opengl.Visibility; import android.os.Build; import android.os.Environment; import android.os.Handler; @@ -48,6 +49,7 @@ import android.text.method.LinkMovementMethod; import android.text.util.Linkify; import android.util.Log; import android.view.Gravity; +import android.view.View; import android.view.ViewGroup; import android.view.KeyEvent; import android.widget.LinearLayout; @@ -979,14 +981,15 @@ public final class Util { notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; boolean playing = downloadService.getPlayerState() == PlayerState.STARTED; + boolean remote = downloadService.isRemoteEnabled(); if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.JELLY_BEAN){ RemoteViews expandedContentView = new RemoteViews(context.getPackageName(), R.layout.notification_expanded); - setupViews(expandedContentView,context,song, playing); + setupViews(expandedContentView,context,song, playing, remote); notification.bigContentView = expandedContentView; } RemoteViews smallContentView = new RemoteViews(context.getPackageName(), R.layout.notification); - setupViews(smallContentView, context, song, playing); + setupViews(smallContentView, context, song, playing, remote); notification.contentView = smallContentView; Intent notificationIntent = new Intent(context, SubsonicFragmentActivity.class); @@ -1005,7 +1008,7 @@ public final class Util { DSubWidgetProvider.notifyInstances(context, downloadService, playing); } - private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean playing){ + private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean playing, boolean remote){ // Use the same text for the ticker and the expanded notification String title = song.getTitle(); @@ -1062,6 +1065,11 @@ public final class Util { next = R.id.control_next; } + if(remote && close == 0) { + close = R.id.notification_close; + rv.setViewVisibility(close, View.VISIBLE); + } + if(previous > 0) { Intent prevIntent = new Intent("KEYCODE_MEDIA_PREVIOUS"); prevIntent.setComponent(new ComponentName(context, DownloadService.class)); -- cgit v1.2.3