Merge change 22023 into eclair-dev
* changes:
Fixing the Split contact UI
diff --git a/src/com/android/contacts/CallDetailActivity.java b/src/com/android/contacts/CallDetailActivity.java
index d7d888c..b2baa2c 100644
--- a/src/com/android/contacts/CallDetailActivity.java
+++ b/src/com/android/contacts/CallDetailActivity.java
@@ -28,10 +28,10 @@
import android.net.Uri;
import android.os.Bundle;
import android.provider.CallLog;
-import android.provider.Contacts;
import android.provider.CallLog.Calls;
-import android.provider.Contacts.People;
-import android.provider.Contacts.Phones;
+import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.PhoneLookup;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.Contacts.Intents.Insert;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
@@ -63,28 +63,28 @@
private TextView mCallDuration;
private String mNumber = null;
-
+
/* package */ LayoutInflater mInflater;
/* package */ Resources mResources;
-
+
static final String[] CALL_LOG_PROJECTION = new String[] {
CallLog.Calls.DATE,
CallLog.Calls.DURATION,
CallLog.Calls.NUMBER,
CallLog.Calls.TYPE,
};
-
+
static final int DATE_COLUMN_INDEX = 0;
static final int DURATION_COLUMN_INDEX = 1;
static final int NUMBER_COLUMN_INDEX = 2;
static final int CALL_TYPE_COLUMN_INDEX = 3;
-
+
static final String[] PHONES_PROJECTION = new String[] {
- Phones.PERSON_ID,
- Phones.DISPLAY_NAME,
- Phones.TYPE,
- Phones.LABEL,
- Phones.NUMBER,
+ PhoneLookup._ID,
+ PhoneLookup.DISPLAY_NAME,
+ PhoneLookup.TYPE,
+ PhoneLookup.LABEL,
+ PhoneLookup.NUMBER,
};
static final int COLUMN_INDEX_ID = 0;
static final int COLUMN_INDEX_NAME = 1;
@@ -100,15 +100,15 @@
mInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
mResources = getResources();
-
+
mCallType = (TextView) findViewById(R.id.type);
mCallTypeIcon = (ImageView) findViewById(R.id.icon);
mCallTime = (TextView) findViewById(R.id.time);
mCallDuration = (TextView) findViewById(R.id.duration);
-
+
getListView().setOnItemClickListener(this);
}
-
+
@Override
public void onResume() {
super.onResume();
@@ -130,13 +130,13 @@
}
}
}
-
+
return super.onKeyDown(keyCode, event);
}
-
+
/**
* Update user interface with details of given call.
- *
+ *
* @param callUri Uri into {@link CallLog.Calls}
*/
private void updateData(Uri callUri) {
@@ -149,13 +149,13 @@
long date = callCursor.getLong(DATE_COLUMN_INDEX);
long duration = callCursor.getLong(DURATION_COLUMN_INDEX);
int callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX);
-
+
// Pull out string in format [relative], [date]
CharSequence dateClause = DateUtils.formatDateRange(this, date, date,
DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE |
DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_YEAR);
mCallTime.setText(dateClause);
-
+
// Set the duration
if (callType == Calls.MISSED_TYPE) {
mCallDuration.setVisibility(View.GONE);
@@ -163,7 +163,7 @@
mCallDuration.setVisibility(View.VISIBLE);
mCallDuration.setText(formatDuration(duration));
}
-
+
// Set the call type icon and caption
String callText = null;
switch (callType) {
@@ -172,43 +172,44 @@
mCallType.setText(R.string.type_incoming);
callText = getString(R.string.callBack);
break;
-
+
case Calls.OUTGOING_TYPE:
mCallTypeIcon.setImageResource(R.drawable.ic_call_log_header_outgoing_call);
mCallType.setText(R.string.type_outgoing);
callText = getString(R.string.callAgain);
break;
-
+
case Calls.MISSED_TYPE:
mCallTypeIcon.setImageResource(R.drawable.ic_call_log_header_missed_call);
mCallType.setText(R.string.type_missed);
callText = getString(R.string.returnCall);
break;
}
-
+
if (mNumber.equals(CallerInfo.UNKNOWN_NUMBER) ||
mNumber.equals(CallerInfo.PRIVATE_NUMBER)) {
// List is empty, let the empty view show instead.
TextView emptyText = (TextView) findViewById(R.id.emptyText);
if (emptyText != null) {
- emptyText.setText(mNumber.equals(CallerInfo.PRIVATE_NUMBER)
+ emptyText.setText(mNumber.equals(CallerInfo.PRIVATE_NUMBER)
? R.string.private_num : R.string.unknown);
}
} else {
// Perform a reverse-phonebook lookup to find the PERSON_ID
String callLabel = null;
Uri personUri = null;
- Uri phoneUri = Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, Uri.encode(mNumber));
+ Uri phoneUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
+ Uri.encode(mNumber));
Cursor phonesCursor = resolver.query(phoneUri, PHONES_PROJECTION, null, null, null);
try {
if (phonesCursor != null && phonesCursor.moveToFirst()) {
long personId = phonesCursor.getLong(COLUMN_INDEX_ID);
personUri = ContentUris.withAppendedId(
- Contacts.People.CONTENT_URI, personId);
+ Contacts.CONTENT_URI, personId);
callText = getString(R.string.recentCalls_callNumber,
phonesCursor.getString(COLUMN_INDEX_NAME));
mNumber = phonesCursor.getString(COLUMN_INDEX_NUMBER);
- callLabel = Phones.getDisplayLabel(this,
+ callLabel = Phone.getDisplayLabel(this,
phonesCursor.getInt(COLUMN_INDEX_TYPE),
phonesCursor.getString(COLUMN_INDEX_LABEL)).toString();
} else {
@@ -217,10 +218,10 @@
} finally {
if (phonesCursor != null) phonesCursor.close();
}
-
+
// Build list of various available actions
List<ViewEntry> actions = new ArrayList<ViewEntry>();
-
+
Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED,
Uri.fromParts("tel", mNumber, null));
ViewEntry entry = new ViewEntry(android.R.drawable.sym_action_call, callText,
@@ -228,12 +229,12 @@
entry.number = mNumber;
entry.label = callLabel;
actions.add(entry);
-
+
Intent smsIntent = new Intent(Intent.ACTION_SENDTO,
Uri.fromParts("sms", mNumber, null));
actions.add(new ViewEntry(R.drawable.sym_action_sms,
getString(R.string.menu_sendTextMessage), smsIntent));
-
+
// Let user view contact details if they exist, otherwise add option
// to create new contact from this number.
if (personUri != null) {
@@ -242,12 +243,12 @@
getString(R.string.menu_viewContact), viewIntent));
} else {
Intent createIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
- createIntent.setType(People.CONTENT_ITEM_TYPE);
+ createIntent.setType(Contacts.CONTENT_ITEM_TYPE);
createIntent.putExtra(Insert.PHONE, mNumber);
actions.add(new ViewEntry(R.drawable.sym_action_add,
getString(R.string.recentCalls_addToContact), createIntent));
}
-
+
ViewAdapter adapter = new ViewAdapter(this, actions);
setListAdapter(adapter);
}
@@ -284,7 +285,7 @@
public Intent intent = null;
public String label = null;
public String number = null;
-
+
public ViewEntry(int icon, String text, Intent intent) {
this.icon = icon;
this.text = text;
@@ -293,16 +294,16 @@
}
static final class ViewAdapter extends BaseAdapter {
-
+
private final List<ViewEntry> mActions;
-
+
private final LayoutInflater mInflater;
-
+
public ViewAdapter(Context context, List<ViewEntry> actions) {
mActions = actions;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
-
+
public int getCount() {
return mActions.size();
}
@@ -314,7 +315,7 @@
public long getItemId(int position) {
return position;
}
-
+
public View getView(int position, View convertView, ViewGroup parent) {
// Make sure we have a valid convertView to start with
if (convertView == null) {
@@ -324,7 +325,7 @@
// Fill action with icon and text.
ViewEntry entry = mActions.get(position);
convertView.setTag(entry);
-
+
ImageView icon = (ImageView) convertView.findViewById(R.id.icon);
TextView text = (TextView) convertView.findViewById(android.R.id.text1);
@@ -338,7 +339,7 @@
line2.setVisibility(View.GONE);
} else {
line2.setVisibility(View.VISIBLE);
-
+
TextView label = (TextView) convertView.findViewById(R.id.label);
if (labelEmpty) {
label.setVisibility(View.GONE);
@@ -350,11 +351,11 @@
TextView number = (TextView) convertView.findViewById(R.id.number);
number.setText(entry.number);
}
-
+
return convertView;
}
}
-
+
public void onItemClick(AdapterView parent, View view, int position, long id) {
// Handle passing action off to correct handler.
if (view.getTag() instanceof ViewEntry) {
@@ -363,5 +364,5 @@
startActivity(entry.intent);
}
}
- }
+ }
}
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index 77a87de..8c94be5 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -155,11 +155,11 @@
/** Custom mode */
static final int MODE_CUSTOM = 8;
/** Show all starred contacts */
- static final int MODE_STARRED = 20;
+ static final int MODE_STARRED = 20 | MODE_MASK_SHOW_PHOTOS;
/** Show frequently contacted contacts */
- static final int MODE_FREQUENT = 30;
+ static final int MODE_FREQUENT = 30 | MODE_MASK_SHOW_PHOTOS;
/** Show starred and the frequent */
- static final int MODE_STREQUENT = 35;
+ static final int MODE_STREQUENT = 35 | MODE_MASK_SHOW_PHOTOS;
/** Show all contacts and pick them when clicking */
static final int MODE_PICK_AGGREGATE = 40 | MODE_MASK_PICKER | MODE_MASK_SHOW_PHOTOS;
/** Show all contacts as well as the option to create a new one */
diff --git a/src/com/android/contacts/RecentCallsListActivity.java b/src/com/android/contacts/RecentCallsListActivity.java
index 6abaf23..7ce01e3 100644
--- a/src/com/android/contacts/RecentCallsListActivity.java
+++ b/src/com/android/contacts/RecentCallsListActivity.java
@@ -34,8 +34,9 @@
import android.os.SystemClock;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
-import android.provider.Contacts.People;
-import android.provider.Contacts.Phones;
+import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.PhoneLookup;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.Contacts.Intents.Insert;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
@@ -96,11 +97,11 @@
/** The projection to use when querying the phones table */
static final String[] PHONES_PROJECTION = new String[] {
- Phones.PERSON_ID,
- Phones.DISPLAY_NAME,
- Phones.TYPE,
- Phones.LABEL,
- Phones.NUMBER
+ PhoneLookup._ID,
+ PhoneLookup.DISPLAY_NAME,
+ PhoneLookup.TYPE,
+ PhoneLookup.LABEL,
+ PhoneLookup.NUMBER
};
static final int PERSON_ID_COLUMN_INDEX = 0;
@@ -147,18 +148,18 @@
int numberType;
String numberLabel;
}
-
+
/**
* Shared builder used by {@link #formatPhoneNumber(String)} to minimize
* allocations when formatting phone numbers.
*/
private static final SpannableStringBuilder sEditable = new SpannableStringBuilder();
-
+
/**
* Invalid formatting type constant for {@link #sFormattingType}.
*/
private static final int FORMATTING_TYPE_INVALID = -1;
-
+
/**
* Cached formatting type for current {@link Locale}, as provided by
* {@link PhoneNumberUtils#getFormatTypeForLocale(Locale)}.
@@ -309,7 +310,7 @@
} else {
Cursor phonesCursor =
RecentCallsListActivity.this.getContentResolver().query(
- Uri.withAppendedPath(Phones.CONTENT_FILTER_URL,
+ Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
Uri.encode(ciq.number)),
PHONES_PROJECTION, null, null, null);
if (phonesCursor != null) {
@@ -320,7 +321,7 @@
info.type = phonesCursor.getInt(PHONE_TYPE_COLUMN_INDEX);
info.label = phonesCursor.getString(LABEL_COLUMN_INDEX);
info.number = phonesCursor.getString(MATCHED_NUMBER_COLUMN_INDEX);
-
+
// New incoming phone number invalidates our formatted
// cache. Any cache fills happen only on the GUI thread.
info.formattedNumber = null;
@@ -378,7 +379,7 @@
views.iconView = (ImageView) view.findViewById(R.id.call_type_icon);
views.callView = view.findViewById(R.id.call_icon);
views.callView.setOnClickListener(this);
-
+
view.setTag(views);
return view;
@@ -394,7 +395,7 @@
String callerName = c.getString(CALLER_NAME_COLUMN_INDEX);
int callerNumberType = c.getInt(CALLER_NUMBERTYPE_COLUMN_INDEX);
String callerNumberLabel = c.getString(CALLER_NUMBERLABEL_COLUMN_INDEX);
-
+
// Store away the number so we can call it directly if you click on the call icon
views.callView.setTag(number);
@@ -418,7 +419,7 @@
enqueueRequest(number, c.getPosition(),
callerName, callerNumberType, callerNumberLabel);
}
-
+
// Format and cache phone number for found contact
if (info.formattedNumber == null) {
info.formattedNumber = formatPhoneNumber(info.number);
@@ -436,7 +437,7 @@
name = callerName;
ntype = callerNumberType;
label = callerNumberLabel;
-
+
// Format the cached call_log phone number
formattedNumber = formatPhoneNumber(number);
}
@@ -444,7 +445,7 @@
if (!TextUtils.isEmpty(name)) {
views.line1View.setText(name);
views.labelView.setVisibility(View.VISIBLE);
- CharSequence numberLabel = Phones.getDisplayLabel(context, ntype, label,
+ CharSequence numberLabel = Phone.getDisplayLabel(context, ntype, label,
mLabelArray);
views.numberView.setVisibility(View.VISIBLE);
views.numberView.setText(formattedNumber);
@@ -478,7 +479,7 @@
// Set the date/time field by mixing relative and absolute times.
int flags = DateUtils.FORMAT_ABBREV_RELATIVE;
-
+
views.dateView.setText(DateUtils.getRelativeTimeSpanString(date,
System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, flags));
@@ -544,11 +545,11 @@
mVoiceMailNumber = ((TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE))
.getVoiceMailNumber();
mQueryHandler = new QueryHandler(this);
-
+
// Reset locale-based formatting cache
sFormattingType = FORMATTING_TYPE_INVALID;
}
-
+
@Override
protected void onResume() {
// The adapter caches looked up numbers, clear it so they will get
@@ -586,7 +587,7 @@
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
-
+
// Clear notifications only when window gains focus. This activity won't
// immediately receive focus if the keyguard screen is above it.
if (hasFocus) {
@@ -619,10 +620,10 @@
if (sFormattingType == FORMATTING_TYPE_INVALID) {
sFormattingType = PhoneNumberUtils.getFormatTypeForLocale(Locale.getDefault());
}
-
+
sEditable.clear();
sEditable.append(number);
-
+
PhoneNumberUtils.formatNumber(sEditable, sFormattingType);
return sEditable.toString();
}
@@ -701,7 +702,7 @@
if (contactInfoPresent) {
menu.add(0, 0, 0, R.string.menu_viewContact)
.setIntent(new Intent(Intent.ACTION_VIEW,
- ContentUris.withAppendedId(People.CONTENT_URI, info.personId)));
+ ContentUris.withAppendedId(Contacts.CONTENT_URI, info.personId)));
}
if (numberUri != null && !isVoicemail) {
@@ -713,7 +714,7 @@
}
if (!contactInfoPresent && numberUri != null && !isVoicemail) {
Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
- intent.setType(People.CONTENT_ITEM_TYPE);
+ intent.setType(Contacts.CONTENT_ITEM_TYPE);
intent.putExtra(Insert.PHONE, number);
menu.add(0, 0, 0, R.string.recentCalls_addToContact)
.setIntent(intent);
@@ -733,7 +734,7 @@
}
case MENU_ITEM_VIEW_CONTACTS: {
- Intent intent = new Intent(Intent.ACTION_VIEW, People.CONTENT_URI);
+ Intent intent = new Intent(Intent.ACTION_VIEW, Contacts.CONTENT_URI);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
return true;
@@ -826,7 +827,7 @@
try {
Cursor phonesCursor =
RecentCallsListActivity.this.getContentResolver().query(
- Uri.withAppendedPath(Phones.CONTENT_FILTER_URL,
+ Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
number),
PHONES_PROJECTION, null, null, null);
if (phonesCursor != null) {