diff options
author | Nancy Chen <nancychen@google.com> | 2015-09-16 15:21:51 -0700 |
---|---|---|
committer | Nancy Chen <nancychen@google.com> | 2015-09-17 14:43:16 -0700 |
commit | 9d6e3b2700f8011645bc3e76b118d4c615b630d6 (patch) | |
tree | 08b962b9dbe959d8ba7c96de2745f4112d6c8aee /src/com/android/dialer/voicemail | |
parent | 69c3db29a3baf8526197110c7c36f8483e70e563 (diff) |
Display duration and prepare voicemail if voicemail is downloaded.
We should always know what the duration of the voicemail is even before
it is downloaded. As such, when a voicemail is expanded, set the voicemail
duration. For a downloaded voicemail, we can go even further and prepare
the audio file when the card is expanded. This means the voicemail can
be played immediately when the user clicks "play" instead of having to
wait for the media player to buffer each time.
Bug: 23566924
Change-Id: I0ce7570eab72b0bf079d3eb8cd10b71981576a9f
Diffstat (limited to 'src/com/android/dialer/voicemail')
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java | 5 | ||||
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java | 16 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java b/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java index 14c5473ae..698530b69 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java @@ -276,9 +276,7 @@ public class VoicemailPlaybackLayout extends LinearLayout mDeleteButton.setOnClickListener(mDeleteButtonListener); mPositionText.setText(formatAsMinutesAndSeconds(0)); - mPositionText.setVisibility(View.INVISIBLE); mTotalDurationText.setText(formatAsMinutesAndSeconds(0)); - mTotalDurationText.setVisibility(View.INVISIBLE); } @Override @@ -368,9 +366,6 @@ public class VoicemailPlaybackLayout extends LinearLayout mStartStopButton.setEnabled(false); mPlaybackSeek.setProgress(0); mPlaybackSeek.setEnabled(false); - - mPositionText.setText(formatAsMinutesAndSeconds(0)); - mTotalDurationText.setText(formatAsMinutesAndSeconds(0)); } @Override diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index 95622bfa2..208096dac 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java @@ -101,6 +101,7 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene private static final String[] HAS_CONTENT_PROJECTION = new String[] { VoicemailContract.Voicemails.HAS_CONTENT, + VoicemailContract.Voicemails.DURATION }; private static final int NUMBER_OF_THREADS_IN_POOL = 2; @@ -256,14 +257,13 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene mView.onSpeakerphoneOn(mIsSpeakerphoneOn); } - mDuration.set(0); + checkForContent(); if (startPlayingImmediately) { // Since setPlaybackView can get called during the view binding process, we don't // want to reset mIsPlaying to false if the user is currently playing the // voicemail and the view is rebound. mIsPlaying = startPlayingImmediately; - checkForContent(); } } } @@ -360,7 +360,7 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene if (hasContent) { prepareContent(); } else { - requestContent(); + mView.setClipPosition(0, mDuration.get()); } } }); @@ -373,10 +373,14 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene ContentResolver contentResolver = mContext.getContentResolver(); Cursor cursor = contentResolver.query( - voicemailUri, HAS_CONTENT_PROJECTION, null, null, null); + voicemailUri, null, null, null, null); try { if (cursor != null && cursor.moveToNext()) { - return cursor.getInt(cursor.getColumnIndexOrThrow( + int duration = cursor.getInt(cursor.getColumnIndex( + VoicemailContract.Voicemails.DURATION)); + // Convert database duration (seconds) into mDuration (milliseconds) + mDuration.set(duration > 0 ? duration * 1000 : 0); + return cursor.getInt(cursor.getColumnIndex( VoicemailContract.Voicemails.HAS_CONTENT)) == 1; } } finally { @@ -604,7 +608,7 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene if (!mIsPrepared) { // If we haven't downloaded the voicemail yet, attempt to download it. - checkForContent(); + requestContent(); mIsPlaying = true; return; } |