Merge change 22020 into eclair-dev
* changes:
New minitab assets, and dithering fix.
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) {
diff --git a/src/com/android/contacts/SplitAggregateView.java b/src/com/android/contacts/SplitAggregateView.java
index 96eb2b5..93e4e42 100644
--- a/src/com/android/contacts/SplitAggregateView.java
+++ b/src/com/android/contacts/SplitAggregateView.java
@@ -16,17 +16,23 @@
package com.android.contacts;
+import com.android.contacts.model.ContactsSource;
+import com.android.contacts.model.Sources;
import com.google.common.util.text.TextUtil;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
-import android.provider.ContactsContract.Contacts.Data;
+import android.provider.ContactsContract.RawContacts;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Nickname;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
+import android.provider.ContactsContract.Contacts.Data;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -48,13 +54,15 @@
*/
public class SplitAggregateView extends ListView {
+ private static final String TAG = "SplitAggregateView";
+
private static final String[] AGGREGATE_DATA_PROJECTION = new String[] {
- Data.MIMETYPE, Data.RES_PACKAGE, Data.RAW_CONTACT_ID, Data.DATA1, Data.DATA2,
+ Data.MIMETYPE, RawContacts.ACCOUNT_TYPE, Data.RAW_CONTACT_ID, Data.DATA1, Data.DATA2,
Data.IS_PRIMARY, StructuredName.DISPLAY_NAME
};
private static final int COL_MIMETYPE = 0;
- private static final int COL_RES_PACKAGE = 1;
+ private static final int COL_ACCOUNT_TYPE = 1;
private static final int COL_RAW_CONTACT_ID = 2;
private static final int COL_DATA1 = 3;
private static final int COL_DATA2 = 4;
@@ -64,6 +72,7 @@
private final Uri mAggregateUri;
private OnContactSelectedListener mListener;
+ private Sources mSources;
/**
* Listener interface that gets the contact ID of the user-selected contact.
@@ -80,6 +89,8 @@
mAggregateUri = aggregateUri;
+ mSources = Sources.getInstance(context);
+
final List<ContactInfo> list = loadData();
setAdapter(new SplitAggregateAdapter(context, list));
@@ -103,7 +114,7 @@
*/
private static class ContactInfo implements Comparable<ContactInfo> {
final long contactId;
- String resPackage;
+ String accountType;
String name;
String phone;
String email;
@@ -130,7 +141,9 @@
}
public int compareTo(ContactInfo another) {
- return resPackage.compareTo(another.resPackage);
+ String thisAccount = accountType != null ? accountType : "";
+ String thatAccount = another.accountType != null ? another.accountType : "";
+ return thisAccount.compareTo(thatAccount);
}
}
@@ -150,7 +163,7 @@
if (info == null) {
info = new ContactInfo(contactId);
contactInfos.put(contactId, info);
- info.resPackage = cursor.getString(COL_RES_PACKAGE);
+ info.accountType = cursor.getString(COL_ACCOUNT_TYPE);
}
String mimetype = cursor.getString(COL_MIMETYPE);
@@ -215,16 +228,16 @@
}
}
+ private static class SplitAggregateItemCache {
+ TextView name;
+ TextView additionalData;
+ ImageView sourceIcon;
+ }
+
/**
* List adapter for the list of {@link ContactInfo} objects.
*/
- private static class SplitAggregateAdapter extends ArrayAdapter<ContactInfo> {
-
- private static class SplitAggregateItemCache {
- TextView name;
- TextView additionalData;
- ImageView sourceIcon;
- }
+ private class SplitAggregateAdapter extends ArrayAdapter<ContactInfo> {
private LayoutInflater mInflater;
@@ -252,22 +265,27 @@
cache.name.setText(info.name);
cache.additionalData.setText(info.getAdditionalData());
- Bitmap sourceBitmap = getSourceIcon(info.resPackage);
- if (sourceBitmap != null) {
- cache.sourceIcon.setImageBitmap(sourceBitmap);
+ Drawable icon = null;
+ ContactsSource source = mSources.getInflatedSource(info.accountType,
+ ContactsSource.LEVEL_SUMMARY);
+ if (source != null) {
+ final String packageName = source.resPackageName;
+ if (source.iconRes > 0) {
+ try {
+ final Context context = getContext().createPackageContext(packageName, 0);
+ icon = context.getResources().getDrawable(source.iconRes);
+
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.d(TAG, "error getting the Package Context for " + packageName, e);
+ }
+ }
+ }
+ if (icon != null) {
+ cache.sourceIcon.setImageDrawable(icon);
} else {
cache.sourceIcon.setImageResource(R.drawable.unknown_source);
}
return convertView;
}
-
- /**
- * Returns the icon corresponding to the source of contact information.
- */
- private Bitmap getSourceIcon(String packageName) {
-
- // TODO: obtain from PackageManager
- return null;
- }
}
}
diff --git a/src/com/android/contacts/model/Sources.java b/src/com/android/contacts/model/Sources.java
index 3258f13..196a306 100644
--- a/src/com/android/contacts/model/Sources.java
+++ b/src/com/android/contacts/model/Sources.java
@@ -85,7 +85,7 @@
final AuthenticatorDescription[] auths = am.getAuthenticatorTypes();
for (SyncAdapterType sync : syncs) {
- if (ContactsContract.AUTHORITY.equals(sync.authority)) {
+ if (!ContactsContract.AUTHORITY.equals(sync.authority)) {
// Skip sync adapters that don't provide contact data.
continue;
}