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/dialer/calllog | |
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/dialer/calllog')
6 files changed, 36 insertions, 13 deletions
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); |