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

Commit 6c3c5890 authored by Martin Brabham's avatar Martin Brabham Committed by Martin Brabham
Browse files

Stop contact editor from adding empty field if no more types.

If there was a field with 1 type and you entered in a value it
popped up a new field for the same kind.

i.e. Add a birth date for new exchange contact

Change-Id: I3a0567d8f4c031ad6bfb0772dac5d116547f6041
Ticket-Id: HAM-291
parent b4021e77
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;

import com.android.contacts.R;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.editor.Editor.EditorListener;
import com.android.contacts.common.model.RawContactModifier;
import com.android.contacts.common.model.RawContactDelta;
@@ -222,6 +223,18 @@ public class KindSectionView extends LinearLayout implements EditorListener {

        final List<View> emptyEditors = getEmptyEditors();

        // Check for primary best type
        AccountType.EditType bestType = RawContactModifier.getBestValidType(mState, mKind, false,
                Integer.MIN_VALUE);
        if (bestType == null) {
            // Fall back to seconday best type
            bestType = RawContactModifier.getBestValidType(mState, mKind, true, Integer.MIN_VALUE);
        }
        // If no type then we don't need an empty for it
        if (bestType == null) {
            return;
        }

        // If there is more than 1 empty editor, then remove it from the list of editors.
        if (emptyEditors.size() > 1) {
            for (final View emptyEditorView : emptyEditors) {