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

Commit 11708263 authored by Walter Jang's avatar Walter Jang Committed by Android (Google) Code Review
Browse files

Merge "Hide types when the associated (empty) edit text loses focus" into mnc-dev

parents 613cc8fd f463e116
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -47,7 +47,15 @@ public class EditorAnimator {

    private AnimatorRunner mRunner = new AnimatorRunner();

    public void hideEditorView(final View victim) {
        removeEditorView(victim, /* removeVictimFromParent =*/ false);
    }

    public void removeEditorView(final View victim) {
        removeEditorView(victim, /* removeVictimFromParent =*/ true);
    }

    private void removeEditorView(final View victim, final boolean removeVictimFromParent) {
        mRunner.endOldAnimation();
        final int offset = victim.getHeight();

@@ -71,12 +79,16 @@ public class EditorAnimator {
                    final View view = viewsToMove.get(i);
                    view.setTranslationY(0.0f);
                }
                if (removeVictimFromParent) {
                    // Remove our target view (if parent is null, we were run several times by quick
                    // fingers. Just ignore)
                    final ViewGroup victimParent = (ViewGroup) victim.getParent();
                    if (victimParent != null) {
                        victimParent.removeView(victim);
                    }
                } else {
                    victim.setVisibility(View.GONE);
                }
            }
        });
    }
+10 −1
Original line number Diff line number Diff line
@@ -254,7 +254,16 @@ public abstract class LabeledEditorView extends LinearLayout implements Editor,
     */
    public void showType() {
        if (mHasTypes && mLabel != null && mLabel.getVisibility() != View.VISIBLE) {
            mLabel.setVisibility(View.VISIBLE);
            EditorAnimator.getInstance().slideAndFadeIn(mLabel, mLabel.getHeight());
        }
    }

    /**
     * Hides the type drop down if there are types to display and it is not already hidden.
     */
    public void hideType() {
        if (mHasTypes && mLabel != null && mLabel.getVisibility() != View.GONE) {
            EditorAnimator.getInstance().hideEditorView(mLabel);
        }
    }

+4 −0
Original line number Diff line number Diff line
@@ -159,7 +159,11 @@ public class TextFieldsEditorView extends LabeledEditorView {
                getEditorListener().onRequest(EditorListener.EDITOR_FOCUS_CHANGED);
            }
            if (foundFocus && !isTypeVisible()) {
                // We just got focus and the types are not visible
                showType();
            } else if (isEmpty()) {
                // We just lost focus and the field is empty
                hideType();
            }
            // Rebuild the label spinner using the new colors.
            rebuildLabel();