diff options
author | Santos Cordon <santoscordon@google.com> | 2013-08-07 22:35:43 -0700 |
---|---|---|
committer | Santos Cordon <santoscordon@google.com> | 2013-08-08 06:48:07 +0000 |
commit | b6404417362ca02c940807426fefdb7568e269e3 (patch) | |
tree | faead554dae2f4b2746a821dd190c28330907e2c | |
parent | fa6d1c3cc9cc049a062d9308b4f4042df2ecfbab (diff) |
Merge/Swap/AddCall support in UI.
Add UI support, presenter logic and CallCommandClient code.
Change-Id: I3d561b67cbecd9b4672ecef49dad99d1f6b07b11
3 files changed, 106 insertions, 10 deletions
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index a5350da08..26480d2c5 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -26,6 +26,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; +import android.widget.ImageButton; import android.widget.PopupMenu; import android.widget.PopupMenu.OnDismissListener; import android.widget.PopupMenu.OnMenuItemClickListener; @@ -38,12 +39,15 @@ import com.android.services.telephony.common.AudioMode; */ public class CallButtonFragment extends BaseFragment<CallButtonPresenter> implements CallButtonPresenter.CallButtonUi, OnMenuItemClickListener, - OnDismissListener { + OnDismissListener, View.OnClickListener, CompoundButton.OnCheckedChangeListener { private ToggleButton mMuteButton; private ToggleButton mAudioButton; private ToggleButton mHoldButton; private ToggleButton mShowDialpadButton; + private ImageButton mMergeButton; + private ImageButton mAddCallButton; + private ImageButton mSwapButton; private PopupMenu mAudioModePopup; private boolean mAudioModePopupVisible; @@ -99,12 +103,13 @@ public class CallButtonFragment extends BaseFragment<CallButtonPresenter> }); mShowDialpadButton = (ToggleButton) parent.findViewById(R.id.dialpadButton); - mShowDialpadButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - getPresenter().showDialpadClicked(isChecked); - } - }); + mShowDialpadButton.setOnClickListener(this); + mAddCallButton = (ImageButton) parent.findViewById(R.id.addButton); + mAddCallButton.setOnClickListener(this); + mMergeButton = (ImageButton) parent.findViewById(R.id.mergeButton); + mMergeButton.setOnClickListener(this); + mSwapButton = (ImageButton) parent.findViewById(R.id.swapButton); + mSwapButton.setOnClickListener(this); return parent; } @@ -124,6 +129,33 @@ public class CallButtonFragment extends BaseFragment<CallButtonPresenter> } @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + } + + @Override + public void onClick(View view) { + int id = view.getId(); + Logger.d(this, "onClick(View " + view + ", id " + id + ")..."); + + switch(id) { + case R.id.addButton: + getPresenter().addCallClicked(); + break; + case R.id.mergeButton: + getPresenter().mergeClicked(); + break; + case R.id.swapButton: + getPresenter().swapClicked(); + break; + case R.id.dialpadButton: + getPresenter().showDialpadClicked(mShowDialpadButton.isChecked()); + default: + Logger.wtf(this, "onClick: unexpected"); + break; + } + } + + @Override public void setVisible(boolean on) { if (on) { getView().setVisibility(View.VISIBLE); @@ -148,6 +180,21 @@ public class CallButtonFragment extends BaseFragment<CallButtonPresenter> } @Override + public void showMerge(boolean show) { + mMergeButton.setVisibility(show ? View.VISIBLE : View.GONE); + } + + @Override + public void showSwap(boolean show) { + mSwapButton.setVisibility(show ? View.VISIBLE : View.GONE); + } + + @Override + public void showAddCall(boolean show) { + mAddCallButton.setVisibility(show ? View.VISIBLE : View.GONE); + } + + @Override public void setAudio(int mode) { } diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index bb2484747..7b6649704 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -146,6 +146,18 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto getUi().setHold(checked); } + public void mergeClicked() { + CallCommandClient.getInstance().merge(); + } + + public void addCallClicked() { + CallCommandClient.getInstance().addCall(); + } + + public void swapClicked() { + CallCommandClient.getInstance().swap(); + } + public void showDialpadClicked(boolean checked) { Logger.v(this, "Show dialpad " + String.valueOf(checked)); getUi().displayDialpad(checked); @@ -160,10 +172,20 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto final boolean isVisible = state.isConnectingOrConnected() && !state.isIncoming(); - getUi().setVisible(isVisible); + ui.setVisible(isVisible); + + Logger.d(this, "Updating call UI for call: ", call); + + if (isVisible && call != null) { + Logger.v(this, "Show hold ", call.can(Capabilities.HOLD)); + Logger.v(this, "Show merge ", call.can(Capabilities.MERGE_CALLS)); + Logger.v(this, "Show swap ", call.can(Capabilities.SWAP_CALLS)); + Logger.v(this, "Show add call ", call.can(Capabilities.ADD_CALL)); - if (call != null) { - getUi().showHold(call.can(Capabilities.HOLD)); + ui.showHold(call.can(Capabilities.HOLD)); + ui.showMerge(call.can(Capabilities.MERGE_CALLS)); + ui.showSwap(call.can(Capabilities.SWAP_CALLS)); + ui.showAddCall(call.can(Capabilities.ADD_CALL)); } } @@ -172,6 +194,9 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto void setMute(boolean on); void setHold(boolean on); void showHold(boolean show); + void showMerge(boolean show); + void showSwap(boolean show); + void showAddCall(boolean show); void displayDialpad(boolean on); void setAudio(int mode); void setSupportedAudio(int mask); diff --git a/InCallUI/src/com/android/incallui/CallCommandClient.java b/InCallUI/src/com/android/incallui/CallCommandClient.java index 8e0a16c46..280bab32c 100644 --- a/InCallUI/src/com/android/incallui/CallCommandClient.java +++ b/InCallUI/src/com/android/incallui/CallCommandClient.java @@ -88,6 +88,30 @@ public class CallCommandClient { } } + public void merge() { + try { + mCommandService.merge(); + } catch (RemoteException e) { + Logger.e(this, "Error merging calls.", e); + } + } + + public void swap() { + try { + mCommandService.swap(); + } catch (RemoteException e) { + Logger.e(this, "Error merging calls.", e); + } + } + + public void addCall() { + try { + mCommandService.addCall(); + } catch (RemoteException e) { + Logger.e(this, "Error merging calls.", e); + } + } + public void setAudioMode(int mode) { try { mCommandService.setAudioMode(mode); |