diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-15 18:04:58 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-15 18:04:59 +0000 |
commit | 2685412eb75941e3929c2cf4d515f621abbfa552 (patch) | |
tree | b626b8ecb95fda8f52229d5b3ae23d46646f7702 | |
parent | efd4c293b3a705cc4a666cbd61c63af8f70933f3 (diff) | |
parent | b0b57a10fbb9bec5c80d7adad8f65750a2f96e1b (diff) |
Merge "Convert to primary action button on call log items." into mnc-dev
-rw-r--r-- | res/layout/call_detail.xml | 6 | ||||
-rw-r--r-- | res/layout/call_log_list_item.xml | 10 | ||||
-rw-r--r-- | res/layout/call_log_list_item_actions.xml | 15 | ||||
-rw-r--r-- | res/values/colors.xml | 2 | ||||
-rw-r--r-- | res/values/dimens.xml | 2 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAdapter.java | 24 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogListItemViewHolder.java | 109 | ||||
-rw-r--r-- | tests/src/com/android/dialer/calllog/CallLogFragmentTest.java | 14 | ||||
-rw-r--r-- | tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java | 2 |
9 files changed, 100 insertions, 84 deletions
diff --git a/res/layout/call_detail.xml b/res/layout/call_detail.xml index abc0fbb70..fde1de5c1 100644 --- a/res/layout/call_detail.xml +++ b/res/layout/call_detail.xml @@ -85,13 +85,13 @@ <ImageView android:id="@+id/call_back_button" - android:layout_width="@dimen/call_button_dimen" - android:layout_height="@dimen/call_button_dimen" + android:layout_width="@dimen/call_log_list_item_primary_action_dimen" + android:layout_height="@dimen/call_log_list_item_primary_action_dimen" android:layout_marginEnd="16dp" android:background="?android:attr/selectableItemBackgroundBorderless" android:src="@drawable/ic_call_24dp" android:scaleType="center" - android:tint="@color/recent_call_log_item_phone_icon_tint" + android:tint="@color/call_log_list_item_primary_action_icon_tint" android:contentDescription="@string/description_call_log_call_action" android:visibility="gone" /> diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml index 7fce595a8..ec512b67f 100644 --- a/res/layout/call_log_list_item.xml +++ b/res/layout/call_log_list_item.xml @@ -137,16 +137,14 @@ </LinearLayout> <ImageView - android:id="@+id/call_icon" - android:layout_width="@dimen/call_button_dimen" - android:layout_height="@dimen/call_button_dimen" + android:id="@+id/primary_action_button" + android:layout_width="@dimen/call_log_list_item_primary_action_dimen" + android:layout_height="@dimen/call_log_list_item_primary_action_dimen" android:layout_gravity="center_vertical" android:layout_marginEnd="@dimen/call_log_icon_margin" android:background="?android:attr/selectableItemBackgroundBorderless" - android:src="@drawable/ic_call_24dp" android:scaleType="center" - android:tint="@color/recent_call_log_item_phone_icon_tint" - android:contentDescription="@string/description_call_log_call_action" + android:tint="@color/call_log_list_item_primary_action_icon_tint" android:visibility="gone" /> </LinearLayout> diff --git a/res/layout/call_log_list_item_actions.xml b/res/layout/call_log_list_item_actions.xml index d4c970655..4d3fb75e4 100644 --- a/res/layout/call_log_list_item_actions.xml +++ b/res/layout/call_log_list_item_actions.xml @@ -29,6 +29,21 @@ android:layout_height="wrap_content" /> <LinearLayout + android:id="@+id/call_action" + style="@style/CallLogActionStyle"> + + <ImageView + style="@style/CallLogActionIconStyle" + android:src="@drawable/ic_call_24dp" /> + + <TextView + android:id="@+id/call_action_text" + style="@style/CallLogActionTextStyle" + android:text="@string/description_call_log_call_action" /> + + </LinearLayout> + + <LinearLayout android:id="@+id/video_call_action" style="@style/CallLogActionStyle"> diff --git a/res/values/colors.xml b/res/values/colors.xml index 352bce562..f83c3284c 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -37,7 +37,7 @@ <color name="call_log_voicemail_highlight_color">#33b5e5</color> <!-- Tint of the recent card phone icon; 30% black --> - <color name="recent_call_log_item_phone_icon_tint">#4d000000</color> + <color name="call_log_list_item_primary_action_icon_tint">#4d000000</color> <color name="voicemail_playback_icon_tint">#8e8e8e</color> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 9d987e851..bcde855b5 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -133,5 +133,5 @@ <dimen name="preference_side_margin">16dp</dimen> <dimen name="preference_summary_line_spacing_extra">4dp</dimen> - <dimen name="call_button_dimen">36dp</dimen> + <dimen name="call_log_list_item_primary_action_dimen">36dp</dimen> </resources> diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 69fbb034b..3c7e080b4 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -41,7 +41,6 @@ import com.android.dialer.PhoneCallDetailsHelper; import com.android.dialer.R; import com.android.dialer.contactinfo.ContactInfoCache; import com.android.dialer.contactinfo.ContactInfoCache.OnContactInfoChangedListener; -import com.android.dialer.util.DialerUtils; import com.android.dialer.voicemail.VoicemailPlaybackPresenter; import com.google.common.annotations.VisibleForTesting; @@ -105,24 +104,6 @@ public class CallLogAdapter extends GroupingListAdapter /** Helper to group call log entries. */ private final CallLogGroupBuilder mCallLogGroupBuilder; - /** Listener for the primary or secondary actions in the list. - * Primary opens the call details. - * Secondary calls or plays. - **/ - private final View.OnClickListener mActionListener = new View.OnClickListener() { - @Override - public void onClick(View view) { - final IntentProvider intentProvider = (IntentProvider) view.getTag(); - if (intentProvider != null) { - final Intent intent = intentProvider.getIntent(mContext); - // See IntentProvider.getCallDetailIntentProvider() for why this may be null. - if (intent != null) { - DialerUtils.startActivityWithErrorToast(mContext, intent); - } - } - } - }; - /** * The OnClickListener used to expand or collapse the action buttons of a call log entry. */ @@ -308,7 +289,6 @@ public class CallLogAdapter extends GroupingListAdapter CallLogListItemViewHolder viewHolder = CallLogListItemViewHolder.create( view, mContext, - mActionListener, mPhoneNumberUtilsWrapper, mCallLogViewsHelper, mVoicemailPlaybackPresenter); @@ -414,13 +394,15 @@ public class CallLogAdapter extends GroupingListAdapter views.dayGroupHeader.setVisibility(View.GONE); } + mCallLogViewsHelper.setPhoneCallDetails(mContext, views, details); + // Update the expanded position if the rowIds match, in case ViewHolders were added/removed. // Then restore the state of the row on rebind. if (mCurrentlyExpandedRowId == views.rowId) { mCurrentlyExpandedPosition = position; } views.showActions(mCurrentlyExpandedPosition == position); - views.updateCallButton(); + views.updatePrimaryActionButton(); String nameForDefaultImage = null; if (TextUtils.isEmpty(info.name)) { diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java index 987bcb85d..1d6a4340a 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -31,6 +31,7 @@ import android.view.ViewGroup; import android.view.ViewStub; import android.view.ViewTreeObserver; import android.widget.QuickContactBadge; +import android.widget.ImageView; import android.widget.TextView; import com.android.contacts.common.CallUtil; @@ -42,6 +43,7 @@ import com.android.dialer.PhoneCallDetailsHelper; import com.android.dialer.PhoneCallDetailsViews; import com.android.dialer.R; import com.android.dialer.calllog.CallLogAsyncTaskUtil; +import com.android.dialer.util.DialerUtils; import com.android.dialer.voicemail.VoicemailPlaybackPresenter; import com.android.dialer.voicemail.VoicemailPlaybackLayout; @@ -51,7 +53,8 @@ import com.android.dialer.voicemail.VoicemailPlaybackLayout; * * This object also contains UI logic pertaining to the view, to isolate it from the CallLogAdapter. */ -public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { +public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder + implements View.OnClickListener { /** The root view of the call log list item */ public final View rootView; @@ -66,12 +69,13 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { /** The view containing the details for the call log row, including the action buttons. */ public final CardView callLogEntryView; /** The actionable view which places a call to the number corresponding to the call log row. */ - public final View callActionView; + public final ImageView primaryActionButtonView; /** The view containing call log item actions. Null until the ViewStub is inflated. */ public View actionsView; /** The button views below are assigned only when the action section is expanded. */ public VoicemailPlaybackLayout voicemailPlaybackView; + public View callButtonView; public View videoCallButtonView; public View createNewContactButtonView; public View addToExistingContactButtonView; @@ -135,7 +139,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { private static final int VOICEMAIL_TRANSCRIPTION_MAX_LINES = 10; private final Context mContext; - private final View.OnClickListener mActionListener; private final PhoneNumberUtilsWrapper mPhoneNumberUtilsWrapper; private final CallLogListItemHelper mCallLogListItemHelper; private final VoicemailPlaybackPresenter mVoicemailPlaybackPresenter; @@ -144,7 +147,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { private CallLogListItemViewHolder( Context context, - View.OnClickListener actionListener, PhoneNumberUtilsWrapper phoneNumberUtilsWrapper, CallLogListItemHelper callLogListItemHelper, VoicemailPlaybackPresenter voicemailPlaybackPresenter, @@ -154,11 +156,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { PhoneCallDetailsViews phoneCallDetailsViews, CardView callLogEntryView, TextView dayGroupHeader, - View callActionView) { + ImageView primaryActionButtonView) { super(rootView); mContext = context; - mActionListener = actionListener; mPhoneNumberUtilsWrapper = phoneNumberUtilsWrapper; mCallLogListItemHelper = callLogListItemHelper; mVoicemailPlaybackPresenter = voicemailPlaybackPresenter; @@ -169,7 +170,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { this.phoneCallDetailsViews = phoneCallDetailsViews; this.callLogEntryView = callLogEntryView; this.dayGroupHeader = dayGroupHeader; - this.callActionView = callActionView; + this.primaryActionButtonView = primaryActionButtonView; Resources resources = mContext.getResources(); mPhotoSize = mContext.getResources().getDimensionPixelSize(R.dimen.contact_photo_size); @@ -180,22 +181,18 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { quickContactView.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE); - if (callActionView != null) { - callActionView.setOnClickListener(mActionListener); - } + primaryActionButtonView.setOnClickListener(this); } public static CallLogListItemViewHolder create( View view, Context context, - View.OnClickListener actionListener, PhoneNumberUtilsWrapper phoneNumberUtilsWrapper, CallLogListItemHelper callLogListItemHelper, VoicemailPlaybackPresenter voicemailPlaybackPresenter) { return new CallLogListItemViewHolder( context, - actionListener, phoneNumberUtilsWrapper, callLogListItemHelper, voicemailPlaybackPresenter, @@ -205,7 +202,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { PhoneCallDetailsViews.fromView(view), (CardView) view.findViewById(R.id.call_log_row), (TextView) view.findViewById(R.id.call_log_day_group_label), - view.findViewById(R.id.call_icon)); + (ImageView) view.findViewById(R.id.primary_action_button)); } /** @@ -223,54 +220,55 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { voicemailPlaybackView = (VoicemailPlaybackLayout) actionsView .findViewById(R.id.voicemail_playback_layout); + callButtonView = actionsView.findViewById(R.id.call_action); + callButtonView.setOnClickListener(this); + videoCallButtonView = actionsView.findViewById(R.id.video_call_action); - videoCallButtonView.setOnClickListener(mActionListener); + videoCallButtonView.setOnClickListener(this); createNewContactButtonView = actionsView.findViewById(R.id.create_new_contact_action); - createNewContactButtonView.setOnClickListener(mActionListener); + createNewContactButtonView.setOnClickListener(this); addToExistingContactButtonView = actionsView.findViewById(R.id.add_to_existing_contact_action); - addToExistingContactButtonView.setOnClickListener(mActionListener); + addToExistingContactButtonView.setOnClickListener(this); sendMessageView = actionsView.findViewById(R.id.send_message_action); - sendMessageView.setOnClickListener(mActionListener); + sendMessageView.setOnClickListener(this); detailsButtonView = actionsView.findViewById(R.id.details_action); - detailsButtonView.setOnClickListener(mActionListener); + detailsButtonView.setOnClickListener(this); } bindActionButtons(); } - public void updateCallButton() { - boolean canPlaceCallToNumber = - PhoneNumberUtilsWrapper.canPlaceCallsTo(number, numberPresentation); - - if (canPlaceCallToNumber) { - boolean isVoicemailNumber = - mPhoneNumberUtilsWrapper.isVoicemailNumber(accountHandle, number); - if (isVoicemailNumber) { - // Make a general call to voicemail to ensure that if there are multiple accounts - // it does not call the voicemail number of a specific phone account. - callActionView.setTag(IntentProvider.getReturnVoicemailCallIntentProvider()); - } else { - callActionView.setTag(IntentProvider.getReturnCallIntentProvider(number)); - } - - if (nameOrNumber != null) { - callActionView.setContentDescription(TextUtils.expandTemplate( + public void updatePrimaryActionButton() { + if (TextUtils.isEmpty(voicemailUri)) { + boolean canPlaceCallToNumber = + PhoneNumberUtilsWrapper.canPlaceCallsTo(number, numberPresentation); + + if (canPlaceCallToNumber) { + boolean isVoicemailNumber = + mPhoneNumberUtilsWrapper.isVoicemailNumber(accountHandle, number); + if (isVoicemailNumber) { + // Call to generic voicemail number, in case there are multiple accounts. + primaryActionButtonView.setTag( + IntentProvider.getReturnVoicemailCallIntentProvider()); + } else { + primaryActionButtonView.setTag( + IntentProvider.getReturnCallIntentProvider(number)); + } + + primaryActionButtonView.setContentDescription(TextUtils.expandTemplate( mContext.getString(R.string.description_call_action), nameOrNumber)); + primaryActionButtonView.setImageResource(R.drawable.ic_call_24dp); + primaryActionButtonView.setVisibility(View.VISIBLE); } else { - callActionView.setContentDescription( - mContext.getString(R.string.description_call_log_call_action)); + primaryActionButtonView.setTag(null); + primaryActionButtonView.setVisibility(View.GONE); } - - callActionView.setVisibility(View.VISIBLE); - } else { - callActionView.setTag(null); - callActionView.setVisibility(View.GONE); } } @@ -282,13 +280,23 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { boolean canPlaceCallToNumber = PhoneNumberUtilsWrapper.canPlaceCallsTo(number, numberPresentation); + if (!TextUtils.isEmpty(voicemailUri) && canPlaceCallToNumber) { + callButtonView.setTag(IntentProvider.getReturnCallIntentProvider(number)); + ((TextView) callButtonView.findViewById(R.id.call_action_text)) + .setText(TextUtils.expandTemplate( + mContext.getString(R.string.call_log_action_call), + nameOrNumber)); + callButtonView.setVisibility(View.VISIBLE); + } else { + callButtonView.setVisibility(View.GONE); + } + // If one of the calls had video capabilities, show the video call button. if (CallUtil.isVideoEnabled(mContext) && canPlaceCallToNumber && phoneCallDetailsViews.callTypeIcons.isVideoShown()) { videoCallButtonView.setTag(IntentProvider.getReturnVideoCallIntentProvider(number)); videoCallButtonView.setVisibility(View.VISIBLE); } else { - videoCallButtonView.setTag(null); videoCallButtonView.setVisibility(View.GONE); } @@ -392,6 +400,18 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { } } + @Override + public void onClick(View view) { + final IntentProvider intentProvider = (IntentProvider) view.getTag(); + if (intentProvider != null) { + final Intent intent = intentProvider.getIntent(mContext); + // See IntentProvider.getCallDetailIntentProvider() for why this may be null. + if (intent != null) { + DialerUtils.startActivityWithErrorToast(mContext, intent); + } + } + } + @NeededForTesting public static CallLogListItemViewHolder createForTest(Context context) { Resources resources = context.getResources(); @@ -401,7 +421,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { CallLogListItemViewHolder viewHolder = new CallLogListItemViewHolder( context, - null /* actionListener */, phoneNumberUtilsWrapper, new CallLogListItemHelper(phoneCallDetailsHelper, resources), null /* voicemailPlaybackPresenter */, @@ -411,7 +430,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { PhoneCallDetailsViews.createForTest(context), new CardView(context), new TextView(context), - new View(context)); + new ImageView(context)); viewHolder.detailsButtonView = new TextView(context); viewHolder.actionsView = new View(context); viewHolder.voicemailPlaybackView = new VoicemailPlaybackLayout(context); diff --git a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java index df6719c38..a739b16d2 100644 --- a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java @@ -326,13 +326,14 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme CallLogListItemViewHolder viewHolder = (CallLogListItemViewHolder) mAdapter.onCreateViewHolder(mParentView, /* viewType */ 0); bindViewForTest(viewHolder); - viewHolder.updateCallButton(); + viewHolder.updatePrimaryActionButton(); // The primaryActionView tag is set in the // {@link com.android.dialer.calllog.CallLogAdapter#bindView} method. If it is possible // to place a call to the phone number, a call intent will have been created for the // primaryActionView. - IntentProvider intentProvider = (IntentProvider) viewHolder.callActionView.getTag(); + IntentProvider intentProvider = + (IntentProvider) viewHolder.primaryActionButtonView.getTag(); Intent intent = intentProvider.getIntent(mActivity); // Starts a call. assertEquals(TestConstants.CALL_INTENT_ACTION, intent.getAction()); @@ -375,12 +376,13 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme if (presentation == Calls.PRESENTATION_RESTRICTED || presentation == Calls.PRESENTATION_UNKNOWN) { //If number is not callable, the primary action view should have a null tag. - assertNull(mItem.callActionView.getTag()); + assertNull(mItem.primaryActionButtonView.getTag()); } else { //If the number is callable, the primary action view should have a non-null tag. - assertNotNull(mItem.callActionView.getTag()); + assertNotNull(mItem.primaryActionButtonView.getTag()); - IntentProvider intentProvider = (IntentProvider)mItem.callActionView.getTag(); + IntentProvider intentProvider = + (IntentProvider) mItem.primaryActionButtonView.getTag(); Intent callIntent = intentProvider.getIntent(mActivity); //The intent should be to make the call @@ -457,7 +459,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme } }); getInstrumentation().waitForIdleSync(); - viewHolder.updateCallButton(); + viewHolder.updatePrimaryActionButton(); } private void bindViewForTest(CallLogListItemViewHolder viewHolder) { diff --git a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java index 091065b91..8ee85a436 100644 --- a/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogListItemHelperTest.java @@ -78,7 +78,7 @@ public class CallLogListItemHelperTest extends AndroidTestCase { public void testSetPhoneCallDetails() { setPhoneCallDetailsWithNumber("12125551234", Calls.PRESENTATION_ALLOWED, "1-212-555-1234"); - assertEquals(View.VISIBLE, mViewHolder.callActionView.getVisibility()); + assertEquals(View.VISIBLE, mViewHolder.primaryActionButtonView.getVisibility()); } public void testSetPhoneCallDetails_Unknown() { |