Merge "Misc fixes for IME adjust" into nyc-dev
This commit is contained in:
@@ -85,9 +85,12 @@ public class DockedStackDividerController implements DimLayerUser {
|
|||||||
|
|
||||||
private static final long IME_ADJUST_DRAWN_TIMEOUT = 200;
|
private static final long IME_ADJUST_DRAWN_TIMEOUT = 200;
|
||||||
|
|
||||||
|
private static final int DIVIDER_WIDTH_INACTIVE_DP = 4;
|
||||||
|
|
||||||
private final WindowManagerService mService;
|
private final WindowManagerService mService;
|
||||||
private final DisplayContent mDisplayContent;
|
private final DisplayContent mDisplayContent;
|
||||||
private int mDividerWindowWidth;
|
private int mDividerWindowWidth;
|
||||||
|
private int mDividerWindowWidthInactive;
|
||||||
private int mDividerInsets;
|
private int mDividerInsets;
|
||||||
private boolean mResizing;
|
private boolean mResizing;
|
||||||
private WindowState mWindow;
|
private WindowState mWindow;
|
||||||
@@ -131,6 +134,8 @@ public class DockedStackDividerController implements DimLayerUser {
|
|||||||
com.android.internal.R.dimen.docked_stack_divider_thickness);
|
com.android.internal.R.dimen.docked_stack_divider_thickness);
|
||||||
mDividerInsets = context.getResources().getDimensionPixelSize(
|
mDividerInsets = context.getResources().getDimensionPixelSize(
|
||||||
com.android.internal.R.dimen.docked_stack_divider_insets);
|
com.android.internal.R.dimen.docked_stack_divider_insets);
|
||||||
|
mDividerWindowWidthInactive = WindowManagerService.dipToPixel(
|
||||||
|
DIVIDER_WIDTH_INACTIVE_DP, mDisplayContent.getDisplayMetrics());
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConfigurationChanged() {
|
void onConfigurationChanged() {
|
||||||
@@ -149,6 +154,10 @@ public class DockedStackDividerController implements DimLayerUser {
|
|||||||
return mDividerInsets;
|
return mDividerInsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getContentWidthInactive() {
|
||||||
|
return mDividerWindowWidthInactive;
|
||||||
|
}
|
||||||
|
|
||||||
void setResizing(boolean resizing) {
|
void setResizing(boolean resizing) {
|
||||||
if (mResizing != resizing) {
|
if (mResizing != resizing) {
|
||||||
mResizing = resizing;
|
mResizing = resizing;
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class TaskStack implements DimLayer.DimLayerUser,
|
public class TaskStack implements DimLayer.DimLayerUser,
|
||||||
BoundsAnimationController.AnimateBoundsUser {
|
BoundsAnimationController.AnimateBoundsUser {
|
||||||
|
/** Minimum size of an adjusted stack bounds relative to original stack bounds. Used to
|
||||||
|
* restrict IME adjustment so that a min portion of top stack remains visible.*/
|
||||||
|
private static final float ADJUSTED_STACK_FRACTION_MIN = 0.3f;
|
||||||
|
|
||||||
|
/** Dimming amount for non-focused stack when stacks are IME-adjusted. */
|
||||||
|
private static final float IME_ADJUST_DIM_AMOUNT = 0.25f;
|
||||||
|
|
||||||
/** Unique identifier */
|
/** Unique identifier */
|
||||||
final int mStackId;
|
final int mStackId;
|
||||||
@@ -249,7 +255,12 @@ public class TaskStack implements DimLayer.DimLayerUser,
|
|||||||
task.scrollLocked(mTmpRect2);
|
task.scrollLocked(mTmpRect2);
|
||||||
} else if (task.isResizeable() && task.mOverrideConfig != Configuration.EMPTY) {
|
} else if (task.isResizeable() && task.mOverrideConfig != Configuration.EMPTY) {
|
||||||
task.getBounds(mTmpRect2);
|
task.getBounds(mTmpRect2);
|
||||||
|
if (mAdjustedForIme && getDockSide() == DOCKED_TOP) {
|
||||||
|
int offsetY = adjustedBounds.bottom - mTmpRect2.bottom;
|
||||||
|
mTmpRect2.offset(0, offsetY);
|
||||||
|
} else {
|
||||||
mTmpRect2.offsetTo(adjustedBounds.left, adjustedBounds.top);
|
mTmpRect2.offsetTo(adjustedBounds.left, adjustedBounds.top);
|
||||||
|
}
|
||||||
task.setTempInsetBounds(tempInsetBounds);
|
task.setTempInsetBounds(tempInsetBounds);
|
||||||
task.resizeLocked(mTmpRect2, task.mOverrideConfig, false /* forced */);
|
task.resizeLocked(mTmpRect2, task.mOverrideConfig, false /* forced */);
|
||||||
}
|
}
|
||||||
@@ -882,6 +893,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
|
|||||||
mImeGoingAway = false;
|
mImeGoingAway = false;
|
||||||
mAdjustImeAmount = 0f;
|
mAdjustImeAmount = 0f;
|
||||||
updateAdjustedBounds();
|
updateAdjustedBounds();
|
||||||
|
mService.setResizeDimLayer(false, mStackId, 1.0f);
|
||||||
} else {
|
} else {
|
||||||
mImeGoingAway |= mAdjustedForIme;
|
mImeGoingAway |= mAdjustedForIme;
|
||||||
}
|
}
|
||||||
@@ -930,6 +942,11 @@ public class TaskStack implements DimLayer.DimLayerUser,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getMinTopStackBottom(final Rect displayContentRect, int originalStackBottom) {
|
||||||
|
return displayContentRect.top + (int)
|
||||||
|
((originalStackBottom - displayContentRect.top) * ADJUSTED_STACK_FRACTION_MIN);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean adjustForIME(final WindowState imeWin) {
|
private boolean adjustForIME(final WindowState imeWin) {
|
||||||
final int dockedSide = getDockSide();
|
final int dockedSide = getDockSide();
|
||||||
final boolean dockedTopOrBottom = dockedSide == DOCKED_TOP || dockedSide == DOCKED_BOTTOM;
|
final boolean dockedTopOrBottom = dockedSide == DOCKED_TOP || dockedSide == DOCKED_BOTTOM;
|
||||||
@@ -953,23 +970,41 @@ public class TaskStack implements DimLayer.DimLayerUser,
|
|||||||
mLastContentBounds.set(contentBounds);
|
mLastContentBounds.set(contentBounds);
|
||||||
final int yOffset = displayContentRect.bottom - contentBounds.bottom;
|
final int yOffset = displayContentRect.bottom - contentBounds.bottom;
|
||||||
|
|
||||||
|
final int dividerWidth =
|
||||||
|
getDisplayContent().mDividerControllerLocked.getContentWidth();
|
||||||
|
final int dividerWidthInactive =
|
||||||
|
getDisplayContent().mDividerControllerLocked.getContentWidthInactive();
|
||||||
|
|
||||||
if (dockedSide == DOCKED_TOP) {
|
if (dockedSide == DOCKED_TOP) {
|
||||||
// If this stack is docked on top, we make it smaller so the bottom stack is not
|
// If this stack is docked on top, we make it smaller so the bottom stack is not
|
||||||
// occluded by IME. We shift its bottom up by the height of the IME (capped by
|
// occluded by IME. We shift its bottom up by the height of the IME, but
|
||||||
// the display content rect). Note that we don't change the task bounds.
|
// leaves at least 30% of the top stack visible.
|
||||||
int bottom = Math.max(
|
final int minTopStackBottom =
|
||||||
mBounds.bottom - yOffset, displayContentRect.top);
|
getMinTopStackBottom(displayContentRect, mBounds.bottom);
|
||||||
|
final int bottom = Math.max(
|
||||||
|
mBounds.bottom - yOffset + dividerWidth - dividerWidthInactive,
|
||||||
|
minTopStackBottom);
|
||||||
mTmpAdjustedBounds.set(mBounds);
|
mTmpAdjustedBounds.set(mBounds);
|
||||||
mTmpAdjustedBounds.bottom =
|
mTmpAdjustedBounds.bottom =
|
||||||
(int) (mAdjustImeAmount * bottom + (1 - mAdjustImeAmount) * mBounds.bottom);
|
(int) (mAdjustImeAmount * bottom + (1 - mAdjustImeAmount) * mBounds.bottom);
|
||||||
mFullyAdjustedImeBounds.set(mBounds);
|
mFullyAdjustedImeBounds.set(mBounds);
|
||||||
} else {
|
} else {
|
||||||
// If this stack is docked on bottom, we shift it up so that it's not occluded by
|
final int top;
|
||||||
// IME. We try to move it up by the height of the IME window (although the best
|
final boolean isFocusedStack = mService.getFocusedStackLocked() == this;
|
||||||
// we could do is to make the top stack fully collapsed).
|
if (isFocusedStack) {
|
||||||
final int dividerWidth = getDisplayContent().mDividerControllerLocked
|
// If this stack is docked on bottom and has focus, we shift it up so that it's not
|
||||||
.getContentWidth();
|
// occluded by IME. We try to move it up by the height of the IME window, but only
|
||||||
int top = Math.max(mBounds.top - yOffset, displayContentRect.top + dividerWidth);
|
// to the extent that leaves at least 30% of the top stack visible.
|
||||||
|
final int minTopStackBottom =
|
||||||
|
getMinTopStackBottom(displayContentRect, mBounds.top - dividerWidth);
|
||||||
|
top = Math.max(
|
||||||
|
mBounds.top - yOffset, minTopStackBottom + dividerWidthInactive);
|
||||||
|
} else {
|
||||||
|
// If this stack is docked on bottom but doesn't have focus, we don't need to adjust
|
||||||
|
// for IME, but still need to apply a small adjustment due to the thinner divider.
|
||||||
|
top = mBounds.top - dividerWidth + dividerWidthInactive;
|
||||||
|
}
|
||||||
|
|
||||||
mTmpAdjustedBounds.set(mBounds);
|
mTmpAdjustedBounds.set(mBounds);
|
||||||
mTmpAdjustedBounds.top =
|
mTmpAdjustedBounds.top =
|
||||||
(int) (mAdjustImeAmount * top + (1 - mAdjustImeAmount) * mBounds.top);
|
(int) (mAdjustImeAmount * top + (1 - mAdjustImeAmount) * mBounds.top);
|
||||||
@@ -1043,6 +1078,12 @@ public class TaskStack implements DimLayer.DimLayerUser,
|
|||||||
mLastContentBounds.setEmpty();
|
mLastContentBounds.setEmpty();
|
||||||
}
|
}
|
||||||
setAdjustedBounds(mTmpAdjustedBounds);
|
setAdjustedBounds(mTmpAdjustedBounds);
|
||||||
|
|
||||||
|
final boolean isFocusedStack = mService.getFocusedStackLocked() == this;
|
||||||
|
if (mAdjustedForIme && adjust && !isFocusedStack) {
|
||||||
|
final float alpha = mAdjustImeAmount * IME_ADJUST_DIM_AMOUNT;
|
||||||
|
mService.setResizeDimLayer(true, mStackId, alpha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isAdjustedForMinimizedDockedStack() {
|
boolean isAdjustedForMinimizedDockedStack() {
|
||||||
|
|||||||
@@ -7445,17 +7445,16 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
void adjustForImeIfNeeded(final DisplayContent displayContent) {
|
void adjustForImeIfNeeded(final DisplayContent displayContent) {
|
||||||
final WindowState imeWin = mInputMethodWindow;
|
final WindowState imeWin = mInputMethodWindow;
|
||||||
final TaskStack focusedStack =
|
final TaskStack focusedStack = getFocusedStackLocked();
|
||||||
mCurrentFocus != null ? mCurrentFocus.getStack() : null;
|
|
||||||
final boolean dockVisible = isStackVisibleLocked(DOCKED_STACK_ID);
|
final boolean dockVisible = isStackVisibleLocked(DOCKED_STACK_ID);
|
||||||
if (imeWin != null && imeWin.isVisibleLw() && imeWin.isDisplayedLw()
|
if (imeWin != null && imeWin.isVisibleLw() && imeWin.isDisplayedLw()
|
||||||
&& dockVisible
|
&& dockVisible && focusedStack != null) {
|
||||||
&& focusedStack != null
|
final boolean isFocusOnBottom = focusedStack.getDockSide() == DOCKED_BOTTOM;
|
||||||
&& focusedStack.getDockSide() == DOCKED_BOTTOM){
|
|
||||||
final ArrayList<TaskStack> stacks = displayContent.getStacks();
|
final ArrayList<TaskStack> stacks = displayContent.getStacks();
|
||||||
for (int i = stacks.size() - 1; i >= 0; --i) {
|
for (int i = stacks.size() - 1; i >= 0; --i) {
|
||||||
final TaskStack stack = stacks.get(i);
|
final TaskStack stack = stacks.get(i);
|
||||||
if (stack.isVisibleLocked()) {
|
final boolean isDockedOnBottom = stack.getDockSide() == DOCKED_BOTTOM;
|
||||||
|
if (stack.isVisibleLocked() && (isFocusOnBottom || isDockedOnBottom)) {
|
||||||
stack.setAdjustedForIme(imeWin);
|
stack.setAdjustedForIme(imeWin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7599,6 +7598,10 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
return mCurrentFocus;
|
return mCurrentFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TaskStack getFocusedStackLocked() {
|
||||||
|
return mCurrentFocus != null ? mCurrentFocus.getStack() : null;
|
||||||
|
}
|
||||||
|
|
||||||
private void showAuditSafeModeNotification() {
|
private void showAuditSafeModeNotification() {
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0,
|
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0,
|
||||||
new Intent(Intent.ACTION_VIEW,
|
new Intent(Intent.ACTION_VIEW,
|
||||||
@@ -9339,6 +9342,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
WindowState newFocus = computeFocusedWindowLocked();
|
WindowState newFocus = computeFocusedWindowLocked();
|
||||||
if (mCurrentFocus != newFocus) {
|
if (mCurrentFocus != newFocus) {
|
||||||
Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "wmUpdateFocus");
|
Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "wmUpdateFocus");
|
||||||
|
TaskStack oldFocusedStack = getFocusedStackLocked();
|
||||||
// This check makes sure that we don't already have the focus
|
// This check makes sure that we don't already have the focus
|
||||||
// change message pending.
|
// change message pending.
|
||||||
mH.removeMessages(H.REPORT_FOCUS_CHANGE);
|
mH.removeMessages(H.REPORT_FOCUS_CHANGE);
|
||||||
@@ -9360,6 +9364,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
mLosingFocus.remove(newFocus);
|
mLosingFocus.remove(newFocus);
|
||||||
|
|
||||||
int focusChanged = mPolicy.focusChangedLw(oldFocus, newFocus);
|
int focusChanged = mPolicy.focusChangedLw(oldFocus, newFocus);
|
||||||
|
TaskStack newFocusedStack = getFocusedStackLocked();
|
||||||
|
|
||||||
if (imWindowChanged && oldFocus != mInputMethodWindow) {
|
if (imWindowChanged && oldFocus != mInputMethodWindow) {
|
||||||
// Focus of the input method window changed. Perform layout if needed.
|
// Focus of the input method window changed. Perform layout if needed.
|
||||||
@@ -9389,6 +9394,20 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
mInputMonitor.setInputFocusLw(mCurrentFocus, updateInputWindows);
|
mInputMonitor.setInputFocusLw(mCurrentFocus, updateInputWindows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Reset and re-apply IME adjustment if needed when stack focus changed.
|
||||||
|
// This makes sure divider starts an animation from pre-adjust position to final
|
||||||
|
// position. Ideally we want to skip the reset and animation from current position
|
||||||
|
// directly to final position.
|
||||||
|
final WindowState imeWin = mInputMethodWindow;
|
||||||
|
if (oldFocusedStack != null) {
|
||||||
|
oldFocusedStack.resetAdjustedForIme(true);
|
||||||
|
}
|
||||||
|
if (newFocusedStack != null) {
|
||||||
|
newFocusedStack.resetAdjustedForIme(true);
|
||||||
|
}
|
||||||
|
displayContent.mDividerControllerLocked.setAdjustedForIme(false, false, imeWin);
|
||||||
|
adjustForImeIfNeeded(displayContent);
|
||||||
|
|
||||||
Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
|
Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user