summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/drawable/ic_voicemail_seek_handle_disabled.xml21
-rw-r--r--src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java19
-rw-r--r--src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java33
3 files changed, 60 insertions, 13 deletions
diff --git a/res/drawable/ic_voicemail_seek_handle_disabled.xml b/res/drawable/ic_voicemail_seek_handle_disabled.xml
new file mode 100644
index 000000000..126280801
--- /dev/null
+++ b/res/drawable/ic_voicemail_seek_handle_disabled.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2015 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/ic_handle"
+ android:autoMirrored="true"
+ android:tint="@color/voicemail_icon_disabled_tint" >
+</bitmap> \ No newline at end of file
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java b/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java
index 698530b69..e0f2a9891 100644
--- a/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java
+++ b/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java
@@ -19,6 +19,7 @@ package com.android.dialer.voicemail;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
+import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
@@ -238,6 +239,8 @@ public class VoicemailPlaybackLayout extends LinearLayout
private TextView mTotalDurationText;
private PositionUpdater mPositionUpdater;
+ private Drawable mVoicemailSeekHandleEnabled;
+ private Drawable mVoicemailSeekHandleDisabled;
public VoicemailPlaybackLayout(Context context) {
this(context, null);
@@ -277,6 +280,11 @@ public class VoicemailPlaybackLayout extends LinearLayout
mPositionText.setText(formatAsMinutesAndSeconds(0));
mTotalDurationText.setText(formatAsMinutesAndSeconds(0));
+
+ mVoicemailSeekHandleEnabled = getResources().getDrawable(
+ R.drawable.ic_voicemail_seek_handle, mContext.getTheme());
+ mVoicemailSeekHandleDisabled = getResources().getDrawable(
+ R.drawable.ic_voicemail_seek_handle_disabled, mContext.getTheme());
}
@Override
@@ -364,17 +372,22 @@ public class VoicemailPlaybackLayout extends LinearLayout
@Override
public void disableUiElements() {
mStartStopButton.setEnabled(false);
- mPlaybackSeek.setProgress(0);
mPlaybackSeek.setEnabled(false);
+ mPlaybackSeek.setThumb(mVoicemailSeekHandleDisabled);
}
@Override
public void enableUiElements() {
mStartStopButton.setEnabled(true);
mPlaybackSeek.setEnabled(true);
+ mPlaybackSeek.setThumb(mVoicemailSeekHandleEnabled);
+ }
- mPositionText.setVisibility(View.VISIBLE);
- mTotalDurationText.setVisibility(View.VISIBLE);
+ @Override
+ public void resetSeekBar() {
+ mPlaybackSeek.setProgress(0);
+ mPlaybackSeek.setEnabled(false);
+ mPlaybackSeek.setThumb(mVoicemailSeekHandleDisabled);
}
@Override
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
index 208096dac..7a2bffcd9 100644
--- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
+++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
@@ -85,6 +85,7 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene
void setFetchContentTimeout();
void setIsFetchingContent();
void setPresenter(VoicemailPlaybackPresenter presenter, Uri voicemailUri);
+ void resetSeekBar();
}
public interface OnVoicemailDeletedListener {
@@ -272,16 +273,20 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene
* Reset the presenter for playback back to its original state.
*/
public void resetAll() {
- reset();
+ pausePresenter(true);
mView = null;
mVoicemailUri = null;
}
/**
- * Reset the presenter such that it is as if the voicemail has not been played.
+ * When navigating away from voicemail playback, we need to release the media player,
+ * pause the UI and save the position.
+ *
+ * @param reset {@code true} if we want to reset the position of the playback, {@code false} if
+ * we want to retain the current position (in case we return to the voicemail).
*/
- public void reset() {
+ public void pausePresenter(boolean reset) {
if (mMediaPlayer != null) {
mMediaPlayer.release();
mMediaPlayer = null;
@@ -291,12 +296,19 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene
mIsPrepared = false;
mIsPlaying = false;
- mPosition = 0;
- mDuration.set(0);
+
+ if (reset) {
+ // We want to reset the position whether or not the view is valid.
+ mPosition = 0;
+ }
if (mView != null) {
mView.onPlaybackStopped();
- mView.setClipPosition(0, mDuration.get());
+ if (reset) {
+ mView.setClipPosition(0, mDuration.get());
+ } else {
+ mPosition = mView.getDesiredClipPosition();
+ }
}
}
@@ -312,7 +324,7 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene
}
// Release the media player, otherwise there may be failures.
- reset();
+ pausePresenter(false);
if (mActivity != null) {
mActivity.getWindow().clearFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
@@ -345,8 +357,8 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene
* voicemail we've been asked to play has any content available.
* <p>
* Notify the user that we are fetching the content, then check to see if the content field in
- * the DB is set. If set, we proceed to {@link #prepareContent()} method. If not set, make
- * a request to fetch the content asynchronously via {@link #requestContent()}.
+ * the DB is set. If set, we proceed to {@link #prepareContent()} method. We get the duration of
+ * the voicemail from the query and set it if the content is not available.
*/
private void checkForContent() {
mAsyncTaskExecutor.submit(Tasks.CHECK_FOR_CONTENT, new AsyncTask<Void, Void, Boolean>() {
@@ -360,6 +372,7 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene
if (hasContent) {
prepareContent();
} else {
+ mView.resetSeekBar();
mView.setClipPosition(0, mDuration.get());
}
}
@@ -523,7 +536,6 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene
mIsPrepared = true;
mDuration.set(mMediaPlayer.getDuration());
- mPosition = mMediaPlayer.getCurrentPosition();
Log.d(TAG, "onPrepared: mPosition=" + mPosition);
mView.setClipPosition(mPosition, mDuration.get());
@@ -618,6 +630,7 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene
if (!mMediaPlayer.isPlaying()) {
// Clamp the start position between 0 and the duration.
mPosition = Math.max(0, Math.min(mPosition, mDuration.get()));
+
mMediaPlayer.seekTo(mPosition);
try {