diff options
Diffstat (limited to 'InCallUI/src')
7 files changed, 135 insertions, 11 deletions
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index 801e7493f..07978ff65 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -120,7 +120,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> @Override public void onStateChange(InCallState state, CallList callList) { - Log.d(TAG, "onStateChange() " + state); + Log.d(this, "onStateChange() " + state); final CallCardUi ui = getUi(); if (ui == null) { return; @@ -255,8 +255,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> if (entry.label == null) { // Name not found. Try lookup. Log.d(TAG, "Contact lookup. Contact provider miss. Searching people api."); - lookupPhoneNumber(identification.getNumber(), - isPrimary, isConference); + lookupPhoneNumber(identification.getNumber(), isPrimary, isConference); } else { Log.d(TAG, "Contact lookup. Found in contact provider: " + entry); updateContactEntry(entry, isPrimary, isConference); @@ -265,12 +264,11 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> @Override public void onImageLoadComplete(int callId, Bitmap photo) { - if (callId == mPrimary.getCallId()) { + if (mPrimary != null && callId == mPrimary.getCallId()) { getUi().setPrimaryImage(photo); - } else if (callId == mSecondary.getCallId()) { + } else if (mSecondary != null && callId == mSecondary.getCallId()) { getUi().setSecondaryImage(photo); } - } }); } else { @@ -411,7 +409,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> updateContactEntry(entry, isPrimary, isConference); if (info.getImageUrl() != null) { - fetchImage(info.getImageUrl()); + fetchImage(info.getImageUrl(), isPrimary); } } }); @@ -459,13 +457,17 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> !TextUtils.isEmpty(mPrimary.getGatewayPackage())); } - private void fetchImage(final String url) { + private void fetchImage(final String url, final boolean isPrimary) { if (url != null && mPhoneNumberService != null) { mPhoneNumberService.fetchImage(url, new PhoneNumberService.ImageLookupListener() { @Override public void onImageFetchComplete(Bitmap bitmap) { if (getUi() != null) { - getUi().setPrimaryImage(bitmap); + if (isPrimary) { + getUi().setPrimaryImage(bitmap); + } else { + getUi().setSecondaryImage(bitmap); + } } } }); 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 b2b76f2fa..dccdcdf32 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; @@ -186,6 +187,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)); + } }; /** @@ -227,6 +234,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/ConferenceManagerPresenter.java b/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java index 6b6f7d815..ccda4a579 100644 --- a/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java +++ b/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java @@ -60,7 +60,7 @@ public class ConferenceManagerPresenter private void update(CallList callList) { mCallerIds = null; - mCallerIds = callList.getActiveCall().getChildCallIds().toArray(new Integer[0]); + mCallerIds = callList.getActiveOrBackgroundCall().getChildCallIds().toArray(new Integer[0]); mNumCallersInConference = mCallerIds.length; Log.v(this, "Number of calls is " + String.valueOf(mNumCallersInConference)); diff --git a/InCallUI/src/com/android/incallui/InCallActivity.java b/InCallUI/src/com/android/incallui/InCallActivity.java index fb9f99c10..38e2a48b6 100644 --- a/InCallUI/src/com/android/incallui/InCallActivity.java +++ b/InCallUI/src/com/android/incallui/InCallActivity.java @@ -323,4 +323,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 1e2f6755d..0f8d4071a 100644 --- a/InCallUI/src/com/android/incallui/InCallPresenter.java +++ b/InCallUI/src/com/android/incallui/InCallPresenter.java @@ -302,6 +302,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); + } +} |