diff options
author | Santos Cordon <santoscordon@google.com> | 2013-07-31 16:36:29 -0700 |
---|---|---|
committer | Santos Cordon <santoscordon@google.com> | 2013-08-01 10:28:54 -0700 |
commit | 150a5c58c67f230c8fd7293b180bbf50aa761480 (patch) | |
tree | c37d6cfe313c0666e7cacf02bdbde958c7534baf /src/com/android/incallui/CallList.java | |
parent | a012c22dfbfedffe2e751f9b1ab776baa325a26f (diff) | |
download | packages_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/CallList.java')
-rw-r--r-- | src/com/android/incallui/CallList.java | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/com/android/incallui/CallList.java b/src/com/android/incallui/CallList.java index ac3e3bfd..f41af930 100644 --- a/src/com/android/incallui/CallList.java +++ b/src/com/android/incallui/CallList.java @@ -82,7 +82,11 @@ public class CallList { public void addListener(Listener listener) { Preconditions.checkNotNull(listener); + mListeners.add(listener); + + // Let the listener know about the active calls immediately. + listener.onCallListChange(this); } public void removeListener(Listener listener) { @@ -96,15 +100,39 @@ public class CallList { * update the Call object when the active call changes. */ public Call getIncomingOrActive() { - Call retval = null; + Call retval = getIncomingCall(); + if (retval == null) { + retval = getFirstCallWithState(Call.State.ACTIVE); + } + return retval; + } + + public Call getBackgroundCall() { + return getFirstCallWithState(Call.State.ONHOLD); + } + + public Call getIncomingCall() { + return getFirstCallWithState(Call.State.INCOMING); + } + public boolean existsLiveCall() { for (Call call : mCallMap.values()) { - if (call.getState() == Call.State.INCOMING) { + if (!isCallDead(call)) { + return true; + } + } + return false; + } + + /** + * Returns first call found in the call map with the specified state. + */ + public Call getFirstCallWithState(int state) { + Call retval = null; + for (Call call : mCallMap.values()) { + if (call.getState() == state) { retval = call; - // incoming call takes precedence, cut out early. break; - } else if (retval == null && call.getState() == Call.State.ACTIVE) { - retval = call; } } |