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

Commit a5acf18d authored by Winson Chung's avatar Winson Chung
Browse files

Updating PIP to match UX



- Updating menu actions to match design, fixing issue where
  the actions background would still be visible if there were
  no actions
- Enabling tap-to-show-menu, minimizing, snap-to-edge by default,
  and removing swipe to dismiss option.
- Making the visible size a fixed value instead of a fraction of
  the PIP size

Test: android.server.cts.ActivityManagerPinnedStackTests
Change-Id: Ib767df497ca7bc901c553d35168080f3b737033a
Signed-off-by: default avatarWinson Chung <winsonc@google.com>
parent d02e1c30
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.hardware.display.DisplayManager;
import android.view.Gravity;
import android.view.ViewConfiguration;
import android.widget.Scroller;
@@ -44,9 +43,6 @@ public class PipSnapAlgorithm {
    // The friction multiplier to control how slippery the PIP is when flung
    private static final float SCROLL_FRICTION_MULTIPLIER = 8f;

    // The fraction of the stack width to show when minimized
    private static final float MINIMIZED_VISIBLE_FRACTION = 0.25f;

    private final Context mContext;

    private final ArrayList<Integer> mSnapGravities = new ArrayList<>();
@@ -56,8 +52,12 @@ public class PipSnapAlgorithm {
    private Scroller mScroller;
    private int mOrientation = Configuration.ORIENTATION_UNDEFINED;

    private final int mMinimizedVisibleSize;

    public PipSnapAlgorithm(Context context) {
        mContext = context;
        mMinimizedVisibleSize = context.getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.pip_minimized_visible_size);
        onConfigurationChanged();
    }

@@ -129,11 +129,10 @@ public class PipSnapAlgorithm {
     * Applies the offset to the {@param stackBounds} to adjust it to a minimized state.
     */
    public void applyMinimizedOffset(Rect stackBounds, Rect movementBounds, Point displaySize) {
        int visibleWidth = (int) (MINIMIZED_VISIBLE_FRACTION * stackBounds.width());
        if (stackBounds.left <= movementBounds.centerX()) {
            stackBounds.offsetTo(-stackBounds.width() + visibleWidth, stackBounds.top);
            stackBounds.offsetTo(-stackBounds.width() + mMinimizedVisibleSize, stackBounds.top);
        } else {
            stackBounds.offsetTo(displaySize.x - visibleWidth, stackBounds.top);
            stackBounds.offsetTo(displaySize.x - mMinimizedVisibleSize, stackBounds.top);
        }
    }

@@ -220,15 +219,23 @@ public class PipSnapAlgorithm {
     * the new bounds out to {@param boundsOut}.
     */
    private void snapRectToClosestEdge(Rect stackBounds, Rect movementBounds, Rect boundsOut) {
        final int fromLeft = Math.abs(stackBounds.left - movementBounds.left);
        final int fromTop = Math.abs(stackBounds.top - movementBounds.top);
        final int fromRight = Math.abs(movementBounds.right - stackBounds.left);
        final int fromBottom = Math.abs(movementBounds.bottom - stackBounds.top);
        // If the stackBounds are minimized, then it should only be snapped back horizontally
        final int boundedLeft = Math.max(movementBounds.left, Math.min(movementBounds.right,
                stackBounds.left));
        final int boundedTop = Math.max(movementBounds.top, Math.min(movementBounds.bottom,
                stackBounds.top));
        boundsOut.set(stackBounds);
        if (stackBounds.left < movementBounds.left ||
                stackBounds.left > movementBounds.right) {
            boundsOut.offsetTo(boundedLeft, boundsOut.top);
            return;
        }

        // Otherwise, just find the closest edge
        final int fromLeft = Math.abs(stackBounds.left - movementBounds.left);
        final int fromTop = Math.abs(stackBounds.top - movementBounds.top);
        final int fromRight = Math.abs(movementBounds.right - stackBounds.left);
        final int fromBottom = Math.abs(movementBounds.bottom - stackBounds.top);
        if (fromLeft <= fromTop && fromLeft <= fromRight && fromLeft <= fromBottom) {
            boundsOut.offsetTo(movementBounds.left, boundedTop);
        } else if (fromTop <= fromLeft && fromTop <= fromRight && fromTop <= fromBottom) {
+3 −0
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@
         when the user opens homescreen. -->
    <dimen name="docked_stack_minimize_thickness">8dp</dimen>

    <!-- The amount to leave on-screen when the PIP is minimized. -->
    <dimen name="pip_minimized_visible_size">48dp</dimen>

    <!-- Min width for a tablet device -->
    <dimen name="min_xlarge_screen_width">800dp</dimen>

+1 −0
Original line number Diff line number Diff line
@@ -1542,6 +1542,7 @@
  <java-symbol type="dimen" name="docked_stack_divider_thickness" />
  <java-symbol type="dimen" name="docked_stack_divider_insets" />
  <java-symbol type="dimen" name="docked_stack_minimize_thickness" />
  <java-symbol type="dimen" name="pip_minimized_visible_size" />
  <java-symbol type="integer" name="config_dockedStackDividerSnapMode" />
  <java-symbol type="fraction" name="docked_stack_divider_fixed_ratio" />
  <java-symbol type="fraction" name="thumbnail_fullscreen_scale" />
+5 −28
Original line number Diff line number Diff line
@@ -13,32 +13,9 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:background="?android:selectableItemBackground">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:orientation="vertical">
<ImageView
            android:id="@+id/icon"
            android:layout_width="@dimen/pip_menu_action_icon_size"
            android:layout_height="@dimen/pip_menu_action_icon_size"
            android:layout_gravity="center_horizontal"
            android:layout_marginBottom="4dp" />
        <TextView
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:includeFontPadding="false"
            android:gravity="center"
            android:textSize="12sp"
            android:textColor="#ffffffff"
            android:textAllCaps="true"
            android:fontFamily="sans-serif" />
    </LinearLayout>
</FrameLayout>
 No newline at end of file
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:padding="10dp"
    android:background="?android:selectableItemBackgroundBorderless" />
 No newline at end of file
+23 −32
Original line number Diff line number Diff line
@@ -13,47 +13,38 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/menu"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#66000000">
    android:background="#00000000">
    <!-- The above background is only for the dismiss button ripple to show. -->

    <LinearLayout
        android:id="@+id/actions"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="48dp">
    </LinearLayout>
    <ImageView
        android:id="@+id/dismiss"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_gravity="top|end"
        android:padding="10dp"
        android:contentDescription="@string/pip_phone_dismiss"
        android:src="@drawable/ic_close_white"
        android:background="?android:selectableItemBackgroundBorderless" />

    <LinearLayout
    <FrameLayout
        android:id="@+id/actions_container"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_gravity="bottom"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/dismiss"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:textSize="12sp"
            android:textColor="#ffffffff"
            android:fontFamily="sans-serif"
            android:text="@string/pip_phone_dismiss"
            android:background="?android:selectableItemBackground" />
        <TextView
            android:id="@+id/expand"
            android:layout_width="0dp"
        android:paddingStart="24dp"
        android:paddingEnd="24dp"
        android:background="#66000000"
        android:visibility="invisible">
        <LinearLayout
            android:id="@+id/actions"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:textSize="12sp"
            android:textColor="#ffffffff"
            android:fontFamily="sans-serif"
            android:text="@string/pip_phone_expand"
            android:background="?android:selectableItemBackground" />
    </LinearLayout>
            android:layout_gravity="center_horizontal"
            android:orientation="horizontal" />
    </FrameLayout>
</FrameLayout>
Loading