diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-16 20:15:24 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-06-16 20:15:24 +0000 |
commit | bff4d81c34c8b851291ada9db2fb07c978607142 (patch) | |
tree | ccd9cf0f6e51346c102ae62ba155dfe6ae8d18ea | |
parent | 1fb6b0afa7bac57073d177514b246a1ee327b428 (diff) | |
parent | e445ae79d87f70f207c1a16a3585c03f577b901f (diff) |
am e445ae79: Merge "Add play voicemail primary action to call log." into mnc-dev
* commit 'e445ae79d87f70f207c1a16a3585c03f577b901f':
Add play voicemail primary action to call log.
-rw-r--r-- | res/drawable-hdpi/ic_play_arrow_24dp.png | bin | 0 -> 195 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_play_arrow_24dp.png | bin | 0 -> 157 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_play_arrow_24dp.png | bin | 0 -> 220 bytes | |||
-rw-r--r-- | res/drawable-xxhdpi/ic_play_arrow_24dp.png | bin | 0 -> 283 bytes | |||
-rw-r--r-- | res/drawable-xxxhdpi/ic_play_arrow_24dp.png | bin | 0 -> 343 bytes | |||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAdapter.java | 7 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/CallLogListItemViewHolder.java | 44 | ||||
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java | 27 | ||||
-rw-r--r-- | tests/src/com/android/dialer/calllog/CallLogFragmentTest.java | 4 |
9 files changed, 65 insertions, 17 deletions
diff --git a/res/drawable-hdpi/ic_play_arrow_24dp.png b/res/drawable-hdpi/ic_play_arrow_24dp.png Binary files differnew file mode 100644 index 000000000..57c9fa546 --- /dev/null +++ b/res/drawable-hdpi/ic_play_arrow_24dp.png diff --git a/res/drawable-mdpi/ic_play_arrow_24dp.png b/res/drawable-mdpi/ic_play_arrow_24dp.png Binary files differnew file mode 100644 index 000000000..c61e948bb --- /dev/null +++ b/res/drawable-mdpi/ic_play_arrow_24dp.png diff --git a/res/drawable-xhdpi/ic_play_arrow_24dp.png b/res/drawable-xhdpi/ic_play_arrow_24dp.png Binary files differnew file mode 100644 index 000000000..a3c80e73d --- /dev/null +++ b/res/drawable-xhdpi/ic_play_arrow_24dp.png diff --git a/res/drawable-xxhdpi/ic_play_arrow_24dp.png b/res/drawable-xxhdpi/ic_play_arrow_24dp.png Binary files differnew file mode 100644 index 000000000..547ef30aa --- /dev/null +++ b/res/drawable-xxhdpi/ic_play_arrow_24dp.png diff --git a/res/drawable-xxxhdpi/ic_play_arrow_24dp.png b/res/drawable-xxxhdpi/ic_play_arrow_24dp.png Binary files differnew file mode 100644 index 000000000..be5c062b5 --- /dev/null +++ b/res/drawable-xxxhdpi/ic_play_arrow_24dp.png diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 3c7e080b4..4304002da 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -116,9 +116,13 @@ public class CallLogAdapter extends GroupingListAdapter return; } + // Always reset the voicemail playback state on expand or collapse. + mVoicemailPlaybackPresenter.reset(); + if (viewHolder.getAdapterPosition() == mCurrentlyExpandedPosition) { // Hide actions, if the clicked item is the expanded item. viewHolder.showActions(false); + mCurrentlyExpandedPosition = RecyclerView.NO_POSITION; mCurrentlyExpandedRowId = NO_EXPANDED_LIST_ITEM; } else { @@ -289,6 +293,7 @@ public class CallLogAdapter extends GroupingListAdapter CallLogListItemViewHolder viewHolder = CallLogListItemViewHolder.create( view, mContext, + mExpandCollapseListener, mPhoneNumberUtilsWrapper, mCallLogViewsHelper, mVoicemailPlaybackPresenter); @@ -297,7 +302,6 @@ public class CallLogAdapter extends GroupingListAdapter viewHolder.callLogEntryView.setAccessibilityDelegate(mAccessibilityDelegate); viewHolder.primaryActionView.setTag(viewHolder); - viewHolder.primaryActionView.setOnClickListener(mExpandCollapseListener); return viewHolder; } @@ -402,7 +406,6 @@ public class CallLogAdapter extends GroupingListAdapter mCurrentlyExpandedPosition = position; } views.showActions(mCurrentlyExpandedPosition == position); - 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 1d6a4340a..f54720b31 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -145,8 +145,12 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder private final int mPhotoSize; + private View.OnClickListener mExpandCollapseListener; + private boolean mVoicemailPrimaryActionButtonClicked; + private CallLogListItemViewHolder( Context context, + View.OnClickListener expandCollapseListener, PhoneNumberUtilsWrapper phoneNumberUtilsWrapper, CallLogListItemHelper callLogListItemHelper, VoicemailPlaybackPresenter voicemailPlaybackPresenter, @@ -160,6 +164,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder super(rootView); mContext = context; + mExpandCollapseListener = expandCollapseListener; mPhoneNumberUtilsWrapper = phoneNumberUtilsWrapper; mCallLogListItemHelper = callLogListItemHelper; mVoicemailPlaybackPresenter = voicemailPlaybackPresenter; @@ -182,17 +187,20 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder quickContactView.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE); primaryActionButtonView.setOnClickListener(this); + primaryActionView.setOnClickListener(mExpandCollapseListener); } public static CallLogListItemViewHolder create( View view, Context context, + View.OnClickListener expandCollapseListener, PhoneNumberUtilsWrapper phoneNumberUtilsWrapper, CallLogListItemHelper callLogListItemHelper, VoicemailPlaybackPresenter voicemailPlaybackPresenter) { return new CallLogListItemViewHolder( context, + expandCollapseListener, phoneNumberUtilsWrapper, callLogListItemHelper, voicemailPlaybackPresenter, @@ -243,8 +251,17 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder bindActionButtons(); } - public void updatePrimaryActionButton() { - if (TextUtils.isEmpty(voicemailUri)) { + private void updatePrimaryActionButton(boolean isExpanded) { + if (!TextUtils.isEmpty(voicemailUri)) { + // Treat as voicemail list item; show play button if not expanded. + if (!isExpanded) { + primaryActionButtonView.setImageResource(R.drawable.ic_play_arrow_24dp); + primaryActionButtonView.setVisibility(View.VISIBLE); + } else { + primaryActionButtonView.setVisibility(View.GONE); + } + } else { + // Treat as normal list item; show call button, if possible. boolean canPlaceCallToNumber = PhoneNumberUtilsWrapper.canPlaceCallsTo(number, numberPresentation); @@ -306,7 +323,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder Uri uri = Uri.parse(voicemailUri); mVoicemailPlaybackPresenter.setPlaybackView( - voicemailPlaybackView, uri, false /* startPlayingImmediately */); + voicemailPlaybackView, uri, mVoicemailPrimaryActionButtonClicked); + mVoicemailPrimaryActionButtonClicked = false; CallLogAsyncTaskUtil.markVoicemailAsRead(mContext, uri); } else { @@ -356,6 +374,8 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder actionsView.setVisibility(View.GONE); } } + + updatePrimaryActionButton(show); } public void expandVoicemailTranscriptionView(boolean isExpanded) { @@ -402,12 +422,17 @@ 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); + if (view.getId() == R.id.primary_action_button && !TextUtils.isEmpty(voicemailUri)) { + mVoicemailPrimaryActionButtonClicked = true; + mExpandCollapseListener.onClick(primaryActionView); + } else { + 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); + } } } } @@ -421,6 +446,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder CallLogListItemViewHolder viewHolder = new CallLogListItemViewHolder( context, + null /* expandCollapseListener */, phoneNumberUtilsWrapper, new CallLogListItemHelper(phoneCallDetailsHelper, resources), null /* voicemailPlaybackPresenter */, diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index d47e9e213..cc6437627 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java @@ -178,6 +178,18 @@ public class VoicemailPlaybackPresenter mMediaPlayer.setOnCompletionListener(this); } + public void reset() { + pausePlayback(); + + mView = null; + mVoicemailUri = null; + + mIsPrepared = false; + mIsPlaying = false; + mPosition = 0; + mDuration.set(0); + } + /** * Specify the view which this presenter controls and the voicemail for playback. */ @@ -204,7 +216,6 @@ public class VoicemailPlaybackPresenter mView.onSpeakerphoneOn(false); checkForContent(); - } } @@ -341,7 +352,9 @@ public class VoicemailPlaybackPresenter public void run() { if (mIsWaitingForResult.getAndSet(false)) { mContext.getContentResolver().unregisterContentObserver(this); - mView.setFetchContentTimeout(); + if (mView != null) { + mView.setFetchContentTimeout(); + } } } @@ -384,7 +397,11 @@ public class VoicemailPlaybackPresenter * and it will call {@link #onError()} otherwise. */ private void prepareToPlayContent() { + if (mView == null) { + return; + } mIsPrepared = false; + mView.setIsBuffering(); try { @@ -402,7 +419,11 @@ public class VoicemailPlaybackPresenter */ @Override public void onPrepared(MediaPlayer mp) { + if (mView == null) { + return; + } mIsPrepared = true; + mDuration.set(mMediaPlayer.getDuration()); mView.enableUiElements(); @@ -421,7 +442,7 @@ public class VoicemailPlaybackPresenter */ @Override public boolean onError(MediaPlayer mp, int what, int extra) { - handleError(new IllegalStateException("MediaPlayer error listener invoked")); + handleError(new IllegalStateException("MediaPlayer error listener invoked: " + extra)); return true; } diff --git a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java index b3906f814..6f4b68b82 100644 --- a/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java +++ b/tests/src/com/android/dialer/calllog/CallLogFragmentTest.java @@ -147,7 +147,7 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme */ @MediumTest public void testCallViewIsNotVisibleForPrivateAndUnknownNumbers() { - final int SIZE = 100; + final int SIZE = 50; mList = new CallLogListItemViewHolder[SIZE]; // Insert the first batch of entries. @@ -320,7 +320,6 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme CallLogListItemViewHolder viewHolder = (CallLogListItemViewHolder) mAdapter.onCreateViewHolder(mParentView, /* viewType */ 0); bindViewForTest(viewHolder); - viewHolder.updatePrimaryActionButton(); // The primaryActionView tag is set in the // {@link com.android.dialer.calllog.CallLogAdapter#bindView} method. If it is possible @@ -453,7 +452,6 @@ public class CallLogFragmentTest extends ActivityInstrumentationTestCase2<Fragme } }); getInstrumentation().waitForIdleSync(); - viewHolder.updatePrimaryActionButton(); } private void bindViewForTest(CallLogListItemViewHolder viewHolder) { |