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
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index b841f62..a34c911 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -474,17 +474,15 @@
// 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 @@
}
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;
}
diff --git a/src/com/android/contacts/editor/KindSectionView.java b/src/com/android/contacts/editor/KindSectionView.java
index adf2a73..a0df1c3 100644
--- a/src/com/android/contacts/editor/KindSectionView.java
+++ b/src/com/android/contacts/editor/KindSectionView.java
@@ -62,7 +62,6 @@
private DataKind mKind;
private RawContactDelta mState;
private boolean mReadOnly;
- private boolean mShowOneEmptyEditor;
private ViewIdGenerator mViewIdGenerator;
@@ -126,16 +125,11 @@
}
}
- /**
- * @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 @@
} 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) {
@@ -271,19 +265,6 @@
}
/**
- * 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.
*/
public boolean hasEmptyEditor() {
diff --git a/src/com/android/contacts/editor/RawContactEditorView.java b/src/com/android/contacts/editor/RawContactEditorView.java
index ee61857..d81dc47 100644
--- a/src/com/android/contacts/editor/RawContactEditorView.java
+++ b/src/com/android/contacts/editor/RawContactEditorView.java
@@ -302,8 +302,7 @@
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);
}
}