summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2014-07-21 13:41:36 -0700
committerNancy Chen <nancychen@google.com>2014-07-22 12:41:46 -0700
commitb2eebafbc1f1e26b5178b2858ca335467b4bc341 (patch)
treeb4f34c153cb5a0f8cba995ca62d84f96e3cb2ccf
parentce4126734173687c887652a8914d4e9d13f6249e (diff)
Enable icon selection in call log
Originally the call log was not hooked up with the PhoneAccount API, this change hooks that part up. Bug: 15473965 Change-Id: I96bdde927473abcdf7493573be29bf4979cf2696
-rw-r--r--src/com/android/dialer/CallDetailActivity.java21
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java17
-rw-r--r--src/com/android/dialer/calllog/PhoneAccountUtils.java54
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);
+ }
+}