diff options
author | Brad Ebinger <breadley@google.com> | 2016-04-07 17:19:18 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-04-07 17:19:18 +0000 |
commit | fae70b9521bfc61ef06afc6eb787987d26acbdad (patch) | |
tree | 5c6d02b0287f778586b8eecb35935748ee35cee6 /src/com/android | |
parent | f5cef690b6df32e31fe7b412c7329749a9eb4ad0 (diff) | |
parent | 8607dfb43c2707ca534d68f2dcf728fece01c82b (diff) |
Merge "Add via number to CallLog Account entry" into nyc-dev am: 87b9abf
am: 8607dfb
* commit '8607dfb43c2707ca534d68f2dcf728fece01c82b':
Add via number to CallLog Account entry
Change-Id: I55e9f40fb5497a4edeec31fc0abeb2efd459f1a2
Diffstat (limited to 'src/com/android')
8 files changed, 83 insertions, 15 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index 42bee1edf..94c2f0018 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -142,10 +142,23 @@ public class CallDetailActivity extends AppCompatActivity } } - String accountLabel = - PhoneAccountUtils.getAccountLabel(mContext, mDetails.accountHandle); + CharSequence accountLabel = PhoneAccountUtils.getAccountLabel(mContext, + mDetails.accountHandle); + CharSequence accountContentDescription = + PhoneCallDetails.createAccountLabelDescription(mResources, mDetails.viaNumber, + accountLabel); + if (!TextUtils.isEmpty(mDetails.viaNumber)) { + if (!TextUtils.isEmpty(accountLabel)) { + accountLabel = mResources.getString(R.string.call_log_via_number_phone_account, + accountLabel, mDetails.viaNumber); + } else { + accountLabel = mResources.getString(R.string.call_log_via_number, + mDetails.viaNumber); + } + } if (!TextUtils.isEmpty(accountLabel)) { mAccountLabel.setText(accountLabel); + mAccountLabel.setContentDescription(accountContentDescription); mAccountLabel.setVisibility(View.VISIBLE); } else { mAccountLabel.setVisibility(View.GONE); diff --git a/src/com/android/dialer/PhoneCallDetails.java b/src/com/android/dialer/PhoneCallDetails.java index 16192fc11..8a2e52090 100644 --- a/src/com/android/dialer/PhoneCallDetails.java +++ b/src/com/android/dialer/PhoneCallDetails.java @@ -18,11 +18,14 @@ package com.android.dialer; import com.android.contacts.common.ContactsUtils.UserType; import com.android.contacts.common.preference.ContactsPreferences; +import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.calllog.PhoneNumberDisplayUtil; import android.content.Context; +import android.content.res.Resources; import android.net.Uri; import android.provider.CallLog.Calls; +import android.support.annotation.Nullable; import android.telecom.PhoneAccountHandle; import android.text.TextUtils; @@ -34,6 +37,8 @@ public class PhoneCallDetails { public CharSequence number; // Post-dial digits associated with the outgoing call. public String postDialDigits; + // The secondary line number the call was received via. + public String viaNumber; // The number presenting rules set by the network, e.g., {@link Calls#PRESENTATION_ALLOWED} public int numberPresentation; // The formatted version of {@link #number}. @@ -152,4 +157,31 @@ public class PhoneCallDetails { } return nameAlternative; } + + /** + * Construct the "on {accountLabel} via {viaNumber}" accessibility description for the account + * list item, depending on the existence of the accountLabel and viaNumber. + * @param viaNumber The number that this call is being placed via. + * @param accountLabel The {@link PhoneAccount} label that this call is being placed with. + * @return The description of the account that this call has been placed on. + */ + public static CharSequence createAccountLabelDescription(Resources resources, + @Nullable String viaNumber, @Nullable CharSequence accountLabel) { + + if((!TextUtils.isEmpty(viaNumber)) && !TextUtils.isEmpty(accountLabel)) { + String msg = resources.getString(R.string.description_via_number_phone_account, + accountLabel, viaNumber); + CharSequence accountNumberLabel = ContactDisplayUtils.getTelephoneTtsSpannable(msg, + viaNumber); + return (accountNumberLabel == null) ? msg : accountNumberLabel; + } else if (!TextUtils.isEmpty(viaNumber)) { + CharSequence viaNumberLabel = ContactDisplayUtils.getTtsSpannedPhoneNumber(resources, + R.string.description_via_number, viaNumber); + return (viaNumberLabel == null) ? viaNumber : viaNumberLabel; + } else if (!TextUtils.isEmpty(accountLabel)) { + return TextUtils.expandTemplate( + resources.getString(R.string.description_phone_account), accountLabel); + } + return ""; + } } diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 506dafdf8..0c1bf9e2e 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -519,15 +519,17 @@ public class CallLogAdapter extends GroupingListAdapter int count = getGroupSize(position); final String number = c.getString(CallLogQuery.NUMBER); + final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO); final String postDialDigits = CompatUtils.isNCompatible() && mActivityType != ACTIVITY_TYPE_ARCHIVE ? c.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; - + final String viaNumber = CompatUtils.isNCompatible() + && mActivityType != ACTIVITY_TYPE_ARCHIVE ? + c.getString(CallLogQuery.VIA_NUMBER) : ""; final int numberPresentation = c.getInt(CallLogQuery.NUMBER_PRESENTATION); final PhoneAccountHandle accountHandle = PhoneAccountUtils.getAccount( c.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME), c.getString(CallLogQuery.ACCOUNT_ID)); - final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO); final ContactInfo cachedContactInfo = ContactInfoHelper.getContactInfo(c); final boolean isVoicemailNumber = mCallLogCache.isVoicemailNumber(accountHandle, number); @@ -547,6 +549,7 @@ public class CallLogAdapter extends GroupingListAdapter final PhoneCallDetails details = new PhoneCallDetails( mContext, number, numberPresentation, formattedNumber, postDialDigits, isVoicemailNumber); + details.viaNumber = viaNumber; details.accountHandle = accountHandle; details.countryIso = countryIso; details.date = c.getLong(CallLogQuery.DATE); diff --git a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java index 7cb35f514..34b2f0ea9 100644 --- a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java +++ b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java @@ -28,6 +28,7 @@ import android.os.AsyncTask; import android.provider.CallLog; import android.provider.VoicemailContract.Voicemails; import android.telecom.PhoneAccountHandle; +import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.util.Log; @@ -44,6 +45,7 @@ import com.android.dialer.util.TelecomUtil; import java.util.ArrayList; import java.util.Arrays; +import java.util.Locale; public class CallLogAsyncTaskUtil { private static String TAG = CallLogAsyncTaskUtil.class.getSimpleName(); @@ -90,12 +92,14 @@ public class CallLogAsyncTaskUtil { static final int DATA_USAGE = 10; static final int TRANSCRIPTION_COLUMN_INDEX = 11; static final int POST_DIAL_DIGITS = 12; + static final int VIA_NUMBER = 13; static { ArrayList<String> projectionList = new ArrayList<>(); projectionList.addAll(Arrays.asList(CALL_LOG_PROJECTION_INTERNAL)); if (CompatUtils.isNCompatible()) { projectionList.add(CallsSdkCompat.POST_DIAL_DIGITS); + projectionList.add(CallsSdkCompat.VIA_NUMBER); } projectionList.trimToSize(); CALL_LOG_PROJECTION = projectionList.toArray(new String[projectionList.size()]); @@ -187,6 +191,8 @@ public class CallLogAsyncTaskUtil { final String number = cursor.getString(CallDetailQuery.NUMBER_COLUMN_INDEX); final String postDialDigits = CompatUtils.isNCompatible() ? cursor.getString(CallDetailQuery.POST_DIAL_DIGITS) : ""; + final String viaNumber = CompatUtils.isNCompatible() ? + cursor.getString(CallDetailQuery.VIA_NUMBER) : ""; final int numberPresentation = cursor.getInt(CallDetailQuery.NUMBER_PRESENTATION_COLUMN_INDEX); @@ -211,6 +217,7 @@ public class CallLogAsyncTaskUtil { context, number, numberPresentation, info.formattedNumber, postDialDigits, isVoicemail); + details.viaNumber = viaNumber; details.accountHandle = accountHandle; details.contactUri = info.lookupUri; details.namePrimary = info.name; diff --git a/src/com/android/dialer/calllog/CallLogGroupBuilder.java b/src/com/android/dialer/calllog/CallLogGroupBuilder.java index 0931e0644..aa45029c0 100644 --- a/src/com/android/dialer/calllog/CallLogGroupBuilder.java +++ b/src/com/android/dialer/calllog/CallLogGroupBuilder.java @@ -125,6 +125,8 @@ public class CallLogGroupBuilder { String groupNumber = cursor.getString(CallLogQuery.NUMBER); String groupPostDialDigits = CompatUtils.isNCompatible() ? cursor.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; + String groupViaNumbers = CompatUtils.isNCompatible() + ? cursor.getString(CallLogQuery.VIA_NUMBER) : ""; int groupCallType = cursor.getInt(CallLogQuery.CALL_TYPE); String groupAccountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME); String groupAccountId = cursor.getString(CallLogQuery.ACCOUNT_ID); @@ -132,6 +134,7 @@ public class CallLogGroupBuilder { String number; String numberPostDialDigits; + String numberViaNumbers; int callType; String accountComponentName; String accountId; @@ -141,18 +144,21 @@ public class CallLogGroupBuilder { number = cursor.getString(CallLogQuery.NUMBER); numberPostDialDigits = CompatUtils.isNCompatible() ? cursor.getString(CallLogQuery.POST_DIAL_DIGITS) : ""; + numberViaNumbers = CompatUtils.isNCompatible() + ? cursor.getString(CallLogQuery.VIA_NUMBER) : ""; callType = cursor.getInt(CallLogQuery.CALL_TYPE); accountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME); accountId = cursor.getString(CallLogQuery.ACCOUNT_ID); final boolean isSameNumber = equalNumbers(groupNumber, number); final boolean isSamePostDialDigits = groupPostDialDigits.equals(numberPostDialDigits); + final boolean isSameViaNumbers = groupViaNumbers.equals(numberViaNumbers); final boolean isSameAccount = isSameAccount( groupAccountComponentName, accountComponentName, groupAccountId, accountId); // Group with the same number and account. Never group voicemails. Only group blocked // calls with other blocked calls. - if (isSameNumber && isSameAccount && isSamePostDialDigits + if (isSameNumber && isSameAccount && isSamePostDialDigits && isSameViaNumbers && areBothNotVoicemail(callType, groupCallType) && (areBothNotBlocked(callType, groupCallType) || areBothBlocked(callType, groupCallType))) { @@ -174,6 +180,7 @@ public class CallLogGroupBuilder { // Update the group values to those of the current call. groupNumber = number; groupPostDialDigits = numberPostDialDigits; + groupViaNumbers = numberViaNumbers; groupCallType = callType; groupAccountComponentName = accountComponentName; groupAccountId = accountId; diff --git a/src/com/android/dialer/calllog/CallLogListItemHelper.java b/src/com/android/dialer/calllog/CallLogListItemHelper.java index 7919a0985..18b6ff5d3 100644 --- a/src/com/android/dialer/calllog/CallLogListItemHelper.java +++ b/src/com/android/dialer/calllog/CallLogListItemHelper.java @@ -190,20 +190,15 @@ import com.android.dialer.calllog.calllogcache.CallLogCache; callDescription.append(mResources.getString(R.string.description_video_call)); } - int stringID = getCallDescriptionStringID(details.callTypes, details.isRead); String accountLabel = mCallLogCache.getAccountLabel(details.accountHandle); + CharSequence onAccountLabel = PhoneCallDetails.createAccountLabelDescription(mResources, + details.viaNumber, accountLabel); - // Use chosen string resource to build up the message. - CharSequence onAccountLabel = accountLabel == null - ? "" - : TextUtils.expandTemplate( - mResources.getString(R.string.description_phone_account), - accountLabel); + int stringID = getCallDescriptionStringID(details.callTypes, details.isRead); callDescription.append( TextUtils.expandTemplate( mResources.getString(stringID), nameOrNumber, - // If no type or location can be determined, sub in empty string. typeOrLocation == null ? "" : typeOrLocation, timeOfCall, onAccountLabel)); diff --git a/src/com/android/dialer/calllog/CallLogQuery.java b/src/com/android/dialer/calllog/CallLogQuery.java index 4900354bf..e1a41199a 100644 --- a/src/com/android/dialer/calllog/CallLogQuery.java +++ b/src/com/android/dialer/calllog/CallLogQuery.java @@ -93,6 +93,7 @@ public final class CallLogQuery { * Call {@link CompatUtils#isNCompatible()} prior to use */ public static int POST_DIAL_DIGITS = -1; + public static int VIA_NUMBER = -1; public static final String[] _PROJECTION; @@ -105,6 +106,8 @@ public final class CallLogQuery { if (CompatUtils.isNCompatible()) { projectionList.add(CallsSdkCompat.POST_DIAL_DIGITS); POST_DIAL_DIGITS = projectionList.size() - 1; + projectionList.add(CallsSdkCompat.VIA_NUMBER); + VIA_NUMBER = projectionList.size() - 1; } _PROJECTION = projectionList.toArray(new String[projectionList.size()]); } diff --git a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java index ff1a44ff7..53121614c 100644 --- a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java +++ b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java @@ -116,8 +116,16 @@ public class PhoneCallDetailsHelper { // Set the account label if it exists. String accountLabel = mCallLogCache.getAccountLabel(details.accountHandle); - - if (accountLabel != null) { + if (!TextUtils.isEmpty(details.viaNumber)) { + if (!TextUtils.isEmpty(accountLabel)) { + accountLabel = mResources.getString(R.string.call_log_via_number_phone_account, + accountLabel, details.viaNumber); + } else { + accountLabel = mResources.getString(R.string.call_log_via_number, + details.viaNumber); + } + } + if (!TextUtils.isEmpty(accountLabel)) { views.callAccountLabel.setVisibility(View.VISIBLE); views.callAccountLabel.setText(accountLabel); int color = mCallLogCache.getAccountColor(details.accountHandle); |