Merge changes I062b6c37,Ie5165364,Ib3cce253 into oc-dev

* changes:
  Add remaining default media icons.
  Disable PiP when a task is locked.
  Fix issue with PiP actions flashing.
This commit is contained in:
TreeHugger Robot
2017-04-19 01:29:10 +00:00
committed by Android (Google) Code Review
11 changed files with 131 additions and 19 deletions

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:pathData="M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z" />
<path
android:pathData="M0 0h24v24H0z" />
</vector>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:pathData="M6 6h2v12H6zm3.5 6l8.5 6V6z" />
<path
android:pathData="M0 0h24v24H0z" />
</vector>

View File

@@ -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" />
</merge>

View File

@@ -1897,6 +1897,18 @@
<!-- PiP minimize description. [CHAR LIMIT=NONE] -->
<string name="pip_minimize_description" translatable="false">Drag or fling the PIP to the edges of the screen to minimize it.</string>
<!-- Button to play the current media on picture-in-picture (PIP) [CHAR LIMIT=30] -->
<string name="pip_play">Play</string>
<!-- Button to pause the current media on picture-in-picture (PIP) [CHAR LIMIT=30] -->
<string name="pip_pause">Pause</string>
<!-- Button to skip to the next media on picture-in-picture (PIP) [CHAR LIMIT=30] -->
<string name="pip_skip_to_next">Skip to next</string>
<!-- Button to skip to the prev media on picture-in-picture (PIP) [CHAR LIMIT=30] -->
<string name="pip_skip_to_prev">Skip to previous</string>
<!-- Tuner string -->
<string name="change_theme_reboot" translatable="false">Changing the theme requires a restart.</string>
<!-- Tuner string -->

View File

@@ -23,8 +23,4 @@
<string name="pip_close">Close PIP</string>
<!-- Button to move picture-in-picture (PIP) screen to the fullscreen in PIP menu [CHAR LIMIT=30] -->
<string name="pip_fullscreen">Full screen</string>
<!-- Button to play the current media on picture-in-picture (PIP) [CHAR LIMIT=30] -->
<string name="pip_play">Play</string>
<!-- Button to pause the current media on picture-in-picture (PIP) [CHAR LIMIT=30] -->
<string name="pip_pause">Pause</string>
</resources>

View File

@@ -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));
}
/**

View File

@@ -412,16 +412,26 @@ public class PipMenuActivity extends Activity {
} else {
actionsContainer.setVisibility(View.VISIBLE);
if (mActionsGroup != null) {
mActionsGroup.removeAllViews();
// Hide extra views
for (int i = mActions.size(); i < mActionsGroup.getChildCount(); i++) {
mActionsGroup.getChildAt(i).setVisibility(View.GONE);
}
// Add needed views
final LayoutInflater inflater = LayoutInflater.from(this);
while (mActionsGroup.getChildCount() < mActions.size()) {
final ImageView actionView = (ImageView) inflater.inflate(
R.layout.pip_menu_action, mActionsGroup, false);
mActionsGroup.addView(actionView);
}
// Recreate the layout
final boolean isLandscapePip = stackBounds != null &&
(stackBounds.width() > stackBounds.height());
final LayoutInflater inflater = LayoutInflater.from(this);
for (int i = 0; i < mActions.size(); i++) {
final RemoteAction action = mActions.get(i);
final ImageView actionView = (ImageView) inflater.inflate(
R.layout.pip_menu_action, mActionsGroup, false);
final ImageView actionView = (ImageView) mActionsGroup.getChildAt(i);
// TODO: Check if the action drawable has changed before we reload it
action.getIcon().loadDrawableAsync(this, d -> {
d.setTint(Color.WHITE);
actionView.setImageDrawable(d);
@@ -439,12 +449,11 @@ public class PipMenuActivity extends Activity {
actionView.setAlpha(DISABLED_ACTION_ALPHA);
actionView.setEnabled(false);
}
if (isLandscapePip && i > 0) {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)
actionView.getLayoutParams();
lp.leftMargin = mBetweenActionPaddingLand;
}
mActionsGroup.addView(actionView);
// Update the margin between actions
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)
actionView.getLayoutParams();
lp.leftMargin = (isLandscapePip && i > 0) ? mBetweenActionPaddingLand : 0;
}
}

View File

@@ -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);
}
}

View File

@@ -10685,6 +10685,13 @@ public class ActivityManagerService extends IActivityManager.Stub
return;
}
// When a task is locked, dismiss the pinned stack if it exists
final PinnedActivityStack pinnedStack = mStackSupervisor.getStack(
PINNED_STACK_ID);
if (pinnedStack != null) {
mStackSupervisor.removeStackLocked(PINNED_STACK_ID);
}
// isSystemInitiated is used to distinguish between locked and pinned mode, as pinned mode
// is initiated by system after the pinning request was shown and locked mode is initiated
// by an authorized app directly