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
diff --git a/src/com/android/incallui/CallButtonPresenter.java b/src/com/android/incallui/CallButtonPresenter.java
index be76f2d..10d4f72 100644
--- a/src/com/android/incallui/CallButtonPresenter.java
+++ b/src/com/android/incallui/CallButtonPresenter.java
@@ -21,10 +21,10 @@
/**
* Logic for call buttons.
*/
-public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButtonUi> {
+public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButtonUi>
+ implements CallList.Listener {
private AudioManager mAudioManager;
- private EndCallListener mEndCallListener;
public void init(AudioManager audioManager) {
mAudioManager = audioManager;
@@ -35,19 +35,26 @@
super.onUiReady(ui);
getUi().setMute(mAudioManager.isMicrophoneMute());
getUi().setSpeaker(mAudioManager.isSpeakerphoneOn());
+
+ CallList.getInstance().addListener(this);
}
- public void show() {
- getUi().setVisible(true);
+ @Override
+ public void onCallListChange(CallList callList) {
+ // show the buttons if there is a live call AND there is no
+ // incoming call.
+ final boolean showButtons = callList.existsLiveCall() &&
+ callList.getIncomingCall() == null;
+ getUi().setVisible(showButtons);
}
public void endCallClicked() {
// TODO(klp): hook up call id.
CallCommandClient.getInstance().disconnectCall(1);
- mEndCallListener.onCallEnd();
-
- // TODO(klp): These states should come from Call objects from the CallList.
+ // TODO(klp): Remove once all state is gathered from CallList.
+ // This will be wrong when you disconnect from a call if
+ // the user has another call on hold.
reset();
}
@@ -74,18 +81,10 @@
getUi().setHold(checked);
}
- public void setEndCallListener(EndCallListener endCallListener) {
- mEndCallListener = endCallListener;
- }
-
public interface CallButtonUi extends Ui {
void setVisible(boolean on);
void setMute(boolean on);
void setSpeaker(boolean on);
void setHold(boolean on);
}
-
- public interface EndCallListener {
- void onCallEnd();
- }
}