Merge "PIP: Show background scrim for PIP controls in Recents" into nyc-dev am: 28194523a4
am: 4deaaf83b8
* commit '4deaaf83b8a09cc0106671145a0b9e04b261c717':
PIP: Show background scrim for PIP controls in Recents
Change-Id: Iad50ce36dcd6cc2cc8096af94dea41110cd8ecc6
This commit is contained in:
@@ -1,29 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2016 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
|
|
||||||
<objectAnimator
|
|
||||||
android:propertyName="scaleX"
|
|
||||||
android:valueTo="0.7"
|
|
||||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
|
||||||
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
|
||||||
<objectAnimator
|
|
||||||
android:propertyName="scaleY"
|
|
||||||
android:valueTo="0.7"
|
|
||||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
|
||||||
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
|
||||||
</set>
|
|
||||||
@@ -14,8 +14,21 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
android:propertyName="translationY"
|
android:propertyName="translationY"
|
||||||
android:valueTo="0dp"
|
android:valueTo="0dp"
|
||||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||||
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
||||||
|
<objectAnimator
|
||||||
|
android:propertyName="scaleX"
|
||||||
|
android:valueTo="1.0"
|
||||||
|
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||||
|
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
||||||
|
<objectAnimator
|
||||||
|
android:propertyName="scaleY"
|
||||||
|
android:valueTo="1.0"
|
||||||
|
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||||
|
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
||||||
|
</set>
|
||||||
|
|||||||
@@ -14,8 +14,21 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<objectAnimator
|
||||||
android:propertyName="translationY"
|
android:propertyName="translationY"
|
||||||
android:valueTo="-57dp"
|
android:valueTo="-57dp"
|
||||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||||
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
||||||
|
<objectAnimator
|
||||||
|
android:propertyName="scaleX"
|
||||||
|
android:valueTo="0.7"
|
||||||
|
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||||
|
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
||||||
|
<objectAnimator
|
||||||
|
android:propertyName="scaleY"
|
||||||
|
android:valueTo="0.7"
|
||||||
|
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||||
|
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
||||||
|
</set>
|
||||||
|
|||||||
@@ -14,16 +14,8 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:propertyName="alpha"
|
||||||
<objectAnimator
|
android:valueTo="1"
|
||||||
android:propertyName="scaleX"
|
|
||||||
android:valueTo="1.0"
|
|
||||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
android:interpolator="@android:interpolator/fast_out_slow_in"
|
||||||
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
android:duration="100" />
|
||||||
<objectAnimator
|
|
||||||
android:propertyName="scaleY"
|
|
||||||
android:valueTo="1.0"
|
|
||||||
android:interpolator="@android:interpolator/fast_out_slow_in"
|
|
||||||
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
|
|
||||||
</set>
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<!--
|
||||||
|
Copyright (C) 2016 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.
|
||||||
|
-->
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
|
||||||
|
<gradient
|
||||||
|
android:startColor="#80000000"
|
||||||
|
android:endColor="#00000000"
|
||||||
|
android:angle="90"/>
|
||||||
|
</shape>
|
||||||
@@ -16,14 +16,31 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:gravity="top|center_horizontal"
|
||||||
android:gravity="top|center_horizontal">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.android.systemui.tv.pip.PipRecentsControlsView
|
<com.android.systemui.tv.pip.PipRecentsControlsView
|
||||||
android:id="@+id/pip_controls"
|
android:id="@+id/pip_controls"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:clipToPadding="false">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/scrim"
|
||||||
|
android:layout_width="160dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:translationY="-46dp"
|
||||||
|
android:layout_gravity="top|center_horizontal"
|
||||||
|
android:background="@drawable/tv_pip_recents_overlay_scrim" />
|
||||||
|
<com.android.systemui.tv.pip.PipControlsView
|
||||||
|
android:id="@+id/pip_control_contents"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_gravity="top|center_horizontal" />
|
||||||
|
</com.android.systemui.tv.pip.PipRecentsControlsView>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/recents"
|
android:id="@+id/recents"
|
||||||
|
|||||||
@@ -52,9 +52,6 @@
|
|||||||
<dimen name="recents_tv_dismiss_icon_bottom_margin">1dip</dimen>
|
<dimen name="recents_tv_dismiss_icon_bottom_margin">1dip</dimen>
|
||||||
<dimen name="recents_tv_dismiss_text_size">12sp</dimen>
|
<dimen name="recents_tv_dismiss_text_size">12sp</dimen>
|
||||||
|
|
||||||
<!-- Values for PIP in recents -->
|
|
||||||
<dimen name="recents_tv_pip_controls_margin_top">10dp</dimen>
|
|
||||||
|
|
||||||
<!-- Extra space around the PIP and its outline in PIP onboarding activity -->
|
<!-- Extra space around the PIP and its outline in PIP onboarding activity -->
|
||||||
<dimen name="tv_pip_bounds_space">3dp</dimen>
|
<dimen name="tv_pip_bounds_space">3dp</dimen>
|
||||||
|
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ public class PipControlsView extends LinearLayout {
|
|||||||
final PipManager mPipManager = PipManager.getInstance();
|
final PipManager mPipManager = PipManager.getInstance();
|
||||||
Listener mListener;
|
Listener mListener;
|
||||||
|
|
||||||
PipControlButtonView mFullButtonView;
|
private PipControlButtonView mFullButtonView;
|
||||||
PipControlButtonView mCloseButtonView;
|
private PipControlButtonView mCloseButtonView;
|
||||||
PipControlButtonView mPlayPauseButtonView;
|
private PipControlButtonView mPlayPauseButtonView;
|
||||||
|
|
||||||
private boolean mHasFocus;
|
private boolean mHasFocus;
|
||||||
private OnFocusChangeListener mOnChildFocusChangeListener;
|
private OnFocusChangeListener mOnChildFocusChangeListener;
|
||||||
|
|||||||
@@ -18,14 +18,15 @@ package com.android.systemui.tv.pip;
|
|||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorInflater;
|
import android.animation.AnimatorInflater;
|
||||||
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.AnimatorSet;
|
import android.animation.AnimatorSet;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnFocusChangeListener;
|
import android.view.View.OnFocusChangeListener;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
|
||||||
@@ -34,9 +35,9 @@ import static com.android.systemui.tv.pip.PipManager.PLAYBACK_STATE_PAUSED;
|
|||||||
import static com.android.systemui.tv.pip.PipManager.PLAYBACK_STATE_UNAVAILABLE;
|
import static com.android.systemui.tv.pip.PipManager.PLAYBACK_STATE_UNAVAILABLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extended version of {@link PipControlsView} that supports animation in Recents.
|
* An FrameLayout that contains {@link PipControlsView} with its scrim.
|
||||||
*/
|
*/
|
||||||
public class PipRecentsControlsView extends PipControlsView {
|
public class PipRecentsControlsView extends FrameLayout {
|
||||||
/**
|
/**
|
||||||
* An interface to listen user action.
|
* An interface to listen user action.
|
||||||
*/
|
*/
|
||||||
@@ -47,7 +48,11 @@ public class PipRecentsControlsView extends PipControlsView {
|
|||||||
abstract void onBackPressed();
|
abstract void onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
private AnimatorSet mFocusGainAnimatorSet;
|
final PipManager mPipManager = PipManager.getInstance();
|
||||||
|
private Listener mListener;
|
||||||
|
private PipControlsView mPipControlsView;
|
||||||
|
private View mScrim;
|
||||||
|
private Animator mFocusGainAnimator;
|
||||||
private AnimatorSet mFocusLoseAnimatorSet;
|
private AnimatorSet mFocusLoseAnimatorSet;
|
||||||
|
|
||||||
public PipRecentsControlsView(Context context) {
|
public PipRecentsControlsView(Context context) {
|
||||||
@@ -71,26 +76,20 @@ public class PipRecentsControlsView extends PipControlsView {
|
|||||||
public void onFinishInflate() {
|
public void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
|
||||||
int buttonsFocusGainAnim = R.anim.tv_pip_controls_buttons_in_recents_focus_gain_animation;
|
mPipControlsView = (PipControlsView) findViewById(R.id.pip_control_contents);
|
||||||
mFocusGainAnimatorSet = new AnimatorSet();
|
mScrim = findViewById(R.id.scrim);
|
||||||
mFocusGainAnimatorSet.playTogether(
|
|
||||||
loadAnimator(this, R.anim.tv_pip_controls_in_recents_focus_gain_animation),
|
mFocusGainAnimator = loadAnimator(mPipControlsView,
|
||||||
loadAnimator(mFullButtonView,buttonsFocusGainAnim),
|
R.anim.tv_pip_controls_in_recents_focus_gain_animation);
|
||||||
loadAnimator(mPlayPauseButtonView, buttonsFocusGainAnim),
|
|
||||||
loadAnimator(mCloseButtonView, buttonsFocusGainAnim));
|
|
||||||
|
|
||||||
int buttonsFocusLoseAnim = R.anim.tv_pip_controls_buttons_in_recents_focus_lose_animation;
|
|
||||||
mFocusLoseAnimatorSet = new AnimatorSet();
|
mFocusLoseAnimatorSet = new AnimatorSet();
|
||||||
mFocusLoseAnimatorSet.playTogether(
|
mFocusLoseAnimatorSet.playSequentially(
|
||||||
loadAnimator(this, R.anim.tv_pip_controls_in_recents_focus_lose_animation),
|
loadAnimator(mPipControlsView,
|
||||||
loadAnimator(mFullButtonView, buttonsFocusLoseAnim),
|
R.anim.tv_pip_controls_in_recents_focus_lose_animation),
|
||||||
loadAnimator(mPlayPauseButtonView, buttonsFocusLoseAnim),
|
loadAnimator(mScrim, R.anim.tv_pip_controls_in_recents_scrim_fade_in_animation));
|
||||||
loadAnimator(mCloseButtonView, buttonsFocusLoseAnim));
|
|
||||||
|
|
||||||
Rect pipBounds = mPipManager.getRecentsFocusedPipBounds();
|
Rect pipBounds = mPipManager.getRecentsFocusedPipBounds();
|
||||||
int pipControlsMarginTop = getContext().getResources().getDimensionPixelSize(
|
setPadding(0, pipBounds.bottom, 0, 0);
|
||||||
R.dimen.recents_tv_pip_controls_margin_top);
|
|
||||||
setPadding(0, pipBounds.bottom + pipControlsMarginTop, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Animator loadAnimator(View view, int animatorResId) {
|
private Animator loadAnimator(View view, int animatorResId) {
|
||||||
@@ -103,44 +102,53 @@ public class PipRecentsControlsView extends PipControlsView {
|
|||||||
* Starts focus gaining animation.
|
* Starts focus gaining animation.
|
||||||
*/
|
*/
|
||||||
public void startFocusGainAnimation() {
|
public void startFocusGainAnimation() {
|
||||||
if (mFocusLoseAnimatorSet.isStarted()) {
|
// Hides the scrim view as soon as possible, before the PIP resize animation starts.
|
||||||
mFocusLoseAnimatorSet.cancel();
|
// If we don't, PIP will be moved down a bit and a gap between the scrim and PIP will be
|
||||||
}
|
// shown at the bottom of the PIP.
|
||||||
mFocusGainAnimatorSet.start();
|
mScrim.setAlpha(0);
|
||||||
|
startAnimator(mFocusGainAnimator, mFocusLoseAnimatorSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts focus losing animation.
|
* Starts focus losing animation.
|
||||||
*/
|
*/
|
||||||
public void startFocusLoseAnimation() {
|
public void startFocusLoseAnimation() {
|
||||||
if (mFocusGainAnimatorSet.isStarted()) {
|
startAnimator(mFocusLoseAnimatorSet, mFocusGainAnimator);
|
||||||
mFocusGainAnimatorSet.cancel();
|
|
||||||
}
|
|
||||||
mFocusLoseAnimatorSet.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the view to the initial state. (i.e. end of the focus gain)
|
* Resets the view to the initial state. (i.e. end of the focus gain)
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
if (mFocusGainAnimatorSet.isStarted()) {
|
cancelAnimator(mFocusGainAnimator);
|
||||||
mFocusGainAnimatorSet.cancel();
|
cancelAnimator(mFocusLoseAnimatorSet);
|
||||||
}
|
|
||||||
if (mFocusLoseAnimatorSet.isStarted()) {
|
|
||||||
mFocusLoseAnimatorSet.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset to initial state (i.e. end of focused)
|
// Reset to initial state (i.e. end of focused)
|
||||||
requestFocus();
|
requestFocus();
|
||||||
setTranslationY(0);
|
mPipControlsView.setTranslationY(0);
|
||||||
setScaleXY(mFullButtonView, 1);
|
mPipControlsView.setScaleX(1);
|
||||||
setScaleXY(mPlayPauseButtonView, 1);
|
mPipControlsView.setScaleY(1);
|
||||||
setScaleXY(mCloseButtonView, 1);
|
mScrim.setAlpha(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setScaleXY(View view, float scale) {
|
private static void startAnimator(Animator animator, Animator previousAnimator) {
|
||||||
view.setScaleX(scale);
|
cancelAnimator(previousAnimator);
|
||||||
view.setScaleY(scale);
|
if (!animator.isStarted()) {
|
||||||
|
animator.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void cancelAnimator(Animator animator) {
|
||||||
|
if (animator.isStarted()) {
|
||||||
|
animator.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets listeners.
|
||||||
|
*/
|
||||||
|
public void setListener(Listener listener) {
|
||||||
|
mPipControlsView.setListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -148,8 +156,8 @@ public class PipRecentsControlsView extends PipControlsView {
|
|||||||
if (!event.isCanceled()
|
if (!event.isCanceled()
|
||||||
&& event.getKeyCode() == KeyEvent.KEYCODE_BACK
|
&& event.getKeyCode() == KeyEvent.KEYCODE_BACK
|
||||||
&& event.getAction() == KeyEvent.ACTION_UP) {
|
&& event.getAction() == KeyEvent.ACTION_UP) {
|
||||||
if (mListener != null) {
|
if (mPipControlsView.mListener != null) {
|
||||||
((PipRecentsControlsView.Listener) mListener).onBackPressed();
|
((PipRecentsControlsView.Listener) mPipControlsView.mListener).onBackPressed();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user