Making phone number disambig dialog more verbose, showing phone type.
Bug: 2212826
Change-Id: Id0c14872c4126d55adab57c576ff079dfe738bc1
diff --git a/res/layout-finger/phone_disambig_item.xml b/res/layout-finger/phone_disambig_item.xml
new file mode 100755
index 0000000..db683a0
--- /dev/null
+++ b/res/layout-finger/phone_disambig_item.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingLeft="30dip"
+ android:paddingRight="30dip"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:gravity="center_vertical">
+
+ <TextView
+ android:id="@android:id/text1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textStyle="bold"
+ android:textAppearance="?android:attr/textAppearanceMediumInverse" />
+
+ <TextView
+ android:id="@android:id/text2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="-4dip"
+ android:textAppearance="?android:attr/textAppearanceSmallInverse" />
+
+</LinearLayout>
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index db182c7..3f5bf29 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -2450,7 +2450,8 @@
Uri dataUri = Uri.withAppendedPath(baseUri, Contacts.Data.CONTENT_DIRECTORY);
Cursor c = getContentResolver().query(dataUri,
- new String[] {Phone._ID, Phone.NUMBER, Phone.IS_SUPER_PRIMARY},
+ new String[] {Phone._ID, Phone.NUMBER, Phone.IS_SUPER_PRIMARY,
+ RawContacts.ACCOUNT_TYPE, Phone.TYPE, Phone.LABEL},
Data.MIMETYPE + "=?", new String[] {Phone.CONTENT_ITEM_TYPE}, null);
if (c != null && c.moveToFirst()) {
return c;
diff --git a/src/com/android/contacts/PhoneDisambigDialog.java b/src/com/android/contacts/PhoneDisambigDialog.java
index e0295e3..6ce944b 100644
--- a/src/com/android/contacts/PhoneDisambigDialog.java
+++ b/src/com/android/contacts/PhoneDisambigDialog.java
@@ -16,10 +16,11 @@
package com.android.contacts;
-import java.util.ArrayList;
-import java.util.List;
-
import com.android.contacts.Collapser.Collapsible;
+import com.android.contacts.model.ContactsSource;
+import com.android.contacts.model.Sources;
+import com.android.contacts.model.ContactsSource.DataKind;
+import com.android.contacts.model.ContactsSource.StringInflater;
import android.app.AlertDialog;
import android.content.ContentUris;
@@ -28,14 +29,20 @@
import android.content.DialogInterface;
import android.database.Cursor;
import android.provider.ContactsContract.Data;
+import android.provider.ContactsContract.RawContacts;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.telephony.PhoneNumberUtils;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ListAdapter;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.List;
/**
* Class used for displaying a dialog with a list of phone numbers of which
@@ -64,7 +71,7 @@
mPhoneItemList = makePhoneItemsList(phonesCursor);
Collapser.collapseList(mPhoneItemList);
- mPhonesAdapter = new PhonesAdapter(mContext, mPhoneItemList);
+ mPhonesAdapter = new PhonesAdapter(mContext, mPhoneItemList, mSendSms);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
@@ -127,21 +134,51 @@
}
private static class PhonesAdapter extends ArrayAdapter<PhoneItem> {
+ private final boolean sendSms;
+ private final Sources mSources;
- public PhonesAdapter(Context context, List<PhoneItem> objects) {
- super(context, android.R.layout.simple_dropdown_item_1line,
- android.R.id.text1, objects);
+ public PhonesAdapter(Context context, List<PhoneItem> objects, boolean sendSms) {
+ super(context, R.layout.phone_disambig_item,
+ android.R.id.text2, objects);
+ this.sendSms = sendSms;
+ mSources = Sources.getInstance(context);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View view = super.getView(position, convertView, parent);
+
+ PhoneItem item = getItem(position);
+ ContactsSource source = mSources.getInflatedSource(item.accountType,
+ ContactsSource.LEVEL_SUMMARY);
+
+ // Obtain a string representation of the phone type specific to the
+ // ContactSource associated with that phone number
+ TextView typeView = (TextView)view.findViewById(android.R.id.text1);
+ DataKind kind = source.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
+ ContentValues values = new ContentValues();
+ values.put(Phone.TYPE, item.type);
+ values.put(Phone.LABEL, item.label);
+ StringInflater header = sendSms ? kind.actionAltHeader : kind.actionHeader;
+ typeView.setText(header.inflateUsing(getContext(), values));
+ return view;
}
}
private class PhoneItem implements Collapsible<PhoneItem> {
- final String phoneNumber;
final long id;
+ final String phoneNumber;
+ final String accountType;
+ final long type;
+ final String label;
- public PhoneItem(String newPhoneNumber, long newId) {
- phoneNumber = (newPhoneNumber != null ? newPhoneNumber : "");
- id = newId;
+ public PhoneItem(long id, String phoneNumber, String accountType, int type, String label) {
+ this.id = id;
+ this.phoneNumber = (phoneNumber != null ? phoneNumber : "");
+ this.accountType = accountType;
+ this.type = type;
+ this.label = label;
}
public boolean collapseWith(PhoneItem phoneItem) {
@@ -173,7 +210,12 @@
while (phonesCursor.moveToNext()) {
long id = phonesCursor.getLong(phonesCursor.getColumnIndex(Data._ID));
String phone = phonesCursor.getString(phonesCursor.getColumnIndex(Phone.NUMBER));
- phoneList.add(new PhoneItem(phone, id));
+ String accountType =
+ phonesCursor.getString(phonesCursor.getColumnIndex(RawContacts.ACCOUNT_TYPE));
+ int type = phonesCursor.getInt(phonesCursor.getColumnIndex(Phone.TYPE));
+ String label = phonesCursor.getString(phonesCursor.getColumnIndex(Phone.LABEL));
+
+ phoneList.add(new PhoneItem(id, phone, accountType, type, label));
}
return phoneList;