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

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

Merge "Don't hide types when associated label is empty" into ub-contactsdialer-a-dev

parents 96efbb85 f7dfa54e
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -417,12 +417,6 @@ public class CompactKindSectionView extends LinearLayout {
        final View view = mLayoutInflater.inflate(
                EditorUiUtils.getLayoutResourceId(dataKind.mimeType), mEditors, false);
        view.setEnabled(isEnabled());

        // Hide the types drop downs until the associated edit field is focused
        if (view instanceof LabeledEditorView) {
            ((LabeledEditorView) view).setHideTypeInitially(true);
        }

        if (view instanceof Editor) {
            final Editor editor = (Editor) view;
            editor.setDeletable(true);
+5 −17
Original line number Diff line number Diff line
@@ -47,15 +47,7 @@ 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();

@@ -79,16 +71,12 @@ 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);
                }
            }
        });
    }
+0 −6
Original line number Diff line number Diff line
@@ -84,9 +84,6 @@ public class EventFieldEditorView extends LabeledEditorView {
        mDateView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!isTypeVisible()) {
                    showType();
                }
                showDialog(R.id.dialog_event_date_picker);
            }
        });
@@ -134,9 +131,6 @@ public class EventFieldEditorView extends LabeledEditorView {
            mDateView.setText(data);
            mDateView.setTextColor(mPrimaryTextColor);
            setDeleteButtonVisible(true);
            if (!isTypeVisible()) {
                showType();
            }
        }
    }

+0 −6
Original line number Diff line number Diff line
@@ -194,13 +194,7 @@ public class KindSectionView extends LinearLayout implements EditorListener {
                    layoutResId + " for MIME type " + mKind.mimeType +
                    " with error " + e.toString());
        }
        // Hide the types drop downs until the associated edit field is focused
        if (view instanceof LabeledEditorView) {
            ((LabeledEditorView) view).setHideTypeInitially(true);
        }

        view.setEnabled(isEnabled());

        if (view instanceof Editor) {
            Editor editor = (Editor) view;
            editor.setDeletable(true);
+3 −41
Original line number Diff line number Diff line
@@ -79,8 +79,6 @@ public abstract class LabeledEditorView extends LinearLayout implements Editor,
    private boolean mWasEmpty = true;
    private boolean mIsDeletable = true;
    private boolean mIsAttachedToWindow;
    private boolean mHideTypeInitially;
    private boolean mHasTypes;

    private EditType mType;

@@ -239,39 +237,6 @@ public abstract class LabeledEditorView extends LinearLayout implements Editor,
        }
    }

    /**
     * Whether to hide the type dropdown after values have been set.
     * By default the drop down is always displayed if there are types to display.
     */
    public void setHideTypeInitially(boolean hideTypeInitially) {
        mHideTypeInitially = hideTypeInitially;
    }

    /**
     * Whether the type drop down is visible.
     */
    public boolean isTypeVisible() {
        return mLabel == null ? false : mLabel.getVisibility() == View.VISIBLE;
    }

    /**
     * Makes the type drop down visible if it is not already so, and there are types to display.
     */
    public void showType() {
        if (mHasTypes && mLabel != null && mLabel.getVisibility() != 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);
        }
    }

    protected void onOptionalFieldVisibilityChange() {
        if (mListener != null) {
            mListener.onRequest(EditorListener.EDITOR_FORM_CHANGED);
@@ -422,15 +387,12 @@ public abstract class LabeledEditorView extends LinearLayout implements Editor,
        setVisibility(View.VISIBLE);

        // Display label selector if multiple types available
        mHasTypes = RawContactModifier.hasEditTypes(kind);
        setupLabelButton(mHasTypes);
        final boolean hasTypes = RawContactModifier.hasEditTypes(kind);
        setupLabelButton(hasTypes);
        mLabel.setEnabled(!readOnly && isEnabled());
        if (mHasTypes) {
        if (hasTypes) {
            mType = RawContactModifier.getCurrentType(entry, kind);
            rebuildLabel();
            if (mHideTypeInitially) {
                mLabel.setVisibility(View.GONE);
            }
        }
    }

Loading