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

Commit da19c50e authored by Ben Lin's avatar Ben Lin
Browse files

Move App Handle back to using Drawable, scale it accordingly for animation.

This CL moves app handle back to being rendered via a drawable, and we will animate
it just directly scaling the drawable in x and y-axis to simulate the spec.

Bug: 314288540
Test: Manual. Open/Close handle menu.
Flag: com.android.window.flags.enable_drawing_app_handle
Change-Id: Id96e44c46c61f851c1da9b1ad247ad1213ed5cde
parent e97bb85a
Loading
Loading
Loading
Loading
+0 −31
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2025 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.windowdecor.HandleImageButton
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="@dimen/desktop_mode_fullscreen_decor_caption_width"
    android:layout_height="@dimen/desktop_mode_fullscreen_decor_caption_height"
    android:paddingVertical="16dp"
    android:paddingHorizontal="10dp"
    android:screenReaderFocusable="true"
    android:importantForAccessibility="yes"
    android:contentDescription="@string/handle_text"
    android:src="@drawable/decor_handle_dark"
    tools:tint="@color/desktop_mode_caption_handle_bar_dark"
    android:scaleType="fitXY"
    android:background="@android:color/transparent"/>
 No newline at end of file
+12 −15
Original line number Diff line number Diff line
@@ -21,20 +21,17 @@
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center">
    <FrameLayout
    <com.android.wm.shell.windowdecor.HandleImageButton
        android:id="@+id/caption_handle"
        android:layout_width="@dimen/desktop_mode_fullscreen_decor_caption_width"
        android:layout_height="@dimen/desktop_mode_fullscreen_decor_caption_height">

        <ViewStub android:id="@+id/captionStub"
            android:inflatedId="@+id/caption_handle"
            android:layout="@layout/app_handle_image_button"
            android:layout_width="@dimen/desktop_mode_fullscreen_decor_caption_width"
            android:layout_height="@dimen/desktop_mode_fullscreen_decor_caption_height" />

        <ViewStub android:id="@+id/caption2Stub"
            android:inflatedId="@+id/caption_handle2"
            android:layout="@layout/drawing_app_handle"
            android:layout_width="@dimen/desktop_mode_fullscreen_decor_caption_width"
            android:layout_height="@dimen/desktop_mode_fullscreen_decor_caption_height" />
    </FrameLayout>
        android:layout_height="@dimen/desktop_mode_fullscreen_decor_caption_height"
        android:paddingVertical="16dp"
        android:paddingHorizontal="10dp"
        android:screenReaderFocusable="true"
        android:importantForAccessibility="yes"
        android:contentDescription="@string/handle_text"
        android:src="@drawable/decor_handle_dark"
        tools:tint="@color/desktop_mode_caption_handle_bar_dark"
        android:scaleType="fitXY"
        android:background="@android:color/transparent"/>
</com.android.wm.shell.windowdecor.WindowDecorLinearLayout>
 No newline at end of file
+0 −27
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2025 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.windowdecor.common.DrawingHandle
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="@dimen/desktop_mode_fullscreen_decor_caption_width"
    android:layout_height="@dimen/desktop_mode_fullscreen_decor_caption_height"
    android:screenReaderFocusable="true"
    android:importantForAccessibility="yes"
    android:contentDescription="@string/handle_text"
    android:scaleType="fitXY"
    android:background="@android:color/transparent"/>
 No newline at end of file
+3 −6
Original line number Diff line number Diff line
@@ -182,7 +182,6 @@ public class DesktopModeTouchEventListener
        final int id = view.getId();
        if (id == R.id.back_button) return "back_button";
        if (id == R.id.caption_handle) return "caption_handle";
        if (id == R.id.caption_handle2) return "caption_handle2";
        if (id == R.id.close_window) return "close_window";
        if (id == R.id.desktop_mode_caption) return "desktop_mode_caption";
        if (id == R.id.maximize_window) return "maximize_window";
@@ -210,8 +209,7 @@ public class DesktopModeTouchEventListener
            mWindowDecorationActions.onClose(mTaskId);
        } else if (id == R.id.back_button) {
            mTaskOperations.injectBackKey(decoration.getTaskInfo().displayId);
        } else if (id == R.id.caption_handle || id == R.id.caption_handle2
                || id == R.id.open_menu_button) {
        } else if (id == R.id.caption_handle || id == R.id.open_menu_button) {
            if (id == R.id.caption_handle && !decoration.getTaskInfo().isFreeform()) {
                // Clicking the App Handle.
                mDesktopModeUiEventLogger.log(decoration.getTaskInfo(),
@@ -281,8 +279,7 @@ public class DesktopModeTouchEventListener

        if (id != R.id.caption_handle && id != R.id.desktop_mode_caption
                && id != R.id.open_menu_button && id != R.id.close_window
                && id != R.id.maximize_window && id != R.id.minimize_window
                && id != R.id.caption_handle2) {
                && id != R.id.maximize_window && id != R.id.minimize_window) {
            debugLogD("onTouch(%s) unsupported view, ignoring", viewName);
            return false;
        }
@@ -463,7 +460,7 @@ public class DesktopModeTouchEventListener
        final int id = v.getId();
        final String viewName = getResourceName(v);
        debugLogD("handleNonFreeformMotionEvent(%s)", viewName);
        if (id != R.id.caption_handle && id != R.id.caption_handle2) {
        if (id != R.id.caption_handle) {
            debugLogD("handleNonFreeformMotionEvent(%s) unsupported view, ignoring",
                    viewName);
            return false;
+3 −12
Original line number Diff line number Diff line
@@ -222,11 +222,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    private final DesktopModeUiEventLogger mDesktopModeUiEventLogger;
    private boolean mIsRecentsTransitionRunning = false;
    private boolean mIsDragging = false;

    /** The last calculated valid drag area of the task. */
    private Rect mLastValidDragArea = null;
    private final boolean mEnableDrawingAppHandle =
            DesktopExperienceFlags.ENABLE_DRAWING_APP_HANDLE.isTrue();

    private final Function0<Unit> mCloseMaximizeMenuFunction = () -> {
        closeMaximizeMenu();
@@ -1874,9 +1871,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
    void checkTouchEvent(MotionEvent ev) {
        if (mResult.mRootView == null || DesktopModeFlags.ENABLE_HANDLE_INPUT_FIX.isTrue()) return;
        final View caption = mResult.mRootView.findViewById(R.id.desktop_mode_caption);
        final View handle = mEnableDrawingAppHandle
                ? caption.findViewById(R.id.caption_handle2)
                : caption.findViewById(R.id.caption_handle);
        final View handle = caption.findViewById(R.id.caption_handle);
        final boolean inHandle = !isHandleMenuActive()
                && checkTouchEventInFocusedCaptionHandle(ev);
        final int action = ev.getActionMasked();
@@ -1902,9 +1897,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
     */
    void updateHoverAndPressStatus(MotionEvent ev) {
        if (mResult.mRootView == null || DesktopModeFlags.ENABLE_HANDLE_INPUT_FIX.isTrue()) return;
        final View handle = mEnableDrawingAppHandle
                ? mResult.mRootView.findViewById(R.id.caption_handle2)
                : mResult.mRootView.findViewById(R.id.caption_handle);
        final View handle = mResult.mRootView.findViewById(R.id.caption_handle);
        final boolean inHandle = !isHandleMenuActive()
                && checkTouchEventInFocusedCaptionHandle(ev);
        final int action = ev.getActionMasked();
@@ -1924,9 +1917,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
     */
    void handleDragInterrupted() {
        if (mResult.mRootView == null) return;
        final View handle = mEnableDrawingAppHandle
                ? mResult.mRootView.findViewById(R.id.caption_handle2)
                : mResult.mRootView.findViewById(R.id.caption_handle);
        final View handle = mResult.mRootView.findViewById(R.id.caption_handle);
        handle.setHovered(false);
        handle.setPressed(false);
    }
Loading