diff options
author | roldenburg <roldenburg@google.com> | 2017-07-12 11:38:26 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-07-13 14:00:05 -0700 |
commit | d67712a9fcfb2b8802274ae2a8a10b8e403f661e (patch) | |
tree | 39e3deb7c4fe0716584d13ee200675c00f6bbcba /java/com/android | |
parent | 905b5862383011727756ab9e2926a0dda12d9ca9 (diff) |
Display correct string for Lightbringer calls in call details
Without this change, all video calls are referred to as just "video call". This
CL uses the Lightbringer interface to allow customizing that text.
Before: https://drive.google.com/open?id=0B7uuA4cyYX0xeVZCTGtMUUtoRVU
After: https://drive.google.com/open?id=0B7uuA4cyYX0xMnFhbTBXMDI2VW8
Bug: 63138393
Test: CallTypeHelperTest
PiperOrigin-RevId: 161692812
Change-Id: I36dc1a1fae96dddee91c5efb8892c4a6c7ef67ca
Diffstat (limited to 'java/com/android')
7 files changed, 67 insertions, 5 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index 4942184a2..41c9d6003 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -967,7 +967,7 @@ public class CallLogAdapter extends GroupingListAdapter } @MainThread - private static CallDetailsEntries createCallDetailsEntries(Cursor cursor, int count) { + private CallDetailsEntries createCallDetailsEntries(Cursor cursor, int count) { Assert.isMainThread(); int position = cursor.getPosition(); CallDetailsEntries.Builder entries = CallDetailsEntries.newBuilder(); @@ -980,6 +980,16 @@ public class CallLogAdapter extends GroupingListAdapter .setDate(cursor.getLong(CallLogQuery.DATE)) .setDuration(cursor.getLong(CallLogQuery.DURATION)) .setFeatures(cursor.getInt(CallLogQuery.FEATURES)); + + String phoneAccountComponentName = cursor.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME); + if (getLightbringer().getPhoneAccountComponentName() != null + && getLightbringer() + .getPhoneAccountComponentName() + .flattenToString() + .equals(phoneAccountComponentName)) { + entry.setIsLightbringerCall(true); + } + entries.addEntries(entry.build()); cursor.moveToNext(); } diff --git a/java/com/android/dialer/calldetails/CallDetailsAdapter.java b/java/com/android/dialer/calldetails/CallDetailsAdapter.java index 48e9b6998..66a736c8d 100644 --- a/java/com/android/dialer/calldetails/CallDetailsAdapter.java +++ b/java/com/android/dialer/calldetails/CallDetailsAdapter.java @@ -26,6 +26,7 @@ import com.android.dialer.calldetails.CallDetailsEntries.CallDetailsEntry; import com.android.dialer.calllogutils.CallTypeHelper; import com.android.dialer.common.Assert; import com.android.dialer.dialercontact.DialerContact; +import com.android.dialer.lightbringer.LightbringerComponent; import java.util.List; /** Adapter for RecyclerView in {@link CallDetailsActivity}. */ @@ -48,7 +49,9 @@ final class CallDetailsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol this.contact = Assert.isNotNull(contact); this.callDetailsEntries = callDetailsEntries; this.listener = listener; - callTypeHelper = new CallTypeHelper(context.getResources()); + callTypeHelper = + new CallTypeHelper( + context.getResources(), LightbringerComponent.get(context).getLightbringer()); } @Override diff --git a/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java b/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java index 6ad158e8c..9c592fc5f 100644 --- a/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java +++ b/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java @@ -91,6 +91,7 @@ public class CallDetailsEntryViewHolder extends ViewHolder { boolean isPulledCall = (entry.getFeatures() & Calls.FEATURES_PULLED_EXTERNALLY) == Calls.FEATURES_PULLED_EXTERNALLY; + boolean isLightbringerCall = entry.getIsLightbringerCall(); callTime.setTextColor(getColorForCallType(context, callType)); callTypeIcon.clear(); @@ -100,7 +101,8 @@ public class CallDetailsEntryViewHolder extends ViewHolder { callTypeIcon.setShowWifi( MotorolaUtils.shouldShowWifiIconInCallLog(context, entry.getFeatures())); - callTypeText.setText(callTypeHelper.getCallTypeText(callType, isVideoCall, isPulledCall)); + callTypeText.setText( + callTypeHelper.getCallTypeText(callType, isVideoCall, isPulledCall, isLightbringerCall)); callTime.setText(CallEntryFormatter.formatDate(context, entry.getDate())); if (CallTypeHelper.isMissedCallType(callType)) { callDuration.setVisibility(View.GONE); diff --git a/java/com/android/dialer/calldetails/proto/call_details_entries.proto b/java/com/android/dialer/calldetails/proto/call_details_entries.proto index 18bc931cb..587fd35bd 100644 --- a/java/com/android/dialer/calldetails/proto/call_details_entries.proto +++ b/java/com/android/dialer/calldetails/proto/call_details_entries.proto @@ -18,6 +18,7 @@ message CallDetailsEntries { optional int64 duration = 5; optional int64 data_usage = 6; repeated enrichedcall.historyquery.proto.HistoryResult history_results = 7; + optional bool is_lightbringer_call = 8; } repeated CallDetailsEntry entries = 1; diff --git a/java/com/android/dialer/calllogutils/CallTypeHelper.java b/java/com/android/dialer/calllogutils/CallTypeHelper.java index d3b5b67d7..783f799f3 100644 --- a/java/com/android/dialer/calllogutils/CallTypeHelper.java +++ b/java/com/android/dialer/calllogutils/CallTypeHelper.java @@ -18,6 +18,7 @@ package com.android.dialer.calllogutils; import android.content.res.Resources; import com.android.dialer.compat.AppCompatConstants; +import com.android.dialer.lightbringer.Lightbringer; /** Helper class to perform operations related to call types. */ public class CallTypeHelper { @@ -50,8 +51,12 @@ public class CallTypeHelper { private final CharSequence mBlockedName; /** Name used to identify calls which were answered on another device. */ private final CharSequence mAnsweredElsewhereName; + /** Name used to identify incoming lightbringer calls. */ + private final CharSequence mIncomingLightbringerCall; + /** Name used to identify outgoing lightbringer calls. */ + private final CharSequence mOutgoingLightbringerCall; - public CallTypeHelper(Resources resources) { + public CallTypeHelper(Resources resources, Lightbringer lightbringer) { // Cache these values so that we do not need to look them up each time. mIncomingName = resources.getString(R.string.type_incoming); mIncomingPulledName = resources.getString(R.string.type_incoming_pulled); @@ -67,6 +72,18 @@ public class CallTypeHelper { mRejectedName = resources.getString(R.string.type_rejected); mBlockedName = resources.getString(R.string.type_blocked); mAnsweredElsewhereName = resources.getString(R.string.type_answered_elsewhere); + + if (lightbringer.getIncomingCallTypeText() != -1) { + mIncomingLightbringerCall = resources.getString(lightbringer.getIncomingCallTypeText()); + } else { + mIncomingLightbringerCall = mIncomingVideoName; + } + + if (lightbringer.getOutgoingCallTypeText() != -1) { + mOutgoingLightbringerCall = resources.getString(lightbringer.getOutgoingCallTypeText()); + } else { + mOutgoingLightbringerCall = mOutgoingVideoName; + } } public static boolean isMissedCallType(int callType) { @@ -77,13 +94,17 @@ public class CallTypeHelper { } /** Returns the text used to represent the given call type. */ - public CharSequence getCallTypeText(int callType, boolean isVideoCall, boolean isPulledCall) { + public CharSequence getCallTypeText( + int callType, boolean isVideoCall, boolean isPulledCall, boolean isLightbringerCall) { switch (callType) { case AppCompatConstants.CALLS_INCOMING_TYPE: if (isVideoCall) { if (isPulledCall) { return mIncomingVideoPulledName; } else { + if (isLightbringerCall) { + return mIncomingLightbringerCall; + } return mIncomingVideoName; } } else { @@ -99,6 +120,9 @@ public class CallTypeHelper { if (isPulledCall) { return mOutgoingVideoPulledName; } else { + if (isLightbringerCall) { + return mOutgoingLightbringerCall; + } return mOutgoingVideoName; } } else { diff --git a/java/com/android/dialer/lightbringer/Lightbringer.java b/java/com/android/dialer/lightbringer/Lightbringer.java index 669e571a0..9b8a18061 100644 --- a/java/com/android/dialer/lightbringer/Lightbringer.java +++ b/java/com/android/dialer/lightbringer/Lightbringer.java @@ -22,6 +22,7 @@ import android.content.Intent; import android.support.annotation.MainThread; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.StringRes; import android.telecom.Call; import android.telecom.PhoneAccountHandle; @@ -56,4 +57,12 @@ public interface Lightbringer { @Nullable @MainThread String getPackageName(); + + @StringRes + @MainThread + int getOutgoingCallTypeText(); + + @StringRes + @MainThread + int getIncomingCallTypeText(); } diff --git a/java/com/android/dialer/lightbringer/stub/LightbringerStub.java b/java/com/android/dialer/lightbringer/stub/LightbringerStub.java index 1cb3c1ff0..92230a49e 100644 --- a/java/com/android/dialer/lightbringer/stub/LightbringerStub.java +++ b/java/com/android/dialer/lightbringer/stub/LightbringerStub.java @@ -22,6 +22,7 @@ import android.content.Intent; import android.support.annotation.MainThread; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.StringRes; import android.telecom.Call; import android.telecom.PhoneAccountHandle; import com.android.dialer.common.Assert; @@ -97,4 +98,16 @@ public class LightbringerStub implements Lightbringer { public String getPackageName() { return null; } + + @StringRes + @Override + public int getOutgoingCallTypeText() { + return -1; + } + + @StringRes + @Override + public int getIncomingCallTypeText() { + return -1; + } } |