diff options
-rw-r--r-- | res/layout/notification_expanded.xml | 35 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadService.java | 6 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/Util.java | 14 |
3 files changed, 43 insertions, 12 deletions
diff --git a/res/layout/notification_expanded.xml b/res/layout/notification_expanded.xml index 3e2c7fcd..5fc4156a 100644 --- a/res/layout/notification_expanded.xml +++ b/res/layout/notification_expanded.xml @@ -19,15 +19,32 @@ android:orientation="vertical" android:paddingLeft="11.0dip" > - <TextView - android:id="@+id/notification_title" - style="@android:style/TextAppearance.StatusBar.EventContent.Title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="left" - android:ellipsize="marquee" - android:focusable="true" - android:singleLine="true" /> + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <TextView + android:id="@+id/notification_title" + style="@android:style/TextAppearance.StatusBar.EventContent.Title" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:layout_gravity="left" + android:ellipsize="marquee" + android:focusable="true" + android:singleLine="true" /> + + <ImageButton + android:id="@+id/notification_close" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/notification_close" + android:background="@drawable/btn_bg" + android:padding="10dip" + android:layout_gravity="right" + android:visibility="gone"/> + </LinearLayout> <TextView android:id="@+id/notification_artist" 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)); |