diff options
author | Santos Cordon <santoscordon@google.com> | 2013-08-02 16:11:32 -0700 |
---|---|---|
committer | Santos Cordon <santoscordon@google.com> | 2013-08-03 16:17:50 -0700 |
commit | 9a43aba1cbbff7f7d443afa327de5c5cd602e39f (patch) | |
tree | 0ad20bef815b5c609acdcf5a82650702232fd004 /InCallUI/src/com/android/incallui/InCallActivity.java | |
parent | 75c86b55d45b1725c46ed2e5d77c9c43fcfd93da (diff) |
Fixing incoming call sequence, adding InCallPresenter
Moved handling of AnswerWidget from AnswerPresenter and into the new
InCallPresenter class.
InCallPresenter now also manages a high-level in-call UI state to be
expanded in subsequent CLs.
Change-Id: Ia4fee84db68f7eaedea307b25329dadb8cf754e5
Diffstat (limited to 'InCallUI/src/com/android/incallui/InCallActivity.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/InCallActivity.java | 68 |
1 files changed, 39 insertions, 29 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 9732203bd..f7663e3c7 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -18,6 +18,7 @@ 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; @@ -31,8 +32,7 @@ import android.widget.Toast; /** * Phone app "in call" screen. */ -public class InCallActivity extends Activity implements AnswerFragment.IFragmentHost, - CallList.Listener { +public class InCallActivity extends Activity { private static final String TAG = InCallActivity.class.getSimpleName(); @@ -42,6 +42,7 @@ public class InCallActivity extends Activity implements AnswerFragment.IFragment private CallButtonFragment mCallButtonFragment; private CallCardFragment mCallCardFragment; private AnswerFragment mAnswerFragment; + private boolean mFragmentsAdded = false; @Override protected void onCreate(Bundle icicle) { @@ -70,8 +71,28 @@ public class InCallActivity extends Activity implements AnswerFragment.IFragment @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 @@ -195,8 +216,21 @@ public class InCallActivity extends Activity implements AnswerFragment.IFragment return super.onKeyDown(keyCode, event); } - private void initializeInCall() { + /** + * 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. if (mCallButtonFragment == null) { @@ -210,10 +244,8 @@ public class InCallActivity extends Activity implements AnswerFragment.IFragment } if (mAnswerFragment == null) { - mAnswerFragment = new AnswerFragment(this); + mAnswerFragment = new AnswerFragment(); } - - CallList.getInstance().addListener(this); } private void toast(String text) { @@ -227,26 +259,4 @@ public class InCallActivity extends Activity implements AnswerFragment.IFragment Log.d(TAG, msg); } } - - @Override - public void addFragment(Fragment fragment) { - Log.d(TAG, "AddFragment"); - - // TODO(klp): Do a check to make sure the fragment isn't already added before trying to - // add it again. - // TODO(klp): IsResumed check only required because CallList notifications are coming in - // an indeterminate order. This should no longer be required with a main Presenter class. - if (this.isResumed()) { - final FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); - fragmentTransaction.add(R.id.main, fragment); - fragmentTransaction.commit(); - } - } - - @Override - public void onCallListChange(CallList callList) { - if (!callList.existsLiveCall()) { - finish(); - } - } } |