summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/playback_layout.xml126
-rw-r--r--res/values/strings.xml11
-rw-r--r--src/com/android/dialer/voicemail/VoicemailPlaybackFragment.java104
-rw-r--r--src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java63
-rw-r--r--tests/src/com/android/dialer/CallDetailActivityTest.java25
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"
->
- <!-- Mute, playback, trash buttons. -->
- <LinearLayout
- android:id="@+id/buttons_linear_layout"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
- <ImageButton
- android:id="@+id/playback_start_stop"
- android:layout_width="match_parent"
- android:layout_height="58dp"
- android:layout_marginEnd="@dimen/call_detail_button_spacing"
- android:layout_weight="1"
- android:background="?android:attr/selectableItemBackground"
- android:src="@drawable/ic_hold_pause"
- android:contentDescription="@string/voicemail_play_start_pause"
- />
- <ImageButton
- android:id="@+id/playback_speakerphone"
- android:layout_width="match_parent"
- android:layout_height="58dip"
- android:layout_weight="1"
- android:background="?android:attr/selectableItemBackground"
- android:src="@drawable/ic_speakerphone_on"
- android:contentDescription="@string/description_playback_speakerphone"
- />
- </LinearLayout>
+ android:background="@color/background_dialer_call_log_list_item">
+
<RelativeLayout
android:id="@+id/seek_container"
android:layout_width="match_parent"
- android:layout_height="80dip"
- android:layout_marginTop="@dimen/call_detail_button_spacing"
- >
- <!-- SeekBar left-right margin decreased from redlines 72dip by 8dip to account for
- half thumb width (thumb is 16dip).
+ android:layout_height="80dp"
+ android:layout_marginTop="@dimen/call_detail_button_spacing">
+
+ <!-- SeekBar left-right margin decreased from redlines 72dp by 8dp to account for
+ half thumb width (thumb is 16dp).
Vertically, SeekBar and rate buttons should be below centre, position achieved by
making them centred but giving a difference between top and bottom padding,
- difference is currently 10dip. -->
+ difference is currently 10dp. -->
<SeekBar
android:id="@+id/playback_seek"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progressDrawable="@drawable/seekbar_drawable"
android:thumb="@drawable/ic_voicemail_seek_handle"
- android:thumbOffset="8dip"
+ android:thumbOffset="8dp"
android:progress="0"
- android:paddingStart="8dip"
- android:paddingEnd="8dip"
- android:paddingTop="30dip"
- android:paddingBottom="20dip"
- android:layout_marginEnd="64dip"
- android:layout_marginStart="64dip"
+ android:paddingStart="8dp"
+ android:paddingEnd="8dp"
+ android:paddingTop="30dp"
+ android:paddingBottom="20dp"
+ android:layout_marginEnd="64dp"
+ android:layout_marginStart="64dp"
android:max="0"
android:layout_centerVertical="true"
- android:contentDescription="@string/description_playback_seek"
- />
+ android:contentDescription="@string/description_playback_seek" />
+
<TextView
android:id="@+id/playback_position_text"
android:layout_height="wrap_content"
@@ -84,45 +57,36 @@
android:textSize="14sp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
- android:layout_marginTop="10dip"
- />
- <TextView
- android:id="@+id/playback_speed_text"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textSize="14sp"
- android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- android:layout_marginTop="10dip"
- android:alpha="0"
- />
+ android:layout_marginTop="10dp" />
+
+ </RelativeLayout>
+
+ <!-- Playback, speakerphone buttons. -->
+ <LinearLayout
+ android:id="@+id/buttons_linear_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
<ImageButton
- android:id="@+id/rate_decrease_button"
- android:src="@drawable/ic_minus"
- android:layout_width="64dip"
- android:layout_height="wrap_content"
+ android:id="@+id/playback_start_stop"
+ android:layout_width="match_parent"
+ android:layout_height="58dp"
+ android:layout_marginEnd="@dimen/call_detail_button_spacing"
+ android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
- android:paddingBottom="19dip"
- android:paddingTop="29dip"
- android:layout_alignParentStart="true"
- android:layout_centerVertical="true"
- android:contentDescription="@string/voicemail_play_slower"
- />
+ android:src="@drawable/ic_hold_pause"
+ android:contentDescription="@string/voicemail_play_start_pause" />
+
<ImageButton
- android:id="@+id/rate_increase_button"
- android:src="@drawable/ic_plus"
- android:layout_width="64dip"
- android:layout_height="wrap_content"
- android:background="?android:attr/selectableItemBackground"
- android:paddingBottom="19dip"
- android:paddingTop="29dip"
- android:layout_alignParentEnd="true"
- android:layout_centerVertical="true"
- android:contentDescription="@string/voicemail_play_faster"
- />
- <View
+ android:id="@+id/playback_speakerphone"
android:layout_width="match_parent"
- android:layout_height="2dp"
- android:layout_alignParentBottom="true"/>
- </RelativeLayout>
+ 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" />
+
+ </LinearLayout>
+
</LinearLayout>
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] -->
<string name="voicemail_status_action_call_server">Call voicemail</string>
- <!-- The slowest voicemail playback speed. [CHAR LIMIT=30] -->
- <string name="voicemail_speed_slowest">Slowest speed</string>
- <!-- Slower than normal voicemail playback speed. [CHAR LIMIT=30] -->
- <string name="voicemail_speed_slower">Slow speed</string>
- <!-- Normal voicemail playback speed. [CHAR LIMIT=30] -->
- <string name="voicemail_speed_normal">Normal speed</string>
- <!-- Faster than normal pvoicemail playback speed. [CHAR LIMIT=30] -->
- <string name="voicemail_speed_faster">Fast speed</string>
- <!-- Fastest voicemail playback speed. [CHAR LIMIT=30] -->
- <string name="voicemail_speed_fastest">Fastest speed</string>
-
<!-- The counter for calls in a group and the date of the latest call as shown in the call log [CHAR LIMIT=15] -->
<string name="call_log_item_count_and_date">(<xliff:g id="count">%1$d</xliff:g>)
<xliff:g id="date">%2$s</xliff:g>
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) {
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<Cal
setActivityIntentForTestVoicemailEntry();
startActivityUnderTest();
mTestUtils.clickButton(mActivityUnderTest, R.id.playback_start_stop);
- mTestUtils.clickButton(mActivityUnderTest, R.id.rate_increase_button);
}
/** Test for bug where missing Extras on intent used to start Activity causes NPE. */
@@ -188,30 +187,6 @@ public class CallDetailActivityTest extends ActivityInstrumentationTestCase2<Cal
assertTrue(menu.findItem(R.id.menu_remove_from_call_log).isVisible());
}
- /**
- * Test to show that we are correctly displaying playback rate on the ui.
- * <p>
- * 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<TextView> 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();