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

Commit 3bbc280d authored by Matt Pietal's avatar Matt Pietal
Browse files

Keyguard: Fix missing IME, and apply better animations

Password bouncer: animate the text field alpha and y positioning along
with the IME reveal. Also fix the ordering of focus events to ensure
the soft keyboard appears.

Fixes: 174020436
Fixes: 175243820
Test: SystemUITests
Change-Id: I62898870f57da1cd5b3da6bc4a2cfb23fe95097f
parent 59ac27f9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -43,6 +43,10 @@ public abstract class KeyguardInputView extends LinearLayout {

    abstract CharSequence getTitle();

    void animateForIme(float interpolatedFraction) {
        return;
    }

    boolean disallowInterceptTouch(MotionEvent event) {
        return false;
    }
+3 −13
Original line number Diff line number Diff line
@@ -136,24 +136,14 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView {

    @Override
    public void startAppearAnimation() {
        // Reset state, and let IME animation reveal the view as it slides in
        setAlpha(0f);
        setTranslationY(0f);
        animate()
                .alpha(1)
                .withLayer()
                .setDuration(300)
                .setInterpolator(mLinearOutSlowInInterpolator);
    }

    @Override
    public boolean startDisappearAnimation(Runnable finishRunnable) {
        animate()
                .alpha(0f)
                .translationY(mDisappearYTranslation)
                .setInterpolator(mFastOutLinearInInterpolator)
                .setDuration(100)
                .withEndAction(finishRunnable);
        return true;
    public void animateForIme(float interpolatedFraction) {
        setAlpha(interpolatedFraction);
    }

    @Override
+12 −8
Original line number Diff line number Diff line
@@ -194,15 +194,19 @@ public class KeyguardPasswordViewController
    @Override
    public void onResume(int reason) {
        super.onResume(reason);
        // Wait a bit to focus the field so the focusable flag on the window is already set then.
        mMainExecutor.execute(() -> {
            if (mView.isShown() && mPasswordEntry.isEnabled()) {

        mPasswordEntry.requestFocus();
        if (reason != KeyguardSecurityView.SCREEN_ON || mShowImeAtScreenOn) {
            showInput();
        }
    }

    private void showInput() {
        mPasswordEntry.post(() -> {
            if (mPasswordEntry.isFocused() && mView.isShown()) {
                mInputMethodManager.showSoftInput(
                        mPasswordEntry, InputMethodManager.SHOW_IMPLICIT);
            }
            }
        });
    }

+7 −4
Original line number Diff line number Diff line
@@ -119,21 +119,24 @@ public class KeyguardSecurityContainer extends FrameLayout {
                @Override
                public WindowInsets onProgress(WindowInsets windowInsets,
                        List<WindowInsetsAnimation> list) {
                    int translationY = 0;
                    if (mDisappearAnimRunning) {
                        mSecurityViewFlipper.setTranslationY(
                                mInitialBounds.bottom - mFinalBounds.bottom);
                    } else {
                        int translationY = 0;
                        float interpolatedFraction = 1f;
                        for (WindowInsetsAnimation animation : list) {
                            if ((animation.getTypeMask() & WindowInsets.Type.ime()) == 0) {
                                continue;
                            }
                            interpolatedFraction = animation.getInterpolatedFraction();

                            final int paddingBottom = (int) MathUtils.lerp(
                                    mInitialBounds.bottom - mFinalBounds.bottom, 0,
                                    animation.getInterpolatedFraction());
                                    interpolatedFraction);
                            translationY += paddingBottom;
                        }
                        mSecurityViewFlipper.setTranslationY(translationY);
                        mSecurityViewFlipper.animateForIme(translationY, interpolatedFraction);
                    }
                    return windowInsets;
                }
@@ -141,7 +144,7 @@ public class KeyguardSecurityContainer extends FrameLayout {
                @Override
                public void onEnd(WindowInsetsAnimation animation) {
                    if (!mDisappearAnimRunning) {
                        mSecurityViewFlipper.setTranslationY(0);
                        mSecurityViewFlipper.animateForIme(0, /* interpolatedFraction */ 1f);
                    }
                }
            };
+10 −0
Original line number Diff line number Diff line
@@ -83,6 +83,16 @@ public class KeyguardSecurityViewFlipper extends ViewFlipper {
        return "";
    }

    /**
      * Translate the entire view, and optionally inform the wrapped view of the progress
      * so it can animate with the parent.
      */
    public void animateForIme(int translationY, float interpolatedFraction) {
        super.setTranslationY(translationY);
        KeyguardInputView v = getSecurityView();
        if (v != null) v.animateForIme(interpolatedFraction);
    }

    @Override
    protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
        return p instanceof LayoutParams;
Loading