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

Commit 88b0a8cc authored by Walter Jang's avatar Walter Jang
Browse files

Revert KindSectionView logic NOT show an empty input field

We don't need to make it optional to show an emtpy input
field since we've changed our minds on not allowing
users to add email and phone numbers on the compact editor.

Bug 21661221

Change-Id: Iec0d3a37a76c787d17922dbc184142dfca98a9de
parent ebf11651
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -474,17 +474,15 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
                    // Only add nicknames if there is a non-empty one
                    if (hasNonEmptyValuesDelta(rawContactDelta, mimeType, dataKind)) {
                        mNicknames.addView(inflateKindSectionView(mNicknames, dataKind,
                                rawContactDelta, /* showOneEmptyEditor =*/ false));
                                rawContactDelta));
                    }
                } else if (Phone.CONTENT_ITEM_TYPE.equals(mimeType)) {
                    mPhoneNumbers.addView(inflateKindSectionView(mPhoneNumbers, dataKind,
                            rawContactDelta, /* showOneEmptyEditor =*/ true));
                            rawContactDelta));
                } else if (Email.CONTENT_ITEM_TYPE.equals(mimeType)) {
                    mEmails.addView(inflateKindSectionView(mEmails, dataKind, rawContactDelta,
                            /* showOneEmptyEditor =*/ true));
                    mEmails.addView(inflateKindSectionView(mEmails, dataKind, rawContactDelta));
                } else if (hasNonEmptyValuesDelta(rawContactDelta, mimeType, dataKind)) {
                    mOther.addView(inflateKindSectionView(mOther, dataKind, rawContactDelta,
                            /* showOneEmptyEditor =*/ false));
                    mOther.addView(inflateKindSectionView(mOther, dataKind, rawContactDelta));
                }
            }
        }
@@ -615,14 +613,13 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
    }

    private KindSectionView inflateKindSectionView(ViewGroup viewGroup, DataKind dataKind,
            RawContactDelta rawContactDelta, boolean showOneEmptyEditor) {
            RawContactDelta rawContactDelta) {
        final KindSectionView result = (KindSectionView) mLayoutInflater.inflate(
                R.layout.item_kind_section, viewGroup, /* attachToRoot =*/ false);
        result.setState(
                dataKind,
                rawContactDelta,
                /* readOnly =*/ false,
                showOneEmptyEditor,
                mViewIdGenerator);
        return result;
    }
+2 −21
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ public class KindSectionView extends LinearLayout implements EditorListener {
    private DataKind mKind;
    private RawContactDelta mState;
    private boolean mReadOnly;
    private boolean mShowOneEmptyEditor;

    private ViewIdGenerator mViewIdGenerator;

@@ -126,16 +125,11 @@ public class KindSectionView extends LinearLayout implements EditorListener {
        }
    }

    /**
     * @param showOneEmptyEditor If true, one empty input will always be displayed,
     *         otherwise an empty input will only be displayed if there is no non-empty value.
     */
    public void setState(DataKind kind, RawContactDelta state, boolean readOnly,
            boolean showOneEmptyEditor, ViewIdGenerator vig) {
            ViewIdGenerator vig) {
        mKind = kind;
        mState = state;
        mReadOnly = readOnly;
        mShowOneEmptyEditor = showOneEmptyEditor;
        mViewIdGenerator = vig;

        setId(mViewIdGenerator.getId(state, kind, null, ViewIdGenerator.NO_VIEW_INDEX));
@@ -260,7 +254,7 @@ public class KindSectionView extends LinearLayout implements EditorListener {
        } else if (emptyEditors.size() == 1) {
            // We have already reached the maximum number of empty editors. Lets not add any more.
            return;
        } else if (mShowOneEmptyEditor || !hasNonEmptyEditor()) {
        } else {
            final ValuesDelta values = RawContactModifier.insertChild(mState, mKind);
            final View newField = createEditorView(values);
            if (shouldAnimate) {
@@ -270,19 +264,6 @@ public class KindSectionView extends LinearLayout implements EditorListener {
        }
    }

    /**
     * Whether there is at least one non-empty editor.
     */
    private boolean hasNonEmptyEditor() {
        for (int i = 0; i < mEditors.getChildCount(); i++) {
            View view = mEditors.getChildAt(i);
            if (!((Editor) view).isEmpty()) {
                return true;
            }
        }
        return false;
    }

    /**
     * Whether this section has any empty editors.
     */
+1 −2
Original line number Diff line number Diff line
@@ -302,8 +302,7 @@ public class RawContactEditorView extends BaseRawContactEditorView {
                final KindSectionView section = (KindSectionView)mInflater.inflate(
                        R.layout.item_kind_section, mFields, false);
                section.setEnabled(isEnabled());
                section.setState(kind, state, /* readOnly =*/ false,
                        /* showOneEmptyEditor =*/ true, vig);
                section.setState(kind, state, /* readOnly =*/ false, vig);
                mFields.addView(section);
            }
        }