From b768e13959a69836096eeddd9a397189e50af959 Mon Sep 17 00:00:00 2001 From: Chiao Cheng Date: Fri, 6 Sep 2013 15:59:01 -0700 Subject: Port dtmf post dial wait feature. Bug: 10459289 Change-Id: Iee799bd72aac9bb86e2f414e68f2643d8ba1c563 --- .../com/android/incallui/CallCommandClient.java | 27 ++++++++ .../com/android/incallui/CallHandlerService.java | 12 +++- .../src/com/android/incallui/InCallActivity.java | 5 ++ .../src/com/android/incallui/InCallPresenter.java | 4 ++ .../android/incallui/PostCharDialogFragment.java | 76 ++++++++++++++++++++++ 5 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 InCallUI/src/com/android/incallui/PostCharDialogFragment.java (limited to 'InCallUI') diff --git a/InCallUI/src/com/android/incallui/CallCommandClient.java b/InCallUI/src/com/android/incallui/CallCommandClient.java index b59788b2c..cb49dca8e 100644 --- a/InCallUI/src/com/android/incallui/CallCommandClient.java +++ b/InCallUI/src/com/android/incallui/CallCommandClient.java @@ -200,4 +200,31 @@ public class CallCommandClient { Log.e(this, "Error setting speaker.", e); } } + + public void postDialWaitContinue(int callId) { + if (mCommandService == null) { + Log.e(this, "Cannot postDialWaitContinue(); CallCommandService == null"); + return; + } + try { + Log.v(this, "postDialWaitContinue()"); + mCommandService.postDialWaitContinue(callId); + } catch (RemoteException e) { + Log.e(this, "Error on postDialWaitContinue().", e); + } + } + + public void postDialCancel(int callId) { + if (mCommandService == null) { + Log.e(this, "Cannot postDialCancel(); CallCommandService == null"); + return; + } + try { + Log.v(this, "postDialCancel()"); + mCommandService.postDialCancel(callId); + } catch (RemoteException e) { + Log.e(this, "Error on postDialCancel().", e); + } + } + } diff --git a/InCallUI/src/com/android/incallui/CallHandlerService.java b/InCallUI/src/com/android/incallui/CallHandlerService.java index b73135590..94c2a11af 100644 --- a/InCallUI/src/com/android/incallui/CallHandlerService.java +++ b/InCallUI/src/com/android/incallui/CallHandlerService.java @@ -45,8 +45,9 @@ public class CallHandlerService extends Service { private static final int ON_SUPPORTED_AUDIO_MODE = 5; private static final int ON_DISCONNECT_CALL = 6; private static final int ON_BRING_TO_FOREGROUND = 7; + private static final int ON_POST_CHAR_WAIT = 8; - private static final int LARGEST_MSG_ID = ON_BRING_TO_FOREGROUND; + private static final int LARGEST_MSG_ID = ON_POST_CHAR_WAIT; private CallList mCallList; @@ -182,6 +183,12 @@ public class CallHandlerService extends Service { public void bringToForeground() { mMainHandler.sendMessage(mMainHandler.obtainMessage(ON_BRING_TO_FOREGROUND)); } + + @Override + public void onPostDialWait(int callId, String chars) { + mMainHandler.sendMessage(mMainHandler.obtainMessage(ON_POST_CHAR_WAIT, callId, 0, + chars)); + } }; /** @@ -223,6 +230,9 @@ public class CallHandlerService extends Service { case ON_DISCONNECT_CALL: mCallList.onDisconnect((Call) msg.obj); break; + case ON_POST_CHAR_WAIT: + mInCallPresenter.onPostDialCharWait(msg.arg1, (String) msg.obj); + break; case ON_AUDIO_MODE: mAudioModeProvider.onAudioModeChange(msg.arg1, msg.arg2 == 1); break; diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index 6cae6b05e..4c1d04089 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -350,4 +350,9 @@ public class InCallActivity extends Activity { mConferenceManagerFragment.setVisible(true); } } + + public void showPostCharWaitDialog(int callId, String chars) { + final PostCharDialogFragment fragment = new PostCharDialogFragment(callId, chars); + fragment.show(getFragmentManager(), "postCharWait"); + } } diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java index cc4cee277..cc04dc5b4 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -264,6 +264,10 @@ public class InCallPresenter implements CallList.Listener { } } + public void onPostDialCharWait(int callId, String chars) { + mInCallActivity.showPostCharWaitDialog(callId, chars); + } + /** * When the state of in-call changes, this is the first method to get called. It determines if * the UI needs to be started or finished depending on the new state and does it. diff --git a/InCallUI/src/com/android/incallui/PostCharDialogFragment.java b/InCallUI/src/com/android/incallui/PostCharDialogFragment.java new file mode 100644 index 000000000..41940ff34 --- /dev/null +++ b/InCallUI/src/com/android/incallui/PostCharDialogFragment.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.incallui; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.DialogInterface; +import android.os.Bundle; +import android.view.WindowManager; + +/** + * Pop up an alert dialog with OK and Cancel buttons to allow user to Accept or Reject the WAIT + * inserted as part of the Dial string. + */ +public class PostCharDialogFragment extends DialogFragment { + + private int mCallId; + private String mPostDialStr; + + public PostCharDialogFragment(int callId, String postDialStr) { + mCallId = callId; + mPostDialStr = postDialStr; + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + super.onCreateDialog(savedInstanceState); + + final StringBuilder buf = new StringBuilder(); + buf.append(getResources().getText(R.string.wait_prompt_str)); + buf.append(mPostDialStr); + + final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setMessage(buf.toString()); + + builder.setPositiveButton(R.string.pause_prompt_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int whichButton) { + CallCommandClient.getInstance().postDialWaitContinue(mCallId); + } + }); + builder.setNegativeButton(R.string.pause_prompt_no, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int whichButton) { + dialog.cancel(); + } + }); + + final AlertDialog dialog = builder.create(); + dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); + return dialog; + } + + @Override + public void onCancel(DialogInterface dialog) { + super.onCancel(dialog); + + CallCommandClient.getInstance().postDialCancel(mCallId); + } +} -- cgit v1.2.3