Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f757eec authored by Jacqueline Bronger's avatar Jacqueline Bronger
Browse files

Improve TV PiP menu buttons

- Save focused button when moving and changing orientation (e.g. during
  expanded mode being toggled)
- Focus the first button when the menu is opened
- Makes sure all buttons are visibly reachable by setting the right
  gravity based on orientation and whether all the buttons fit
- Scrolls to the focused button if it happens to go out of bounds during
  any change
- Fade buttons out and in during orientation change
- Scale buttons to 1.1x when selected
- Fix move button description (typo in resource reference)

Bug: 220109276
Bug: 219887361
Test: manual

Change-Id: Ibe1b2ee3e505bd218c49f6cd0cbcbf7956452b26
parent bb2980a0
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2022 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">

    <item android:state_focused="true">
        <set>
            <objectAnimator
                android:duration="200"
                android:propertyName="scaleX"
                android:valueFrom="1.0"
                android:valueTo="1.1"
                android:valueType="floatType"/>
            <objectAnimator
                android:duration="200"
                android:propertyName="scaleY"
                android:valueFrom="1.0"
                android:valueTo="1.1"
                android:valueType="floatType"/>
        </set>
    </item>
    <item android:state_focused="false">
        <set>
            <objectAnimator
                android:duration="200"
                android:propertyName="scaleX"
                android:valueFrom="1.1"
                android:valueTo="1.0"
                android:valueType="floatType"/>
            <objectAnimator
                android:duration="200"
                android:propertyName="scaleY"
                android:valueFrom="1.1"
                android:valueTo="1.0"
                android:valueType="floatType"/>
        </set>
    </item>
</selector>
 No newline at end of file
+2 −6
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
        android:id="@+id/tv_pip_menu_scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_horizontal"
        android:layout_alignTop="@+id/tv_pip"
        android:layout_alignStart="@+id/tv_pip"
        android:layout_alignEnd="@+id/tv_pip"
@@ -49,15 +48,12 @@
        android:layout_alignStart="@+id/tv_pip"
        android:layout_alignEnd="@+id/tv_pip"
        android:layout_alignBottom="@+id/tv_pip"
        android:gravity="center_vertical"
        android:scrollbars="none">

        <LinearLayout
            android:id="@+id/tv_pip_menu_action_buttons"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="center"
            android:layout_gravity="center"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:alpha="0">

@@ -77,7 +73,7 @@
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/pip_ic_move_white"
                android:text="@String/pip_move" />
                android:text="@string/pip_move" />

            <com.android.wm.shell.pip.tv.TvPipMenuActionButton
                android:id="@+id/tv_pip_menu_expand_button"
+9 −2
Original line number Diff line number Diff line
@@ -20,10 +20,17 @@
        android:id="@+id/button"
        android:layout_width="@dimen/pip_menu_button_size"
        android:layout_height="@dimen/pip_menu_button_size"
        android:layout_margin="@dimen/pip_menu_button_margin"
        android:background="@drawable/tv_pip_button_bg"
        android:padding="@dimen/pip_menu_button_margin"
        android:stateListAnimator="@animator/tv_pip_menu_action_button_animator"
        android:focusable="true">

        <View android:id="@+id/background"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_gravity="center"
              android:duplicateParentState="true"
              android:background="@drawable/tv_pip_button_bg"/>

        <ImageView android:id="@+id/icon"
                   android:layout_width="@dimen/pip_menu_icon_size"
                   android:layout_height="@dimen/pip_menu_icon_size"
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
-->
<resources>
    <!-- The dimensions to user for picture-in-picture action buttons. -->
    <dimen name="pip_menu_button_size">40dp</dimen>
    <dimen name="pip_menu_button_size">48dp</dimen>
    <dimen name="pip_menu_button_radius">20dp</dimen>
    <dimen name="pip_menu_icon_size">20dp</dimen>
    <dimen name="pip_menu_button_margin">4dp</dimen>
+2 −0
Original line number Diff line number Diff line
@@ -384,6 +384,7 @@ public class TvPipController implements PipTransitionController.PipTransitionCal
                animationDuration, rect -> {
                    mTvPipMenuController.updateExpansionState();
                });
        mTvPipMenuController.onPipTransitionStarted(bounds);
    }

    /**
@@ -573,6 +574,7 @@ public class TvPipController implements PipTransitionController.PipTransitionCal
                            "%s: onExpandedAspectRatioChanged: %f", TAG, ratio);

                mTvPipBoundsState.setDesiredTvExpandedAspectRatio(ratio, false);
                mTvPipMenuController.updateExpansionState();

                // 1) PiP is expanded and only aspect ratio changed, but wasn't disabled
                // --> update bounds, but don't toggle
Loading