Merge "Take IME into account when deciding nav bar background window" into udc-qpr-dev
This commit is contained in:
@@ -271,13 +271,13 @@ public class DisplayPolicy {
|
|||||||
private WindowState mSystemUiControllingWindow;
|
private WindowState mSystemUiControllingWindow;
|
||||||
|
|
||||||
// Candidate window to determine the color of navigation bar. The window needs to be top
|
// Candidate window to determine the color of navigation bar. The window needs to be top
|
||||||
// fullscreen-app windows or dim layers that are intersecting with the window frame of status
|
// fullscreen-app windows or dim layers that are intersecting with the window frame of
|
||||||
// bar.
|
// navigation bar.
|
||||||
private WindowState mNavBarColorWindowCandidate;
|
private WindowState mNavBarColorWindowCandidate;
|
||||||
|
|
||||||
// The window to determine opacity and background of translucent navigation bar. The window
|
// Candidate window to determine opacity and background of translucent navigation bar.
|
||||||
// needs to be opaque.
|
// The window frame must intersect the frame of navigation bar.
|
||||||
private WindowState mNavBarBackgroundWindow;
|
private WindowState mNavBarBackgroundWindowCandidate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of {@link AppearanceRegion} to indicate that which region of status bar applies
|
* A collection of {@link AppearanceRegion} to indicate that which region of status bar applies
|
||||||
@@ -1383,7 +1383,7 @@ public class DisplayPolicy {
|
|||||||
mBottomGestureHost = null;
|
mBottomGestureHost = null;
|
||||||
mTopFullscreenOpaqueWindowState = null;
|
mTopFullscreenOpaqueWindowState = null;
|
||||||
mNavBarColorWindowCandidate = null;
|
mNavBarColorWindowCandidate = null;
|
||||||
mNavBarBackgroundWindow = null;
|
mNavBarBackgroundWindowCandidate = null;
|
||||||
mStatusBarAppearanceRegionList.clear();
|
mStatusBarAppearanceRegionList.clear();
|
||||||
mLetterboxDetails.clear();
|
mLetterboxDetails.clear();
|
||||||
mStatusBarBackgroundWindows.clear();
|
mStatusBarBackgroundWindows.clear();
|
||||||
@@ -1510,8 +1510,8 @@ public class DisplayPolicy {
|
|||||||
mNavBarColorWindowCandidate = win;
|
mNavBarColorWindowCandidate = win;
|
||||||
addSystemBarColorApp(win);
|
addSystemBarColorApp(win);
|
||||||
}
|
}
|
||||||
if (mNavBarBackgroundWindow == null) {
|
if (mNavBarBackgroundWindowCandidate == null) {
|
||||||
mNavBarBackgroundWindow = win;
|
mNavBarBackgroundWindowCandidate = win;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1535,12 +1535,19 @@ public class DisplayPolicy {
|
|||||||
}
|
}
|
||||||
if (isOverlappingWithNavBar(win) && mNavBarColorWindowCandidate == null) {
|
if (isOverlappingWithNavBar(win) && mNavBarColorWindowCandidate == null) {
|
||||||
mNavBarColorWindowCandidate = win;
|
mNavBarColorWindowCandidate = win;
|
||||||
|
addSystemBarColorApp(win);
|
||||||
}
|
}
|
||||||
} else if (appWindow && attached == null && mNavBarColorWindowCandidate == null
|
} else if (appWindow && attached == null
|
||||||
|
&& (mNavBarColorWindowCandidate == null || mNavBarBackgroundWindowCandidate == null)
|
||||||
&& win.getFrame().contains(
|
&& win.getFrame().contains(
|
||||||
getBarContentFrameForWindow(win, Type.navigationBars()))) {
|
getBarContentFrameForWindow(win, Type.navigationBars()))) {
|
||||||
mNavBarColorWindowCandidate = win;
|
if (mNavBarColorWindowCandidate == null) {
|
||||||
addSystemBarColorApp(win);
|
mNavBarColorWindowCandidate = win;
|
||||||
|
addSystemBarColorApp(win);
|
||||||
|
}
|
||||||
|
if (mNavBarBackgroundWindowCandidate == null) {
|
||||||
|
mNavBarBackgroundWindowCandidate = win;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2461,7 +2468,7 @@ public class DisplayPolicy {
|
|||||||
return win.isFullyTransparentBarAllowed(getBarContentFrameForWindow(win, type));
|
return win.isFullyTransparentBarAllowed(getBarContentFrameForWindow(win, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean drawsBarBackground(WindowState win) {
|
private static boolean drawsBarBackground(WindowState win) {
|
||||||
if (win == null) {
|
if (win == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2501,7 +2508,11 @@ public class DisplayPolicy {
|
|||||||
*/
|
*/
|
||||||
private int configureNavBarOpacity(int appearance, boolean multiWindowTaskVisible,
|
private int configureNavBarOpacity(int appearance, boolean multiWindowTaskVisible,
|
||||||
boolean freeformRootTaskVisible) {
|
boolean freeformRootTaskVisible) {
|
||||||
final boolean drawBackground = drawsBarBackground(mNavBarBackgroundWindow);
|
final WindowState navBackgroundWin = chooseNavigationBackgroundWindow(
|
||||||
|
mNavBarBackgroundWindowCandidate,
|
||||||
|
mDisplayContent.mInputMethodWindow,
|
||||||
|
mNavigationBarPosition);
|
||||||
|
final boolean drawBackground = navBackgroundWin != null;
|
||||||
|
|
||||||
if (mNavBarOpacityMode == NAV_BAR_FORCE_TRANSPARENT) {
|
if (mNavBarOpacityMode == NAV_BAR_FORCE_TRANSPARENT) {
|
||||||
if (drawBackground) {
|
if (drawBackground) {
|
||||||
@@ -2521,7 +2532,7 @@ public class DisplayPolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFullyTransparentAllowed(mNavBarBackgroundWindow, Type.navigationBars())) {
|
if (!isFullyTransparentAllowed(navBackgroundWin, Type.navigationBars())) {
|
||||||
appearance |= APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS;
|
appearance |= APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2532,6 +2543,20 @@ public class DisplayPolicy {
|
|||||||
return appearance & ~APPEARANCE_OPAQUE_NAVIGATION_BARS;
|
return appearance & ~APPEARANCE_OPAQUE_NAVIGATION_BARS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
@Nullable
|
||||||
|
static WindowState chooseNavigationBackgroundWindow(WindowState candidate,
|
||||||
|
WindowState imeWindow, @NavigationBarPosition int navBarPosition) {
|
||||||
|
if (imeWindow != null && imeWindow.isVisible() && navBarPosition == NAV_BAR_BOTTOM
|
||||||
|
&& drawsBarBackground(imeWindow)) {
|
||||||
|
return imeWindow;
|
||||||
|
}
|
||||||
|
if (drawsBarBackground(candidate)) {
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isImmersiveMode(WindowState win) {
|
private boolean isImmersiveMode(WindowState win) {
|
||||||
if (win == null) {
|
if (win == null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -2704,9 +2729,9 @@ public class DisplayPolicy {
|
|||||||
pw.print(prefix); pw.print("mNavBarColorWindowCandidate=");
|
pw.print(prefix); pw.print("mNavBarColorWindowCandidate=");
|
||||||
pw.println(mNavBarColorWindowCandidate);
|
pw.println(mNavBarColorWindowCandidate);
|
||||||
}
|
}
|
||||||
if (mNavBarBackgroundWindow != null) {
|
if (mNavBarBackgroundWindowCandidate != null) {
|
||||||
pw.print(prefix); pw.print("mNavBarBackgroundWindow=");
|
pw.print(prefix); pw.print("mNavBarBackgroundWindowCandidate=");
|
||||||
pw.println(mNavBarBackgroundWindow);
|
pw.println(mNavBarBackgroundWindowCandidate);
|
||||||
}
|
}
|
||||||
if (mLastStatusBarAppearanceRegions != null) {
|
if (mLastStatusBarAppearanceRegions != null) {
|
||||||
pw.print(prefix); pw.println("mLastStatusBarAppearanceRegions=");
|
pw.print(prefix); pw.println("mLastStatusBarAppearanceRegions=");
|
||||||
|
|||||||
@@ -178,6 +178,44 @@ public class DisplayPolicyTests extends WindowTestsBase {
|
|||||||
dimmingNonImTarget, imeNonDrawNavBar, NAV_BAR_BOTTOM));
|
dimmingNonImTarget, imeNonDrawNavBar, NAV_BAR_BOTTOM));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChooseNavigationBackgroundWindow() {
|
||||||
|
final WindowState drawBarWin = createOpaqueFullscreen(false);
|
||||||
|
final WindowState nonDrawBarWin = createDimmingDialogWindow(true);
|
||||||
|
|
||||||
|
final WindowState visibleIme = createInputMethodWindow(true, true, false);
|
||||||
|
final WindowState invisibleIme = createInputMethodWindow(false, true, false);
|
||||||
|
final WindowState nonDrawBarIme = createInputMethodWindow(true, false, false);
|
||||||
|
|
||||||
|
assertEquals(drawBarWin, DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
drawBarWin, null, NAV_BAR_BOTTOM));
|
||||||
|
assertNull(DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
null, null, NAV_BAR_BOTTOM));
|
||||||
|
assertNull(DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
nonDrawBarWin, null, NAV_BAR_BOTTOM));
|
||||||
|
|
||||||
|
assertEquals(visibleIme, DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
drawBarWin, visibleIme, NAV_BAR_BOTTOM));
|
||||||
|
assertEquals(visibleIme, DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
null, visibleIme, NAV_BAR_BOTTOM));
|
||||||
|
assertEquals(visibleIme, DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
nonDrawBarWin, visibleIme, NAV_BAR_BOTTOM));
|
||||||
|
|
||||||
|
assertEquals(drawBarWin, DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
drawBarWin, invisibleIme, NAV_BAR_BOTTOM));
|
||||||
|
assertNull(DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
null, invisibleIme, NAV_BAR_BOTTOM));
|
||||||
|
assertNull(DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
nonDrawBarWin, invisibleIme, NAV_BAR_BOTTOM));
|
||||||
|
|
||||||
|
assertEquals(drawBarWin, DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
drawBarWin, nonDrawBarIme, NAV_BAR_BOTTOM));
|
||||||
|
assertNull(DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
null, nonDrawBarIme, NAV_BAR_BOTTOM));
|
||||||
|
assertNull(DisplayPolicy.chooseNavigationBackgroundWindow(
|
||||||
|
nonDrawBarWin, nonDrawBarIme, NAV_BAR_BOTTOM));
|
||||||
|
}
|
||||||
|
|
||||||
@SetupWindows(addWindows = W_NAVIGATION_BAR)
|
@SetupWindows(addWindows = W_NAVIGATION_BAR)
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateLightNavigationBarLw() {
|
public void testUpdateLightNavigationBarLw() {
|
||||||
|
|||||||
Reference in New Issue
Block a user