Merge "Extend providedInternalInsets to be type specific" into tm-dev am: 36d012ca1c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17352110

Change-Id: I8e2fe89fe64fb5df33c56ec6631b15e29822e998
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-04-13 02:30:12 +00:00
committed by Automerger Merge Worker
4 changed files with 93 additions and 33 deletions

View File

@@ -3590,12 +3590,13 @@ public interface WindowManager extends ViewManager {
/** /**
* If specified, the insets provided by this window will be our window frame minus the * If specified, the insets provided by this window will be our window frame minus the
* insets specified by providedInternalInsets. This should not be used together with * insets specified by providedInternalInsets for each type. This should not be used
* {@link WindowState#mGivenContentInsets}. If both of them are set, both will be applied. * together with {@link WindowState#mGivenContentInsets}. If both of them are set, both will
* be applied.
* *
* @hide * @hide
*/ */
public Insets providedInternalInsets = Insets.NONE; public Insets[] providedInternalInsets;
/** /**
* If specified, the insets provided by this window for the IME will be our window frame * If specified, the insets provided by this window for the IME will be our window frame
@@ -3603,7 +3604,7 @@ public interface WindowManager extends ViewManager {
* *
* @hide * @hide
*/ */
public Insets providedInternalImeInsets = Insets.NONE; public Insets[] providedInternalImeInsets;
/** /**
* If specified, the frame that used to calculate relative {@link RoundedCorner} will be * If specified, the frame that used to calculate relative {@link RoundedCorner} will be
@@ -3989,8 +3990,18 @@ public interface WindowManager extends ViewManager {
} else { } else {
out.writeInt(0); out.writeInt(0);
} }
providedInternalInsets.writeToParcel(out, 0 /* parcelableFlags */); if (providedInternalInsets != null) {
providedInternalImeInsets.writeToParcel(out, 0 /* parcelableFlags */); out.writeInt(providedInternalInsets.length);
out.writeTypedArray(providedInternalInsets, 0 /* parcelableFlags */);
} else {
out.writeInt(0);
}
if (providedInternalImeInsets != null) {
out.writeInt(providedInternalImeInsets.length);
out.writeTypedArray(providedInternalImeInsets, 0 /* parcelableFlags */);
} else {
out.writeInt(0);
}
out.writeBoolean(insetsRoundedCornerFrame); out.writeBoolean(insetsRoundedCornerFrame);
if (paramsForRotation != null) { if (paramsForRotation != null) {
checkNonRecursiveParams(); checkNonRecursiveParams();
@@ -4070,8 +4081,16 @@ public interface WindowManager extends ViewManager {
providesInsetsTypes = new int[insetsTypesLength]; providesInsetsTypes = new int[insetsTypesLength];
in.readIntArray(providesInsetsTypes); in.readIntArray(providesInsetsTypes);
} }
providedInternalInsets = Insets.CREATOR.createFromParcel(in); int providedInternalInsetsLength = in.readInt();
providedInternalImeInsets = Insets.CREATOR.createFromParcel(in); if (providedInternalInsetsLength > 0) {
providedInternalInsets = new Insets[providedInternalInsetsLength];
in.readTypedArray(providedInternalInsets, Insets.CREATOR);
}
int providedInternalImeInsetsLength = in.readInt();
if (providedInternalImeInsetsLength > 0) {
providedInternalImeInsets = new Insets[providedInternalImeInsetsLength];
in.readTypedArray(providedInternalImeInsets, Insets.CREATOR);
}
insetsRoundedCornerFrame = in.readBoolean(); insetsRoundedCornerFrame = in.readBoolean();
int paramsForRotationLength = in.readInt(); int paramsForRotationLength = in.readInt();
if (paramsForRotationLength > 0) { if (paramsForRotationLength > 0) {
@@ -4374,12 +4393,12 @@ public interface WindowManager extends ViewManager {
changes |= LAYOUT_CHANGED; changes |= LAYOUT_CHANGED;
} }
if (!providedInternalInsets.equals(o.providedInternalInsets)) { if (!Arrays.equals(providedInternalInsets, o.providedInternalInsets)) {
providedInternalInsets = o.providedInternalInsets; providedInternalInsets = o.providedInternalInsets;
changes |= LAYOUT_CHANGED; changes |= LAYOUT_CHANGED;
} }
if (!providedInternalImeInsets.equals(o.providedInternalImeInsets)) { if (!Arrays.equals(providedInternalImeInsets, o.providedInternalImeInsets)) {
providedInternalImeInsets = o.providedInternalImeInsets; providedInternalImeInsets = o.providedInternalImeInsets;
changes |= LAYOUT_CHANGED; changes |= LAYOUT_CHANGED;
} }
@@ -4590,13 +4609,21 @@ public interface WindowManager extends ViewManager {
sb.append(InsetsState.typeToString(providesInsetsTypes[i])); sb.append(InsetsState.typeToString(providesInsetsTypes[i]));
} }
} }
if (!providedInternalInsets.equals(Insets.NONE)) { if (providedInternalInsets != null) {
sb.append(System.lineSeparator());
sb.append(" providedInternalInsets="); sb.append(" providedInternalInsets=");
sb.append(providedInternalInsets); for (int i = 0; i < providedInternalInsets.length; ++i) {
if (i > 0) sb.append(' ');
sb.append((providedInternalInsets[i]));
}
} }
if (!providedInternalImeInsets.equals(Insets.NONE)) { if (providedInternalImeInsets != null) {
sb.append(System.lineSeparator());
sb.append(" providedInternalImeInsets="); sb.append(" providedInternalImeInsets=");
sb.append(providedInternalImeInsets); for (int i = 0; i < providedInternalImeInsets.length; ++i) {
if (i > 0) sb.append(' ');
sb.append((providedInternalImeInsets[i]));
}
} }
if (insetsRoundedCornerFrame) { if (insetsRoundedCornerFrame) {
sb.append(" insetsRoundedCornerFrame="); sb.append(" insetsRoundedCornerFrame=");

View File

@@ -86,6 +86,7 @@ public class WindowManagerWrapper {
public static final int ITYPE_RIGHT_TAPPABLE_ELEMENT = InsetsState.ITYPE_RIGHT_TAPPABLE_ELEMENT; public static final int ITYPE_RIGHT_TAPPABLE_ELEMENT = InsetsState.ITYPE_RIGHT_TAPPABLE_ELEMENT;
public static final int ITYPE_BOTTOM_TAPPABLE_ELEMENT = public static final int ITYPE_BOTTOM_TAPPABLE_ELEMENT =
InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT; InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
public static final int ITYPE_SIZE = InsetsState.SIZE;
public static final int ANIMATION_DURATION_RESIZE = InsetsController.ANIMATION_DURATION_RESIZE; public static final int ANIMATION_DURATION_RESIZE = InsetsController.ANIMATION_DURATION_RESIZE;
public static final Interpolator RESIZE_INTERPOLATOR = InsetsController.RESIZE_INTERPOLATOR; public static final Interpolator RESIZE_INTERPOLATOR = InsetsController.RESIZE_INTERPOLATOR;

View File

@@ -83,6 +83,7 @@ import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.Gravity; import android.view.Gravity;
import android.view.HapticFeedbackConstants; import android.view.HapticFeedbackConstants;
import android.view.InsetsState;
import android.view.InsetsState.InternalInsetsType; import android.view.InsetsState.InternalInsetsType;
import android.view.InsetsVisibilities; import android.view.InsetsVisibilities;
import android.view.KeyEvent; import android.view.KeyEvent;
@@ -1558,10 +1559,12 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
| WindowManager.LayoutParams.FLAG_SLIPPERY, | WindowManager.LayoutParams.FLAG_SLIPPERY,
PixelFormat.TRANSLUCENT); PixelFormat.TRANSLUCENT);
lp.gravity = gravity; lp.gravity = gravity;
lp.providedInternalInsets = new Insets[InsetsState.SIZE];
if (insetsHeight != -1) { if (insetsHeight != -1) {
lp.providedInternalInsets = Insets.of(0, height - insetsHeight, 0, 0); lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] =
Insets.of(0, height - insetsHeight, 0, 0);
} else { } else {
lp.providedInternalInsets = Insets.NONE; lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] = null;
} }
lp.token = new Binder(); lp.token = new Binder();
lp.accessibilityTitle = mContext.getString(R.string.nav_bar); lp.accessibilityTitle = mContext.getString(R.string.nav_bar);

View File

@@ -1146,8 +1146,13 @@ public class DisplayPolicy {
mDisplayContent.setInsetProvider(ITYPE_NAVIGATION_BAR, win, mDisplayContent.setInsetProvider(ITYPE_NAVIGATION_BAR, win,
(displayFrames, windowContainer, inOutFrame) -> { (displayFrames, windowContainer, inOutFrame) -> {
if (!mNavButtonForcedVisible) { if (!mNavButtonForcedVisible) {
inOutFrame.inset(win.getLayoutingAttrs( final Insets[] providedInternalInsets = win.getLayoutingAttrs(
displayFrames.mRotation).providedInternalInsets); displayFrames.mRotation).providedInternalInsets;
if (providedInternalInsets != null
&& providedInternalInsets.length > ITYPE_NAVIGATION_BAR
&& providedInternalInsets[ITYPE_NAVIGATION_BAR] != null) {
inOutFrame.inset(providedInternalInsets[ITYPE_NAVIGATION_BAR]);
}
inOutFrame.inset(win.mGivenContentInsets); inOutFrame.inset(win.mGivenContentInsets);
} }
}, },
@@ -1193,13 +1198,16 @@ public class DisplayPolicy {
if (attrs.providesInsetsTypes != null) { if (attrs.providesInsetsTypes != null) {
for (@InternalInsetsType int insetsType : attrs.providesInsetsTypes) { for (@InternalInsetsType int insetsType : attrs.providesInsetsTypes) {
final TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider = final TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider =
!attrs.providedInternalImeInsets.equals(Insets.NONE) (displayFrames, windowContainer, inOutFrame) -> {
? (displayFrames, windowContainer, inOutFrame) -> { final Insets[] providedInternalImeInsets =
inOutFrame.inset(win.getLayoutingAttrs( win.getLayoutingAttrs(displayFrames.mRotation)
displayFrames.mRotation) .providedInternalImeInsets;
.providedInternalImeInsets); if (providedInternalImeInsets != null
} && providedInternalImeInsets.length > insetsType
: null; && providedInternalImeInsets[insetsType] != null) {
inOutFrame.inset(providedInternalImeInsets[insetsType]);
}
};
switch (insetsType) { switch (insetsType) {
case ITYPE_STATUS_BAR: case ITYPE_STATUS_BAR:
mStatusBarAlt = win; mStatusBarAlt = win;
@@ -1220,8 +1228,13 @@ public class DisplayPolicy {
} }
mDisplayContent.setInsetProvider(insetsType, win, (displayFrames, mDisplayContent.setInsetProvider(insetsType, win, (displayFrames,
windowContainer, inOutFrame) -> { windowContainer, inOutFrame) -> {
inOutFrame.inset(win.getLayoutingAttrs( final Insets[] providedInternalInsets = win.getLayoutingAttrs(
displayFrames.mRotation).providedInternalInsets); displayFrames.mRotation).providedInternalInsets;
if (providedInternalInsets != null
&& providedInternalInsets.length > insetsType
&& providedInternalInsets[insetsType] != null) {
inOutFrame.inset(providedInternalInsets[insetsType]);
}
inOutFrame.inset(win.mGivenContentInsets); inOutFrame.inset(win.mGivenContentInsets);
}, imeFrameProvider); }, imeFrameProvider);
mInsetsSourceWindowsExceptIme.add(win); mInsetsSourceWindowsExceptIme.add(win);
@@ -1937,15 +1950,23 @@ public class DisplayPolicy {
&& lp.paramsForRotation[rotation] != null) { && lp.paramsForRotation[rotation] != null) {
lp = lp.paramsForRotation[rotation]; lp = lp.paramsForRotation[rotation];
} }
final Insets providedInternalInsets;
if (lp.providedInternalInsets != null
&& lp.providedInternalInsets.length > ITYPE_NAVIGATION_BAR
&& lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] != null) {
providedInternalInsets = lp.providedInternalInsets[ITYPE_NAVIGATION_BAR];
} else {
providedInternalInsets = Insets.NONE;
}
if (position == NAV_BAR_LEFT) { if (position == NAV_BAR_LEFT) {
if (lp.width > lp.providedInternalInsets.right) { if (lp.width > providedInternalInsets.right) {
return lp.width - lp.providedInternalInsets.right; return lp.width - providedInternalInsets.right;
} else { } else {
return 0; return 0;
} }
} else if (position == NAV_BAR_RIGHT) { } else if (position == NAV_BAR_RIGHT) {
if (lp.width > lp.providedInternalInsets.left) { if (lp.width > providedInternalInsets.left) {
return lp.width - lp.providedInternalInsets.left; return lp.width - providedInternalInsets.left;
} else { } else {
return 0; return 0;
} }
@@ -1994,10 +2015,18 @@ public class DisplayPolicy {
return 0; return 0;
} }
LayoutParams lp = mNavigationBar.getLayoutingAttrs(rotation); LayoutParams lp = mNavigationBar.getLayoutingAttrs(rotation);
if (lp.height < lp.providedInternalInsets.top) { final Insets providedInternalInsets;
if (lp.providedInternalInsets != null
&& lp.providedInternalInsets.length > ITYPE_NAVIGATION_BAR
&& lp.providedInternalInsets[ITYPE_NAVIGATION_BAR] != null) {
providedInternalInsets = lp.providedInternalInsets[ITYPE_NAVIGATION_BAR];
} else {
providedInternalInsets = Insets.NONE;
}
if (lp.height < providedInternalInsets.top) {
return 0; return 0;
} }
return lp.height - lp.providedInternalInsets.top; return lp.height - providedInternalInsets.top;
} }
/** /**