Merge "Use runtime attributes for insets calculation" into tm-qpr-dev
This commit is contained in:
@@ -1212,7 +1212,8 @@ public class DisplayPolicy {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (attrs.providedInsets != null) {
|
if (attrs.providedInsets != null) {
|
||||||
for (InsetsFrameProvider provider : attrs.providedInsets) {
|
for (int i = attrs.providedInsets.length - 1; i >= 0; i--) {
|
||||||
|
final InsetsFrameProvider provider = attrs.providedInsets[i];
|
||||||
switch (provider.type) {
|
switch (provider.type) {
|
||||||
case ITYPE_STATUS_BAR:
|
case ITYPE_STATUS_BAR:
|
||||||
mStatusBarAlt = win;
|
mStatusBarAlt = win;
|
||||||
@@ -1231,21 +1232,29 @@ public class DisplayPolicy {
|
|||||||
mExtraNavBarAltPosition = getAltBarPosition(attrs);
|
mExtraNavBarAltPosition = getAltBarPosition(attrs);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// The index of the provider and corresponding insets types cannot change at
|
||||||
|
// runtime as ensured in WMS. Make use of the index in the provider directly
|
||||||
|
// to access the latest provided size at runtime.
|
||||||
|
final int index = i;
|
||||||
final TriConsumer<DisplayFrames, WindowContainer, Rect> frameProvider =
|
final TriConsumer<DisplayFrames, WindowContainer, Rect> frameProvider =
|
||||||
provider.insetsSize != null
|
provider.insetsSize != null
|
||||||
? (displayFrames, windowContainer, inOutFrame) -> {
|
? (displayFrames, windowContainer, inOutFrame) -> {
|
||||||
inOutFrame.inset(win.mGivenContentInsets);
|
inOutFrame.inset(win.mGivenContentInsets);
|
||||||
|
final InsetsFrameProvider ifp =
|
||||||
|
win.mAttrs.forRotation(displayFrames.mRotation)
|
||||||
|
.providedInsets[index];
|
||||||
calculateInsetsFrame(displayFrames, windowContainer,
|
calculateInsetsFrame(displayFrames, windowContainer,
|
||||||
inOutFrame, provider.source,
|
inOutFrame, ifp.source, ifp.insetsSize);
|
||||||
provider.insetsSize);
|
|
||||||
} : null;
|
} : null;
|
||||||
final TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider =
|
final TriConsumer<DisplayFrames, WindowContainer, Rect> imeFrameProvider =
|
||||||
provider.imeInsetsSize != null
|
provider.imeInsetsSize != null
|
||||||
? (displayFrames, windowContainer, inOutFrame) -> {
|
? (displayFrames, windowContainer, inOutFrame) -> {
|
||||||
inOutFrame.inset(win.mGivenContentInsets);
|
inOutFrame.inset(win.mGivenContentInsets);
|
||||||
|
final InsetsFrameProvider ifp =
|
||||||
|
win.mAttrs.forRotation(displayFrames.mRotation)
|
||||||
|
.providedInsets[index];
|
||||||
calculateInsetsFrame(displayFrames, windowContainer,
|
calculateInsetsFrame(displayFrames, windowContainer,
|
||||||
inOutFrame, provider.source,
|
inOutFrame, ifp.source, ifp.imeInsetsSize);
|
||||||
provider.imeInsetsSize);
|
|
||||||
} : null;
|
} : null;
|
||||||
mDisplayContent.setInsetProvider(provider.type, win, frameProvider,
|
mDisplayContent.setInsetProvider(provider.type, win, frameProvider,
|
||||||
imeFrameProvider);
|
imeFrameProvider);
|
||||||
@@ -1256,14 +1265,14 @@ public class DisplayPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateInsetsFrame(DisplayFrames df, WindowContainer coutainer, Rect inOutFrame,
|
private void calculateInsetsFrame(DisplayFrames df, WindowContainer container, Rect inOutFrame,
|
||||||
int source, Insets insetsSize) {
|
int source, Insets insetsSize) {
|
||||||
if (source == InsetsFrameProvider.SOURCE_DISPLAY) {
|
if (source == InsetsFrameProvider.SOURCE_DISPLAY) {
|
||||||
inOutFrame.set(df.mUnrestricted);
|
inOutFrame.set(df.mUnrestricted);
|
||||||
} else if (source == InsetsFrameProvider.SOURCE_CONTAINER_BOUNDS) {
|
} else if (source == InsetsFrameProvider.SOURCE_CONTAINER_BOUNDS) {
|
||||||
inOutFrame.set(coutainer.getBounds());
|
inOutFrame.set(container.getBounds());
|
||||||
}
|
}
|
||||||
if (insetsSize == null || insetsSize.equals(Insets.NONE)) {
|
if (insetsSize == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Only one side of the provider shall be applied. Check in the order of left - top -
|
// Only one side of the provider shall be applied. Check in the order of left - top -
|
||||||
@@ -1276,6 +1285,8 @@ public class DisplayPolicy {
|
|||||||
inOutFrame.left = inOutFrame.right - insetsSize.right;
|
inOutFrame.left = inOutFrame.right - insetsSize.right;
|
||||||
} else if (insetsSize.bottom != 0) {
|
} else if (insetsSize.bottom != 0) {
|
||||||
inOutFrame.top = inOutFrame.bottom - insetsSize.bottom;
|
inOutFrame.top = inOutFrame.bottom - insetsSize.bottom;
|
||||||
|
} else {
|
||||||
|
inOutFrame.setEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user