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

Commit 2cb16bf4 authored by Massimo Carli's avatar Massimo Carli
Browse files

[2/n] Adds reachability education for double-tap

Double-tap education which explains to the
users how double-tap works for repositioning an app in
letterbox or size compat mode.

The education appears the very first time an app is launched
by a user and every time the user double-tap to reposition
the app.

Fixes: 255943773
Test: atest WMShellUnitTests:ReachabilityEduLayoutTest
      atest WMShellUnitTests:LetterboxEduWindowManagerTest
      atest WMShellUnitTests:ReachabilityEduWindowManagerTest

Change-Id: I583a2ca8e552885b3578eaa4e344d89a67143b57
parent 279819f0
Loading
Loading
Loading
Loading
+70 −1
Original line number Original line Diff line number Diff line
@@ -48,6 +48,12 @@ import java.util.Objects;
public class TaskInfo {
public class TaskInfo {
    private static final String TAG = "TaskInfo";
    private static final String TAG = "TaskInfo";


    /**
     * The value to use when the property has not a specific value.
     * @hide
     */
    public static final int PROPERTY_VALUE_UNSET = -1;

    /**
    /**
     * The id of the user the task was running as if this is a leaf task. The id of the current
     * The id of the user the task was running as if this is a leaf task. The id of the current
     * running user of the system otherwise.
     * running user of the system otherwise.
@@ -229,6 +235,40 @@ public class TaskInfo {
     */
     */
    public boolean topActivityEligibleForLetterboxEducation;
    public boolean topActivityEligibleForLetterboxEducation;


    /**
     * Whether the double tap is enabled
     * @hide
     */
    public boolean isLetterboxDoubleTapEnabled;

    /**
     * If {@link isLetterboxDoubleTapEnabled} it contains the current letterbox vertical position or
     * {@link TaskInfo.PROPERTY_VALUE_UNSET} otherwise.
     * @hide
     */
    public int topActivityLetterboxVerticalPosition;

    /**
     * If {@link isLetterboxDoubleTapEnabled} it contains the current letterbox vertical position or
     * {@link TaskInfo.PROPERTY_VALUE_UNSET} otherwise.
     * @hide
     */
    public int topActivityLetterboxHorizontalPosition;

    /**
     * If {@link isLetterboxDoubleTapEnabled} it contains the current width of the letterboxed
     * activity or {@link TaskInfo.PROPERTY_VALUE_UNSET} otherwise
     * @hide
     */
    public int topActivityLetterboxWidth;

    /**
     * If {@link isLetterboxDoubleTapEnabled} it contains the current height of the letterboxed
     * activity or {@link TaskInfo.PROPERTY_VALUE_UNSET} otherwise
     * @hide
     */
    public int topActivityLetterboxHeight;

    /**
    /**
     * Whether this task is resizable. Unlike {@link #resizeMode} (which is what the top activity
     * Whether this task is resizable. Unlike {@link #resizeMode} (which is what the top activity
     * supports), this is what the system actually uses for resizability based on other policy and
     * supports), this is what the system actually uses for resizability based on other policy and
@@ -407,7 +447,8 @@ public class TaskInfo {
    /** @hide */
    /** @hide */
    public boolean hasCompatUI() {
    public boolean hasCompatUI() {
        return hasCameraCompatControl() || topActivityInSizeCompat
        return hasCameraCompatControl() || topActivityInSizeCompat
                || topActivityEligibleForLetterboxEducation;
                || topActivityEligibleForLetterboxEducation
                || isLetterboxDoubleTapEnabled;
    }
    }


    /**
    /**
@@ -447,6 +488,12 @@ public class TaskInfo {
                && isResizeable == that.isResizeable
                && isResizeable == that.isResizeable
                && supportsMultiWindow == that.supportsMultiWindow
                && supportsMultiWindow == that.supportsMultiWindow
                && displayAreaFeatureId == that.displayAreaFeatureId
                && displayAreaFeatureId == that.displayAreaFeatureId
                && isLetterboxDoubleTapEnabled == that.isLetterboxDoubleTapEnabled
                && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
                && topActivityLetterboxWidth == that.topActivityLetterboxWidth
                && topActivityLetterboxHeight == that.topActivityLetterboxHeight
                && topActivityLetterboxHorizontalPosition
                    == that.topActivityLetterboxHorizontalPosition
                && Objects.equals(positionInParent, that.positionInParent)
                && Objects.equals(positionInParent, that.positionInParent)
                && Objects.equals(pictureInPictureParams, that.pictureInPictureParams)
                && Objects.equals(pictureInPictureParams, that.pictureInPictureParams)
                && Objects.equals(shouldDockBigOverlays, that.shouldDockBigOverlays)
                && Objects.equals(shouldDockBigOverlays, that.shouldDockBigOverlays)
@@ -475,6 +522,12 @@ public class TaskInfo {
                && topActivityInSizeCompat == that.topActivityInSizeCompat
                && topActivityInSizeCompat == that.topActivityInSizeCompat
                && topActivityEligibleForLetterboxEducation
                && topActivityEligibleForLetterboxEducation
                    == that.topActivityEligibleForLetterboxEducation
                    == that.topActivityEligibleForLetterboxEducation
                && isLetterboxDoubleTapEnabled == that.isLetterboxDoubleTapEnabled
                && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
                && topActivityLetterboxHorizontalPosition
                    == that.topActivityLetterboxHorizontalPosition
                && topActivityLetterboxWidth == that.topActivityLetterboxWidth
                && topActivityLetterboxHeight == that.topActivityLetterboxHeight
                && cameraCompatControlState == that.cameraCompatControlState
                && cameraCompatControlState == that.cameraCompatControlState
                // Bounds are important if top activity has compat controls.
                // Bounds are important if top activity has compat controls.
                && (!hasCompatUI() || configuration.windowConfiguration.getBounds()
                && (!hasCompatUI() || configuration.windowConfiguration.getBounds()
@@ -529,6 +582,11 @@ public class TaskInfo {
        mTopActivityLocusId = source.readTypedObject(LocusId.CREATOR);
        mTopActivityLocusId = source.readTypedObject(LocusId.CREATOR);
        displayAreaFeatureId = source.readInt();
        displayAreaFeatureId = source.readInt();
        cameraCompatControlState = source.readInt();
        cameraCompatControlState = source.readInt();
        isLetterboxDoubleTapEnabled = source.readBoolean();
        topActivityLetterboxVerticalPosition = source.readInt();
        topActivityLetterboxHorizontalPosition = source.readInt();
        topActivityLetterboxWidth = source.readInt();
        topActivityLetterboxHeight = source.readInt();
    }
    }


    /**
    /**
@@ -576,6 +634,11 @@ public class TaskInfo {
        dest.writeTypedObject(mTopActivityLocusId, flags);
        dest.writeTypedObject(mTopActivityLocusId, flags);
        dest.writeInt(displayAreaFeatureId);
        dest.writeInt(displayAreaFeatureId);
        dest.writeInt(cameraCompatControlState);
        dest.writeInt(cameraCompatControlState);
        dest.writeBoolean(isLetterboxDoubleTapEnabled);
        dest.writeInt(topActivityLetterboxVerticalPosition);
        dest.writeInt(topActivityLetterboxHorizontalPosition);
        dest.writeInt(topActivityLetterboxWidth);
        dest.writeInt(topActivityLetterboxHeight);
    }
    }


    @Override
    @Override
@@ -611,6 +674,12 @@ public class TaskInfo {
                + " topActivityInSizeCompat=" + topActivityInSizeCompat
                + " topActivityInSizeCompat=" + topActivityInSizeCompat
                + " topActivityEligibleForLetterboxEducation= "
                + " topActivityEligibleForLetterboxEducation= "
                        + topActivityEligibleForLetterboxEducation
                        + topActivityEligibleForLetterboxEducation
                + " topActivityLetterboxed= " + isLetterboxDoubleTapEnabled
                + " topActivityLetterboxVerticalPosition= " + topActivityLetterboxVerticalPosition
                + " topActivityLetterboxHorizontalPosition= "
                        + topActivityLetterboxHorizontalPosition
                + " topActivityLetterboxWidth=" + topActivityLetterboxWidth
                + " topActivityLetterboxHeight=" + topActivityLetterboxHeight
                + " locusId=" + mTopActivityLocusId
                + " locusId=" + mTopActivityLocusId
                + " displayAreaFeatureId=" + displayAreaFeatureId
                + " displayAreaFeatureId=" + displayAreaFeatureId
                + " cameraCompatControlState="
                + " cameraCompatControlState="
+699 −0

File added.

Preview size limit exceeded, changes collapsed.

+699 −0

File added.

Preview size limit exceeded, changes collapsed.

+70 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2023 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.
  -->
<com.android.wm.shell.compatui.ReachabilityEduLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.android.wm.shell.compatui.ReachabilityEduHandLayout
        style="@style/ReachabilityEduHandLayout"
        android:text="@string/letterbox_reachability_reposition_text"
        app:drawableTopCompat="@drawable/reachability_education_ic_right_hand"
        android:layout_gravity="center_horizontal|top"
        android:layout_marginTop="@dimen/letterbox_reachability_education_dialog_margin"
        android:id="@+id/reachability_move_up_button"
        android:maxWidth="@dimen/letterbox_reachability_education_item_width"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <com.android.wm.shell.compatui.ReachabilityEduHandLayout
        style="@style/ReachabilityEduHandLayout"
        android:text="@string/letterbox_reachability_reposition_text"
        app:drawableTopCompat="@drawable/reachability_education_ic_right_hand"
        android:layout_gravity="center_vertical|right"
        android:layout_marginTop="@dimen/letterbox_reachability_education_dialog_margin"
        android:id="@+id/reachability_move_right_button"
        android:maxWidth="@dimen/letterbox_reachability_education_item_width"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>


    <com.android.wm.shell.compatui.ReachabilityEduHandLayout
        style="@style/ReachabilityEduHandLayout"
        android:text="@string/letterbox_reachability_reposition_text"
        app:drawableTopCompat="@drawable/reachability_education_ic_left_hand"
        android:layout_gravity="center_vertical|left"
        android:layout_marginTop="@dimen/letterbox_reachability_education_dialog_margin"
        android:id="@+id/reachability_move_left_button"
        android:maxWidth="@dimen/letterbox_reachability_education_item_width"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <com.android.wm.shell.compatui.ReachabilityEduHandLayout
        style="@style/ReachabilityEduHandLayout"
        android:text="@string/letterbox_reachability_reposition_text"
        app:drawableTopCompat="@drawable/reachability_education_ic_right_hand"
        android:layout_gravity="center_horizontal|bottom"
        android:layout_marginTop="@dimen/letterbox_reachability_education_dialog_margin"
        android:id="@+id/reachability_move_down_button"
        android:maxWidth="@dimen/letterbox_reachability_education_item_width"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</com.android.wm.shell.compatui.ReachabilityEduLayout>
+1 −1
Original line number Original line Diff line number Diff line
<!--
<!--
  ~ Copyright (C) 2022 The Android Open Source Project
  ~ Copyright (C) 2023 The Android Open Source Project
  ~
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ you may not use this file except in compliance with the License.
Loading