diff options
author | Santos Cordon <santoscordon@google.com> | 2013-08-05 02:17:28 -0700 |
---|---|---|
committer | Santos Cordon <santoscordon@google.com> | 2013-08-05 14:45:22 -0700 |
commit | 7ac6cb331919db2a3a8985e4cb3299b309d9012a (patch) | |
tree | 65cf7323fe8f355bfa7b80c21b1f0aca68bc2c49 /InCallUI/src/com/android/incallui/InCallActivity.java | |
parent | 9a43aba1cbbff7f7d443afa327de5c5cd602e39f (diff) |
Improve InCall State management
CL Contains the following changes:
- InCallPresenter now manages an overall in-call state
- Other presenters now listen to in-call state changes instead of
getting updates from CallList directly.
- Changes AnswerPresenter to a static fragment instead of dynamically
loading it. It makes code easier and more aligned with other fragments
used in the class.
- Presenters now save the appropriate call and use callId() for commands
sent to the telephony layer.
- Extra logging in CallList
- cleaned up the startup sequence in InCallActivity and moved everything
to onCreate instead of onCreate & onResume
Change-Id: I4ce4182eefcc134bfa16c33be8fe4aefc041f563
Diffstat (limited to 'InCallUI/src/com/android/incallui/InCallActivity.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallActivity.java | 63 |
1 files changed, 20 insertions, 43 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index f7663e3c7..f63b52ef8 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -18,8 +18,6 @@ package com.android.incallui; import android.app.Activity; import android.app.Fragment; -import android.app.FragmentManager; -import android.app.FragmentTransaction; import android.content.Intent; import android.os.Bundle; import android.util.Log; @@ -33,16 +31,13 @@ import android.widget.Toast; * Phone app "in call" screen. */ public class InCallActivity extends Activity { - private static final String TAG = InCallActivity.class.getSimpleName(); - private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE); private CallButtonFragment mCallButtonFragment; private CallCardFragment mCallCardFragment; private AnswerFragment mAnswerFragment; - private boolean mFragmentsAdded = false; @Override protected void onCreate(Bundle icicle) { @@ -67,32 +62,10 @@ public class InCallActivity extends Activity { logD("onCreate(): exit"); } - @Override protected void onResume() { logD("onResume()..."); super.onResume(); - - if (!mFragmentsAdded) { - getFragmentManager().beginTransaction() - .add(R.id.main, mAnswerFragment) - .commit(); - - mFragmentsAdded = true; - } - - InCallPresenter.getInstance().setActivity(this); - } - - @Override - public void onAttachFragment(Fragment fragment) { - if (fragment instanceof AnswerFragment) { - mAnswerFragment = (AnswerFragment) fragment; - - getFragmentManager().beginTransaction() - .hide(mAnswerFragment) - .commit(); - } } // onPause is guaranteed to be called when the InCallActivity goes @@ -133,7 +106,11 @@ public class InCallActivity extends Activity { @Override public void finish() { logD("finish()..."); - moveTaskToBack(true); + super.finish(); + + // TODO(klp): Actually finish the activity for now. Revisit performance implications of + // this before launch. + // moveTaskToBack(true); } @Override @@ -216,20 +193,6 @@ public class InCallActivity extends Activity { return super.onKeyDown(keyCode, event); } - /** - * Called to show the incoming call widget. - */ - /* package */ void showIncoming(boolean show) { - final FragmentTransaction trans = getFragmentManager().beginTransaction(); - if (show) { - trans.show(mAnswerFragment); - } else { - trans.hide(mAnswerFragment); - } - - trans.commitAllowingStateLoss(); - } - private void initializeInCall() { // TODO(klp): Make sure that this doesn't need to move back to onResume() since they are // statically added fragments. @@ -244,8 +207,22 @@ public class InCallActivity extends Activity { } if (mAnswerFragment == null) { - mAnswerFragment = new AnswerFragment(); + mAnswerFragment = (AnswerFragment) getFragmentManager() + .findFragmentById(R.id.answerFragment); } + + setUpPresenters(); + } + + private void setUpPresenters() { + InCallPresenter mainPresenter = InCallPresenter.getInstance(); + + mainPresenter.addListener(mCallButtonFragment.getPresenter()); + mainPresenter.addListener(mCallCardFragment.getPresenter()); + mainPresenter.addListener(mAnswerFragment.getPresenter()); + + // setting activity should be last thing in setup process + mainPresenter.setActivity(this); } private void toast(String text) { |