summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-05-14 15:41:24 -0700
committerAndrew Lee <anwlee@google.com>2015-05-14 17:11:55 -0700
commitc2289b3d15b93397bde2c9e6a35a995dea191fdb (patch)
tree5d275c3a3924bb772285a83b0d0a2d0cdfd0af16 /src
parenta812d28bfdac171e726d6b865e7ea5cfda24d924 (diff)
Change VM playback fragment layout.
- Remove increase/decrease playback rate functionality. - Flip button controls below the scrubber. - Delete TextController. Bug: 20433758 Change-Id: Id628bac0c9f8baed014079f2a89ce912fd2bb549
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/voicemail/VoicemailPlaybackFragment.java104
-rw-r--r--src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java63
2 files changed, 8 insertions, 159 deletions
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackFragment.java b/src/com/android/dialer/voicemail/VoicemailPlaybackFragment.java
index fd98688f1..8aa019779 100644
--- a/src/com/android/dialer/voicemail/VoicemailPlaybackFragment.java
+++ b/src/com/android/dialer/voicemail/VoicemailPlaybackFragment.java
@@ -256,9 +256,7 @@ public class VoicemailPlaybackFragment extends Fragment {
private final SeekBar mPlaybackSeek;
private final ImageButton mStartStopButton;
private final ImageButton mPlaybackSpeakerphone;
- private final ImageButton mRateDecreaseButton;
- private final ImageButton mRateIncreaseButton;
- private final TextViewWithMessagesController mTextController;
+ private final TextView mPlaybackPosition;
public PlaybackViewImpl(ActivityReference activityReference, Context applicationContext,
View playbackLayout) {
@@ -272,13 +270,8 @@ public class VoicemailPlaybackFragment extends Fragment {
R.id.playback_start_stop);
mPlaybackSpeakerphone = (ImageButton) playbackLayout.findViewById(
R.id.playback_speakerphone);
- mRateDecreaseButton = (ImageButton) playbackLayout.findViewById(
- R.id.rate_decrease_button);
- mRateIncreaseButton = (ImageButton) playbackLayout.findViewById(
- R.id.rate_increase_button);
- mTextController = new TextViewWithMessagesController(
- (TextView) playbackLayout.findViewById(R.id.playback_position_text),
- (TextView) playbackLayout.findViewById(R.id.playback_speed_text));
+ mPlaybackPosition =
+ (TextView) playbackLayout.findViewById(R.id.playback_position_text);
}
@Override
@@ -303,16 +296,6 @@ public class VoicemailPlaybackFragment extends Fragment {
}
@Override
- public void setRateDecreaseButtonListener(View.OnClickListener listener) {
- mRateDecreaseButton.setOnClickListener(listener);
- }
-
- @Override
- public void setRateIncreaseButtonListener(View.OnClickListener listener) {
- mRateIncreaseButton.setOnClickListener(listener);
- }
-
- @Override
public void setStartStopListener(View.OnClickListener listener) {
mStartStopButton.setOnClickListener(listener);
}
@@ -323,12 +306,6 @@ public class VoicemailPlaybackFragment extends Fragment {
}
@Override
- public void setRateDisplay(float rate, int stringResourceId) {
- mTextController.setTemporaryText(
- mApplicationContext.getString(stringResourceId), 1, TimeUnit.SECONDS);
- }
-
- @Override
public void setPositionSeekListener(SeekBar.OnSeekBarChangeListener listener) {
mPlaybackSeek.setOnSeekBarChangeListener(listener);
}
@@ -379,8 +356,7 @@ public class VoicemailPlaybackFragment extends Fragment {
mPlaybackSeek.setMax(seekBarMax);
}
mPlaybackSeek.setProgress(seekBarPosition);
- mTextController.setPermanentText(
- formatAsMinutesAndSeconds(seekBarMax - seekBarPosition));
+ mPlaybackPosition.setText(formatAsMinutesAndSeconds(seekBarMax - seekBarPosition));
}
private String getString(int resId) {
@@ -390,19 +366,19 @@ public class VoicemailPlaybackFragment extends Fragment {
@Override
public void setIsBuffering() {
disableUiElements();
- mTextController.setPermanentText(getString(R.string.voicemail_buffering));
+ mPlaybackPosition.setText(getString(R.string.voicemail_buffering));
}
@Override
public void setIsFetchingContent() {
disableUiElements();
- mTextController.setPermanentText(getString(R.string.voicemail_fetching_content));
+ mPlaybackPosition.setText(getString(R.string.voicemail_fetching_content));
}
@Override
public void setFetchContentTimeout() {
disableUiElements();
- mTextController.setPermanentText(getString(R.string.voicemail_fetching_timout));
+ mPlaybackPosition.setText(getString(R.string.voicemail_fetching_timout));
}
@Override
@@ -412,8 +388,6 @@ public class VoicemailPlaybackFragment extends Fragment {
@Override
public void disableUiElements() {
- mRateIncreaseButton.setEnabled(false);
- mRateDecreaseButton.setEnabled(false);
mStartStopButton.setEnabled(false);
mPlaybackSpeakerphone.setEnabled(false);
mPlaybackSeek.setProgress(0);
@@ -423,14 +397,12 @@ public class VoicemailPlaybackFragment extends Fragment {
@Override
public void playbackError(Exception e) {
disableUiElements();
- mTextController.setPermanentText(getString(R.string.voicemail_playback_error));
+ mPlaybackPosition.setText(getString(R.string.voicemail_playback_error));
Log.e(TAG, "Could not play voicemail", e);
}
@Override
public void enableUiElements() {
- mRateIncreaseButton.setEnabled(true);
- mRateDecreaseButton.setEnabled(true);
mStartStopButton.setEnabled(true);
mPlaybackSpeakerphone.setEnabled(true);
mPlaybackSeek.setEnabled(true);
@@ -491,64 +463,4 @@ public class VoicemailPlaybackFragment extends Fragment {
}
}
}
-
- /**
- * Controls a TextView with dynamically changing text.
- * <p>
- * There are two methods here of interest,
- * {@link TextViewWithMessagesController#setPermanentText(String)} and
- * {@link TextViewWithMessagesController#setTemporaryText(String, long, TimeUnit)}. The
- * former is used to set the text on the text view immediately, and is used in our case for
- * the countdown of duration remaining during voicemail playback. The second is used to
- * temporarily replace this countdown with a message, in our case faster voicemail speed or
- * slower voicemail speed, before returning to the countdown display.
- * <p>
- * All the methods on this class must be called from the ui thread.
- */
- private static final class TextViewWithMessagesController {
- private static final float VISIBLE = 1;
- private static final float INVISIBLE = 0;
- private static final long SHORT_ANIMATION_MS = 200;
- private static final long LONG_ANIMATION_MS = 400;
- private final Object mLock = new Object();
- private final TextView mPermanentTextView;
- private final TextView mTemporaryTextView;
- @GuardedBy("mLock") private Runnable mRunnable;
-
- public TextViewWithMessagesController(TextView permanentTextView,
- TextView temporaryTextView) {
- mPermanentTextView = permanentTextView;
- mTemporaryTextView = temporaryTextView;
- }
-
- public void setPermanentText(String text) {
- mPermanentTextView.setText(text);
- }
-
- public void setTemporaryText(String text, long duration, TimeUnit units) {
- synchronized (mLock) {
- mTemporaryTextView.setText(text);
- mTemporaryTextView.animate().alpha(VISIBLE).setDuration(SHORT_ANIMATION_MS);
- mPermanentTextView.animate().alpha(INVISIBLE).setDuration(SHORT_ANIMATION_MS);
- mRunnable = new Runnable() {
- @Override
- public void run() {
- synchronized (mLock) {
- // We check for (mRunnable == this) becuase if not true, then another
- // setTemporaryText call has taken place in the meantime, and this
- // one is now defunct and needs to take no action.
- if (mRunnable == this) {
- mRunnable = null;
- mTemporaryTextView.animate()
- .alpha(INVISIBLE).setDuration(LONG_ANIMATION_MS);
- mPermanentTextView.animate()
- .alpha(VISIBLE).setDuration(LONG_ANIMATION_MS);
- }
- }
- }
- };
- mTemporaryTextView.postDelayed(mRunnable, units.toMillis(duration));
- }
- }
- }
}
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
index 6a1041140..029f5bdd0 100644
--- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
+++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
@@ -80,9 +80,6 @@ public class VoicemailPlaybackPresenter implements OnAudioFocusChangeListener {
boolean isSpeakerPhoneOn();
void setSpeakerPhoneOn(boolean on);
void finish();
- void setRateDisplay(float rate, int stringResourceId);
- void setRateIncreaseButtonListener(View.OnClickListener listener);
- void setRateDecreaseButtonListener(View.OnClickListener listener);
void setIsFetchingContent();
void disableUiElements();
void enableUiElements();
@@ -121,28 +118,6 @@ public class VoicemailPlaybackPresenter implements OnAudioFocusChangeListener {
private static final String CLIP_POSITION_KEY = VoicemailPlaybackPresenter.class.getName()
+ ".CLIP_POSITION_KEY";
- /** The preset variable-speed rates. Each is greater than the previous by 25%. */
- private static final float[] PRESET_RATES = new float[] {
- 0.64f, 0.8f, 1.0f, 1.25f, 1.5625f
- };
- /** The string resource ids corresponding to the names given to the above preset rates. */
- private static final int[] PRESET_NAMES = new int[] {
- R.string.voicemail_speed_slowest,
- R.string.voicemail_speed_slower,
- R.string.voicemail_speed_normal,
- R.string.voicemail_speed_faster,
- R.string.voicemail_speed_fastest,
- };
-
- /**
- * Pointer into the {@link VoicemailPlaybackPresenter#PRESET_RATES} array.
- * <p>
- * This doesn't need to be synchronized, it's used only by the {@link RateChangeListener}
- * which in turn is only executed on the ui thread. This can't be encapsulated inside the
- * rate change listener since multiple rate change listeners must share the same value.
- */
- private int mRateIndex = 2;
-
/**
* The most recently calculated duration.
* <p>
@@ -349,8 +324,6 @@ public class VoicemailPlaybackPresenter implements OnAudioFocusChangeListener {
mPlayer.setOnErrorListener(new MediaPlayerErrorListener());
mPlayer.setOnCompletionListener(new MediaPlayerCompletionListener());
mView.setSpeakerPhoneOn(mView.isSpeakerPhoneOn());
- mView.setRateDecreaseButtonListener(createRateDecreaseListener());
- mView.setRateIncreaseButtonListener(createRateIncreaseListener());
if (mPlaying) {
resetPrepareStartPlaying(mPosition);
} else {
@@ -422,37 +395,6 @@ public class VoicemailPlaybackPresenter implements OnAudioFocusChangeListener {
}
}
- public View.OnClickListener createRateDecreaseListener() {
- return new RateChangeListener(false);
- }
-
- public View.OnClickListener createRateIncreaseListener() {
- return new RateChangeListener(true);
- }
-
- /**
- * Listens to clicks on the rate increase and decrease buttons.
- * <p>
- * This class is not thread-safe, but all interactions with it will happen on the ui thread.
- */
- private class RateChangeListener implements View.OnClickListener {
- private final boolean mIncrease;
-
- public RateChangeListener(boolean increase) {
- mIncrease = increase;
- }
-
- @Override
- public void onClick(View v) {
- // Adjust the current rate, then clamp it to the allowed values.
- mRateIndex = constrain(mRateIndex + (mIncrease ? 1 : -1), 0, PRESET_RATES.length - 1);
- // Whether or not we have actually changed the index, call changeRate().
- // This will ensure that we show the "fastest" or "slowest" text on the ui to indicate
- // to the user that it doesn't get any faster or slower.
- changeRate(PRESET_RATES[mRateIndex], PRESET_NAMES[mRateIndex]);
- }
- }
-
private class AsyncPrepareTask extends AsyncTask<Void, Void, Exception> {
private int mClipPositionInMillis;
@@ -607,11 +549,6 @@ public class VoicemailPlaybackPresenter implements OnAudioFocusChangeListener {
}
}
- private void changeRate(float rate, int stringResourceId) {
- ((SingleThreadedMediaPlayerProxy) mPlayer).setVariableSpeed(rate);
- mView.setRateDisplay(rate, stringResourceId);
- }
-
private class SpeakerphoneListener implements View.OnClickListener {
@Override
public void onClick(View v) {