diff options
author | Santos Cordon <santoscordon@google.com> | 2014-11-10 19:21:53 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-11-10 19:21:54 +0000 |
commit | 98462166b10ef65f14e33b1d507bb07479ce069b (patch) | |
tree | 3c09be4405c420e67c217a77993a50bebccd0305 /InCallUI | |
parent | 5afa4c6b44d4857fc5be60784ffce116e80291b4 (diff) | |
parent | a691bd24f96acae7849f5f84f6e5f998fa58e8c0 (diff) |
Merge "Make add-call a global property of telecom. (4/4)" into lmp-mr1-dev
Diffstat (limited to 'InCallUI')
5 files changed, 47 insertions, 9 deletions
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index cdfd0eb8f..36f6f4e2a 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -401,12 +401,14 @@ public final class Call { @Override public String toString() { - return String.format(Locale.US, "[%s, %s, %s, children:%s, parent:%s, videoState:%d]", + return String.format(Locale.US, "[%s, %s, %s, children:%s, parent:%s, conferenceable:%s, " + + "videoState:%d]", mId, State.toString(getState()), PhoneCapabilities.toString(mTelecommCall.getDetails().getCallCapabilities()), mChildCallIds, getParentId(), + this.mTelecommCall.getConferenceableCalls(), mTelecommCall.getDetails().getVideoState()); } } diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 85f721a59..2e83e321d 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -23,8 +23,8 @@ import android.telecom.PhoneCapabilities; import android.telecom.TelecomManager; import android.telecom.VideoProfile; - import com.android.incallui.AudioModeProvider.AudioModeListener; +import com.android.incallui.InCallPresenter.CanAddCallListener; import com.android.incallui.InCallPresenter.InCallState; import com.android.incallui.InCallPresenter.InCallStateListener; import com.android.incallui.InCallPresenter.IncomingCallListener; @@ -39,7 +39,7 @@ import java.util.Objects; */ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButtonUi> implements InCallStateListener, AudioModeListener, IncomingCallListener, - InCallDetailsListener { + InCallDetailsListener, CanAddCallListener { private Call mCall; private boolean mAutomaticallyMuted = false; @@ -58,6 +58,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto InCallPresenter.getInstance().addListener(this); InCallPresenter.getInstance().addIncomingCallListener(this); InCallPresenter.getInstance().addDetailsListener(this); + InCallPresenter.getInstance().addCanAddCallListener(this); } @Override @@ -126,6 +127,13 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto } @Override + public void onCanAddCallChanged(boolean canAddCall) { + if (mCall != null) { + updateCallButtons(mCall, getUi().getContext()); + } + } + + @Override public void onAudioMode(int mode) { if (getUi() != null) { getUi().setAudio(mode); @@ -384,10 +392,10 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto Log.v(this, "Enable hold", call.can(PhoneCapabilities.HOLD)); Log.v(this, "Show merge ", call.can(PhoneCapabilities.MERGE_CONFERENCE)); Log.v(this, "Show swap ", call.can(PhoneCapabilities.SWAP_CONFERENCE)); - Log.v(this, "Show add call ", call.can(PhoneCapabilities.ADD_CALL)); + Log.v(this, "Show add call ", TelecomAdapter.getInstance().canAddCall()); Log.v(this, "Show mute ", call.can(PhoneCapabilities.MUTE)); - final boolean canAdd = call.can(PhoneCapabilities.ADD_CALL); + final boolean canAdd = TelecomAdapter.getInstance().canAddCall(); final boolean enableHoldOption = call.can(PhoneCapabilities.HOLD); final boolean supportHold = call.can(PhoneCapabilities.SUPPORT_HOLD); final boolean isCallOnHold = call.getState() == Call.State.ONHOLD; @@ -411,7 +419,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto final boolean isVideoOverflowScenario = canVideoCall && (showAddCallOption || showMergeOption) && (showHoldOption || showSwapOption); // If we show hold/swap, add, and merge simultaneously, the overflow menu is needed. - final boolean isCdmaConferenceOverflowScenario = + final boolean isOverflowScenario = (showHoldOption || showSwapOption) && showMergeOption && showAddCallOption; if (isVideoOverflowScenario) { @@ -420,14 +428,14 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto ui.showAddCallButton(false); ui.showMergeButton(false); - ui.showOverflowButton(true); ui.configureOverflowMenu( showMergeOption, showAddCallOption /* showAddMenuOption */, showHoldOption && enableHoldOption /* showHoldMenuOption */, showSwapOption); + ui.showOverflowButton(true); } else { - if (isCdmaConferenceOverflowScenario) { + if (isOverflowScenario) { ui.showAddCallButton(false); ui.showMergeButton(false); @@ -441,6 +449,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto ui.showAddCallButton(showAddCallOption); } + ui.showOverflowButton(isOverflowScenario); ui.showHoldButton(showHoldOption); ui.enableHold(enableHoldOption); ui.showSwapButton(showSwapOption); diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index 40fcf534c..0bbebe5b1 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/src/com/android/incallui/CallList.java @@ -17,7 +17,6 @@ package com.android.incallui; import com.google.common.collect.Maps; -import com.google.common.collect.Sets; import com.google.common.base.Preconditions; import android.os.Handler; diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index ec30ee1fa..202730458 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -72,6 +72,8 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { private final List<IncomingCallListener> mIncomingCallListeners = new CopyOnWriteArrayList<>(); private final Set<InCallDetailsListener> mDetailsListeners = Collections.newSetFromMap( new ConcurrentHashMap<InCallDetailsListener, Boolean>(8, 0.9f, 1)); + private final Set<CanAddCallListener> mCanAddCallListeners = Collections.newSetFromMap( + new ConcurrentHashMap<CanAddCallListener, Boolean>(8, 0.9f, 1)); private final Set<InCallUiListener> mInCallUiListeners = Collections.newSetFromMap( new ConcurrentHashMap<InCallUiListener, Boolean>(8, 0.9f, 1)); private final Set<InCallOrientationListener> mOrientationListeners = Collections.newSetFromMap( @@ -105,6 +107,12 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { public void onCallRemoved(Phone phone, android.telecom.Call call) { call.removeListener(mCallListener); } + @Override + public void onCanAddCallChanged(Phone phone, boolean canAddCall) { + for (CanAddCallListener listener : mCanAddCallListeners) { + listener.onCanAddCallChanged(canAddCall); + } + } }; private final android.telecom.Call.Listener mCallListener = @@ -476,6 +484,17 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { } } + public void addCanAddCallListener(CanAddCallListener listener) { + Preconditions.checkNotNull(listener); + mCanAddCallListeners.add(listener); + } + + public void removeCanAddCallListener(CanAddCallListener listener) { + if (listener != null) { + mCanAddCallListeners.remove(listener); + } + } + public void addOrientationListener(InCallOrientationListener listener) { Preconditions.checkNotNull(listener); mOrientationListeners.add(listener); @@ -1238,6 +1257,10 @@ public class InCallPresenter implements CallList.Listener, InCallPhoneListener { public void onIncomingCall(InCallState oldState, InCallState newState, Call call); } + public interface CanAddCallListener { + public void onCanAddCallChanged(boolean canAddCall); + } + public interface InCallDetailsListener { public void onDetailsChanged(Call call, android.telecom.Call.Details details); } diff --git a/InCallUI/src/com/android/incallui/TelecomAdapter.java b/InCallUI/src/com/android/incallui/TelecomAdapter.java index b0c170ab4..291466ded 100644 --- a/InCallUI/src/com/android/incallui/TelecomAdapter.java +++ b/InCallUI/src/com/android/incallui/TelecomAdapter.java @@ -243,4 +243,9 @@ final class TelecomAdapter implements InCallPhoneListener { Log.e(this, "error phoneAccountSelected, accountHandle is null"); } } + + boolean canAddCall() { + // Default to true if we are not connected to telecom. + return mPhone == null ? true : mPhone.canAddCall(); + } } |