Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 698e7634 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Disable resize when IME is adjusted

Bug: 28175599
Change-Id: I338dd230443973d912f17946ed722789b0f545a2
parent eb88d83f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -43,6 +43,15 @@ oneway interface IDockedStackListener {
     */
    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.
     */
+23 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ public class Divider extends SystemUI {
    private DockDividerVisibilityListener mDockDividerVisibilityListener;
    private boolean mVisible = false;
    private boolean mMinimized = false;
    private boolean mAdjustedForIme = false;
    private ForcedResizableInfoActivityController mForcedResizableController;

    @Override
@@ -84,7 +85,7 @@ public class Divider extends SystemUI {
        addDivider(configuration);
        if (mMinimized) {
            mView.setMinimizedDockStack(true);
            mWindowManager.setTouchable(false);
            updateTouchable();
        }
    }

@@ -109,7 +110,7 @@ public class Divider extends SystemUI {
            public void run() {
                if (mMinimized != minimized) {
                    mMinimized = minimized;
                    mWindowManager.setTouchable(!minimized);
                    updateTouchable();
                    if (animDuration > 0) {
                        mView.setMinimizedDockStack(minimized, animDuration);
                    } else {
@@ -129,6 +130,10 @@ public class Divider extends SystemUI {
        });
    }

    private void updateTouchable() {
        mWindowManager.setTouchable(!mMinimized && !mAdjustedForIme);
    }

    class DockDividerVisibilityListener extends IDockedStackListener.Stub {

        @Override
@@ -147,6 +152,22 @@ public class Divider extends SystemUI {
            updateMinimizedDockedStack(minimized, animDuration);
        }

        @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));
+36 −2
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.graphics.Rect;
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.DividerSnapAlgorithm.SnapTarget;
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 @@ public class DividerView extends FrameLayout implements OnTouchListener,
     * 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 @@ public class DividerView extends FrameLayout implements OnTouchListener,
    private int mExitStartPosition;
    private GestureDetector mGestureDetector;
    private boolean mDockedStackMinimized;
    private boolean mAdjustedForIme;

    private final AccessibilityDelegate mHandleDelegate = new AccessibilityDelegate() {
        @Override
@@ -657,6 +657,40 @@ public class DividerView extends FrameLayout implements OnTouchListener,
        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);
+5 −0
Original line number Diff line number Diff line
@@ -530,6 +530,11 @@ public class NavigationBarView extends LinearLayout {
                        throws RemoteException {
                }

                @Override
                public void onAdjustedForImeChanged(boolean adjustedForIme, long animDuration)
                        throws RemoteException {
                }

                @Override
                public void onDockSideChanged(int newDockSide) throws RemoteException {
                }
+18 −2
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public class DockedStackDividerController implements DimLayerUser {
    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 @@ public class DockedStackDividerController implements DimLayerUser {
            if (animate) {
                startImeAdjustAnimation(adjusted ? 0 : 1, adjusted ? 1 : 0);
            }
            notifyAdjustedForImeChanged(adjusted, animate ? IME_ADJUST_ANIM_DURATION : 0);
        }
    }

@@ -291,12 +292,27 @@ public class DockedStackDividerController implements DimLayerUser {
        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 @@ public class DockedStackDividerController implements DimLayerUser {
            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)