summaryrefslogtreecommitdiffstats
path: root/src/com/android/incallui/AnswerFragment.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
commit150a5c58c67f230c8fd7293b180bbf50aa761480 (patch)
treec37d6cfe313c0666e7cacf02bdbde958c7534baf /src/com/android/incallui/AnswerFragment.java
parenta012c22dfbfedffe2e751f9b1ab776baa325a26f (diff)
downloadpackages_apps_InCallUI-150a5c58c67f230c8fd7293b180bbf50aa761480.tar.gz
packages_apps_InCallUI-150a5c58c67f230c8fd7293b180bbf50aa761480.tar.bz2
packages_apps_InCallUI-150a5c58c67f230c8fd7293b180bbf50aa761480.zip
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 'src/com/android/incallui/AnswerFragment.java')
-rw-r--r--src/com/android/incallui/AnswerFragment.java59
1 files changed, 46 insertions, 13 deletions
diff --git a/src/com/android/incallui/AnswerFragment.java b/src/com/android/incallui/AnswerFragment.java
index 90bc4360..76c92516 100644
--- a/src/com/android/incallui/AnswerFragment.java
+++ b/src/com/android/incallui/AnswerFragment.java
@@ -16,6 +16,9 @@
package com.android.incallui;
+import com.google.common.base.Preconditions;
+
+import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -26,16 +29,22 @@ import android.view.ViewGroup;
*
*/
public class AnswerFragment extends BaseFragment<AnswerPresenter> implements
- GlowPadWrapper.AnswerListener {
+ GlowPadWrapper.AnswerListener, AnswerPresenter.AnswerUi {
+ final private IFragmentHost mFragmentHost;
+
+ public AnswerFragment(IFragmentHost fragmentHost) {
+ mFragmentHost = fragmentHost;
+
+ // Normally called with onCreateView, however, AnswerPresenter's interaction
+ // begins before any UI is displayed.
+ // Order matters with this call because mFragmentHost mustn't be null when the presenter
+ // asks AnswerFragment to display itself (see showAnswerWidget).
+ getPresenter().onUiReady(this);
+ }
@Override
public AnswerPresenter createPresenter() {
- return new AnswerPresenter(new AnswerPresenter.Listener() {
- @Override
- public void onClose() {
- close();
- }
- });
+ return new AnswerPresenter();
}
@Override
@@ -47,12 +56,6 @@ public class AnswerFragment extends BaseFragment<AnswerPresenter> implements
return glowPad;
}
- private void close() {
- final FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
- fragmentTransaction.remove(this);
- fragmentTransaction.commit();
- }
-
@Override
public void onAnswer() {
getPresenter().onAnswer();
@@ -67,4 +70,34 @@ public class AnswerFragment extends BaseFragment<AnswerPresenter> implements
public void onText() {
getPresenter().onText();
}
+
+ @Override
+ public void showAnswerWidget(boolean show) {
+ Preconditions.checkNotNull(mFragmentHost);
+
+ if (show) {
+ mFragmentHost.addFragment(this);
+ } else {
+ close();
+ }
+ }
+
+ private void close() {
+ // TODO(klp): With a proper main presenter, we will not need to check for isAdded.
+ if (isAdded()) {
+ final FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
+ fragmentTransaction.remove(this);
+ fragmentTransaction.commit();
+ }
+ }
+
+ // Stop gap until we can consolidate presenters and make InCallActivity a UI Class that relies
+ // on it's the consolidated presenter.
+ //
+ // TODO(klp): Remove individual presenters for button/answer/callcard and have a single
+ // presenter that interacts directly with this activity. This will allow us to remove
+ // this unnecessary interface.
+ static interface IFragmentHost {
+ public void addFragment(Fragment fragment);
+ }
}