From 7b2b43c0589ec79ba74359f7d9d6e0450fc322ab Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Thu, 17 Dec 2015 09:11:12 +0000 Subject: Show work badge icon/description in InCallUI/Dialer Add work badge icon into IncallUI Add work description into incoming call notification To see this feature 1. Receive/Make a call from work contact (a contact in work profile has the phone number) 2. See work description in incoming call notification and work badge icon in IncallUI BUG=26082618 Change-Id: I182b48a34d3d87ee3093e8433ae33939705d59d7 --- InCallUI/res/layout/primary_call_info.xml | 11 +++++++++ InCallUI/res/values/strings.xml | 10 +++++++++ .../src/com/android/incallui/CallCardFragment.java | 5 ++++- .../com/android/incallui/CallCardPresenter.java | 15 ++++++++----- InCallUI/src/com/android/incallui/CallerInfo.java | 20 +++++++++++++++-- .../src/com/android/incallui/CallerInfoUtils.java | 1 + .../src/com/android/incallui/ContactInfoCache.java | 4 ++++ .../com/android/incallui/StatusBarNotifier.java | 26 ++++++++++++++++++++-- 8 files changed, 82 insertions(+), 10 deletions(-) diff --git a/InCallUI/res/layout/primary_call_info.xml b/InCallUI/res/layout/primary_call_info.xml index 629d22047..5dcebd0dd 100644 --- a/InCallUI/res/layout/primary_call_info.xml +++ b/InCallUI/res/layout/primary_call_info.xml @@ -69,6 +69,17 @@ android:clipChildren="false" android:clipToPadding="false"> + + Missed call from %s Ongoing call + + Ongoing work call Ongoing Wi-Fi call + + Ongoing Wi-Fi work call On hold Incoming call + + Incoming work call Incoming Wi-Fi call + + Incoming Wi-Fi work call Incoming video call diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index dbb2c9dff..93d499e38 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -132,6 +132,7 @@ public class CallCardFragment extends BaseFragment if (mPrimary == null) { // Clear the primary display info. - ui.setPrimary(null, null, false, null, null, false, false); + ui.setPrimary(null, null, false, null, null, false, false, false); return; } @@ -731,7 +732,8 @@ public class CallCardPresenter extends Presenter null /* label */, getConferencePhoto(mPrimary), false /* isSipCall */, - showContactPhoto); + showContactPhoto, + false /* isWorkContact */); } else if (mPrimaryContactInfo != null) { Log.d(TAG, "Update primary display info for " + mPrimaryContactInfo); @@ -763,6 +765,7 @@ public class CallCardPresenter extends Presenter maybeShowHdAudioIcon(); boolean nameIsNumber = name != null && name.equals(mPrimaryContactInfo.number); + boolean isWorkContact = (mPrimaryContactInfo.userType == ContactsUtils.USER_TYPE_WORK); ui.setPrimary( number, name, @@ -770,12 +773,13 @@ public class CallCardPresenter extends Presenter isChildNumberShown || isCallSubjectShown ? null : mPrimaryContactInfo.label, mPrimaryContactInfo.photo, mPrimaryContactInfo.isSipCall, - showContactPhoto); + showContactPhoto, + isWorkContact); updateContactInteractions(); } else { // Clear the primary display info. - ui.setPrimary(null, null, false, null, null, false, false); + ui.setPrimary(null, null, false, null, null, false, false, false); } if (mEmergencyCallListener != null) { @@ -1091,7 +1095,8 @@ public class CallCardPresenter extends Presenter void showContactContext(boolean show); void setCallCardVisible(boolean visible); void setPrimary(String number, String name, boolean nameIsNumber, String label, - Drawable photo, boolean isSipCall, boolean isContactPhotoShown); + Drawable photo, boolean isSipCall, boolean isContactPhotoShown, + boolean isWorkContact); void setSecondary(boolean show, String name, boolean nameIsNumber, String label, String providerLabel, boolean isConference, boolean isVideoCall, boolean isFullscreen); diff --git a/InCallUI/src/com/android/incallui/CallerInfo.java b/InCallUI/src/com/android/incallui/CallerInfo.java index 4ea4970a3..609696130 100644 --- a/InCallUI/src/com/android/incallui/CallerInfo.java +++ b/InCallUI/src/com/android/incallui/CallerInfo.java @@ -16,12 +16,15 @@ package com.android.incallui; +import com.google.common.primitives.Longs; + import android.content.Context; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.net.Uri; import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.provider.ContactsContract; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; import android.provider.ContactsContract.PhoneLookup; @@ -29,6 +32,8 @@ import android.provider.ContactsContract.RawContacts; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; +import com.android.contacts.common.ContactsUtils; +import com.android.contacts.common.ContactsUtils.UserType; import com.android.contacts.common.util.PhoneNumberHelper; import com.android.contacts.common.util.TelephonyManagerUtils; import com.android.dialer.calllog.ContactInfoHelper; @@ -103,6 +108,7 @@ public class CallerInfo { public String lookupKeyOrNull; public boolean needUpdate; public Uri contactRefUri; + public @UserType long userType; /** * Contact display photo URI. If a contact has no display photo but a thumbnail, it'll be @@ -161,6 +167,7 @@ public class CallerInfo { // TODO: Move all the basic initialization here? mIsEmergency = false; mIsVoiceMail = false; + userType = ContactsUtils.USER_TYPE_CURRENT; } /** @@ -180,6 +187,7 @@ public class CallerInfo { info.cachedPhoto = null; info.isCachedPhotoCurrent = false; info.contactExists = false; + info.userType = ContactsUtils.USER_TYPE_CURRENT; Log.v(TAG, "getCallerInfo() based on cursor..."); @@ -189,6 +197,7 @@ public class CallerInfo { // care of here. Maybe we should store it in the // CallerInfo object as well. + long contactId = 0L; int columnIndex; // Look for the name @@ -231,7 +240,7 @@ public class CallerInfo { // Look for the person_id. columnIndex = getColumnIndexForPersonId(contactRef, cursor); if (columnIndex != -1) { - final long contactId = cursor.getLong(columnIndex); + contactId = cursor.getLong(columnIndex); if (contactId != 0 && !Contacts.isEnterpriseContactId(contactId)) { info.contactIdOrZero = contactId; Log.v(TAG, "==> got info.contactIdOrZero: " + info.contactIdOrZero); @@ -278,6 +287,12 @@ public class CallerInfo { info.shouldSendToVoicemail = (columnIndex != -1) && ((cursor.getInt(columnIndex)) == 1); info.contactExists = true; + + // Determine userType by directoryId and contactId + final String directory = contactRef == null ? null + : contactRef.getQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY); + final Long directoryId = directory == null ? null : Longs.tryParse(directory); + info.userType = ContactsUtils.determineUserType(directoryId, contactId); } cursor.close(); } @@ -524,7 +539,8 @@ public class CallerInfo { .append("\ncachedPhoto: " + cachedPhoto) .append("\nisCachedPhotoCurrent: " + isCachedPhotoCurrent) .append("\nemergency: " + mIsEmergency) - .append("\nvoicemail " + mIsVoiceMail) + .append("\nvoicemail: " + mIsVoiceMail) + .append("\nuserType: " + userType) .append(" }") .toString(); } else { diff --git a/InCallUI/src/com/android/incallui/CallerInfoUtils.java b/InCallUI/src/com/android/incallui/CallerInfoUtils.java index 31fc9f1e6..ae59d7d2d 100644 --- a/InCallUI/src/com/android/incallui/CallerInfoUtils.java +++ b/InCallUI/src/com/android/incallui/CallerInfoUtils.java @@ -109,6 +109,7 @@ public class CallerInfoUtils { info.number = ci.phoneNumber; info.normalizedNumber = ci.normalizedNumber; info.photoUri = ci.contactDisplayPhotoUri; + info.userType = ci.userType; CachedContactInfo cacheInfo = lookupService.buildCachedContactInfo(info); cacheInfo.setLookupKey(ci.lookupKeyOrNull); diff --git a/InCallUI/src/com/android/incallui/ContactInfoCache.java b/InCallUI/src/com/android/incallui/ContactInfoCache.java index 9894f5532..bba973b1c 100644 --- a/InCallUI/src/com/android/incallui/ContactInfoCache.java +++ b/InCallUI/src/com/android/incallui/ContactInfoCache.java @@ -37,6 +37,7 @@ import android.telecom.TelecomManager; import android.text.TextUtils; import android.util.Pair; +import com.android.contacts.common.ContactsUtils; import com.android.contacts.common.util.PhoneNumberHelper; import com.android.dialer.calllog.ContactInfo; import com.android.dialer.service.CachedNumberLookupService; @@ -553,6 +554,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete cce.location = displayLocation; cce.label = label; cce.isSipCall = isSipCall; + cce.userType = info.userType; if (info.contactExists) { cce.contactLookupResult = LogState.LOOKUP_LOCAL_CONTACT; @@ -660,6 +662,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete public Address locationAddress; public List> openingHours; public int contactLookupResult = LogState.LOOKUP_NOT_FOUND; + public long userType = ContactsUtils.USER_TYPE_CURRENT; @Override public String toString() { @@ -676,6 +679,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete .add("locationAddress", locationAddress) .add("openingHours", openingHours) .add("contactLookupResult", contactLookupResult) + .add("userType", userType) .toString(); } } diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 1f2729ea3..fdf185ba5 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -34,6 +34,8 @@ import android.text.BidiFormatter; import android.text.TextDirectionHeuristics; import android.text.TextUtils; +import com.android.contacts.common.ContactsUtils; +import com.android.contacts.common.ContactsUtils.UserType; import com.android.contacts.common.preference.ContactsPreferences; import com.android.contacts.common.util.BitmapUtil; import com.android.contacts.common.util.ContactDisplayUtils; @@ -221,7 +223,8 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, // Check if data has changed; if nothing is different, don't issue another notification. final int iconResId = getIconToDisplay(call); Bitmap largeIcon = getLargeIconToDisplay(contactInfo, call); - final String content = getContentString(call); + final String content = + getContentString(call, contactInfo.userType); final String contentTitle = getContentTitle(contactInfo, call); final int notificationType; @@ -435,7 +438,7 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, /** * Returns the message to use with the notification. */ - private String getContentString(Call call) { + private String getContentString(Call call, @UserType long userType) { boolean isIncomingOrWaiting = call.getState() == Call.State.INCOMING || call.getState() == Call.State.CALL_WAITING; @@ -469,9 +472,28 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, resId = R.string.notification_requesting_video_call; } + if (userType == ContactsUtils.USER_TYPE_WORK) { + resId = getWorkStringFromPersonalString(resId); + } + return mContext.getString(resId); } + private static int getWorkStringFromPersonalString(int resId) { + switch(resId) { + case R.string.notification_ongoing_call: + return R.string.notification_ongoing_work_call; + case R.string.notification_ongoing_call_wifi: + return R.string.notification_ongoing_work_call_wifi; + case R.string.notification_incoming_call_wifi: + return R.string.notification_incoming_work_call_wifi; + case R.string.notification_incoming_call: + return R.string.notification_incoming_work_call; + default: + return resId; + } + } + /** * Gets the most relevant call to display in the notification. */ -- cgit v1.2.3