aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-03-24 20:36:34 -0700
committerScott Jackson <daneren2005@gmail.com>2014-03-24 20:36:34 -0700
commit2292312f402048db15107bebb6c36236e5bcf591 (patch)
tree4f44f8f0b733aa5e58f4d87c6ee13c583bb388e0 /src
parente17f51685e633ca2fff6512cf44e87ad660aa396 (diff)
downloaddsub-2292312f402048db15107bebb6c36236e5bcf591.tar.gz
dsub-2292312f402048db15107bebb6c36236e5bcf591.tar.bz2
dsub-2292312f402048db15107bebb6c36236e5bcf591.zip
#313 Add x for remote, make it stop + disconnect
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java6
-rw-r--r--src/github/daneren2005/dsub/util/Util.java14
2 files changed, 17 insertions, 3 deletions
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));