From 58eaabcc31e23fd4c071ad911b96da6eea4abc28 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Tue, 26 May 2015 16:14:31 -0700 Subject: Refactor Voicemail Playback into standalone view. + Substitutes the existing playback widget in CallDetailActivity, although the plan is to move this to the call log shortly. + Convert the widget from a fragment into a layout. This allows us to more easily create multiple instances of the voicemail widget in the same view, as we intend to do in the call log. + Shift UI-related logic from Presenter to the Layout. + Fix janky seeking, so that it now works correctly consistently rather than sporadically, and doesn't need to buffer again. - Remove the VariableSpeed player formerly used in the Presenter. We don't use this functionality anymore, and this allows us to directly used the framework MediaPlayer (instead of a custom legacy proxy). Bug: 21170557 Bug: 20693172 Change-Id: Ia34f459df10e43763b32fdb0954f83e882664231 --- src/com/android/dialer/CallDetailActivity.java | 74 +++++++++++++++----------- 1 file changed, 43 insertions(+), 31 deletions(-) (limited to 'src/com/android/dialer/CallDetailActivity.java') diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index 1c684a510..7fa3750d2 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -61,7 +61,8 @@ import com.android.dialer.calllog.PhoneNumberUtilsWrapper; import com.android.dialer.util.IntentUtil; import com.android.dialer.util.DialerUtils; import com.android.dialer.util.TelecomUtil; -import com.android.dialer.voicemail.VoicemailPlaybackFragment; +import com.android.dialer.voicemail.VoicemailPlaybackLayout; +import com.android.dialer.voicemail.VoicemailPlaybackPresenter; import java.util.List; @@ -217,7 +218,7 @@ public class CallDetailActivity extends Activity { /** Helper to load contact photos. */ private ContactPhotoManager mContactPhotoManager; - private LinearLayout mVoicemailHeader; + private VoicemailPlaybackPresenter mVoicemailPlaybackPresenter; private Uri mVoicemailUri; private BidiFormatter mBidiFormatter = BidiFormatter.getInstance(); @@ -255,6 +256,7 @@ public class CallDetailActivity extends Activity { getActionBar().setDisplayHomeAsUpEnabled(true); optionallyHandleVoicemail(); + if (getIntent().getBooleanExtra(EXTRA_FROM_NOTIFICATION, false)) { closeSystemDialogs(); } @@ -267,6 +269,38 @@ public class CallDetailActivity extends Activity { CallLogAsyncTaskUtil.getCallDetails(this, getCallLogEntryUris(), mCallLogAsyncTaskListener); } + @Override + public void onPause() { + if (mVoicemailPlaybackPresenter != null) { + mVoicemailPlaybackPresenter.onPause(); + } + super.onPause(); + } + + @Override + public void onDestroy() { + if (mVoicemailPlaybackPresenter != null) { + mVoicemailPlaybackPresenter.onDestroy(); + } + super.onDestroy(); + } + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + if (mVoicemailPlaybackPresenter != null) { + mVoicemailPlaybackPresenter.onSaveInstanceState(outState); + } + } + + @Override + public void onRestoreInstanceState(Bundle savedInstanceState) { + if (mVoicemailPlaybackPresenter != null) { + mVoicemailPlaybackPresenter.onRestoreInstanceState(savedInstanceState); + } + super.onRestoreInstanceState(savedInstanceState); + } + /** * Handle voicemail playback or hide voicemail ui. *

@@ -274,37 +308,15 @@ public class CallDetailActivity extends Activity { * playback. If it doesn't, then don't inflate the voicemail ui. */ private void optionallyHandleVoicemail() { - if (hasVoicemail()) { - LayoutInflater inflater = - (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); - mVoicemailHeader = - (LinearLayout) inflater.inflate(R.layout.call_details_voicemail_header, null); - View voicemailContainer = mVoicemailHeader.findViewById(R.id.voicemail_container); - ListView historyList = (ListView) findViewById(R.id.history); - historyList.addHeaderView(mVoicemailHeader); - // Has voicemail: add the voicemail fragment. Add suitable arguments to set the uri - // to play and optionally start the playback. - // Do a query to fetch the voicemail status messages. - VoicemailPlaybackFragment playbackFragment; - - playbackFragment = (VoicemailPlaybackFragment) getFragmentManager().findFragmentByTag( - VOICEMAIL_FRAGMENT_TAG); - - if (playbackFragment == null) { - playbackFragment = new VoicemailPlaybackFragment(); - Bundle fragmentArguments = new Bundle(); - fragmentArguments.putParcelable(EXTRA_VOICEMAIL_URI, mVoicemailUri); - if (getIntent().getBooleanExtra(EXTRA_VOICEMAIL_START_PLAYBACK, false)) { - fragmentArguments.putBoolean(EXTRA_VOICEMAIL_START_PLAYBACK, true); - } - playbackFragment.setArguments(fragmentArguments); - getFragmentManager().beginTransaction() - .add(R.id.voicemail_container, playbackFragment, VOICEMAIL_FRAGMENT_TAG) - .commitAllowingStateLoss(); - } + VoicemailPlaybackLayout voicemailPlaybackLayout = + (VoicemailPlaybackLayout) findViewById(R.id.voicemail_playback_layout); + + mVoicemailPlaybackPresenter = new VoicemailPlaybackPresenter(this); + mVoicemailPlaybackPresenter.setPlaybackView( + voicemailPlaybackLayout, mVoicemailUri, false /* startPlayingImmediately */); - voicemailContainer.setVisibility(View.VISIBLE); + voicemailPlaybackLayout.setVisibility(View.VISIBLE); CallLogAsyncTaskUtil.markVoicemailAsRead(this, mVoicemailUri); } } -- cgit v1.2.3