Merge "Show DialpadChooser correctly."
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 999531e..b1f9f6f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1019,8 +1019,8 @@
was found that could perform the selected action -->
<string name="quickcontact_missing_app">No application found to handle this action</string>
- <!-- Shown as the header name for a person when the name is missing or unknown. -->
- <string name="quickcontact_missing_name">Unknown</string>
+ <!-- Shown as the display name for a person when the name is missing or unknown. [CHAR LIMIT=18]-->
+ <string name="missing_name">(no name)</string>
<!-- The menu item to open the list of accounts -->
<string name="menu_accounts">Accounts</string>
diff --git a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
index a22102a..7144dfb 100644
--- a/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
+++ b/src/com/android/contacts/detail/ContactDetailDisplayUtils.java
@@ -99,6 +99,8 @@
styledName = altDisplayName;
}
}
+ } else {
+ styledName = context.getResources().getString(R.string.missing_name);
}
return styledName;
}
diff --git a/src/com/android/contacts/group/GroupBrowseListAdapter.java b/src/com/android/contacts/group/GroupBrowseListAdapter.java
index 753261a..630a397 100644
--- a/src/com/android/contacts/group/GroupBrowseListAdapter.java
+++ b/src/com/android/contacts/group/GroupBrowseListAdapter.java
@@ -56,6 +56,15 @@
public void setCursor(Cursor cursor) {
mCursor = cursor;
+
+ // If there's no selected group already and the cursor is valid, then by default, select the
+ // first group
+ if (mSelectedGroupUri == null && cursor != null && cursor.getCount() > 0) {
+ GroupListItem firstItem = getItem(0);
+ long groupId = (firstItem == null) ? null : firstItem.getGroupId();
+ mSelectedGroupUri = getGroupUriFromId(groupId);
+ }
+
notifyDataSetChanged();
}
@@ -89,6 +98,10 @@
return mSelectedGroupUri != null && mSelectedGroupUri.equals(groupUri);
}
+ public Uri getSelectedGroup() {
+ return mSelectedGroupUri;
+ }
+
@Override
public int getCount() {
return mCursor == null ? 0 : mCursor.getCount();
diff --git a/src/com/android/contacts/group/GroupBrowseListFragment.java b/src/com/android/contacts/group/GroupBrowseListFragment.java
index a1544cf..835400f 100644
--- a/src/com/android/contacts/group/GroupBrowseListFragment.java
+++ b/src/com/android/contacts/group/GroupBrowseListFragment.java
@@ -223,6 +223,7 @@
}
mListView.setEmptyView(mEmptyView);
+ mSelectedGroupUri = mAdapter.getSelectedGroup();
if (mSelectionVisible && mSelectedGroupUri != null) {
viewGroup(mSelectedGroupUri);
}
diff --git a/src/com/android/contacts/list/ContactListAdapter.java b/src/com/android/contacts/list/ContactListAdapter.java
index 7322fc6..467dcc3 100644
--- a/src/com/android/contacts/list/ContactListAdapter.java
+++ b/src/com/android/contacts/list/ContactListAdapter.java
@@ -15,6 +15,8 @@
*/
package com.android.contacts.list;
+import com.android.contacts.R;
+
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
@@ -28,7 +30,6 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
-import android.widget.QuickContactBadge;
/**
* A cursor adapter for the {@link ContactsContract.Contacts#CONTENT_TYPE} content type.
@@ -121,7 +122,7 @@
public ContactListAdapter(Context context) {
super(context);
- mUnknownNameText = context.getText(android.R.string.unknownName);
+ mUnknownNameText = context.getText(R.string.missing_name);
mViewTypeProfileEntry = getViewTypeCount() - 1;
}
diff --git a/src/com/android/contacts/list/ContactTileAdapter.java b/src/com/android/contacts/list/ContactTileAdapter.java
index 8993cdd..1e65612 100644
--- a/src/com/android/contacts/list/ContactTileAdapter.java
+++ b/src/com/android/contacts/list/ContactTileAdapter.java
@@ -24,6 +24,7 @@
import android.content.ContentUris;
import android.content.Context;
+import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
@@ -50,6 +51,7 @@
private DisplayType mDisplayType;
private Listener mListener;
private Context mContext;
+ private Resources mResources;
private Cursor mContactCursor = null;
private ContactPhotoManager mPhotoManager;
@@ -114,6 +116,7 @@
DisplayType displayType) {
mListener = listener;
mContext = context;
+ mResources = context.getResources();
mColumnCount = (displayType == DisplayType.FREQUENT_ONLY ? 1 : numCols);
mDisplayType = displayType;
@@ -213,7 +216,8 @@
String lookupKey = cursor.getString(mLookupIndex);
ContactEntry contact = new ContactEntry();
- contact.name = cursor.getString(mNameIndex);
+ String name = cursor.getString(mNameIndex);
+ contact.name = (name != null) ? name : mResources.getString(R.string.missing_name);
contact.status = cursor.getString(mStatusIndex);
contact.photoUri = (photoUri != null ? Uri.parse(photoUri) : null);
contact.lookupKey = ContentUris.withAppendedId(
@@ -223,8 +227,8 @@
if (mDisplayType == DisplayType.STREQUENT_PHONE_ONLY) {
int phoneNumberType = cursor.getInt(mPhoneNumberTypeIndex);
String phoneNumberCustomLabel = cursor.getString(mPhoneNumberLabelIndex);
- contact.phoneLabel = (String) Phone.getTypeLabel(mContext.getResources(),
- phoneNumberType, phoneNumberCustomLabel);
+ contact.phoneLabel = (String) Phone.getTypeLabel(mResources, phoneNumberType,
+ phoneNumberCustomLabel);
contact.phoneNumber = cursor.getString(mPhoneNumberIndex);
} else {
contact.status = cursor.getString(mStatusIndex);
diff --git a/src/com/android/contacts/quickcontact/QuickContactActivity.java b/src/com/android/contacts/quickcontact/QuickContactActivity.java
index 47e7173..d236e01 100644
--- a/src/com/android/contacts/quickcontact/QuickContactActivity.java
+++ b/src/com/android/contacts/quickcontact/QuickContactActivity.java
@@ -228,7 +228,7 @@
// find and prepare correct header view
mPhotoContainer = findViewById(R.id.photo_container);
- setHeaderText(R.id.name, R.string.quickcontact_missing_name);
+ setHeaderNameText(R.id.name, R.string.missing_name);
setHeaderText(R.id.status, null);
setHeaderText(R.id.timestamp, null);
setHeaderImage(R.id.presence, null);
@@ -317,12 +317,33 @@
}
};
- /** Assign this string to the view, if found in {@link #mPhotoContainer}. */
+ /** Assign this string to the view if it is not empty. */
+ private void setHeaderNameText(int id, int resId) {
+ setHeaderNameText(id, getText(resId));
+ }
+
+ /** Assign this string to the view if it is not empty. */
+ private void setHeaderNameText(int id, CharSequence value) {
+ final View view = mPhotoContainer.findViewById(id);
+ if (view instanceof TextView) {
+ if (!TextUtils.isEmpty(value)) {
+ ((TextView)view).setText(value);
+ }
+ }
+ }
+
+ /**
+ * Assign this string to the view (if found in {@link #mPhotoContainer}), or hiding this view
+ * if there is no string.
+ */
private void setHeaderText(int id, int resId) {
setHeaderText(id, getText(resId));
}
- /** Assign this string to the view, if found in {@link #mPhotoContainer}. */
+ /**
+ * Assign this string to the view (if found in {@link #mPhotoContainer}), or hiding this view
+ * if there is no string.
+ */
private void setHeaderText(int id, CharSequence value) {
final View view = mPhotoContainer.findViewById(id);
if (view instanceof TextView) {
@@ -483,7 +504,7 @@
final Drawable statusIcon = ContactPresenceIconUtil.getChatCapabilityIcon(
context, presence, chatCapability);
- setHeaderText(R.id.name, name);
+ setHeaderNameText(R.id.name, name);
// TODO: Bring this back once we have a design
// setHeaderImage(R.id.presence, statusIcon);
}
diff --git a/src/com/android/contacts/socialwidget/SocialWidgetProvider.java b/src/com/android/contacts/socialwidget/SocialWidgetProvider.java
index 3d7881b..4686c81 100644
--- a/src/com/android/contacts/socialwidget/SocialWidgetProvider.java
+++ b/src/com/android/contacts/socialwidget/SocialWidgetProvider.java
@@ -186,6 +186,10 @@
SpannableStringBuilder sb = new SpannableStringBuilder();
CharSequence name = displayName;
+ // If there is no display name, use the default missing name string
+ if (TextUtils.isEmpty(name)) {
+ name = context.getString(R.string.missing_name);
+ }
if (!TextUtils.isEmpty(phoneticName)) {
name = context.getString(R.string.widget_name_and_phonetic,
name, phoneticName);