Fix a bug that caused contact card viewing to crash.
The uri that was passed with the ACTION_VIEW intent was malformed.
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index 6ab769a..af56caf 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -185,7 +185,7 @@
Aggregates.PRIMARY_PHONE_ID, //3
Aggregates.PRIMARY_EMAIL_ID, //4
};
-
+
static final String[] AGGREGATES_PRIMARY_PHONE_PROJECTION = new String[] {
Aggregates._ID, // 0
Aggregates.DISPLAY_NAME, // 1
@@ -195,7 +195,7 @@
CommonDataKinds.Phone.LABEL, //5
CommonDataKinds.Phone.NUMBER, //6
};
-
+
static final int ID_COLUMN_INDEX = 0;
static final int NAME_COLUMN_INDEX = 1;
static final int STARRED_COLUMN_INDEX = 2;
@@ -568,7 +568,7 @@
break;
} */
- case DISPLAY_TYPE_ALL:
+ case DISPLAY_TYPE_ALL:
default: {
mMode = MODE_ALL_CONTACTS;
mDisplayInfo = null;
@@ -823,7 +823,7 @@
return;
}
long id = info.id;
- Uri dataUri = Uri.withAppendedPath(Aggregates.CONTENT_URI, id + "/data");
+ Uri dataUri = ContentUris.withAppendedId(Aggregates.CONTENT_URI, id);
// Setup the menu header
menu.setHeaderTitle(cursor.getString(NAME_COLUMN_INDEX));
@@ -842,13 +842,13 @@
this, CommonDataKinds.Phone.CONTENT_ITEM_TYPE, type, label);
Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
ContentUris.withAppendedId(Data.CONTENT_URI, id));
- menu.add(0, MENU_ITEM_CALL, 0,
+ menu.add(0, MENU_ITEM_CALL, 0,
String.format(getString(R.string.menu_callNumber), label)).setIntent(intent);
// Send SMS item
menu.add(0, MENU_ITEM_SEND_SMS, 0, R.string.menu_sendSMS)
.setIntent(new Intent(Intent.ACTION_SENDTO,
- Uri.fromParts("sms",
+ Uri.fromParts("sms",
cursor.getString(PRIMARY_PHONE_NUMBER_COLUMN_INDEX), null)));
}
@@ -967,7 +967,7 @@
}
startActivity(intent);
finish();
- } else */
+ } else */
if (id != -1) {
if ((mMode & MODE_MASK_PICKER) == 0) {
Intent intent = new Intent(Intent.ACTION_VIEW,
@@ -1073,7 +1073,7 @@
} else {
return NAME_COLUMN + " COLLATE LOCALIZED ASC";
} */
-
+
return NAME_COLUMN + " COLLATE LOCALIZED ASC";
}
@@ -1095,9 +1095,9 @@
/* case MODE_PICK_CONTACT:
case MODE_PICK_OR_CREATE_CONTACT:
case MODE_INSERT_OR_EDIT_CONTACT: */
- mQueryHandler.startQuery(QUERY_TOKEN, null,
- Uri.parse(ContactsContract.AUTHORITY_URI + "/aggregates_primary_phone/*"),
- AGGREGATES_PRIMARY_PHONE_PROJECTION, null, null,
+ mQueryHandler.startQuery(QUERY_TOKEN, null,
+ Uri.parse(ContactsContract.AUTHORITY_URI + "/aggregates_primary_phone/*"),
+ AGGREGATES_PRIMARY_PHONE_PROJECTION, null, null,
getSortOrder(AGGREGATES_PRIMARY_PHONE_PROJECTION));
break;
@@ -1137,10 +1137,10 @@
} */
case MODE_STARRED:
- mQueryHandler.startQuery(QUERY_TOKEN, null,
+ mQueryHandler.startQuery(QUERY_TOKEN, null,
Uri.parse(ContactsContract.AUTHORITY_URI + "/aggregates_primary_phone/*"),
AGGREGATES_PRIMARY_PHONE_PROJECTION,
- Aggregates.STARRED + "=1", null,
+ Aggregates.STARRED + "=1", null,
getSortOrder(AGGREGATES_PRIMARY_PHONE_PROJECTION));
break;
@@ -1196,7 +1196,7 @@
case MODE_PICK_CONTACT:
case MODE_PICK_OR_CREATE_CONTACT:
case MODE_INSERT_OR_EDIT_CONTACT: {
- return resolver.query(getPeopleFilterUri(filter),
+ return resolver.query(getPeopleFilterUri(filter),
AGGREGATES_PRIMARY_PHONE_PROJECTION, null, null,
getSortOrder(AGGREGATES_PRIMARY_PHONE_PROJECTION));
}
@@ -1208,9 +1208,9 @@
}
case MODE_STARRED: {
- return resolver.query(getPeopleFilterUri(filter),
+ return resolver.query(getPeopleFilterUri(filter),
AGGREGATES_PRIMARY_PHONE_PROJECTION,
- Aggregates.STARRED + "=1", null,
+ Aggregates.STARRED + "=1", null,
getSortOrder(AGGREGATES_PRIMARY_PHONE_PROJECTION));
}
@@ -1587,7 +1587,7 @@
} else {
numberView.setVisibility(View.GONE);
labelView.setVisibility(View.GONE);
- }
+ }
// Set the label
if (!cursor.isNull(PRIMARY_PHONE_TYPE_COLUMN_INDEX)) {
@@ -1744,7 +1744,7 @@
public Object [] getSections() {
if (mMode == MODE_STARRED) {
return new String[] { " " };
- } else {
+ } else {
return mIndexer.getSections();
}
}
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java
index b38156d..a40d8b4 100644
--- a/src/com/android/contacts/ViewContactActivity.java
+++ b/src/com/android/contacts/ViewContactActivity.java
@@ -86,7 +86,7 @@
/**
* Displays the details of a specific contact.
*/
-public class ViewContactActivity extends ListActivity
+public class ViewContactActivity extends ListActivity
implements View.OnCreateContextMenuListener, View.OnClickListener,
DialogInterface.OnClickListener {
private static final String TAG = "ViewContact";
@@ -117,7 +117,7 @@
private Cursor mCursor;
private boolean mObserverRegistered;
-
+
private ContentObserver mObserver = new ContentObserver(new Handler()) {
@Override
public boolean deliverSelfNotifications() {
@@ -194,7 +194,7 @@
mNoPhotoResource = R.drawable.ic_contact_picture_3;
}
- mUri = getIntent().getData();
+ mUri = Uri.withAppendedPath(getIntent().getData(), "data");
mResolver = getContentResolver();
// Build the list of sections. The order they're added to mSections dictates the
@@ -283,7 +283,7 @@
// Load the photo
mPhotoView.setImageBitmap(People.loadContactPhoto(this, mUri, mNoPhotoResource,
null)); */
-
+
mPhotoView.setImageBitmap(BitmapFactory.decodeResource(getResources(),
mNoPhotoResource, null));
@@ -355,7 +355,7 @@
Log.e(TAG, "bad menuInfo");
return;
}
-
+
// TODO(emillar) Bring this back.
/*ViewEntry entry = ContactEntryAdapter.getEntry(mSections, info.position, SHOW_SEPARATORS);
switch (entry.kind) {
@@ -377,7 +377,7 @@
menu.add(0, 0, 0, R.string.menu_viewAddress).setIntent(entry.intent);
break;
}
-
+
case ContactEntryAdapter.Entry.KIND_GROUP: {
menu.add(0, 0, 0, R.string.menu_viewGroup).setIntent(entry.intent);
break;
@@ -393,7 +393,7 @@
showDialog(DIALOG_CONFIRM_DELETE);
return true;
}
-
+
// TODO(emillar) Bring this back.
/*case MENU_ITEM_SHOW_BARCODE:
if (mCursor.moveToFirst()) {
@@ -404,7 +404,7 @@
if (!TextUtils.isEmpty(name)) {
// Correctly handle when section headers are hidden
int sepAdjust = SHOW_SEPARATORS ? 1 : 0;
-
+
bundle.putString(Contacts.Intents.Insert.NAME, name);
// The 0th ViewEntry in each ArrayList below is a separator item
int entriesToAdd = Math.min(mPhoneEntries.size() - sepAdjust, PHONE_KEYS.length);
@@ -439,7 +439,7 @@
}
return super.onOptionsItemSelected(item);
}
-
+
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
@@ -535,7 +535,7 @@
*/
private void buildSeparators() {
ViewEntry separator;
-
+
separator = new ViewEntry();
separator.kind = ViewEntry.KIND_SEPARATOR;
separator.data = getString(R.string.listSeparatorCallNumber);
@@ -588,7 +588,7 @@
/**
* Build up the entries to display on the screen.
- *
+ *
* @param personCursor the URI for the contact being displayed
*/
private final void buildEntries(Cursor aggCursor) {
@@ -601,13 +601,13 @@
if (SHOW_SEPARATORS) {
buildSeparators();
}
-
+
// Build up method entries
if (mUri != null) {
while (aggCursor.moveToNext()) {
final String mimetype = aggCursor.getString(DATA_MIMETYPE_COLUMN);
final String pkg = aggCursor.getString(DATA_PACKAGE_COLUMN);
-
+
ViewEntry entry = new ViewEntry();
final long id = aggCursor.getLong(DATA_ID_COLUMN);
@@ -618,8 +618,8 @@
entry.kind = 0;
if (mimetype.equals(CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
- || mimetype.equals(CommonDataKinds.Email.CONTENT_ITEM_TYPE)
- || mimetype.equals(CommonDataKinds.Postal.CONTENT_ITEM_TYPE)
+ || mimetype.equals(CommonDataKinds.Email.CONTENT_ITEM_TYPE)
+ || mimetype.equals(CommonDataKinds.Postal.CONTENT_ITEM_TYPE)
|| mimetype.equals(CommonDataKinds.Im.CONTENT_ITEM_TYPE)) {
final int type = aggCursor.getInt(DATA_1_COLUMN);
final String label = aggCursor.getString(DATA_2_COLUMN);
@@ -635,7 +635,7 @@
// Build phone entries
if (mimetype.equals(CommonDataKinds.Phone.CONTENT_ITEM_TYPE)) {
mNumPhoneNumbers++;
-
+
final CharSequence displayLabel = ContactsUtils.getDisplayLabel(
this, mimetype, type, label);
entry.label = buildActionString(R.string.actionCall, displayLabel, true);
@@ -649,7 +649,7 @@
entry.actionIcon = android.R.drawable.sym_action_call;
mPhoneEntries.add(entry);
- if (type == CommonDataKinds.Phone.TYPE_MOBILE
+ if (type == CommonDataKinds.Phone.TYPE_MOBILE
|| mShowSmsLinksForAllPhones) {
// Add an SMS entry
ViewEntry smsEntry = new ViewEntry();
@@ -721,7 +721,7 @@
}*/
entry.actionIcon = android.R.drawable.sym_action_chat;
mImEntries.add(entry);
- }
+ }
// Build organization entries
} else if (mimetype.equals(CommonDataKinds.Organization.CONTENT_ITEM_TYPE)) {
final int type = aggCursor.getInt(DATA_1_COLUMN);
@@ -733,13 +733,13 @@
if (isPrimary) {
entry.primaryIcon = R.drawable.ic_default_number;
}
-
+
// Don't crash if the data is bogus
if (TextUtils.isEmpty(company) && TextUtils.isEmpty(title)) {
Log.w(TAG, "empty data for contact method " + id);
continue;
}
-
+
entry.data = title;
entry.actionIcon = R.drawable.sym_action_organization;
entry.label = company;
@@ -759,17 +759,17 @@
Log.w(TAG, "empty data for contact method " + id);
continue;
}
-
+
mOtherEntries.add(entry);
// Build the ringtone and send to voicemail entries
} else if (mimetype.equals(CommonDataKinds.CustomRingtone.CONTENT_ITEM_TYPE)) {
final Boolean sendToVoicemail = "1".equals(aggCursor.getString(DATA_1_COLUMN));
final String ringtoneStr = aggCursor.getString(DATA_2_COLUMN);
- // TODO(emillar) we need to enforce uniqueness of custom ringtone entries on a
+ // TODO(emillar) we need to enforce uniqueness of custom ringtone entries on a
// single aggregate. This could be done by checking against the reference ID stored
// in the aggregate.
-
+
// Build the send directly to voice mail entry
if (sendToVoicemail) {
entry.label = getString(R.string.actionIncomingCall);
@@ -791,7 +791,7 @@
}
}
}
-
+
// TODO(emillar) Add group entries
// // Build the group entries
// final Uri groupsUri = Uri.withAppendedPath(mUri, GroupMembership.CONTENT_DIRECTORY);
@@ -834,7 +834,7 @@
// groupCursor.close();
// }
// }
-
+
}
}
}
@@ -852,7 +852,7 @@
return getString(actionResId, type.toString());
}
}
-
+
/**
* A basic structure with the data for a contact entry in the list.
*/
@@ -872,18 +872,18 @@
public TextView data;
public ImageView actionIcon;
public ImageView presenceIcon;
-
+
// Need to keep track of this too
ViewEntry entry;
}
-
+
ViewAdapter(Context context, ArrayList<ArrayList<ViewEntry>> sections) {
super(context, sections, SHOW_SEPARATORS);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
- ViewEntry entry = getEntry(mSections, position, false);
+ ViewEntry entry = getEntry(mSections, position, false);
View v;
// Handle separators specially