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

Commit 0865f08f authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Migrate LAYOUT_STABLE in new insets world"

parents 14763d14 7f761874
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -239,7 +239,8 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
        return state.calculateInsets(frame, false /* isScreenRound */,
                false /* alwaysConsumeSystemBars */, null /* displayCutout */,
                null /* legacyContentInsets */, null /* legacyStableInsets */,
                LayoutParams.SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode*/, typeSideMap)
                LayoutParams.SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode*/,
                0 /* legacySystemUiFlags */, typeSideMap)
               .getInsets(mTypes);
    }

+5 −3
Original line number Diff line number Diff line
@@ -246,6 +246,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
    private int mPendingTypesToShow;

    private int mLastLegacySoftInputMode;
    private int mLastLegacySystemUiFlags;
    private boolean mStartingAnimation;

    private SyncRtSurfaceTransactionApplier mApplier;
@@ -274,7 +275,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            WindowInsets insets = state.calculateInsets(mFrame, mLastInsets.isRound(),
                    mLastInsets.shouldAlwaysConsumeSystemBars(), mLastInsets.getDisplayCutout(),
                    mLastLegacyContentInsets, mLastLegacyStableInsets, mLastLegacySoftInputMode,
                    null /* typeSideMap */);
                    mLastLegacySystemUiFlags, null /* typeSideMap */);
            mViewRoot.mView.dispatchWindowInsetsAnimationProgress(insets);

            for (int i = mTmpFinishedControls.size() - 1; i >= 0; i--) {
@@ -317,12 +318,13 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
    @VisibleForTesting
    public WindowInsets calculateInsets(boolean isScreenRound,
            boolean alwaysConsumeSystemBars, DisplayCutout cutout, Rect legacyContentInsets,
            Rect legacyStableInsets, int legacySoftInputMode) {
            Rect legacyStableInsets, int legacySoftInputMode, int legacySystemUiFlags) {
        mLastLegacyContentInsets.set(legacyContentInsets);
        mLastLegacyStableInsets.set(legacyStableInsets);
        mLastLegacySoftInputMode = legacySoftInputMode;
        mLastLegacySystemUiFlags = legacySystemUiFlags;
        mLastInsets = mState.calculateInsets(mFrame, isScreenRound, alwaysConsumeSystemBars, cutout,
                legacyContentInsets, legacyStableInsets, legacySoftInputMode,
                legacyContentInsets, legacyStableInsets, legacySoftInputMode, legacySystemUiFlags,
                null /* typeSideMap */);
        return mLastInsets;
    }
+6 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.view;

import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_IME;
import static android.view.ViewRootImpl.NEW_INSETS_MODE_NONE;
@@ -143,7 +144,8 @@ public class InsetsState implements Parcelable {
    public WindowInsets calculateInsets(Rect frame, boolean isScreenRound,
            boolean alwaysConsumeSystemBars, DisplayCutout cutout,
            @Nullable Rect legacyContentInsets, @Nullable Rect legacyStableInsets,
            int legacySoftInputMode, @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
            int legacySoftInputMode, int legacySystemUiFlags,
            @Nullable @InternalInsetsSide SparseIntArray typeSideMap) {
        Insets[] typeInsetsMap = new Insets[Type.SIZE];
        Insets[] typeMaxInsetsMap = new Insets[Type.SIZE];
        boolean[] typeVisibilityMap = new boolean[SIZE];
@@ -186,7 +188,9 @@ public class InsetsState implements Parcelable {
        return new WindowInsets(typeInsetsMap, typeMaxInsetsMap, typeVisibilityMap, isScreenRound,
                alwaysConsumeSystemBars, cutout, softInputAdjustMode == SOFT_INPUT_ADJUST_RESIZE
                        ? systemBars() | ime()
                        : systemBars());
                        : systemBars(),
                sNewInsetsMode == NEW_INSETS_MODE_FULL
                        && (legacySystemUiFlags & SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0);
    }

    public Rect calculateVisibleInsets(Rect frame, Rect legacyVisibleInsets,
+3 −1
Original line number Diff line number Diff line
@@ -2082,7 +2082,9 @@ public final class ViewRootImpl implements ViewParent,
            mLastWindowInsets = mInsetsController.calculateInsets(
                    mContext.getResources().getConfiguration().isScreenRound(),
                    mAttachInfo.mAlwaysConsumeSystemBars, displayCutout,
                    contentInsets, stableInsets, mWindowAttributes.softInputMode);
                    contentInsets, stableInsets, mWindowAttributes.softInputMode,
                    (mWindowAttributes.systemUiVisibility
                            | mWindowAttributes.subtreeSystemUiVisibility));
        }
        return mLastWindowInsets;
    }
+28 −15
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static android.view.WindowInsets.Type.STATUS_BARS;
import static android.view.WindowInsets.Type.SYSTEM_GESTURES;
import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT;
import static android.view.WindowInsets.Type.all;
import static android.view.WindowInsets.Type.ime;
import static android.view.WindowInsets.Type.indexOf;
import static android.view.WindowInsets.Type.systemBars;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
@@ -46,6 +47,7 @@ import android.view.WindowManager.LayoutParams.SoftInputModeFlags;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethod;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Preconditions;

import java.lang.annotation.Retention;
@@ -91,6 +93,7 @@ public final class WindowInsets {
    private final boolean mDisplayCutoutConsumed;

    private final int mCompatInsetTypes;
    private final boolean mCompatIgnoreVisibility;

    /**
     * Since new insets may be added in the future that existing apps couldn't
@@ -117,7 +120,8 @@ public final class WindowInsets {
            boolean isRound, boolean alwaysConsumeSystemBars, DisplayCutout displayCutout) {
        this(createCompatTypeMap(systemWindowInsetsRect), createCompatTypeMap(stableInsetsRect),
                createCompatVisibilityMap(createCompatTypeMap(systemWindowInsetsRect)),
                isRound, alwaysConsumeSystemBars, displayCutout, systemBars());
                isRound, alwaysConsumeSystemBars, displayCutout, systemBars(),
                false /* compatIgnoreVisibility */);
    }

    /**
@@ -136,7 +140,8 @@ public final class WindowInsets {
            @Nullable Insets[] typeMaxInsetsMap,
            boolean[] typeVisibilityMap,
            boolean isRound,
            boolean alwaysConsumeSystemBars, DisplayCutout displayCutout, int compatInsetTypes) {
            boolean alwaysConsumeSystemBars, DisplayCutout displayCutout, int compatInsetTypes,
            boolean compatIgnoreVisibility) {
        mSystemWindowInsetsConsumed = typeInsetsMap == null;
        mTypeInsetsMap = mSystemWindowInsetsConsumed
                ? new Insets[SIZE]
@@ -151,6 +156,7 @@ public final class WindowInsets {
        mIsRound = isRound;
        mAlwaysConsumeSystemBars = alwaysConsumeSystemBars;
        mCompatInsetTypes = compatInsetTypes;
        mCompatIgnoreVisibility = compatIgnoreVisibility;

        mDisplayCutoutConsumed = displayCutout == null;
        mDisplayCutout = (mDisplayCutoutConsumed || displayCutout.isEmpty())
@@ -167,7 +173,8 @@ public final class WindowInsets {
                src.mStableInsetsConsumed ? null : src.mTypeMaxInsetsMap,
                src.mTypeVisibilityMap, src.mIsRound,
                src.mAlwaysConsumeSystemBars, displayCutoutCopyConstructorArgument(src),
                src.mCompatInsetTypes);
                src.mCompatInsetTypes,
                src.mCompatIgnoreVisibility);
    }

    private static DisplayCutout displayCutoutCopyConstructorArgument(WindowInsets w) {
@@ -219,7 +226,7 @@ public final class WindowInsets {
    @UnsupportedAppUsage
    public WindowInsets(Rect systemWindowInsets) {
        this(createCompatTypeMap(systemWindowInsets), null, new boolean[SIZE], false, false, null,
                systemBars());
                systemBars(), false /* compatIgnoreVisibility */);
    }

    /**
@@ -239,7 +246,8 @@ public final class WindowInsets {
    /**
     * @hide
     */
    static void assignCompatInsets(Insets[] typeInsetsMap, Rect insets) {
    @VisibleForTesting
    public static void assignCompatInsets(Insets[] typeInsetsMap, Rect insets) {
        typeInsetsMap[indexOf(STATUS_BARS)] = Insets.of(0, insets.top, 0, 0);
        typeInsetsMap[indexOf(NAVIGATION_BARS)] =
                Insets.of(insets.left, 0, insets.right, insets.bottom);
@@ -288,7 +296,15 @@ public final class WindowInsets {
     */
    @NonNull
    public Insets getSystemWindowInsets() {
        return getInsets(mTypeInsetsMap, mCompatInsetTypes);
        Insets result = mCompatIgnoreVisibility
                ? getMaxInsets(mCompatInsetTypes & ~ime())
                : getInsets(mCompatInsetTypes);

        // We can't query max insets for IME, so we need to add it manually after.
        if ((mCompatInsetTypes & ime()) != 0 && mCompatIgnoreVisibility) {
            result = Insets.max(result, getInsets(ime()));
        }
        return result;
    }

    /**
@@ -448,7 +464,7 @@ public final class WindowInsets {
                mTypeVisibilityMap,
                mIsRound, mAlwaysConsumeSystemBars,
                null /* displayCutout */,
                mCompatInsetTypes);
                mCompatInsetTypes, mCompatIgnoreVisibility);
    }


@@ -491,11 +507,11 @@ public final class WindowInsets {
     */
    @NonNull
    public WindowInsets consumeSystemWindowInsets() {
        return new WindowInsets(null, mStableInsetsConsumed ? null : mTypeMaxInsetsMap,
        return new WindowInsets(null, null,
                mTypeVisibilityMap,
                mIsRound, mAlwaysConsumeSystemBars,
                displayCutoutCopyConstructorArgument(this),
                mCompatInsetTypes);
                mCompatInsetTypes, mCompatIgnoreVisibility);
    }

    // TODO(b/119190588): replace @code with @link below
@@ -741,10 +757,7 @@ public final class WindowInsets {
     */
    @NonNull
    public WindowInsets consumeStableInsets() {
        return new WindowInsets(mSystemWindowInsetsConsumed ? null : mTypeInsetsMap, null,
                mTypeVisibilityMap, mIsRound, mAlwaysConsumeSystemBars,
                displayCutoutCopyConstructorArgument(this),
                mCompatInsetTypes);
        return consumeSystemWindowInsets();
    }

    /**
@@ -829,7 +842,7 @@ public final class WindowInsets {
                        : mDisplayCutout == null
                                ? DisplayCutout.NO_CUTOUT
                                : mDisplayCutout.inset(left, top, right, bottom),
                mCompatInsetTypes);
                mCompatInsetTypes, mCompatIgnoreVisibility);
    }

    @Override
@@ -1147,7 +1160,7 @@ public final class WindowInsets {
            return new WindowInsets(mSystemInsetsConsumed ? null : mTypeInsetsMap,
                    mStableInsetsConsumed ? null : mTypeMaxInsetsMap, mTypeVisibilityMap,
                    mIsRound, mAlwaysConsumeSystemBars, mDisplayCutout,
                    systemBars());
                    systemBars(), false /* compatIgnoreVisibility */);
        }
    }

Loading