From c2289b3d15b93397bde2c9e6a35a995dea191fdb Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 14 May 2015 15:41:24 -0700 Subject: Change VM playback fragment layout. - Remove increase/decrease playback rate functionality. - Flip button controls below the scrubber. - Delete TextController. Bug: 20433758 Change-Id: Id628bac0c9f8baed014079f2a89ce912fd2bb549 --- res/layout/playback_layout.xml | 126 ++++++++------------- res/values/strings.xml | 11 -- .../voicemail/VoicemailPlaybackFragment.java | 104 ++--------------- .../voicemail/VoicemailPlaybackPresenter.java | 63 ----------- .../com/android/dialer/CallDetailActivityTest.java | 25 ---- 5 files changed, 53 insertions(+), 276 deletions(-) diff --git a/res/layout/playback_layout.xml b/res/layout/playback_layout.xml index 00f1c3f4a..96feba648 100644 --- a/res/layout/playback_layout.xml +++ b/res/layout/playback_layout.xml @@ -19,64 +19,37 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:background="@color/background_dialer_call_log_list_item" -> - - - - - + android:background="@color/background_dialer_call_log_list_item"> + - + difference is currently 10dp. --> + android:contentDescription="@string/description_playback_seek" /> + - + android:layout_marginTop="10dp" /> + + + + + + + android:src="@drawable/ic_hold_pause" + android:contentDescription="@string/voicemail_play_start_pause" /> + - - + android:layout_height="58dp" + android:layout_weight="1" + android:background="?android:attr/selectableItemBackground" + android:src="@drawable/ic_speakerphone_on" + android:contentDescription="@string/description_playback_speakerphone" /> + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 2e236a64a..e3b268247 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -152,17 +152,6 @@ server directly to listen to the voicemails. [CHAR LIMIT=20] --> Call voicemail - - Slowest speed - - Slow speed - - Normal speed - - Fast speed - - Fastest speed - (%1$d) %2$s 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 @@ -302,16 +295,6 @@ public class VoicemailPlaybackFragment extends Fragment { return mApplicationContext; } - @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); @@ -322,12 +305,6 @@ public class VoicemailPlaybackFragment extends Fragment { mPlaybackSpeakerphone.setOnClickListener(listener); } - @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. - *

- * 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. - *

- * 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. - *

- * 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. *

@@ -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. - *

- * 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 { 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) { diff --git a/tests/src/com/android/dialer/CallDetailActivityTest.java b/tests/src/com/android/dialer/CallDetailActivityTest.java index f9f0a5846..15e90fcf6 100644 --- a/tests/src/com/android/dialer/CallDetailActivityTest.java +++ b/tests/src/com/android/dialer/CallDetailActivityTest.java @@ -155,7 +155,6 @@ public class CallDetailActivityTest extends ActivityInstrumentationTestCase2 - * See bug http://b/5044075. - */ - @Suppress - public void testVoicemailPlaybackRateDisplayedOnUi() throws Throwable { - setActivityIntentForTestVoicemailEntry(); - startActivityUnderTest(); - // Find the TextView containing the duration. It should be initially displaying "00:00". - List views = mTestUtils.getTextViewsWithString(mActivityUnderTest, "00:00"); - assertEquals(1, views.size()); - TextView timeDisplay = views.get(0); - // Hit the plus button. At this point we should be displaying "fast speed". - mTestUtils.clickButton(mActivityUnderTest, R.id.rate_increase_button); - assertEquals("fast speed", mTestUtils.getText(timeDisplay)); - // Hit the minus button. We should be back to "normal" speed. - mTestUtils.clickButton(mActivityUnderTest, R.id.rate_decrease_button); - assertEquals("normal speed", mTestUtils.getText(timeDisplay)); - // Wait for one and a half seconds. The timer will be back. - Thread.sleep(1500); - assertEquals("00:00", mTestUtils.getText(timeDisplay)); - } - @Suppress public void testClickingCallStopsPlayback() throws Throwable { setActivityIntentForRealFileVoicemailEntry(); -- cgit v1.2.3