diff options
author | Nancy Chen <nancychen@google.com> | 2014-07-22 19:44:36 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-07-22 16:21:19 +0000 |
commit | 70823030dc4aa425ad6d39a9bb5f71bdae7ae68d (patch) | |
tree | 23fbbc1f827692f7b34421995d04f9ee4e5d6c2d /src | |
parent | 384f1394ae979f35646a879feabb70fb40e98fa5 (diff) | |
parent | b2eebafbc1f1e26b5178b2858ca335467b4bc341 (diff) |
Merge "Enable icon selection in call log" into lmp-dev
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/CallDetailActivity.java | 21 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAdapter.java | 17 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/PhoneAccountUtils.java | 54 |
3 files changed, 69 insertions, 23 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index 3ef78af5c..42e4659f2 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -17,6 +17,7 @@ package com.android.dialer; import android.app.Activity; +import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; @@ -32,6 +33,8 @@ import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.VoicemailContract.Voicemails; +import android.telecomm.PhoneAccount; +import android.telecomm.TelecommManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; @@ -54,6 +57,7 @@ import com.android.dialer.calllog.CallLogQuery; import com.android.dialer.calllog.CallTypeHelper; import com.android.dialer.calllog.ContactInfo; import com.android.dialer.calllog.ContactInfoHelper; +import com.android.dialer.calllog.PhoneAccountUtils; import com.android.dialer.calllog.PhoneNumberDisplayHelper; import com.android.dialer.calllog.PhoneNumberUtilsWrapper; import com.android.dialer.util.AsyncTaskExecutor; @@ -491,7 +495,11 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware final int callType = callCursor.getInt(CALL_TYPE_COLUMN_INDEX); String countryIso = callCursor.getString(COUNTRY_ISO_COLUMN_INDEX); final String geocode = callCursor.getString(GEOCODED_LOCATION_COLUMN_INDEX); - final Drawable accountIcon = getAccountIcon(callCursor); + + final Drawable accountIcon = PhoneAccountUtils.getAccountIcon(this, + PhoneAccountUtils.getAccount( + callCursor.getString(ACCOUNT_COMPONENT_NAME), + callCursor.getString(ACCOUNT_ID))); if (TextUtils.isEmpty(countryIso)) { countryIso = mDefaultCountryIso; @@ -547,17 +555,6 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware } } - /** - * Generate account object from data in Telecomm database - */ - private Drawable getAccountIcon(Cursor c) { - final String component_name = c.getString(ACCOUNT_COMPONENT_NAME); - final String account_id = c.getString(ACCOUNT_ID); - - // TODO: actually pull data from the database - return null; - } - /** Load the contact photos and places them in the corresponding views. */ private void loadContactPhotos(Uri contactUri, Uri photoUri, String displayName, String lookupKey, int contactType) { diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index e83144185..682dbd131 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -16,6 +16,7 @@ package com.android.dialer.calllog; +import android.content.ComponentName; import android.content.ContentValues; import android.content.Context; import android.content.Intent; @@ -644,9 +645,11 @@ public class CallLogAdapter extends GroupingListAdapter final long date = c.getLong(CallLogQuery.DATE); final long duration = c.getLong(CallLogQuery.DURATION); final int callType = c.getInt(CallLogQuery.CALL_TYPE); - final PhoneAccountHandle accountHandle = getAccountHandle(c); - final Drawable accountIcon = accountHandle == null ? null : - TelecommManager.from(mContext).getPhoneAccount(accountHandle).getIcon(mContext); + final PhoneAccountHandle accountHandle = PhoneAccountUtils.getAccount( + c.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME), + c.getString(CallLogQuery.ACCOUNT_ID)); + final Drawable accountIcon = PhoneAccountUtils.getAccountIcon(mContext, + accountHandle); final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO); final long rowId = c.getLong(CallLogQuery.ID); views.rowId = rowId; @@ -1262,14 +1265,6 @@ public class CallLogAdapter extends GroupingListAdapter return features; } - private PhoneAccountHandle getAccountHandle(Cursor c) { - final String component_name = c.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME); - final String account_id = c.getString(CallLogQuery.ACCOUNT_ID); - - // TODO: actually pull data from the database - return null; - } - private void setPhoto(CallLogListItemViews views, long photoId, Uri contactUri, String displayName, String identifier, int contactType) { views.quickContactView.assignContactUri(contactUri); diff --git a/src/com/android/dialer/calllog/PhoneAccountUtils.java b/src/com/android/dialer/calllog/PhoneAccountUtils.java new file mode 100644 index 000000000..adb12f9f1 --- /dev/null +++ b/src/com/android/dialer/calllog/PhoneAccountUtils.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 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 + */ + +package com.android.dialer.calllog; + +import android.content.ComponentName; +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.telecomm.PhoneAccount; +import android.telecomm.PhoneAccountHandle; +import android.telecomm.TelecommManager; +import android.text.TextUtils; + +/** + * Methods to help extract {@code PhoneAccount} information from database and Telecomm sources + */ +public class PhoneAccountUtils { + /** + * Generate account info from data in Telecomm database + */ + public static PhoneAccountHandle getAccount(String componentString, + String accountId) { + if (TextUtils.isEmpty(componentString) || TextUtils.isEmpty(accountId)) { + return null; + } + final ComponentName componentName = ComponentName.unflattenFromString(componentString); + return new PhoneAccountHandle(componentName, accountId); + } + + /** + * Generate account icon from data in Telecomm database + */ + public static Drawable getAccountIcon(Context context, PhoneAccountHandle phoneAccount) { + final PhoneAccount accountMetadata = TelecommManager.from(context) + .getPhoneAccount(phoneAccount); + if (accountMetadata == null) { + return null; + } + return accountMetadata.getIcon(context); + } +} |