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

Commit dd9ed8f3 authored by Tiger Huang's avatar Tiger Huang Committed by Automerger Merge Worker
Browse files

Merge "Make canBeImeTarget be compatible with legacy behavior" into rvc-dev...

Merge "Make canBeImeTarget be compatible with legacy behavior" into rvc-dev am: d10a12cf am: 0efcdcb7

Change-Id: If579ac6507db6b0f660fba2cd7eca909142932a7
parents dc67e6c3 0efcdcb7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1249,6 +1249,7 @@ public class InputMethodService extends AbstractInputMethodService {
                WindowManager.LayoutParams.TYPE_INPUT_METHOD, Gravity.BOTTOM, false);
        mWindow.getWindow().getAttributes().setFitInsetsTypes(statusBars() | navigationBars());
        mWindow.getWindow().getAttributes().setFitInsetsSides(Side.all() & ~Side.BOTTOM);
        mWindow.getWindow().getAttributes().setFitInsetsIgnoringVisibility(true);

        // IME layout should always be inset by navigation bar, no matter its current visibility,
        // unless automotive requests it, since automotive may hide the navigation bar.
+15 −11
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.res.Configuration;
import android.graphics.Point;
import android.os.Handler;
import android.os.RemoteException;
import android.util.Slog;
@@ -97,7 +98,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
        }
        if (mSystemWindows.mDisplayController.getDisplayLayout(displayId).rotation()
                != pd.mRotation && isImeShowing(displayId)) {
            pd.startAnimation(true);
            pd.startAnimation(true, false /* forceRestart */);
        }
    }

@@ -200,7 +201,15 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                        continue;
                    }
                    if (activeControl.getType() == InsetsState.ITYPE_IME) {
                        mHandler.post(() -> {
                            final Point lastSurfacePosition = mImeSourceControl != null
                                    ? mImeSourceControl.getSurfacePosition() : null;
                            mImeSourceControl = activeControl;
                            if (!activeControl.getSurfacePosition().equals(lastSurfacePosition)
                                    && mAnimation != null) {
                                startAnimation(mImeShowing, true /* forceRestart */);
                            }
                        });
                    }
                }
            }
@@ -212,7 +221,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                return;
            }
            if (DEBUG) Slog.d(TAG, "Got showInsets for ime");
            startAnimation(true /* show */);
            startAnimation(true /* show */, false /* forceRestart */);
        }

        @Override
@@ -221,7 +230,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                return;
            }
            if (DEBUG) Slog.d(TAG, "Got hideInsets for ime");
            startAnimation(false /* show */);
            startAnimation(false /* show */, false /* forceRestart */);
        }

        /**
@@ -239,7 +248,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
            return imeSource.getFrame().top + (int) surfaceOffset;
        }

        private void startAnimation(final boolean show) {
        private void startAnimation(final boolean show, final boolean forceRestart) {
            final InsetsSource imeSource = mInsetsState.getSource(InsetsState.ITYPE_IME);
            if (imeSource == null || mImeSourceControl == null) {
                return;
@@ -250,7 +259,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                            + (mAnimationDirection == DIRECTION_SHOW ? "SHOW"
                            : (mAnimationDirection == DIRECTION_HIDE ? "HIDE" : "NONE")));
                }
                if ((mAnimationDirection == DIRECTION_SHOW && show)
                if (!forceRestart && (mAnimationDirection == DIRECTION_SHOW && show)
                        || (mAnimationDirection == DIRECTION_HIDE && !show)) {
                    return;
                }
@@ -270,11 +279,6 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                final float shownY = defaultY;
                final float startY = show ? hiddenY : shownY;
                final float endY = show ? shownY : hiddenY;
                if (mImeShowing && show) {
                    // IME is already showing, so set seek to end
                    seekValue = shownY;
                    seek = true;
                }
                mImeShowing = show;
                mAnimation = ValueAnimator.ofFloat(startY, endY);
                mAnimation.setDuration(
+3 −3
Original line number Diff line number Diff line
@@ -2275,9 +2275,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            return false;
        }

        if (PixelFormat.formatHasAlpha(mAttrs.format) && mAttrs.alpha == 0) {
            // Support legacy use cases where completely transparent windows can still be ime target
            // with FLAG_NOT_FOCUSABLE and ALT_FOCUSABLE_IM set.
        if (PixelFormat.formatHasAlpha(mAttrs.format)) {
            // Support legacy use cases where transparent windows can still be ime target with
            // FLAG_NOT_FOCUSABLE and ALT_FOCUSABLE_IM set.
            // Certain apps listen for IME insets using transparent windows and ADJUST_NOTHING to
            // manually synchronize app content to IME animation b/144619551.
            // TODO(b/145812508): remove this once new focus management is complete b/141738570
+0 −2
Original line number Diff line number Diff line
@@ -251,11 +251,9 @@ public class WindowStateTests extends WindowTestsBase {

        // b/145812508: special legacy use-case for transparent/translucent windows.
        appWindow.mAttrs.format = PixelFormat.TRANSPARENT;
        appWindow.mAttrs.alpha = 0;
        assertTrue(appWindow.canBeImeTarget());

        appWindow.mAttrs.format = PixelFormat.OPAQUE;
        appWindow.mAttrs.alpha = 1;
        appWindow.mAttrs.flags &= ~FLAG_ALT_FOCUSABLE_IM;
        assertFalse(appWindow.canBeImeTarget());
        appWindow.mAttrs.flags &= ~FLAG_NOT_FOCUSABLE;