Disable resize when IME is adjusted
Bug: 28175599
Change-Id: I338dd230443973d912f17946ed722789b0f545a2
diff --git a/core/java/android/view/IDockedStackListener.aidl b/core/java/android/view/IDockedStackListener.aidl
index 88ac271..36a81db 100644
--- a/core/java/android/view/IDockedStackListener.aidl
+++ b/core/java/android/view/IDockedStackListener.aidl
@@ -44,6 +44,15 @@
void onDockedStackMinimizedChanged(boolean minimized, long animDuration);
/**
+ * Called when window manager decides to adjust the divider for IME. Like the minimized state,
+ * the divider should make itself not interactable and shrink a bit, but in a different way.s
+ *
+ * @param minimized Whether the stacks are currently adjusted for the IME
+ * @param animDuration The duration of the animation for changing the adjusted state.
+ */
+ void onAdjustedForImeChanged(boolean adjustedForIme, long animDuration);
+
+ /**
* Called when window manager repositioned the docked stack after a screen rotation change.
*/
void onDockSideChanged(int newDockSide);
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java
index 2bf0b40..5d1a61d 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java
@@ -39,6 +39,7 @@
private DockDividerVisibilityListener mDockDividerVisibilityListener;
private boolean mVisible = false;
private boolean mMinimized = false;
+ private boolean mAdjustedForIme = false;
private ForcedResizableInfoActivityController mForcedResizableController;
@Override
@@ -84,7 +85,7 @@
addDivider(configuration);
if (mMinimized) {
mView.setMinimizedDockStack(true);
- mWindowManager.setTouchable(false);
+ updateTouchable();
}
}
@@ -109,7 +110,7 @@
public void run() {
if (mMinimized != minimized) {
mMinimized = minimized;
- mWindowManager.setTouchable(!minimized);
+ updateTouchable();
if (animDuration > 0) {
mView.setMinimizedDockStack(minimized, animDuration);
} else {
@@ -129,6 +130,10 @@
});
}
+ private void updateTouchable() {
+ mWindowManager.setTouchable(!mMinimized && !mAdjustedForIme);
+ }
+
class DockDividerVisibilityListener extends IDockedStackListener.Stub {
@Override
@@ -148,6 +153,22 @@
}
@Override
+ public void onAdjustedForImeChanged(boolean adjustedForIme, long animDuration)
+ throws RemoteException {
+ mView.post(() -> {
+ if (mAdjustedForIme != adjustedForIme) {
+ mAdjustedForIme = adjustedForIme;
+ updateTouchable();
+ if (animDuration > 0) {
+ mView.setAdjustedForIme(adjustedForIme, animDuration);
+ } else {
+ mView.setAdjustedForIme(adjustedForIme);
+ }
+ }
+ });
+ }
+
+ @Override
public void onDockSideChanged(final int newDockSide) throws RemoteException {
mView.post(() -> mView.notifyDockSideChanged(newDockSide));
}
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
index 66a413c..4d1c6ba 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
@@ -31,7 +31,6 @@
import android.graphics.Region.Op;
import android.hardware.display.DisplayManager;
import android.os.Bundle;
-import android.os.Vibrator;
import android.util.AttributeSet;
import android.view.Display;
import android.view.DisplayInfo;
@@ -61,7 +60,6 @@
import com.android.internal.policy.DockedDividerUtils;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
-import com.android.systemui.recents.Constants.Metrics;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.DockedTopTaskEvent;
@@ -98,6 +96,7 @@
* How much the background gets scaled when we are in the minimized dock state.
*/
private static final float MINIMIZE_DOCK_SCALE = 0f;
+ private static final float ADJUSTED_FOR_IME_SCALE = 0.5f;
private static final PathInterpolator SLOWDOWN_INTERPOLATOR =
new PathInterpolator(0.5f, 1f, 0.5f, 1f);
@@ -147,6 +146,7 @@
private int mExitStartPosition;
private GestureDetector mGestureDetector;
private boolean mDockedStackMinimized;
+ private boolean mAdjustedForIme;
private final AccessibilityDelegate mHandleDelegate = new AccessibilityDelegate() {
@Override
@@ -657,6 +657,40 @@
mDockedStackMinimized = minimized;
}
+ public void setAdjustedForIme(boolean adjustedForIme) {
+ updateDockSide();
+ mHandle.setAlpha(adjustedForIme ? 0f : 1f);
+ if (!adjustedForIme) {
+ resetBackground();
+ } else if (mDockSide == WindowManager.DOCKED_TOP) {
+ mBackground.setPivotY(0);
+ mBackground.setScaleY(MINIMIZE_DOCK_SCALE);
+ }
+ mAdjustedForIme = adjustedForIme;
+ }
+
+ public void setAdjustedForIme(boolean adjustedForIme, long animDuration) {
+ updateDockSide();
+ mHandle.animate()
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
+ .setDuration(animDuration)
+ .alpha(adjustedForIme ? 0f : 1f)
+ .start();
+ if (mDockSide == WindowManager.DOCKED_TOP) {
+ mBackground.setPivotY(0);
+ mBackground.animate()
+ .scaleY(adjustedForIme ? MINIMIZE_DOCK_SCALE : 1f);
+ }
+ if (!adjustedForIme) {
+ mBackground.animate().withEndAction(mResetBackgroundRunnable);
+ }
+ mBackground.animate()
+ .setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
+ .setDuration(animDuration)
+ .start();
+ mAdjustedForIme = adjustedForIme;
+ }
+
private void resetBackground() {
mBackground.setPivotX(mBackground.getWidth() / 2);
mBackground.setPivotY(mBackground.getHeight() / 2);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index d7fa567..4b7d56b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -531,6 +531,11 @@
}
@Override
+ public void onAdjustedForImeChanged(boolean adjustedForIme, long animDuration)
+ throws RemoteException {
+ }
+
+ @Override
public void onDockSideChanged(int newDockSide) throws RemoteException {
}
});
diff --git a/services/core/java/com/android/server/wm/DockedStackDividerController.java b/services/core/java/com/android/server/wm/DockedStackDividerController.java
index 7d76759..21c9ee6 100644
--- a/services/core/java/com/android/server/wm/DockedStackDividerController.java
+++ b/services/core/java/com/android/server/wm/DockedStackDividerController.java
@@ -78,7 +78,7 @@
private static final Interpolator IME_ADJUST_ENTRY_INTERPOLATOR =
new PathInterpolator(0.1f, 0f, 0.1f, 1f);
- private static final long IME_ADJUST_DURATION = 280;
+ private static final long IME_ADJUST_ANIM_DURATION = 280;
private final WindowManagerService mService;
private final DisplayContent mDisplayContent;
@@ -198,6 +198,7 @@
if (animate) {
startImeAdjustAnimation(adjusted ? 0 : 1, adjusted ? 1 : 0);
}
+ notifyAdjustedForImeChanged(adjusted, animate ? IME_ADJUST_ANIM_DURATION : 0);
}
}
@@ -291,12 +292,27 @@
mDockedStackListeners.finishBroadcast();
}
+ void notifyAdjustedForImeChanged(boolean adjustedForIme, long animDuration) {
+ final int size = mDockedStackListeners.beginBroadcast();
+ for (int i = 0; i < size; ++i) {
+ final IDockedStackListener listener = mDockedStackListeners.getBroadcastItem(i);
+ try {
+ listener.onAdjustedForImeChanged(adjustedForIme, animDuration);
+ } catch (RemoteException e) {
+ Slog.e(TAG_WM, "Error delivering adjusted for ime changed event.", e);
+ }
+ }
+ mDockedStackListeners.finishBroadcast();
+ }
+
void registerDockedStackListener(IDockedStackListener listener) {
mDockedStackListeners.register(listener);
notifyDockedDividerVisibilityChanged(wasVisible());
notifyDockedStackExistsChanged(
mDisplayContent.mService.mStackIdToStack.get(DOCKED_STACK_ID) != null);
notifyDockedStackMinimizedChanged(mMinimizedDock, 0 /* animDuration */);
+ notifyAdjustedForImeChanged(mAdjustedForIme, 0 /* animDuration */);
+
}
void setResizeDimLayer(boolean visible, int targetStackId, float alpha) {
@@ -450,7 +466,7 @@
mAnimationStarted = true;
mAnimationStartTime = now;
mAnimationDuration = (long)
- (IME_ADJUST_DURATION * mService.getWindowAnimationScaleLocked());
+ (IME_ADJUST_ANIM_DURATION * mService.getWindowAnimationScaleLocked());
}
float t = Math.min(1f, (float) (now - mAnimationStartTime) / mAnimationDuration);
t = (mAnimationTarget == 1f ? IME_ADJUST_ENTRY_INTERPOLATOR : TOUCH_RESPONSE_INTERPOLATOR)