diff --git a/packages/SystemUI/res/drawable/ic_pause_white_24dp.xml b/packages/SystemUI/res/drawable/ic_pause_white.xml similarity index 100% rename from packages/SystemUI/res/drawable/ic_pause_white_24dp.xml rename to packages/SystemUI/res/drawable/ic_pause_white.xml diff --git a/packages/SystemUI/res/drawable/ic_play_arrow_white_24dp.xml b/packages/SystemUI/res/drawable/ic_play_arrow_white.xml similarity index 100% rename from packages/SystemUI/res/drawable/ic_play_arrow_white_24dp.xml rename to packages/SystemUI/res/drawable/ic_play_arrow_white.xml diff --git a/packages/SystemUI/res/drawable/ic_skip_next_white.xml b/packages/SystemUI/res/drawable/ic_skip_next_white.xml new file mode 100644 index 0000000000000..040c7e6422415 --- /dev/null +++ b/packages/SystemUI/res/drawable/ic_skip_next_white.xml @@ -0,0 +1,28 @@ + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/ic_skip_previous_white.xml b/packages/SystemUI/res/drawable/ic_skip_previous_white.xml new file mode 100644 index 0000000000000..b9b94b73a00fc --- /dev/null +++ b/packages/SystemUI/res/drawable/ic_skip_previous_white.xml @@ -0,0 +1,28 @@ + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/layout/tv_pip_controls.xml b/packages/SystemUI/res/layout/tv_pip_controls.xml index c6bcd32901dd3..61ac6f6991ffe 100644 --- a/packages/SystemUI/res/layout/tv_pip_controls.xml +++ b/packages/SystemUI/res/layout/tv_pip_controls.xml @@ -40,7 +40,7 @@ android:layout_width="100dp" android:layout_height="wrap_content" android:layout_marginStart="-50dp" - android:src="@drawable/ic_pause_white_24dp" + android:src="@drawable/ic_pause_white" android:text="@string/pip_pause" android:visibility="gone" /> diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 33b1dd40e471d..2fd8b7f27ae0b 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1897,6 +1897,18 @@ Drag or fling the PIP to the edges of the screen to minimize it. + + Play + + + Pause + + + Skip to next + + + Skip to previous + Changing the theme requires a restart. diff --git a/packages/SystemUI/res/values/strings_tv.xml b/packages/SystemUI/res/values/strings_tv.xml index 41626fcb0a49b..e578068163d75 100644 --- a/packages/SystemUI/res/values/strings_tv.xml +++ b/packages/SystemUI/res/values/strings_tv.xml @@ -23,8 +23,4 @@ Close PIP Full screen - - Play - - Pause diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMediaController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMediaController.java index 3a4caa9a1e885..62ec09be2f514 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMediaController.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMediaController.java @@ -48,6 +48,8 @@ public class PipMediaController { private static final String ACTION_PLAY = "com.android.systemui.pip.phone.PLAY"; private static final String ACTION_PAUSE = "com.android.systemui.pip.phone.PAUSE"; + private static final String ACTION_NEXT = "com.android.systemui.pip.phone.NEXT"; + private static final String ACTION_PREV = "com.android.systemui.pip.phone.PREV"; /** * A listener interface to receive notification on changes to the media actions. @@ -67,6 +69,8 @@ public class PipMediaController { private RemoteAction mPauseAction; private RemoteAction mPlayAction; + private RemoteAction mNextAction; + private RemoteAction mPrevAction; private BroadcastReceiver mPlayPauseActionReceiver = new BroadcastReceiver() { @Override @@ -76,6 +80,10 @@ public class PipMediaController { mMediaController.getTransportControls().play(); } else if (action.equals(ACTION_PAUSE)) { mMediaController.getTransportControls().pause(); + } else if (action.equals(ACTION_NEXT)) { + mMediaController.getTransportControls().skipToNext(); + } else if (action.equals(ACTION_PREV)) { + mMediaController.getTransportControls().skipToPrevious(); } } }; @@ -95,6 +103,8 @@ public class PipMediaController { IntentFilter mediaControlFilter = new IntentFilter(); mediaControlFilter.addAction(ACTION_PLAY); mediaControlFilter.addAction(ACTION_PAUSE); + mediaControlFilter.addAction(ACTION_NEXT); + mediaControlFilter.addAction(ACTION_PREV); mContext.registerReceiver(mPlayPauseActionReceiver, mediaControlFilter); createMediaActions(); @@ -143,11 +153,21 @@ public class PipMediaController { int state = mMediaController.getPlaybackState().getState(); boolean isPlaying = MediaSession.isActiveState(state); long actions = mMediaController.getPlaybackState().getActions(); + + // Prev action + mPrevAction.setEnabled((actions & PlaybackState.ACTION_SKIP_TO_PREVIOUS) != 0); + mediaActions.add(mPrevAction); + + // Play/pause action if (!isPlaying && ((actions & PlaybackState.ACTION_PLAY) != 0)) { mediaActions.add(mPlayAction); } else if (isPlaying && ((actions & PlaybackState.ACTION_PAUSE) != 0)) { mediaActions.add(mPauseAction); } + + // Next action + mNextAction.setEnabled((actions & PlaybackState.ACTION_SKIP_TO_NEXT) != 0); + mediaActions.add(mNextAction); return mediaActions; } @@ -157,15 +177,27 @@ public class PipMediaController { private void createMediaActions() { String pauseDescription = mContext.getString(R.string.pip_pause); mPauseAction = new RemoteAction(Icon.createWithResource(mContext, - R.drawable.ic_pause_white_24dp), pauseDescription, pauseDescription, + R.drawable.ic_pause_white), pauseDescription, pauseDescription, PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_PAUSE), FLAG_UPDATE_CURRENT)); String playDescription = mContext.getString(R.string.pip_play); mPlayAction = new RemoteAction(Icon.createWithResource(mContext, - R.drawable.ic_play_arrow_white_24dp), playDescription, playDescription, + R.drawable.ic_play_arrow_white), playDescription, playDescription, PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_PLAY), FLAG_UPDATE_CURRENT)); + + String nextDescription = mContext.getString(R.string.pip_skip_to_next); + mNextAction = new RemoteAction(Icon.createWithResource(mContext, + R.drawable.ic_skip_next_white), nextDescription, nextDescription, + PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_NEXT), + FLAG_UPDATE_CURRENT)); + + String prevDescription = mContext.getString(R.string.pip_skip_to_prev); + mPrevAction = new RemoteAction(Icon.createWithResource(mContext, + R.drawable.ic_skip_previous_white), prevDescription, prevDescription, + PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_PREV), + FLAG_UPDATE_CURRENT)); } /** diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipControlsView.java b/packages/SystemUI/src/com/android/systemui/pip/tv/PipControlsView.java index 4c81907c35f7e..acea3b6b12ad2 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipControlsView.java +++ b/packages/SystemUI/src/com/android/systemui/pip/tv/PipControlsView.java @@ -186,10 +186,10 @@ public class PipControlsView extends LinearLayout { } else { mPlayPauseButtonView.setVisibility(View.VISIBLE); if (state == PipManager.PLAYBACK_STATE_PLAYING) { - mPlayPauseButtonView.setImageResource(R.drawable.ic_pause_white_24dp); + mPlayPauseButtonView.setImageResource(R.drawable.ic_pause_white); mPlayPauseButtonView.setText(R.string.pip_pause); } else { - mPlayPauseButtonView.setImageResource(R.drawable.ic_play_arrow_white_24dp); + mPlayPauseButtonView.setImageResource(R.drawable.ic_play_arrow_white); mPlayPauseButtonView.setText(R.string.pip_play); } }