Merge "PIP: Implement focus change animation in PIP control buttons" into nyc-dev
am: 6309cab
* commit '6309cabcda6a6a3e2e397808f34ec6cc91b535aa':
PIP: Implement focus change animation in PIP control buttons
Change-Id: I0d5121aae90d5d39b4a2930a05419ac5806e0718
This commit is contained in:
@@ -18,4 +18,4 @@
|
|||||||
android:propertyName="alpha"
|
android:propertyName="alpha"
|
||||||
android:valueTo="1"
|
android:valueTo="1"
|
||||||
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" />
|
||||||
@@ -18,4 +18,4 @@
|
|||||||
android:propertyName="alpha"
|
android:propertyName="alpha"
|
||||||
android:valueTo="0"
|
android:valueTo="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" />
|
||||||
21
packages/SystemUI/res/anim/tv_pip_menu_fade_in_animation.xml
Normal file
21
packages/SystemUI/res/anim/tv_pip_menu_fade_in_animation.xml
Normal 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" />
|
||||||
@@ -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" />
|
||||||
@@ -14,11 +14,5 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:shape="oval">
|
android:color="#9AFFFFFF" android:radius="17dp" />
|
||||||
<size
|
|
||||||
android:width="34dp"
|
|
||||||
android:height="34dp" />
|
|
||||||
<solid
|
|
||||||
android:color="#4DFFFFFF" />
|
|
||||||
</shape>
|
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -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>
|
|
||||||
@@ -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>
|
|
||||||
@@ -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>
|
|
||||||
42
packages/SystemUI/res/layout/tv_pip_control_button.xml
Normal file
42
packages/SystemUI/res/layout/tv_pip_control_button.xml
Normal 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>
|
||||||
@@ -20,77 +20,26 @@
|
|||||||
<!-- Layout for {@link com.android.systemui.tv.pip.PipControlsView}. -->
|
<!-- Layout for {@link com.android.systemui.tv.pip.PipControlsView}. -->
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
<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_width="100dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:src="@drawable/ic_fullscreen_white_24dp"
|
||||||
android:gravity="center">
|
android:text="@string/pip_fullscreen" />
|
||||||
|
|
||||||
<ImageView android:id="@+id/full_button"
|
<com.android.systemui.tv.pip.PipControlsButtonView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/close_button"
|
||||||
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
|
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="-50dp"
|
android:layout_marginStart="-50dp"
|
||||||
android:orientation="vertical"
|
android:src="@drawable/ic_close_white"
|
||||||
android:gravity="center">
|
android:text="@string/pip_close" />
|
||||||
|
|
||||||
<ImageView android:id="@+id/close_button"
|
<com.android.systemui.tv.pip.PipControlsButtonView
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/play_pause_button"
|
||||||
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"
|
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="-50dp"
|
android:layout_marginStart="-50dp"
|
||||||
android:orientation="vertical"
|
android:src="@drawable/ic_pause_white_24dp"
|
||||||
android:gravity="center" >
|
android:text="@string/pip_pause" />
|
||||||
|
|
||||||
<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>
|
|
||||||
</merge>
|
</merge>
|
||||||
|
|||||||
@@ -29,5 +29,6 @@
|
|||||||
<com.android.systemui.tv.pip.PipControlsView
|
<com.android.systemui.tv.pip.PipControlsView
|
||||||
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:alpha="0" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -54,8 +54,6 @@
|
|||||||
|
|
||||||
<!-- 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>
|
||||||
<!-- 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 -->
|
<!-- Values for entering Recents and exiting Recents -->
|
||||||
<dimen name="recents_tv_home_recents_shift">125dip</dimen>
|
<dimen name="recents_tv_home_recents_shift">125dip</dimen>
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -57,13 +57,9 @@ public class PipControlsView extends LinearLayout {
|
|||||||
final PipManager mPipManager = PipManager.getInstance();
|
final PipManager mPipManager = PipManager.getInstance();
|
||||||
Listener mListener;
|
Listener mListener;
|
||||||
|
|
||||||
View mFullButtonView;
|
PipControlButtonView mFullButtonView;
|
||||||
View mFullDescriptionView;
|
PipControlButtonView mCloseButtonView;
|
||||||
View mPlayPauseView;
|
PipControlButtonView mPlayPauseButtonView;
|
||||||
ImageView mPlayPauseButtonImageView;
|
|
||||||
TextView mPlayPauseDescriptionTextView;
|
|
||||||
View mCloseButtonView;
|
|
||||||
View mCloseDescriptionView;
|
|
||||||
|
|
||||||
private boolean mHasFocus;
|
private boolean mHasFocus;
|
||||||
private OnFocusChangeListener mOnChildFocusChangeListener;
|
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
|
@Override
|
||||||
public void onMediaControllerChanged() {
|
public void onMediaControllerChanged() {
|
||||||
updateMediaController();
|
updateMediaController();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final OnFocusChangeListener mFocusChangeListener = new OnFocusChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
|
onChildViewFocusChanged();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public PipControlsView(Context context) {
|
public PipControlsView(Context context) {
|
||||||
this(context, null, 0, 0);
|
this(context, null, 0, 0);
|
||||||
}
|
}
|
||||||
@@ -108,26 +111,30 @@ public class PipControlsView extends LinearLayout {
|
|||||||
public void onFinishInflate() {
|
public void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
|
||||||
mFullButtonView = findViewById(R.id.full_button);
|
mFullButtonView = (PipControlButtonView) findViewById(R.id.full_button);
|
||||||
mFullDescriptionView = findViewById(R.id.full_desc);
|
mFullButtonView.setOnFocusChangeListener(mFocusChangeListener);
|
||||||
mFullButtonView.setOnClickListener(new View.OnClickListener() {
|
mFullButtonView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
mPipManager.movePipToFullscreen();
|
mPipManager.movePipToFullscreen();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mFullButtonView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
|
||||||
|
mCloseButtonView = (PipControlButtonView) findViewById(R.id.close_button);
|
||||||
|
mCloseButtonView.setOnFocusChangeListener(mFocusChangeListener);
|
||||||
|
mCloseButtonView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onClick(View v) {
|
||||||
mFullDescriptionView.setVisibility(hasFocus ? View.VISIBLE : View.INVISIBLE);
|
mPipManager.closePip();
|
||||||
onChildViewFocusChanged();
|
if (mListener != null) {
|
||||||
|
mListener.onClosed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mPlayPauseView = findViewById(R.id.play_pause);
|
mPlayPauseButtonView = (PipControlButtonView) findViewById(R.id.play_pause_button);
|
||||||
mPlayPauseButtonImageView = (ImageView) findViewById(R.id.play_pause_button);
|
mPlayPauseButtonView.setOnFocusChangeListener(mFocusChangeListener);
|
||||||
mPlayPauseDescriptionTextView = (TextView) findViewById(R.id.play_pause_desc);
|
mPlayPauseButtonView.setOnClickListener(new View.OnClickListener() {
|
||||||
mPlayPauseButtonImageView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (mMediaController == null || mMediaController.getPlaybackState() == null) {
|
if (mMediaController == null || mMediaController.getPlaybackState() == null) {
|
||||||
@@ -143,33 +150,6 @@ public class PipControlsView extends LinearLayout {
|
|||||||
// View will be updated later in {@link mMediaControllerCallback}
|
// 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
|
@Override
|
||||||
@@ -206,15 +186,15 @@ public class PipControlsView extends LinearLayout {
|
|||||||
private void updatePlayPauseView() {
|
private void updatePlayPauseView() {
|
||||||
int state = mPipManager.getPlaybackState();
|
int state = mPipManager.getPlaybackState();
|
||||||
if (state == PLAYBACK_STATE_UNAVAILABLE) {
|
if (state == PLAYBACK_STATE_UNAVAILABLE) {
|
||||||
mPlayPauseView.setVisibility(View.GONE);
|
mPlayPauseButtonView.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
mPlayPauseView.setVisibility(View.VISIBLE);
|
mPlayPauseButtonView.setVisibility(View.VISIBLE);
|
||||||
if (state == PLAYBACK_STATE_PLAYING) {
|
if (state == PLAYBACK_STATE_PLAYING) {
|
||||||
mPlayPauseButtonImageView.setImageResource(R.drawable.tv_pip_pause_button);
|
mPlayPauseButtonView.setImageResource(R.drawable.ic_pause_white_24dp);
|
||||||
mPlayPauseDescriptionTextView.setText(R.string.pip_pause);
|
mPlayPauseButtonView.setText(R.string.pip_pause);
|
||||||
} else {
|
} else {
|
||||||
mPlayPauseButtonImageView.setImageResource(R.drawable.tv_pip_play_button);
|
mPlayPauseButtonView.setImageResource(R.drawable.ic_play_arrow_white_24dp);
|
||||||
mPlayPauseDescriptionTextView.setText(R.string.pip_play);
|
mPlayPauseButtonView.setText(R.string.pip_play);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,7 +209,7 @@ public class PipControlsView extends LinearLayout {
|
|||||||
private void onChildViewFocusChanged() {
|
private void onChildViewFocusChanged() {
|
||||||
// At this moment, hasFocus() returns true although there's no focused child.
|
// At this moment, hasFocus() returns true although there's no focused child.
|
||||||
boolean hasFocus = (mFullButtonView != null && mFullButtonView.isFocused())
|
boolean hasFocus = (mFullButtonView != null && mFullButtonView.isFocused())
|
||||||
|| (mPlayPauseButtonImageView != null && mPlayPauseButtonImageView.isFocused())
|
|| (mPlayPauseButtonView != null && mPlayPauseButtonView.isFocused())
|
||||||
|| (mCloseButtonView != null && mCloseButtonView.isFocused());
|
|| (mCloseButtonView != null && mCloseButtonView.isFocused());
|
||||||
if (mHasFocus != hasFocus) {
|
if (mHasFocus != hasFocus) {
|
||||||
mHasFocus = hasFocus;
|
mHasFocus = hasFocus;
|
||||||
|
|||||||
@@ -16,10 +16,14 @@
|
|||||||
|
|
||||||
package com.android.systemui.tv.pip;
|
package com.android.systemui.tv.pip;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorInflater;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.Interpolators;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity to show the PIP menu to control PIP.
|
* 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 final PipManager mPipManager = PipManager.getInstance();
|
||||||
|
|
||||||
private PipControlsView mPipControlsView;
|
private Animator mFadeInAnimation;
|
||||||
|
private Animator mFadeOutAnimation;
|
||||||
|
private View mPipControlsView;
|
||||||
private boolean mRestorePipSizeWhenClose;
|
private boolean mRestorePipSizeWhenClose;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,8 +44,14 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
setContentView(R.layout.tv_pip_menu);
|
setContentView(R.layout.tv_pip_menu);
|
||||||
mPipManager.addListener(this);
|
mPipManager.addListener(this);
|
||||||
|
|
||||||
mPipControlsView = (PipControlsView) findViewById(R.id.pip_controls);
|
|
||||||
mRestorePipSizeWhenClose = true;
|
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() {
|
private void restorePipAndFinish() {
|
||||||
@@ -50,9 +62,16 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
mFadeInAnimation.start();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
mFadeOutAnimation.start();
|
||||||
restorePipAndFinish();
|
restorePipAndFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,28 +72,20 @@ public class PipRecentsControlsView extends PipControlsView {
|
|||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
|
||||||
int buttonsFocusGainAnim = R.anim.tv_pip_controls_buttons_in_recents_focus_gain_animation;
|
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 = new AnimatorSet();
|
||||||
mFocusGainAnimatorSet.playTogether(
|
mFocusGainAnimatorSet.playTogether(
|
||||||
loadAnimator(this, R.anim.tv_pip_controls_in_recents_focus_gain_animation),
|
loadAnimator(this, R.anim.tv_pip_controls_in_recents_focus_gain_animation),
|
||||||
loadAnimator(mFullButtonView,buttonsFocusGainAnim),
|
loadAnimator(mFullButtonView,buttonsFocusGainAnim),
|
||||||
loadAnimator(mPlayPauseButtonImageView, buttonsFocusGainAnim),
|
loadAnimator(mPlayPauseButtonView, buttonsFocusGainAnim),
|
||||||
loadAnimator(mCloseButtonView, buttonsFocusGainAnim),
|
loadAnimator(mCloseButtonView, buttonsFocusGainAnim));
|
||||||
loadAnimator(mFullDescriptionView, textFocusGainAnim),
|
|
||||||
loadAnimator(mPlayPauseDescriptionTextView, textFocusGainAnim),
|
|
||||||
loadAnimator(mCloseDescriptionView, textFocusGainAnim));
|
|
||||||
|
|
||||||
int buttonsFocusLoseAnim = R.anim.tv_pip_controls_buttons_in_recents_focus_lose_animation;
|
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 = new AnimatorSet();
|
||||||
mFocusLoseAnimatorSet.playTogether(
|
mFocusLoseAnimatorSet.playTogether(
|
||||||
loadAnimator(this, R.anim.tv_pip_controls_in_recents_focus_lose_animation),
|
loadAnimator(this, R.anim.tv_pip_controls_in_recents_focus_lose_animation),
|
||||||
loadAnimator(mFullButtonView, buttonsFocusLoseAnim),
|
loadAnimator(mFullButtonView, buttonsFocusLoseAnim),
|
||||||
loadAnimator(mPlayPauseButtonImageView, buttonsFocusLoseAnim),
|
loadAnimator(mPlayPauseButtonView, buttonsFocusLoseAnim),
|
||||||
loadAnimator(mCloseButtonView, buttonsFocusLoseAnim),
|
loadAnimator(mCloseButtonView, buttonsFocusLoseAnim));
|
||||||
loadAnimator(mFullDescriptionView, textFocusLoseAnim),
|
|
||||||
loadAnimator(mPlayPauseDescriptionTextView, textFocusLoseAnim),
|
|
||||||
loadAnimator(mCloseDescriptionView, textFocusLoseAnim));
|
|
||||||
|
|
||||||
Rect pipBounds = mPipManager.getRecentsFocusedPipBounds();
|
Rect pipBounds = mPipManager.getRecentsFocusedPipBounds();
|
||||||
int pipControlsMarginTop = getContext().getResources().getDimensionPixelSize(
|
int pipControlsMarginTop = getContext().getResources().getDimensionPixelSize(
|
||||||
@@ -142,11 +134,8 @@ public class PipRecentsControlsView extends PipControlsView {
|
|||||||
requestFocus();
|
requestFocus();
|
||||||
setTranslationY(0);
|
setTranslationY(0);
|
||||||
setScaleXY(mFullButtonView, 1);
|
setScaleXY(mFullButtonView, 1);
|
||||||
setScaleXY(mPlayPauseButtonImageView, 1);
|
setScaleXY(mPlayPauseButtonView, 1);
|
||||||
setScaleXY(mCloseButtonView, 1);
|
setScaleXY(mCloseButtonView, 1);
|
||||||
mFullDescriptionView.setAlpha(1);
|
|
||||||
mPlayPauseDescriptionTextView.setAlpha(1);
|
|
||||||
mCloseDescriptionView.setAlpha(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setScaleXY(View view, float scale) {
|
private void setScaleXY(View view, float scale) {
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.systemui.tv.pip;
|
package com.android.systemui.tv.pip;
|
||||||
|
|
||||||
import android.animation.AnimatorInflater;
|
|
||||||
import android.animation.AnimatorSet;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|||||||
Reference in New Issue
Block a user