Merge "Centralize number of lines to display in DataKind."
diff --git a/src/com/android/contacts/detail/ContactDetailFragment.java b/src/com/android/contacts/detail/ContactDetailFragment.java
index a5bea92..8f77371 100644
--- a/src/com/android/contacts/detail/ContactDetailFragment.java
+++ b/src/com/android/contacts/detail/ContactDetailFragment.java
@@ -133,13 +133,6 @@
private static final String KEY_CONTACT_URI = "contactUri";
private static final String KEY_LIST_STATE = "liststate";
- // TODO: Make maxLines a field in {@link DataKind}
- private static final int WEBSITE_MAX_LINES = 1;
- private static final int SIP_ADDRESS_MAX_LINES= 1;
- private static final int POSTAL_ADDRESS_MAX_LINES = 10;
- private static final int GROUP_MAX_LINES = 10;
- private static final int NOTE_MAX_LINES = 100;
-
private Context mContext;
private View mView;
private OnScrollListener mVerticalScrollListener;
@@ -595,6 +588,7 @@
final DetailViewEntry entry = DetailViewEntry.fromValues(mContext, mimeType, kind,
dataId, entryValues, mContactData.isDirectoryEntry(),
mContactData.getDirectoryId());
+ entry.maxLines = kind.maxLinesForDisplay;
final boolean hasData = !TextUtils.isEmpty(entry.data);
Integer superPrimary = entryValues.getAsInteger(Data.IS_SUPER_PRIMARY);
@@ -651,11 +645,11 @@
mContactData.getDirectoryId());
buildImActions(mContext, imEntry, entryValues);
imEntry.applyStatus(status, false);
+ imEntry.maxLines = imKind.maxLinesForDisplay;
mImEntries.add(imEntry);
}
} else if (StructuredPostal.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) {
// Build postal entries
- entry.maxLines = POSTAL_ADDRESS_MAX_LINES;
entry.intent = StructuredPostalUtils.getViewPostalAddressIntent(entry.data);
mPostalEntries.add(entry);
} else if (Im.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) {
@@ -687,12 +681,10 @@
} else if (Note.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) {
// Build note entries
entry.uri = null;
- entry.maxLines = NOTE_MAX_LINES;
mNoteEntries.add(entry);
} else if (Website.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) {
// Build Website entries
entry.uri = null;
- entry.maxLines = WEBSITE_MAX_LINES;
try {
WebAddress webAddress = new WebAddress(entry.data);
entry.intent = new Intent(Intent.ACTION_VIEW,
@@ -704,7 +696,6 @@
} else if (SipAddress.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) {
// Build SipAddress entries
entry.uri = null;
- entry.maxLines = SIP_ADDRESS_MAX_LINES;
if (mHasSip) {
entry.intent = ContactsUtils.getCallIntent(
Uri.fromParts(Constants.SCHEME_SIP, entry.data, null));
@@ -768,7 +759,6 @@
entry.mimetype = GroupMembership.MIMETYPE;
entry.kind = mContext.getString(R.string.groupsLabel);
entry.data = sb.toString();
- entry.maxLines = GROUP_MAX_LINES;
mGroupEntries.add(entry);
}
}
diff --git a/src/com/android/contacts/model/BaseAccountType.java b/src/com/android/contacts/model/BaseAccountType.java
index cd113eb..4d82ece 100644
--- a/src/com/android/contacts/model/BaseAccountType.java
+++ b/src/com/android/contacts/model/BaseAccountType.java
@@ -79,6 +79,12 @@
protected static final int FLAGS_RELATION = EditorInfo.TYPE_CLASS_TEXT
| EditorInfo.TYPE_TEXT_FLAG_CAP_WORDS | EditorInfo.TYPE_TEXT_VARIATION_PERSON_NAME;
+ // Specify the maximum number of lines that can be used to display various field types. If no
+ // value is specified for a particular type, we use the default value from {@link DataKind}.
+ protected static final int MAX_LINES_FOR_POSTAL_ADDRESS = 10;
+ protected static final int MAX_LINES_FOR_GROUP = 10;
+ protected static final int MAX_LINES_FOR_NOTE = 100;
+
private interface Tag {
static final String DATA_KIND = "DataKind";
static final String TYPE = "Type";
@@ -323,6 +329,8 @@
new EditField(StructuredPostal.FORMATTED_ADDRESS, R.string.postal_address,
FLAGS_POSTAL));
+ kind.maxLinesForDisplay = MAX_LINES_FOR_POSTAL_ADDRESS;
+
return kind;
}
@@ -391,6 +399,8 @@
kind.fieldList = Lists.newArrayList();
kind.fieldList.add(new EditField(Note.NOTE, R.string.label_notes, FLAGS_NOTE));
+ kind.maxLinesForDisplay = MAX_LINES_FOR_NOTE;
+
return kind;
}
@@ -430,6 +440,8 @@
kind.fieldList = Lists.newArrayList();
kind.fieldList.add(new EditField(GroupMembership.GROUP_ROW_ID, -1, -1));
+ kind.maxLinesForDisplay = MAX_LINES_FOR_GROUP;
+
return kind;
}
@@ -1210,6 +1222,7 @@
R.string.postal_country, FLAGS_POSTAL).setOptional(true));
}
} else {
+ kind.maxLinesForDisplay= MAX_LINES_FOR_POSTAL_ADDRESS;
kind.fieldList.add(
new EditField(StructuredPostal.FORMATTED_ADDRESS, R.string.postal_address,
FLAGS_POSTAL));
@@ -1344,6 +1357,7 @@
new SimpleInflater(R.string.label_notes), new SimpleInflater(Note.NOTE));
kind.fieldList.add(new EditField(Note.NOTE, R.string.label_notes, FLAGS_NOTE));
+ kind.maxLinesForDisplay = MAX_LINES_FOR_NOTE;
throwIfList(kind);
@@ -1417,6 +1431,7 @@
R.string.groupsLabel, Weight.GROUP_MEMBERSHIP, -1, null, null);
kind.fieldList.add(new EditField(GroupMembership.GROUP_ROW_ID, -1, -1));
+ kind.maxLinesForDisplay = MAX_LINES_FOR_GROUP;
throwIfList(kind);
diff --git a/src/com/android/contacts/model/DataKind.java b/src/com/android/contacts/model/DataKind.java
index 857f3e4..c697e6f 100644
--- a/src/com/android/contacts/model/DataKind.java
+++ b/src/com/android/contacts/model/DataKind.java
@@ -83,8 +83,16 @@
*/
public SimpleDateFormat dateFormatWithYear;
+ /**
+ * The number of lines available for displaying this kind of data in a
+ * {@link ContactDetailFragment} (and possibly elsewhere)
+ * Defaults to 1.
+ */
+ public int maxLinesForDisplay;
+
public DataKind() {
editorLayoutResourceId = R.layout.text_fields_editor_view;
+ maxLinesForDisplay = 1;
}
public DataKind(String mimeType, int titleRes, int weight, boolean editable,
@@ -95,6 +103,7 @@
this.editable = editable;
this.typeOverallMax = -1;
this.editorLayoutResourceId = editorLayoutResourceId;
+ maxLinesForDisplay = 1;
}
@Override