diff options
author | Tyler Gunn <tgunn@google.com> | 2014-07-15 12:40:28 -0700 |
---|---|---|
committer | Tyler Gunn <tgunn@google.com> | 2014-07-15 12:44:01 -0700 |
commit | 5619f2ed87cb207352c0ff5578348baeb69ee202 (patch) | |
tree | a794e13d436109711c0ba759eafa6d65fe258fa8 | |
parent | 57750bca2f46ed9f6da4be0dea3959a0d9f49c01 (diff) |
Various call log / call details video call changes.
Requires cl/501841.
Call log:
1. Add video call affordance.
2. Add accessibility text for calls, video call afforance.
3. Fixed unit test
Call details:
1. Showing video icon when a call had video.
2. Changing call headings to indicate they were video calls.
Bug: 16013879
Bug: 16013344
Bug: 16013684
Change-Id: I53b5bf9b0b1a63f9d119318d59f690d310cca7c8
12 files changed, 154 insertions, 25 deletions
diff --git a/res/layout/call_log_list_item_actions.xml b/res/layout/call_log_list_item_actions.xml index 22fcca0c2..ac83f4ac8 100644 --- a/res/layout/call_log_list_item_actions.xml +++ b/res/layout/call_log_list_item_actions.xml @@ -41,6 +41,22 @@ android:textSize="@dimen/call_log_list_item_actions_text_size" android:textStyle="bold" android:nextFocusLeft="@+id/primary_action_view" + android:nextFocusRight="@+id/video_call_action" + android:focusable="true" + android:singleLine="true"/> + <TextView + android:id="@+id/video_call_action" + android:background="@drawable/action_button_background" + android:gravity="center" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:paddingStart="@dimen/call_log_action_horizontal_padding" + android:paddingEnd="@dimen/call_log_action_horizontal_padding" + android:text="@string/call_log_action_video_call" + android:textColor="?attr/call_log_secondary_text_color" + android:textSize="@dimen/call_log_list_item_actions_text_size" + android:textStyle="bold" + android:nextFocusLeft="@+id/call_back_action" android:nextFocusRight="@+id/voicemail_action" android:focusable="true" android:singleLine="true"/> @@ -56,7 +72,7 @@ android:textColor="@color/call_log_action_text" android:textSize="@dimen/call_log_list_item_actions_text_size" android:textStyle="bold" - android:nextFocusLeft="@+id/call_back_action" + android:nextFocusLeft="@+id/video_call_action" android:nextFocusRight="@+id/details_action" android:focusable="true" android:singleLine="true"/> diff --git a/res/values/strings.xml b/res/values/strings.xml index e51aff714..8375df8a0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -425,6 +425,14 @@ --> <string name="description_num_calls"><xliff:g id="numberOfCalls">%1$s</xliff:g> calls.</string> + <!-- String indicating a call log entry had video capabilities. + + Note: AccessibilityServices use this attribute to announce what the view represents. + This is especially valuable for views without textual representation like ImageView. + [CHAR LIMIT=NONE] + --> + <string name="description_video_call">Video call.</string> + <!-- String describing the button to SMS a number or contact. Note: AccessibilityServices use this attribute to announce what the view represents. @@ -641,21 +649,6 @@ [CHAR LIMIT=NONE] --> <string name="description_outgoing_call">Call to <xliff:g id="nameOrNumber" example="John Smith">%1$s</xliff:g>, <xliff:g id="typeOrLocation" example="Mobile">%2$s</xliff:g>, <xliff:g id="timeOfCall" example="2 min ago">%3$s</xliff:g>.</string> - <!-- String describing an incoming missed video call entry in the call log. - Note: AccessibilityServices uses this attribute to announce what the view represents. - [CHAR LIMIT=NONE] --> - <string name="description_incoming_missed_video_call">Missed video call from <xliff:g id="nameOrNumber" example="John Smith">%1$s</xliff:g>, <xliff:g id="typeOrLocation" example="Mobile">%2$s</xliff:g>, <xliff:g id="timeOfCall" example="2 min ago">%3$s</xliff:g>.</string> - - <!-- String describing an incoming answered video call entry in the call log. - Note: AccessibilityServices uses this attribute to announce what the view represents. - [CHAR LIMIT=NONE] --> - <string name="description_incoming_answered_video_call">Answered video call from <xliff:g id="nameOrNumber" example="John Smith">%1$s</xliff:g>, <xliff:g id="typeOrLocation" example="Mobile">%2$s</xliff:g>, <xliff:g id="timeOfCall" example="2 min ago">%3$s</xliff:g>.</string> - - <!-- String describing an outgoing video call entry in the call log. - Note: AccessibilityServices uses this attribute to announce what the view represents. - [CHAR LIMIT=NONE] --> - <string name="description_outgoing_video_call">Video call to <xliff:g id="nameOrNumber" example="John Smith">%1$s</xliff:g>, <xliff:g id="typeOrLocation" example="Mobile">%2$s</xliff:g>, <xliff:g id="timeOfCall" example="2 min ago">%3$s</xliff:g>.</string> - <!-- String describing the "call back" action for an entry in the call log. The call back action triggers a return call to the named user. Note: AccessibilityServices uses this attribute to announce the purpose of the button. diff --git a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java index cc116e7ad..105462ffe 100644 --- a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java +++ b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java @@ -122,11 +122,12 @@ public class CallDetailHistoryAdapter extends BaseAdapter { TextView durationView = (TextView) result.findViewById(R.id.duration); int callType = details.callTypes[0]; + boolean isVideoCall = (details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO; + callTypeIconView.clear(); callTypeIconView.add(callType); - callTypeIconView.setShowVideo( - (details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO); - callTypeTextView.setText(mCallTypeHelper.getCallTypeText(callType)); + callTypeIconView.setShowVideo(isVideoCall); + callTypeTextView.setText(mCallTypeHelper.getCallTypeText(callType, isVideoCall)); // Set the date. CharSequence dateValue = DateUtils.formatDateRange(mContext, details.date, details.date, DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index f4b9f3a94..d70a40dea 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -895,6 +895,7 @@ public class CallLogAdapter extends GroupingListAdapter // focus was successful. The first successful focus will satisfy the OR // block and block further attempts to set focus. boolean focused = views.callBackButtonView.requestAccessibilityFocus() || + views.videoCallButtonView.requestAccessibilityFocus() || views.voicemailButtonView.requestAccessibilityFocus() || views.detailsButtonView.requestAccessibilityFocus(); } else { @@ -929,6 +930,11 @@ public class CallLogAdapter extends GroupingListAdapter R.id.call_back_action); } + if (views.videoCallButtonView == null) { + views.videoCallButtonView = (TextView)views.actionsView.findViewById( + R.id.video_call_action); + } + if (views.voicemailButtonView == null) { views.voicemailButtonView = (TextView)views.actionsView.findViewById( R.id.voicemail_action); @@ -960,8 +966,10 @@ public class CallLogAdapter extends GroupingListAdapter * @param views The call log item views. */ private void bindActionButtons(CallLogListItemViews views) { + boolean canPlaceCallToNumber = + PhoneNumberUtilsWrapper.canPlaceCallsTo(views.number, views.numberPresentation); // Set return call intent, otherwise null. - if (PhoneNumberUtilsWrapper.canPlaceCallsTo(views.number, views.numberPresentation)) { + if (canPlaceCallToNumber) { // Sets the primary action to call the number. views.callBackButtonView.setTag( IntentProvider.getReturnCallIntentProvider(views.number, views.mAccount)); @@ -973,6 +981,18 @@ public class CallLogAdapter extends GroupingListAdapter views.callBackButtonView.setVisibility(View.GONE); } + // If one of the calls had video capabilities, show the video call button. + if (canPlaceCallToNumber && views.phoneCallDetailsViews.callTypeIcons.isVideoShown()) { + views.videoCallButtonView.setTag( + IntentProvider.getReturnVideoCallIntentProvider(views.number, + views.mAccount)); + views.videoCallButtonView.setVisibility(View.VISIBLE); + views.videoCallButtonView.setOnClickListener(mActionListener); + } else { + views.videoCallButtonView.setTag(null); + views.videoCallButtonView.setVisibility(View.GONE); + } + // For voicemail calls, show the "VOICEMAIL" action button; hide otherwise. if (views.callType == Calls.VOICEMAIL_TYPE) { views.voicemailButtonView.setOnClickListener(mActionListener); @@ -991,6 +1011,7 @@ public class CallLogAdapter extends GroupingListAdapter IntentProvider.getCallDetailIntentProvider( views.rowId, views.callIds, null) ); + if (views.isExternal && !views.reported) { views.reportButtonView.setVisibility(View.VISIBLE); } diff --git a/src/com/android/dialer/calllog/CallLogListItemHelper.java b/src/com/android/dialer/calllog/CallLogListItemHelper.java index cb7c7cda3..b2c1e2d14 100644 --- a/src/com/android/dialer/calllog/CallLogListItemHelper.java +++ b/src/com/android/dialer/calllog/CallLogListItemHelper.java @@ -77,6 +77,9 @@ import com.android.dialer.R; views.callBackButtonView.setContentDescription( mResources.getString(R.string.description_call_back_action, views.nameOrNumber)); + views.videoCallButtonView.setContentDescription( + mResources.getString(R.string.description_video_call_action, views.nameOrNumber)); + views.voicemailButtonView.setContentDescription( mResources.getString(R.string.description_voicemail_action, views.nameOrNumber)); @@ -149,6 +152,11 @@ import com.android.dialer.R; details.callTypes.length)); } + // If call had video capabilities, add the "Video Call" string. + if ((details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) { + callDescription.append(mResources.getString(R.string.description_video_call)); + } + int stringID = getCallDescriptionStringID(details); // Use chosen string resource to build up the message. diff --git a/src/com/android/dialer/calllog/CallLogListItemViews.java b/src/com/android/dialer/calllog/CallLogListItemViews.java index 3efa5cbea..70d545e89 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViews.java +++ b/src/com/android/dialer/calllog/CallLogListItemViews.java @@ -44,6 +44,8 @@ public final class CallLogListItemViews { public View actionsView; /** The "call back" action button - assigned only when the action section is expanded. */ public TextView callBackButtonView; + /** The "video call" action button - assigned only when the action section is expanded. */ + public TextView videoCallButtonView; /** The "voicemail" action button - assigned only when the action section is expanded. */ public TextView voicemailButtonView; /** The "details" action button - assigned only when the action section is expanded. */ diff --git a/src/com/android/dialer/calllog/CallTypeHelper.java b/src/com/android/dialer/calllog/CallTypeHelper.java index 1c4f44f23..36c0975bd 100644 --- a/src/com/android/dialer/calllog/CallTypeHelper.java +++ b/src/com/android/dialer/calllog/CallTypeHelper.java @@ -31,6 +31,12 @@ public class CallTypeHelper { private final CharSequence mOutgoingName; /** Name used to identify missed calls. */ private final CharSequence mMissedName; + /** Name used to identify incoming video calls. */ + private final CharSequence mIncomingVideoName; + /** Name used to identify outgoing video calls. */ + private final CharSequence mOutgoingVideoName; + /** Name used to identify missed video calls. */ + private final CharSequence mMissedVideoName; /** Name used to identify voicemail calls. */ private final CharSequence mVoicemailName; /** Color used to identify new missed calls. */ @@ -43,22 +49,37 @@ public class CallTypeHelper { mIncomingName = resources.getString(R.string.type_incoming); mOutgoingName = resources.getString(R.string.type_outgoing); mMissedName = resources.getString(R.string.type_missed); + mIncomingVideoName = resources.getString(R.string.type_incoming_video); + mOutgoingVideoName = resources.getString(R.string.type_outgoing_video); + mMissedVideoName = resources.getString(R.string.type_missed_video); mVoicemailName = resources.getString(R.string.type_voicemail); mNewMissedColor = resources.getColor(R.color.call_log_missed_call_highlight_color); mNewVoicemailColor = resources.getColor(R.color.call_log_voicemail_highlight_color); } /** Returns the text used to represent the given call type. */ - public CharSequence getCallTypeText(int callType) { + public CharSequence getCallTypeText(int callType, boolean isVideoCall) { switch (callType) { case Calls.INCOMING_TYPE: - return mIncomingName; + if (isVideoCall) { + return mIncomingVideoName; + } else { + return mIncomingName; + } case Calls.OUTGOING_TYPE: - return mOutgoingName; + if (isVideoCall) { + return mOutgoingVideoName; + } else { + return mOutgoingName; + } case Calls.MISSED_TYPE: - return mMissedName; + if (isVideoCall) { + return mMissedVideoName; + } else { + return mMissedName; + } case Calls.VOICEMAIL_TYPE: return mVoicemailName; diff --git a/src/com/android/dialer/calllog/CallTypeIconsView.java b/src/com/android/dialer/calllog/CallTypeIconsView.java index 382056c72..ef729ae39 100644 --- a/src/com/android/dialer/calllog/CallTypeIconsView.java +++ b/src/com/android/dialer/calllog/CallTypeIconsView.java @@ -85,6 +85,15 @@ public class CallTypeIconsView extends View { } } + /** + * Determines if the video icon should be shown. + * + * @return True if the video icon should be shown. + */ + public boolean isVideoShown() { + return mShowVideo; + } + @NeededForTesting public int getCount() { return mCallTypes.size(); diff --git a/src/com/android/dialer/calllog/IntentProvider.java b/src/com/android/dialer/calllog/IntentProvider.java index 9820102d2..c52dff87f 100644 --- a/src/com/android/dialer/calllog/IntentProvider.java +++ b/src/com/android/dialer/calllog/IntentProvider.java @@ -47,6 +47,16 @@ public abstract class IntentProvider { }; } + public static IntentProvider getReturnVideoCallIntentProvider(final String number, + final PhoneAccount account) { + return new IntentProvider() { + @Override + public Intent getIntent(Context context) { + return CallUtil.getVideoCallIntent(number, account); + } + }; + } + public static IntentProvider getPlayVoicemailIntentProvider(final long rowId, final String voicemailUri) { return new IntentProvider() { diff --git a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java index 147201bcb..d0c13eeb6 100644 --- a/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java +++ b/tests/src/com/android/dialer/PhoneCallDetailsHelperTest.java @@ -159,6 +159,22 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { assertCallTypeIconsEquals(Calls.VOICEMAIL_TYPE); } + /** + * Tests a case where the video call feature is present. + */ + public void testSetPhoneCallDetails_Video() { + setPhoneCallDetailsWithFeatures(Calls.FEATURES_VIDEO); + assertIsVideoCall(true); + } + + /** + * Tests a case where the video call feature is not present. + */ + public void testSetPhoneCallDetails_NoVideo() { + setPhoneCallDetailsWithFeatures(Calls.FEATURES_NONE); + assertIsVideoCall(false); + } + public void testSetPhoneCallDetails_MultipleCallTypeIcons() { setPhoneCallDetailsWithCallTypeIcons(Calls.INCOMING_TYPE, Calls.OUTGOING_TYPE); assertCallTypeIconsEquals(Calls.INCOMING_TYPE, Calls.OUTGOING_TYPE); @@ -258,6 +274,11 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { assertTrue(mViews.callLocationAndDate.getText().toString().contains(text)); } + /** Asserts that the video icon is shown. */ + private void assertIsVideoCall(boolean isVideoCall) { + assertEquals(isVideoCall, mViews.callTypeIcons.isVideoShown()); + } + /** Asserts that the call type contains the images with the given drawables. */ private void assertCallTypeIconsEquals(int... ids) { assertEquals(ids.length, mViews.callTypeIcons.getCount()); @@ -325,6 +346,18 @@ public class PhoneCallDetailsHelperTest extends AndroidTestCase { ); } + /** + * Sets the phone call details with default values and the given call features. + */ + private void setPhoneCallDetailsWithFeatures(int features) { + mHelper.setPhoneCallDetails(mViews, + new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, + TEST_FORMATTED_NUMBER, TEST_COUNTRY_ISO, TEST_GEOCODE, + new int[]{ Calls.INCOMING_TYPE }, TEST_DATE, TEST_DURATION, null, + features, null) + ); + } + private void setCallDetailsHeaderWithNumber(String number, int presentation) { mHelper.setCallDetailsHeader(mNameView, new PhoneCallDetails(number, presentation, diff --git a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java index 8fbda1596..4c9d92cfc 100644 --- a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java @@ -327,6 +327,21 @@ public class CallLogListItemHelperTest extends AndroidTestCase { .contains(this.mResources.getString(R.string.description_num_calls, 2))); } + /** + * Test getCallDescription method used to get the accessibility description for calls. + * Test that the "Video call." message is present if the call had video capability. + */ + public void testGetCallDescription_Video() { + PhoneCallDetails details = new PhoneCallDetails(TEST_NUMBER, Calls.PRESENTATION_ALLOWED, + TEST_FORMATTED_NUMBER, + TEST_COUNTRY_ISO, TEST_GEOCODE, + new int[]{Calls.INCOMING_TYPE, Calls.INCOMING_TYPE}, TEST_DATE, TEST_DURATION, + null, Calls.FEATURES_VIDEO, null); + CharSequence description = mHelper.getCallDescription(details); + assertTrue(description.toString() + .contains(this.mResources.getString(R.string.description_video_call, 2))); + } + /** Asserts that the primary action view does not have a call intent. */ private void assertNoCallIntent() { Object intentProvider = (IntentProvider)mViews.primaryActionView.getTag(); diff --git a/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java b/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java index c13b936e5..dc3f525d8 100644 --- a/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java +++ b/tests/src/com/android/dialer/calllog/CallLogQueryTestUtils.java @@ -29,7 +29,7 @@ public class CallLogQueryTestUtils { public static Object[] createTestValues() { Object[] values = new Object[]{ 0L, "", 0L, 0L, Calls.INCOMING_TYPE, "", "", "", null, 0, null, null, null, null, - 0L, null, 0, Calls.PRESENTATION_ALLOWED, + 0L, null, 0, Calls.PRESENTATION_ALLOWED, null, null, Calls.FEATURES_NONE, null }; assertEquals(CallLogQuery._PROJECTION.length, values.length); return values; |