Merge "PIP: Implement focus change animation in PIP control buttons" into nyc-dev

This commit is contained in:
Jaewan Kim
2016-04-14 01:41:55 +00:00
committed by Android (Google) Code Review
18 changed files with 302 additions and 300 deletions

View File

@@ -18,4 +18,4 @@
android:propertyName="alpha"
android:valueTo="1"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
android:duration="100" />

View File

@@ -18,4 +18,4 @@
android:propertyName="alpha"
android:valueTo="0"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:duration="@integer/recents_tv_pip_focus_anim_duration" />
android:duration="100" />

View File

@@ -0,0 +1,21 @@
<?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.
-->
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="alpha"
android:valueTo="1"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:duration="100" />

View File

@@ -0,0 +1,21 @@
<?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.
-->
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="alpha"
android:valueTo="0"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:duration="100" />

View File

@@ -14,11 +14,5 @@
limitations under the License.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="34dp"
android:height="34dp" />
<solid
android:color="#4DFFFFFF" />
</shape>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#9AFFFFFF" android:radius="17dp" />

View File

@@ -1,38 +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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:constantSize="true">
<item android:state_focused="true">
<layer-list>
<item android:drawable="@drawable/tv_pip_button_focused" />
<item android:drawable="@drawable/ic_close_white"
android:top="@dimen/tv_pip_button_icon_padding"
android:bottom="@dimen/tv_pip_button_icon_padding"
android:left="@dimen/tv_pip_button_icon_padding"
android:right="@dimen/tv_pip_button_icon_padding" />
</layer-list>
</item>
<item>
<layer-list>
<item android:drawable="@drawable/ic_close_white"
android:top="@dimen/tv_pip_button_icon_padding"
android:bottom="@dimen/tv_pip_button_icon_padding"
android:left="@dimen/tv_pip_button_icon_padding"
android:right="@dimen/tv_pip_button_icon_padding" />
</layer-list>
</item>
</selector>

View File

@@ -1,38 +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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:constantSize="true">
<item android:state_focused="true">
<layer-list>
<item android:drawable="@drawable/tv_pip_button_focused" />
<item android:drawable="@drawable/ic_fullscreen_white_24dp"
android:top="@dimen/tv_pip_button_icon_padding"
android:bottom="@dimen/tv_pip_button_icon_padding"
android:left="@dimen/tv_pip_button_icon_padding"
android:right="@dimen/tv_pip_button_icon_padding" />
</layer-list>
</item>
<item>
<layer-list>
<item android:drawable="@drawable/ic_fullscreen_white_24dp"
android:top="@dimen/tv_pip_button_icon_padding"
android:bottom="@dimen/tv_pip_button_icon_padding"
android:left="@dimen/tv_pip_button_icon_padding"
android:right="@dimen/tv_pip_button_icon_padding" />
</layer-list>
</item>
</selector>

View File

@@ -1,38 +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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:constantSize="true">
<item android:state_focused="true">
<layer-list>
<item android:drawable="@drawable/tv_pip_button_focused" />
<item android:drawable="@drawable/ic_pause_white_24dp"
android:top="@dimen/tv_pip_button_icon_padding"
android:bottom="@dimen/tv_pip_button_icon_padding"
android:left="@dimen/tv_pip_button_icon_padding"
android:right="@dimen/tv_pip_button_icon_padding" />
</layer-list>
</item>
<item>
<layer-list>
<item android:drawable="@drawable/ic_pause_white_24dp"
android:top="@dimen/tv_pip_button_icon_padding"
android:bottom="@dimen/tv_pip_button_icon_padding"
android:left="@dimen/tv_pip_button_icon_padding"
android:right="@dimen/tv_pip_button_icon_padding" />
</layer-list>
</item>
</selector>

View File

@@ -1,38 +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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:constantSize="true">
<item android:state_focused="true">
<layer-list>
<item android:drawable="@drawable/tv_pip_button_focused" />
<item android:drawable="@drawable/ic_play_arrow_white_24dp"
android:top="@dimen/tv_pip_button_icon_padding"
android:bottom="@dimen/tv_pip_button_icon_padding"
android:left="@dimen/tv_pip_button_icon_padding"
android:right="@dimen/tv_pip_button_icon_padding" />
</layer-list>
</item>
<item>
<layer-list>
<item android:drawable="@drawable/ic_play_arrow_white_24dp"
android:top="@dimen/tv_pip_button_icon_padding"
android:bottom="@dimen/tv_pip_button_icon_padding"
android:left="@dimen/tv_pip_button_icon_padding"
android:right="@dimen/tv_pip_button_icon_padding" />
</layer-list>
</item>
</selector>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 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.
*/
-->
<!-- Layout for {@link com.android.systemui.tv.pip.PipControlButtonView}. -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/button"
android:layout_width="34dp"
android:layout_height="34dp"
android:padding="5dp"
android:focusable="true"
android:src="@drawable/ic_fullscreen_white_24dp"
android:background="@drawable/tv_pip_button_focused"
android:layerType="software" />
<TextView android:id="@+id/desc"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:gravity="center"
android:text="@string/pip_fullscreen"
android:alpha="0"
android:fontFamily="sans-serif"
android:textSize="12sp"
android:textColor="#EEEEEE" />
</merge>

View File

@@ -20,77 +20,26 @@
<!-- Layout for {@link com.android.systemui.tv.pip.PipControlsView}. -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
<com.android.systemui.tv.pip.PipControlsButtonView
android:id="@+id/full_button"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center">
android:src="@drawable/ic_fullscreen_white_24dp"
android:text="@string/pip_fullscreen" />
<ImageView android:id="@+id/full_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:src="@drawable/tv_pip_full_button" />
<TextView android:id="@+id/full_desc"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:gravity="center"
android:visibility="invisible"
android:text="@string/pip_fullscreen"
android:fontFamily="sans-serif"
android:textSize="12sp"
android:textColor="#EEEEEE" />
</LinearLayout>
<LinearLayout
<com.android.systemui.tv.pip.PipControlsButtonView
android:id="@+id/close_button"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginStart="-50dp"
android:orientation="vertical"
android:gravity="center">
android:src="@drawable/ic_close_white"
android:text="@string/pip_close" />
<ImageView android:id="@+id/close_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:src="@drawable/tv_pip_close_button" />
<TextView android:id="@+id/close_desc"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:gravity="center"
android:visibility="invisible"
android:text="@string/pip_close"
android:fontFamily="sans-serif"
android:textSize="12sp"
android:textColor="#EEEEEE" />
</LinearLayout>
<LinearLayout android:id="@+id/play_pause"
<com.android.systemui.tv.pip.PipControlsButtonView
android:id="@+id/play_pause_button"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginStart="-50dp"
android:orientation="vertical"
android:gravity="center" >
<ImageView android:id="@+id/play_pause_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true"
android:src="@drawable/tv_pip_pause_button" />
<TextView android:id="@+id/play_pause_desc"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:gravity="center"
android:visibility="invisible"
android:text="@string/pip_pause"
android:fontFamily="sans-serif"
android:textSize="12sp"
android:textColor="#EEEEEE" />
</LinearLayout>
android:src="@drawable/ic_pause_white_24dp"
android:text="@string/pip_pause" />
</merge>

View File

@@ -29,5 +29,6 @@
<com.android.systemui.tv.pip.PipControlsView
android:id="@+id/pip_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:alpha="0" />
</LinearLayout>

View File

@@ -54,8 +54,6 @@
<!-- Extra space around the PIP and its outline in PIP onboarding activity -->
<dimen name="tv_pip_bounds_space">3dp</dimen>
<!-- Extra space around the PIP control button icon to match with the focused circle -->
<dimen name="tv_pip_button_icon_padding">5dp</dimen>
<!-- Values for entering Recents and exiting Recents -->
<dimen name="recents_tv_home_recents_shift">125dip</dimen>

View File

@@ -0,0 +1,142 @@
/*
* 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.
*/
package com.android.systemui.tv.pip;
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View.OnFocusChangeListener;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.systemui.R;
/**
* A view containing PIP controls including fullscreen, close, and media controls.
*/
public class PipControlButtonView extends LinearLayout {
private OnFocusChangeListener mFocusChangeListener;
private ImageView mButtonImageView;
private TextView mDescriptionTextView;
private Animator mFocusGainAnimator;
private Animator mFocusLoseAnimator;
private final OnFocusChangeListener mInternalFocusChangeListener =
new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (mFocusLoseAnimator.isStarted()) {
mFocusLoseAnimator.cancel();
}
mFocusGainAnimator.start();
} else {
if (mFocusGainAnimator.isStarted()) {
mFocusGainAnimator.cancel();
}
mFocusLoseAnimator.start();
}
if (mFocusChangeListener != null) {
mFocusChangeListener.onFocusChange(v, hasFocus);
}
}
};
public PipControlButtonView(Context context) {
this(context, null, 0, 0);
}
public PipControlButtonView(Context context, AttributeSet attrs) {
this(context, attrs, 0, 0);
}
public PipControlButtonView(Context context, AttributeSet attrs, int defStyleAttr) {
this(context, attrs, defStyleAttr, 0);
}
public PipControlButtonView(
Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
LayoutInflater inflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.tv_pip_control_button, this);
setOrientation(LinearLayout.VERTICAL);
setGravity(Gravity.CENTER);
mButtonImageView = (ImageView) findViewById(R.id.button);
mDescriptionTextView = (TextView) findViewById(R.id.desc);
int[] values = new int[] {android.R.attr.src, android.R.attr.text};
TypedArray typedArray =
context.obtainStyledAttributes(attrs, values, defStyleAttr, defStyleRes);
mButtonImageView.setImageDrawable(typedArray.getDrawable(0));
mDescriptionTextView.setText(typedArray.getText(1));
typedArray.recycle();
}
@Override
public void onFinishInflate() {
super.onFinishInflate();
mButtonImageView.setOnFocusChangeListener(mInternalFocusChangeListener);
mFocusGainAnimator = AnimatorInflater.loadAnimator(getContext(),
R.anim.tv_pip_controls_text_focus_gain_animation);
mFocusGainAnimator.setTarget(mDescriptionTextView);
mFocusLoseAnimator = AnimatorInflater.loadAnimator(getContext(),
R.anim.tv_pip_controls_text_focus_lose_animation);
mFocusLoseAnimator.setTarget(mDescriptionTextView);
}
@Override
public void setOnClickListener(OnClickListener listener) {
mButtonImageView.setOnClickListener(listener);
}
@Override
public void setOnFocusChangeListener(OnFocusChangeListener listener) {
mFocusChangeListener = listener;
}
/**
* Sets the drawable for the button with the given resource id.
*/
public void setImageResource(int resId) {
mButtonImageView.setImageResource(resId);
}
/**
* Sets the text for description the with the given resource id.
*/
public void setText(int resId) {
mDescriptionTextView.setText(resId);
}
@Override
public boolean isFocused() {
return mButtonImageView.isFocused();
}
}

View File

@@ -57,13 +57,9 @@ public class PipControlsView extends LinearLayout {
final PipManager mPipManager = PipManager.getInstance();
Listener mListener;
View mFullButtonView;
View mFullDescriptionView;
View mPlayPauseView;
ImageView mPlayPauseButtonImageView;
TextView mPlayPauseDescriptionTextView;
View mCloseButtonView;
View mCloseDescriptionView;
PipControlButtonView mFullButtonView;
PipControlButtonView mCloseButtonView;
PipControlButtonView mPlayPauseButtonView;
private boolean mHasFocus;
private OnFocusChangeListener mOnChildFocusChangeListener;
@@ -75,13 +71,20 @@ public class PipControlsView extends LinearLayout {
}
};
private PipManager.MediaListener mPipMediaListener = new PipManager.MediaListener() {
private final PipManager.MediaListener mPipMediaListener = new PipManager.MediaListener() {
@Override
public void onMediaControllerChanged() {
updateMediaController();
}
};
private final OnFocusChangeListener mFocusChangeListener = new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
onChildViewFocusChanged();
}
};
public PipControlsView(Context context) {
this(context, null, 0, 0);
}
@@ -108,26 +111,30 @@ public class PipControlsView extends LinearLayout {
public void onFinishInflate() {
super.onFinishInflate();
mFullButtonView = findViewById(R.id.full_button);
mFullDescriptionView = findViewById(R.id.full_desc);
mFullButtonView = (PipControlButtonView) findViewById(R.id.full_button);
mFullButtonView.setOnFocusChangeListener(mFocusChangeListener);
mFullButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPipManager.movePipToFullscreen();
}
});
mFullButtonView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
mCloseButtonView = (PipControlButtonView) findViewById(R.id.close_button);
mCloseButtonView.setOnFocusChangeListener(mFocusChangeListener);
mCloseButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
mFullDescriptionView.setVisibility(hasFocus ? View.VISIBLE : View.INVISIBLE);
onChildViewFocusChanged();
public void onClick(View v) {
mPipManager.closePip();
if (mListener != null) {
mListener.onClosed();
}
}
});
mPlayPauseView = findViewById(R.id.play_pause);
mPlayPauseButtonImageView = (ImageView) findViewById(R.id.play_pause_button);
mPlayPauseDescriptionTextView = (TextView) findViewById(R.id.play_pause_desc);
mPlayPauseButtonImageView.setOnClickListener(new View.OnClickListener() {
mPlayPauseButtonView = (PipControlButtonView) findViewById(R.id.play_pause_button);
mPlayPauseButtonView.setOnFocusChangeListener(mFocusChangeListener);
mPlayPauseButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mMediaController == null || mMediaController.getPlaybackState() == null) {
@@ -143,33 +150,6 @@ public class PipControlsView extends LinearLayout {
// View will be updated later in {@link mMediaControllerCallback}
}
});
mPlayPauseButtonImageView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
mPlayPauseDescriptionTextView.setVisibility(
hasFocus ? View.VISIBLE : View.INVISIBLE);
onChildViewFocusChanged();
}
});
mCloseButtonView = findViewById(R.id.close_button);
mCloseDescriptionView = findViewById(R.id.close_desc);
mCloseButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPipManager.closePip();
if (mListener != null) {
mListener.onClosed();
}
}
});
mCloseButtonView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
mCloseDescriptionView.setVisibility(hasFocus ? View.VISIBLE : View.INVISIBLE);
onChildViewFocusChanged();
}
});
}
@Override
@@ -206,15 +186,15 @@ public class PipControlsView extends LinearLayout {
private void updatePlayPauseView() {
int state = mPipManager.getPlaybackState();
if (state == PLAYBACK_STATE_UNAVAILABLE) {
mPlayPauseView.setVisibility(View.GONE);
mPlayPauseButtonView.setVisibility(View.GONE);
} else {
mPlayPauseView.setVisibility(View.VISIBLE);
mPlayPauseButtonView.setVisibility(View.VISIBLE);
if (state == PLAYBACK_STATE_PLAYING) {
mPlayPauseButtonImageView.setImageResource(R.drawable.tv_pip_pause_button);
mPlayPauseDescriptionTextView.setText(R.string.pip_pause);
mPlayPauseButtonView.setImageResource(R.drawable.ic_pause_white_24dp);
mPlayPauseButtonView.setText(R.string.pip_pause);
} else {
mPlayPauseButtonImageView.setImageResource(R.drawable.tv_pip_play_button);
mPlayPauseDescriptionTextView.setText(R.string.pip_play);
mPlayPauseButtonView.setImageResource(R.drawable.ic_play_arrow_white_24dp);
mPlayPauseButtonView.setText(R.string.pip_play);
}
}
}
@@ -229,7 +209,7 @@ public class PipControlsView extends LinearLayout {
private void onChildViewFocusChanged() {
// At this moment, hasFocus() returns true although there's no focused child.
boolean hasFocus = (mFullButtonView != null && mFullButtonView.isFocused())
|| (mPlayPauseButtonImageView != null && mPlayPauseButtonImageView.isFocused())
|| (mPlayPauseButtonView != null && mPlayPauseButtonView.isFocused())
|| (mCloseButtonView != null && mCloseButtonView.isFocused());
if (mHasFocus != hasFocus) {
mHasFocus = hasFocus;

View File

@@ -16,10 +16,14 @@
package com.android.systemui.tv.pip;
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import com.android.systemui.R;
import com.android.systemui.Interpolators;
/**
* Activity to show the PIP menu to control PIP.
@@ -29,7 +33,9 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
private final PipManager mPipManager = PipManager.getInstance();
private PipControlsView mPipControlsView;
private Animator mFadeInAnimation;
private Animator mFadeOutAnimation;
private View mPipControlsView;
private boolean mRestorePipSizeWhenClose;
@Override
@@ -38,8 +44,14 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
setContentView(R.layout.tv_pip_menu);
mPipManager.addListener(this);
mPipControlsView = (PipControlsView) findViewById(R.id.pip_controls);
mRestorePipSizeWhenClose = true;
mPipControlsView = (PipControlsView) findViewById(R.id.pip_controls);
mFadeInAnimation = AnimatorInflater.loadAnimator(
this, R.anim.tv_pip_menu_fade_in_animation);
mFadeInAnimation.setTarget(mPipControlsView);
mFadeOutAnimation = AnimatorInflater.loadAnimator(
this, R.anim.tv_pip_menu_fade_out_animation);
mFadeOutAnimation.setTarget(mPipControlsView);
}
private void restorePipAndFinish() {
@@ -50,9 +62,16 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
finish();
}
@Override
public void onResume() {
super.onResume();
mFadeInAnimation.start();
}
@Override
public void onPause() {
super.onPause();
mFadeOutAnimation.start();
restorePipAndFinish();
}

View File

@@ -72,28 +72,20 @@ public class PipRecentsControlsView extends PipControlsView {
super.onFinishInflate();
int buttonsFocusGainAnim = R.anim.tv_pip_controls_buttons_in_recents_focus_gain_animation;
int textFocusGainAnim = R.anim.tv_pip_controls_text_in_recents_focus_gain_animation;
mFocusGainAnimatorSet = new AnimatorSet();
mFocusGainAnimatorSet.playTogether(
loadAnimator(this, R.anim.tv_pip_controls_in_recents_focus_gain_animation),
loadAnimator(mFullButtonView,buttonsFocusGainAnim),
loadAnimator(mPlayPauseButtonImageView, buttonsFocusGainAnim),
loadAnimator(mCloseButtonView, buttonsFocusGainAnim),
loadAnimator(mFullDescriptionView, textFocusGainAnim),
loadAnimator(mPlayPauseDescriptionTextView, textFocusGainAnim),
loadAnimator(mCloseDescriptionView, textFocusGainAnim));
loadAnimator(mPlayPauseButtonView, buttonsFocusGainAnim),
loadAnimator(mCloseButtonView, buttonsFocusGainAnim));
int buttonsFocusLoseAnim = R.anim.tv_pip_controls_buttons_in_recents_focus_lose_animation;
int textFocusLoseAnim = R.anim.tv_pip_controls_text_in_recents_focus_lose_animation;
mFocusLoseAnimatorSet = new AnimatorSet();
mFocusLoseAnimatorSet.playTogether(
loadAnimator(this, R.anim.tv_pip_controls_in_recents_focus_lose_animation),
loadAnimator(mFullButtonView, buttonsFocusLoseAnim),
loadAnimator(mPlayPauseButtonImageView, buttonsFocusLoseAnim),
loadAnimator(mCloseButtonView, buttonsFocusLoseAnim),
loadAnimator(mFullDescriptionView, textFocusLoseAnim),
loadAnimator(mPlayPauseDescriptionTextView, textFocusLoseAnim),
loadAnimator(mCloseDescriptionView, textFocusLoseAnim));
loadAnimator(mPlayPauseButtonView, buttonsFocusLoseAnim),
loadAnimator(mCloseButtonView, buttonsFocusLoseAnim));
Rect pipBounds = mPipManager.getRecentsFocusedPipBounds();
int pipControlsMarginTop = getContext().getResources().getDimensionPixelSize(
@@ -142,11 +134,8 @@ public class PipRecentsControlsView extends PipControlsView {
requestFocus();
setTranslationY(0);
setScaleXY(mFullButtonView, 1);
setScaleXY(mPlayPauseButtonImageView, 1);
setScaleXY(mPlayPauseButtonView, 1);
setScaleXY(mCloseButtonView, 1);
mFullDescriptionView.setAlpha(1);
mPlayPauseDescriptionTextView.setAlpha(1);
mCloseDescriptionView.setAlpha(1);
}
private void setScaleXY(View view, float scale) {

View File

@@ -16,8 +16,6 @@
package com.android.systemui.tv.pip;
import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.content.Context;
import android.graphics.PixelFormat;
import android.util.Log;