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

Commit 74dee26c authored by Tiger Huang's avatar Tiger Huang Committed by Automerger Merge Worker
Browse files

Merge "Use insetsRoundedCornerFrame to identify taskbar insets source" into udc-dev am: b2eae6ca

parents aa66255a b2eae6ca
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -133,7 +133,7 @@ public class InsetsSource implements Parcelable {
        return mVisibleFrame == null || !mVisibleFrame.isEmpty();
        return mVisibleFrame == null || !mVisibleFrame.isEmpty();
    }
    }


    public boolean getInsetsRoundedCornerFrame() {
    public boolean insetsRoundedCornerFrame() {
        return mInsetsRoundedCornerFrame;
        return mInsetsRoundedCornerFrame;
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -275,7 +275,7 @@ public class InsetsState implements Parcelable {
        final Rect roundedCornerFrame = new Rect(mRoundedCornerFrame);
        final Rect roundedCornerFrame = new Rect(mRoundedCornerFrame);
        for (int i = mSources.size() - 1; i >= 0; i--) {
        for (int i = mSources.size() - 1; i >= 0; i--) {
            final InsetsSource source = mSources.valueAt(i);
            final InsetsSource source = mSources.valueAt(i);
            if (source.getInsetsRoundedCornerFrame()) {
            if (source.insetsRoundedCornerFrame()) {
                final Insets insets = source.calculateInsets(roundedCornerFrame, false);
                final Insets insets = source.calculateInsets(roundedCornerFrame, false);
                roundedCornerFrame.inset(insets);
                roundedCornerFrame.inset(insets);
            }
            }
+1 −29
Original line number Original line Diff line number Diff line
@@ -18,9 +18,6 @@ package android.view;


import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.util.ArraySet;

import java.util.Set;


/**
/**
 * Holds information about how to execute task transition animations.
 * Holds information about how to execute task transition animations.
@@ -36,32 +33,12 @@ public class TaskTransitionSpec implements Parcelable {
     */
     */
    public final int backgroundColor;
    public final int backgroundColor;


    /**
    public TaskTransitionSpec(int backgroundColor) {
     * TEMPORARY FIELD (b/202383002)
     * TODO: Remove once we use surfaceflinger rounded corners on tasks rather than taskbar overlays
     *  or when shell transitions are fully enabled
     *
     * A set of {@InsetsState.InternalInsetsType}s we want to use as the source to set the bounds
     * of the task during the animation. Used to make sure that task animate above the taskbar.
     * Will also be used to crop to the frame size of the inset source to the inset size to prevent
     * the taskbar rounded corners overlay from being invisible during task transition animation.
     */
    public final Set<Integer> animationBoundInsets;

    public TaskTransitionSpec(
            int backgroundColor, Set<Integer> animationBoundInsets) {
        this.backgroundColor = backgroundColor;
        this.backgroundColor = backgroundColor;
        this.animationBoundInsets = animationBoundInsets;
    }
    }


    public TaskTransitionSpec(Parcel in) {
    public TaskTransitionSpec(Parcel in) {
        this.backgroundColor = in.readInt();
        this.backgroundColor = in.readInt();

        int animationBoundInsetsSize = in.readInt();
        this.animationBoundInsets = new ArraySet<>(animationBoundInsetsSize);
        for (int i = 0; i < animationBoundInsetsSize; i++) {
            this.animationBoundInsets.add(in.readInt());
        }
    }
    }


    @Override
    @Override
@@ -72,11 +49,6 @@ public class TaskTransitionSpec implements Parcelable {
    @Override
    @Override
    public void writeToParcel(Parcel dest, int flags) {
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(backgroundColor);
        dest.writeInt(backgroundColor);

        dest.writeInt(animationBoundInsets.size());
        for (int insetType : animationBoundInsets) {
            dest.writeInt(insetType);
        }
    }
    }


    public static final @android.annotation.NonNull Parcelable.Creator<TaskTransitionSpec>
    public static final @android.annotation.NonNull Parcelable.Creator<TaskTransitionSpec>
+8 −11
Original line number Original line Diff line number Diff line
@@ -59,9 +59,6 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {
    public static final long TOUCH_ANIMATION_DURATION = 150;
    public static final long TOUCH_ANIMATION_DURATION = 150;
    public static final long TOUCH_RELEASE_ANIMATION_DURATION = 200;
    public static final long TOUCH_RELEASE_ANIMATION_DURATION = 200;


    /** The task bar expanded height. Used to determine whether to insets divider bounds or not. */
    private float mExpandedTaskBarHeight;

    private final int mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    private final int mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();


    private SplitLayout mSplitLayout;
    private SplitLayout mSplitLayout;
@@ -216,17 +213,19 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {


    void onInsetsChanged(InsetsState insetsState, boolean animate) {
    void onInsetsChanged(InsetsState insetsState, boolean animate) {
        mSplitLayout.getDividerBounds(mTempRect);
        mSplitLayout.getDividerBounds(mTempRect);
        final InsetsSource taskBarInsetsSource =
                insetsState.peekSource(InsetsState.ITYPE_EXTRA_NAVIGATION_BAR);
        // Only insets the divider bar with task bar when it's expanded so that the rounded corners
        // Only insets the divider bar with task bar when it's expanded so that the rounded corners
        // will be drawn against task bar.
        // will be drawn against task bar.
        // But there is no need to do it when IME showing because there are no rounded corners at
        // But there is no need to do it when IME showing because there are no rounded corners at
        // the bottom. This also avoids the problem of task bar height not changing when IME
        // the bottom. This also avoids the problem of task bar height not changing when IME
        // floating.
        // floating.
        if (!insetsState.isSourceOrDefaultVisible(InsetsSource.ID_IME, WindowInsets.Type.ime())
        if (!insetsState.isSourceOrDefaultVisible(InsetsSource.ID_IME, WindowInsets.Type.ime())) {
                && taskBarInsetsSource != null
            for (int i = insetsState.sourceSize() - 1; i >= 0; i--) {
                && taskBarInsetsSource.getFrame().height() >= mExpandedTaskBarHeight) {
                final InsetsSource source = insetsState.sourceAt(i);
            mTempRect.inset(taskBarInsetsSource.calculateVisibleInsets(mTempRect));
                if (source.getType() == WindowInsets.Type.navigationBars()
                        && source.insetsRoundedCornerFrame()) {
                    mTempRect.inset(source.calculateVisibleInsets(mTempRect));
                }
            }
        }
        }


        if (!mTempRect.equals(mDividerBounds)) {
        if (!mTempRect.equals(mDividerBounds)) {
@@ -251,8 +250,6 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {
        mDividerBar = findViewById(R.id.divider_bar);
        mDividerBar = findViewById(R.id.divider_bar);
        mHandle = findViewById(R.id.docked_divider_handle);
        mHandle = findViewById(R.id.docked_divider_handle);
        mBackground = findViewById(R.id.docked_divider_background);
        mBackground = findViewById(R.id.docked_divider_background);
        mExpandedTaskBarHeight = getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.taskbar_frame_height);
        mTouchElevation = getResources().getDimensionPixelSize(
        mTouchElevation = getResources().getDimensionPixelSize(
                R.dimen.docked_stack_divider_lift_elevation);
                R.dimen.docked_stack_divider_lift_elevation);
        mDoubleTapDetector = new GestureDetector(getContext(), new DoubleTapListener());
        mDoubleTapDetector = new GestureDetector(getContext(), new DoubleTapListener());
+29 −17
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@ import android.os.IBinder;
import android.view.InsetsSource;
import android.view.InsetsSource;
import android.view.InsetsState;
import android.view.InsetsState;
import android.view.SurfaceControl;
import android.view.SurfaceControl;
import android.view.WindowInsets;
import android.window.ITaskOrganizerController;
import android.window.ITaskOrganizerController;
import android.window.TaskAppearedInfo;
import android.window.TaskAppearedInfo;
import android.window.WindowContainerToken;
import android.window.WindowContainerToken;
@@ -57,7 +58,6 @@ import com.android.wm.shell.unfold.UnfoldAnimationController;


import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.List;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Optional;


/**
/**
@@ -130,14 +130,34 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer {
            new DisplayInsetsController.OnInsetsChangedListener() {
            new DisplayInsetsController.OnInsetsChangedListener() {
        @Override
        @Override
        public void insetsChanged(InsetsState insetsState) {
        public void insetsChanged(InsetsState insetsState) {
            // Update bounds only when the insets of navigation bar or task bar is changed.
            final boolean[] navigationBarChanged = {false};
            if (Objects.equals(insetsState.peekSource(InsetsState.ITYPE_NAVIGATION_BAR),
            InsetsState.traverse(insetsState, mInsetsState, new InsetsState.OnTraverseCallbacks() {
                    mInsetsState.peekSource(InsetsState.ITYPE_NAVIGATION_BAR))
                @Override
                    && Objects.equals(insetsState.peekSource(
                public void onIdMatch(InsetsSource source1, InsetsSource source2) {
                            InsetsState.ITYPE_EXTRA_NAVIGATION_BAR),
                    if (source1.getType() == WindowInsets.Type.navigationBars()
                    mInsetsState.peekSource(InsetsState.ITYPE_EXTRA_NAVIGATION_BAR))) {
                            && !source1.equals(source2)) {
                        navigationBarChanged[0] = true;
                    }
                }

                @Override
                public void onIdNotFoundInState1(int index2, InsetsSource source2) {
                    if (source2.getType() == WindowInsets.Type.navigationBars()) {
                        navigationBarChanged[0] = true;
                    }
                }

                @Override
                public void onIdNotFoundInState2(int index1, InsetsSource source1) {
                    if (source1.getType() == WindowInsets.Type.navigationBars()) {
                        navigationBarChanged[0] = true;
                    }
                }
            });
            if (!navigationBarChanged[0]) {
                return;
                return;
            }
            }
            // Update bounds only when the insets of navigation bar or task bar is changed.
            mInsetsState.set(insetsState);
            mInsetsState.set(insetsState);
            updateBounds();
            updateBounds();
        }
        }
@@ -344,16 +364,8 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer {


    private Rect calculateBounds() {
    private Rect calculateBounds() {
        final Rect bounds = new Rect(0, 0, mDisplayWidth, mDisplayHeight);
        final Rect bounds = new Rect(0, 0, mDisplayWidth, mDisplayHeight);
        final InsetsSource navBarSource = mInsetsState.peekSource(InsetsState.ITYPE_NAVIGATION_BAR);
        bounds.inset(mInsetsState.calculateInsets(
        final InsetsSource taskBarSource = mInsetsState.peekSource(
                bounds, WindowInsets.Type.navigationBars(), false /* ignoreVisibility */));
                InsetsState.ITYPE_EXTRA_NAVIGATION_BAR);
        if (navBarSource != null && !navBarSource.getFrame().isEmpty()) {
            bounds.inset(navBarSource.calculateInsets(bounds, false /* ignoreVisibility */));
        } else if (taskBarSource != null && !taskBarSource.getFrame().isEmpty()) {
            bounds.inset(taskBarSource.calculateInsets(bounds, false /* ignoreVisibility */));
        } else {
            bounds.setEmpty();
        }
        return bounds;
        return bounds;
    }
    }


Loading