Merge "Refine the bounds of the wrap-content sides" into sc-v2-dev
This commit is contained in:
@@ -2517,6 +2517,14 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
|| lp.type == TYPE_VOLUME_OVERLAY;
|
|| lp.type == TYPE_VOLUME_OVERLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Rect getWindowBoundsInsetSystemBars() {
|
||||||
|
final Rect bounds = new Rect(
|
||||||
|
mContext.getResources().getConfiguration().windowConfiguration.getBounds());
|
||||||
|
bounds.inset(mInsetsController.getState().calculateInsets(
|
||||||
|
bounds, Type.systemBars(), false /* ignoreVisibility */));
|
||||||
|
return bounds;
|
||||||
|
}
|
||||||
|
|
||||||
int dipToPx(int dip) {
|
int dipToPx(int dip) {
|
||||||
final DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
|
final DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
|
||||||
return (int) (displayMetrics.density * dip + 0.5f);
|
return (int) (displayMetrics.density * dip + 0.5f);
|
||||||
@@ -2603,8 +2611,9 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
|| lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
|
|| lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
|
||||||
// For wrap content, we have to remeasure later on anyways. Use size consistent with
|
// For wrap content, we have to remeasure later on anyways. Use size consistent with
|
||||||
// below so we get best use of the measure cache.
|
// below so we get best use of the measure cache.
|
||||||
desiredWindowWidth = dipToPx(config.screenWidthDp);
|
final Rect bounds = getWindowBoundsInsetSystemBars();
|
||||||
desiredWindowHeight = dipToPx(config.screenHeightDp);
|
desiredWindowWidth = bounds.width();
|
||||||
|
desiredWindowHeight = bounds.height();
|
||||||
} else {
|
} else {
|
||||||
// After addToDisplay, the frame contains the frameHint from window manager, which
|
// After addToDisplay, the frame contains the frameHint from window manager, which
|
||||||
// for most windows is going to be the same size as the result of relayoutWindow.
|
// for most windows is going to be the same size as the result of relayoutWindow.
|
||||||
@@ -2681,9 +2690,9 @@ public final class ViewRootImpl implements ViewParent,
|
|||||||
desiredWindowWidth = size.x;
|
desiredWindowWidth = size.x;
|
||||||
desiredWindowHeight = size.y;
|
desiredWindowHeight = size.y;
|
||||||
} else {
|
} else {
|
||||||
Configuration config = res.getConfiguration();
|
final Rect bounds = getWindowBoundsInsetSystemBars();
|
||||||
desiredWindowWidth = dipToPx(config.screenWidthDp);
|
desiredWindowWidth = bounds.width();
|
||||||
desiredWindowHeight = dipToPx(config.screenHeightDp);
|
desiredWindowHeight = bounds.height();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,12 +133,19 @@ class InsetsPolicy {
|
|||||||
abortTransient();
|
abortTransient();
|
||||||
}
|
}
|
||||||
mFocusedWin = focusedWin;
|
mFocusedWin = focusedWin;
|
||||||
InsetsControlTarget statusControlTarget = getStatusControlTarget(focusedWin);
|
final InsetsControlTarget statusControlTarget =
|
||||||
InsetsControlTarget navControlTarget = getNavControlTarget(focusedWin);
|
getStatusControlTarget(focusedWin, false /* fake */);
|
||||||
mStateController.onBarControlTargetChanged(statusControlTarget,
|
final InsetsControlTarget navControlTarget =
|
||||||
getFakeControlTarget(focusedWin, statusControlTarget),
|
getNavControlTarget(focusedWin, false /* fake */);
|
||||||
|
mStateController.onBarControlTargetChanged(
|
||||||
|
statusControlTarget,
|
||||||
|
statusControlTarget == mDummyControlTarget
|
||||||
|
? getStatusControlTarget(focusedWin, true /* fake */)
|
||||||
|
: null,
|
||||||
navControlTarget,
|
navControlTarget,
|
||||||
getFakeControlTarget(focusedWin, navControlTarget));
|
navControlTarget == mDummyControlTarget
|
||||||
|
? getNavControlTarget(focusedWin, true /* fake */)
|
||||||
|
: null);
|
||||||
mStatusBar.updateVisibility(statusControlTarget, ITYPE_STATUS_BAR);
|
mStatusBar.updateVisibility(statusControlTarget, ITYPE_STATUS_BAR);
|
||||||
mNavBar.updateVisibility(navControlTarget, ITYPE_NAVIGATION_BAR);
|
mNavBar.updateVisibility(navControlTarget, ITYPE_NAVIGATION_BAR);
|
||||||
}
|
}
|
||||||
@@ -294,13 +301,9 @@ class InsetsPolicy {
|
|||||||
mShowingTransientTypes.clear();
|
mShowingTransientTypes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable InsetsControlTarget getFakeControlTarget(@Nullable WindowState focused,
|
private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin,
|
||||||
InsetsControlTarget realControlTarget) {
|
boolean fake) {
|
||||||
return realControlTarget == mDummyControlTarget ? focused : null;
|
if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1 && !fake) {
|
||||||
}
|
|
||||||
|
|
||||||
private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin) {
|
|
||||||
if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1) {
|
|
||||||
return mDummyControlTarget;
|
return mDummyControlTarget;
|
||||||
}
|
}
|
||||||
final WindowState notificationShade = mPolicy.getNotificationShade();
|
final WindowState notificationShade = mPolicy.getNotificationShade();
|
||||||
@@ -318,7 +321,7 @@ class InsetsPolicy {
|
|||||||
// we will dispatch the real visibility of status bar to the client.
|
// we will dispatch the real visibility of status bar to the client.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (forceShowsStatusBarTransiently()) {
|
if (forceShowsStatusBarTransiently() && !fake) {
|
||||||
// Status bar is forcibly shown transiently, and its new visibility won't be
|
// Status bar is forcibly shown transiently, and its new visibility won't be
|
||||||
// dispatched to the client so that we can keep the layout stable. We will dispatch the
|
// dispatched to the client so that we can keep the layout stable. We will dispatch the
|
||||||
// fake control to the client, so that it can re-show the bar during this scenario.
|
// fake control to the client, so that it can re-show the bar during this scenario.
|
||||||
@@ -343,13 +346,14 @@ class InsetsPolicy {
|
|||||||
&& !win.inMultiWindowMode();
|
&& !win.inMultiWindowMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin) {
|
private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin,
|
||||||
|
boolean fake) {
|
||||||
final WindowState imeWin = mDisplayContent.mInputMethodWindow;
|
final WindowState imeWin = mDisplayContent.mInputMethodWindow;
|
||||||
if (imeWin != null && imeWin.isVisible()) {
|
if (imeWin != null && imeWin.isVisible()) {
|
||||||
// Force showing navigation bar while IME is visible.
|
// Force showing navigation bar while IME is visible.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (mShowingTransientTypes.indexOf(ITYPE_NAVIGATION_BAR) != -1) {
|
if (mShowingTransientTypes.indexOf(ITYPE_NAVIGATION_BAR) != -1 && !fake) {
|
||||||
return mDummyControlTarget;
|
return mDummyControlTarget;
|
||||||
}
|
}
|
||||||
if (focusedWin == mPolicy.getNotificationShade()) {
|
if (focusedWin == mPolicy.getNotificationShade()) {
|
||||||
@@ -366,7 +370,7 @@ class InsetsPolicy {
|
|||||||
// bar, and we will dispatch the real visibility of navigation bar to the client.
|
// bar, and we will dispatch the real visibility of navigation bar to the client.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (forceShowsNavigationBarTransiently()) {
|
if (forceShowsNavigationBarTransiently() && !fake) {
|
||||||
// Navigation bar is forcibly shown transiently, and its new visibility won't be
|
// Navigation bar is forcibly shown transiently, and its new visibility won't be
|
||||||
// dispatched to the client so that we can keep the layout stable. We will dispatch the
|
// dispatched to the client so that we can keep the layout stable. We will dispatch the
|
||||||
// fake control to the client, so that it can re-show the bar during this scenario.
|
// fake control to the client, so that it can re-show the bar during this scenario.
|
||||||
|
|||||||
Reference in New Issue
Block a user