Skip to content
Permalink
Browse files

Remove stop button for now and show play/pause in compact mode

  • Loading branch information
ferjm committed Nov 18, 2019
1 parent 35c4c35 commit 59f22abb3e8ce75968030152175221bf3a24c907
Showing with 4 additions and 12 deletions.
  1. +4 −12 support/android/apk/servoapp/src/main/java/org/mozilla/servo/MediaSession.java
@@ -101,7 +101,6 @@ public void showMediaSessionControls() {
if (mPlaybackState == PLAYBACK_STATE_PLAYING) {
filter.addAction(KEY_MEDIA_PAUSE);
}
filter.addAction(KEY_MEDIA_STOP);

int id;
if (mMediaSessionActionReceiver == null) {
@@ -116,9 +115,6 @@ public void onReceive(Context context, Intent intent) {
} else if (intent.getAction().equals(KEY_MEDIA_PLAY)) {
mView.mediaSessionAction(ACTION_PLAY);
Log.d("MediaSession", "PLAY action");
} else if (intent.getAction().equals(KEY_MEDIA_STOP)) {
mView.mediaSessionAction(ACTION_STOP);
Log.d("MediaSession", "STOP action");
}
}
};
@@ -128,18 +124,11 @@ public void onReceive(Context context, Intent intent) {

mContext.registerReceiver(mMediaSessionActionReceiver, filter);

Intent stopIntent = new Intent(KEY_MEDIA_STOP);
Notification.Action stopAction =
new Notification.Action(R.drawable.media_session_stop, "Stop",
PendingIntent.getBroadcast(mContext, 0, stopIntent, 0));

Notification.Builder builder = new Notification.Builder(mContext, this.MEDIA_CHANNEL_ID);
builder
.setSmallIcon(R.drawable.media_session_icon)
.setContentTitle(mTitle)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.addAction(stopAction)
.setStyle(new Notification.MediaStyle());
.setVisibility(Notification.VISIBILITY_PUBLIC);

String contentText = new String();
if (mArtist != null && !mArtist.isEmpty()) {
@@ -173,6 +162,9 @@ public void onReceive(Context context, Intent intent) {
builder.addAction(pauseAction);
}

builder.setStyle(new Notification.MediaStyle()
.setShowActionsInCompactView(0));

NotificationManager notificationManager =
mContext.getSystemService(NotificationManager.class);
notificationManager.notify(id, builder.build());

0 comments on commit 59f22ab

Please sign in to comment.
You can’t perform that action at this time.