summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-06-18 19:04:00 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-06-18 19:04:00 +0000
commitd8a20a25333de341a52ec47f8e780ba58fd25e46 (patch)
treeb3a21868a668152c0e6c7dc22144be47f7b187d1
parenta8c10beb64e9fd9d24cef4d8ed651cb3ac22908b (diff)
parenta6d65d510e9ca65b165c9ac41e8261abadb5536e (diff)
am a6d65d51: Merge "Pass activity into VoicemailPlaybackPresenter." into mnc-dev
* commit 'a6d65d510e9ca65b165c9ac41e8261abadb5536e': Pass activity into VoicemailPlaybackPresenter.
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java1
-rw-r--r--src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java8
-rw-r--r--tests/src/com/android/dialer/voicemail/VoicemailPlaybackTest.java19
3 files changed, 19 insertions, 9 deletions
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index 6f9767c41..0f19f1491 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -188,7 +188,6 @@ public class CallLogFragment extends Fragment
setHasOptionsMenu(true);
mVoicemailPlaybackPresenter = new VoicemailPlaybackPresenter(activity, state);
- activity.setVolumeControlStream(VoicemailPlaybackPresenter.PLAYBACK_STREAM);
}
/** Called by the CallLogQueryHandler when the list of calls has been fetched or updated. */
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
index cc6437627..60425e484 100644
--- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
+++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
@@ -121,6 +121,7 @@ public class VoicemailPlaybackPresenter
*/
private final AtomicInteger mDuration = new AtomicInteger(0);
+ private Activity mActivity;
private Context mContext;
private PlaybackView mView;
private static MediaPlayer mMediaPlayer;
@@ -147,11 +148,14 @@ public class VoicemailPlaybackPresenter
private PowerManager.WakeLock mProximityWakeLock;
private AudioManager mAudioManager;
- public VoicemailPlaybackPresenter(Context context, Bundle savedInstanceState) {
- mContext = context;
+ public VoicemailPlaybackPresenter(Activity activity, Bundle savedInstanceState) {
+ mActivity = activity;
+ mContext = activity;
mAsyncTaskExecutor = AsyncTaskExecutors.createAsyncTaskExecutor();
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+ mActivity.setVolumeControlStream(VoicemailPlaybackPresenter.PLAYBACK_STREAM);
+
if (savedInstanceState != null) {
// Restores playback state when activity is recreated, such as after rotation.
mVoicemailUri = (Uri) savedInstanceState.getParcelable(VOICEMAIL_URI_KEY);
diff --git a/tests/src/com/android/dialer/voicemail/VoicemailPlaybackTest.java b/tests/src/com/android/dialer/voicemail/VoicemailPlaybackTest.java
index 96ef62abf..ea341a30e 100644
--- a/tests/src/com/android/dialer/voicemail/VoicemailPlaybackTest.java
+++ b/tests/src/com/android/dialer/voicemail/VoicemailPlaybackTest.java
@@ -18,6 +18,7 @@ package com.android.dialer.voicemail;
import static com.android.dialer.voicemail.VoicemailPlaybackPresenter.Tasks.CHECK_FOR_CONTENT;
+import android.app.Activity;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
@@ -25,13 +26,14 @@ import android.content.Context;
import android.content.res.AssetManager;
import android.net.Uri;
import android.provider.VoicemailContract;
-import android.test.InstrumentationTestCase;
+import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;
import android.view.View;
import android.widget.TextView;
import com.android.contacts.common.test.IntegrationTestUtils;
import com.android.dialer.R;
+import com.android.dialer.calllog.CallLogActivity;
import com.android.dialer.util.AsyncTaskExecutors;
import com.android.dialer.util.FakeAsyncTaskExecutor;
import com.android.dialer.util.LocaleTestUtils;
@@ -48,13 +50,13 @@ import java.util.Locale;
* Unit tests for the {@link VoicemailPlaybackPresenter} and {@link VoicemailPlaybackLayout}.
*/
@LargeTest
-public class VoicemailPlaybackTest extends InstrumentationTestCase {
+public class VoicemailPlaybackTest extends ActivityInstrumentationTestCase2<CallLogActivity> {
private static final String TEST_ASSET_NAME = "quick_test_recording.mp3";
private static final String MIME_TYPE = "audio/mp3";
private static final String CONTACT_NUMBER = "+1412555555";
private static final String VOICEMAIL_FILE_LOCATION = "/sdcard/sadlfj893w4j23o9sfu.mp3";
- private Context mContext;
+ private Activity mActivity;
private VoicemailPlaybackPresenter mPresenter;
private VoicemailPlaybackLayout mLayout;
@@ -63,6 +65,10 @@ public class VoicemailPlaybackTest extends InstrumentationTestCase {
private LocaleTestUtils mLocaleTestUtils;
private FakeAsyncTaskExecutor mFakeAsyncTaskExecutor;
+ public VoicemailPlaybackTest() {
+ super(CallLogActivity.class);
+ }
+
@Override
public void setUp() throws Exception {
super.setUp();
@@ -75,10 +81,11 @@ public class VoicemailPlaybackTest extends InstrumentationTestCase {
mLocaleTestUtils = new LocaleTestUtils(getInstrumentation().getTargetContext());
mLocaleTestUtils.setLocale(Locale.US);
- mContext = getInstrumentation().getTargetContext();
- mLayout = new VoicemailPlaybackLayout(mContext);
+ mActivity = getActivity();
+ mLayout = new VoicemailPlaybackLayout(mActivity);
mLayout.onFinishInflate();
- mPresenter = new VoicemailPlaybackPresenter(mContext, null);
+
+ mPresenter = new VoicemailPlaybackPresenter(mActivity, null);
}
@Override