summaryrefslogtreecommitdiff
path: root/InCallUI/src/com/android/incallui/InCallActivity.java
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2013-07-31 16:36:29 -0700
committerSantos Cordon <santoscordon@google.com>2013-08-01 10:28:54 -0700
commit75c86b55d45b1725c46ed2e5d77c9c43fcfd93da (patch)
tree7a4ed0c2daa175d79c93e9f59428858106e84562 /InCallUI/src/com/android/incallui/InCallActivity.java
parentc2b430394ac612ba4dd455fb988e29bfcc4d5c5f (diff)
Adding multi-call support.
Before this change, the UI came up when we were notified that a new call came in, but we did not actually look at the call state, etc. This seemingly worked while we only supported single calls but did not scale. This change does two main things: a) Plugs in CallList into the presenters so that they can perform their logic based on the actual state of the calls (necessary for multi-call support) b) Adds Secondary CallInfo UI to the Call Card so that we can display information foreground and background calls. As a result of (a) from above, a lot of changes you see will be to Presenters, which now take their cues from CallList and update their Ui's accordingly. A problem with this approach is that the presenters (callcard/buttons/answer-widget) perform their changes independently. A subsequent change will consolidate interactions with CallList to a Presenter-Manager class and away from the presenters. Change-Id: I89d1926fa1eef6f10d897d2ce360f666c8f341f8
Diffstat (limited to 'InCallUI/src/com/android/incallui/InCallActivity.java')
-rw-r--r--InCallUI/src/com/android/incallui/InCallActivity.java65
1 files changed, 41 insertions, 24 deletions
diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java
index 04f1f09b1..9732203bd 100644
--- a/InCallUI/src/com/android/incallui/InCallActivity.java
+++ b/InCallUI/src/com/android/incallui/InCallActivity.java
@@ -17,6 +17,7 @@
package com.android.incallui;
import android.app.Activity;
+import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
@@ -30,15 +31,17 @@ import android.widget.Toast;
/**
* Phone app "in call" screen.
*/
-public class InCallActivity extends Activity implements CallButtonPresenter.EndCallListener {
+public class InCallActivity extends Activity implements AnswerFragment.IFragmentHost,
+ CallList.Listener {
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 CallButtonPresenter mCallButtonPresenter;
- private CallCardPresenter mCallCardPresenter;
+ private CallButtonFragment mCallButtonFragment;
+ private CallCardFragment mCallCardFragment;
+ private AnswerFragment mAnswerFragment;
@Override
protected void onCreate(Bundle icicle) {
@@ -68,19 +71,6 @@ public class InCallActivity extends Activity implements CallButtonPresenter.EndC
protected void onResume() {
logD("onResume()...");
- // TODO(klp): create once and reset when needed.
- final AnswerFragment answerFragment = new AnswerFragment();
- final AnswerPresenter presenter = answerFragment.getPresenter();
- presenter.addCloseListener(new AnswerPresenter.Listener() {
- @Override
- public void onClose() {
- mCallButtonPresenter.show();
- }
- });
-
- final FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
- fragmentTransaction.add(R.id.main, answerFragment);
- fragmentTransaction.commit();
super.onResume();
}
@@ -207,13 +197,23 @@ public class InCallActivity extends Activity implements CallButtonPresenter.EndC
private void initializeInCall() {
- final CallButtonFragment callButtonFragment = (CallButtonFragment) getFragmentManager()
- .findFragmentById(R.id.callButtonFragment);
- mCallButtonPresenter = callButtonFragment.getPresenter();
- mCallButtonPresenter.setEndCallListener(this);
+ // TODO(klp): Make sure that this doesn't need to move back to onResume() since they are
+ // statically added fragments.
+ if (mCallButtonFragment == null) {
+ mCallButtonFragment = (CallButtonFragment) getFragmentManager()
+ .findFragmentById(R.id.callButtonFragment);
+ }
+
+ if (mCallCardFragment == null) {
+ mCallCardFragment = (CallCardFragment) getFragmentManager()
+ .findFragmentById(R.id.callCardFragment);
+ }
+
+ if (mAnswerFragment == null) {
+ mAnswerFragment = new AnswerFragment(this);
+ }
- final CallCardFragment callCardFragment = (CallCardFragment) getFragmentManager()
- .findFragmentById(R.id.callCardFragment);
+ CallList.getInstance().addListener(this);
}
private void toast(String text) {
@@ -229,7 +229,24 @@ public class InCallActivity extends Activity implements CallButtonPresenter.EndC
}
@Override
- public void onCallEnd() {
- finish();
+ 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();
+ }
}
}