IMS: UI Enhancements for ECT and Deflect feature
Interface for dynamic number selection for ECT
and call deflect feature.
Change-Id: Idfe12b29ea2a33efade5f22bc92b0402a572b282
CRs-Fixed: 1076071 1076072
diff --git a/InCallUI/res/values/qtistrings.xml b/InCallUI/res/values/qtistrings.xml
index eba800a..5876c87 100644
--- a/InCallUI/res/values/qtistrings.xml
+++ b/InCallUI/res/values/qtistrings.xml
@@ -91,6 +91,7 @@
<string name="qti_ims_onscreenAssuredTransfer">Assured Transfer</string>
<!-- Text for the onscreen "consultative transfer" button -->
<string name="qti_ims_onscreenConsultativeTransfer">Consultative Transfer</string>
+ <string name="qti_call_transfer_title">Call Transfer</string>
<!-- Message indicating video calls not allowed if user enabled TTY Mode -->
<string name="video_call_not_allowed_if_tty_enabled">Please disable TTY Mode to upgrade to video calls.</string>
@@ -99,6 +100,7 @@
<string name="qti_description_target_deflect">Deflect</string>
<string name="qti_description_deflect_error">Number not set. Provide the number via IMS settings and retry.</string>
<string name="qti_description_deflect_service_error">Call Deflection service is not supported.</string>
+ <string name="qti_deflect_title">Deflect Number</string>
<!-- Message indicating call failed due to handover not feasible -->
<string name="call_failed_ho_not_feasible">Call was ended as LTE to 3G/2G handover was not feasible.</string>
<!-- Text for the onscreen "Add Participant" button -->
diff --git a/InCallUI/src/com/android/incallui/AnswerFragment.java b/InCallUI/src/com/android/incallui/AnswerFragment.java
index 5333058..11cdfda 100644
--- a/InCallUI/src/com/android/incallui/AnswerFragment.java
+++ b/InCallUI/src/com/android/incallui/AnswerFragment.java
@@ -16,10 +16,13 @@
package com.android.incallui;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
+import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@@ -274,8 +277,32 @@
getPresenter().onText();
}
- public void onDeflect(Context context) {
- getPresenter().onDeflect(context);
+ public void onDeflectNumberSelect(Context context) {
+ getPresenter().setDeflectCallId();
+ Intent dialogIntent = new Intent("com.qti.editnumber.INTENT_ACTION_LAUNCH_DIALOG");
+ dialogIntent.putExtra(QtiCallUtils.INTENT_EXTRA_DIALOG_TITLE,
+ getResources().getString(R.string.qti_deflect_title));
+ try {
+ startActivityForResult(dialogIntent, QtiCallUtils.ACTIVITY_REQUEST_ENTER_NUMBER);
+ } catch (ActivityNotFoundException e) {
+ Log.e(this, "Unable to launch EditNumberUI Dialog");
+ }
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ String number = null;
+ if (data == null) {
+ Log.w(this, "Data is null from intent" );
+ return;
+ }
+
+ if ((requestCode == QtiCallUtils.ACTIVITY_REQUEST_ENTER_NUMBER) &&
+ (resultCode == Activity.RESULT_OK)) {
+ Bundle b = data.getExtras();
+ number = b.getString("Number");
+ }
+ getPresenter().onDeflect(getContext(), number);
}
/**
diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java
index b8b5185..ca08b52 100644
--- a/InCallUI/src/com/android/incallui/AnswerPresenter.java
+++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java
@@ -360,30 +360,23 @@
/**
* Deflect the incoming call.
*/
- public void onDeflect(Context context) {
+ public void onDeflect(Context context, String deflectCallNumber) {
if (mCallId == null) {
return;
}
- Log.d(this, "onDeflect " + mCallId);
- String deflectCallNumber = QtiImsExtUtils.getCallDeflectNumber(
- context.getContentResolver());
- /* If not set properly, inform user via toast */
- if (deflectCallNumber == null) {
- Log.w(this, "getCallDeflectNumber is null or Empty.");
- QtiCallUtils.displayToast(context, R.string.qti_description_deflect_error);
- } else {
- int phoneId = 0;
- try {
- Log.d(this, "Sending deflect request with Phone id " + phoneId +
- " to " + deflectCallNumber);
- QtiImsExtManager.getInstance().sendCallDeflectRequest(phoneId,
- deflectCallNumber, imsInterfaceListener);
- } catch (QtiImsException e) {
- Log.e(this, "sendCallDeflectRequest exception " + e);
- QtiCallUtils.displayToast(getUi().getContext(),
- R.string.qti_description_deflect_service_error);
- }
+ Log.d(this, "onDeflect mCallId:" + mCallId + "deflectCallNumber:" + deflectCallNumber);
+
+ int phoneId = 0;
+ try {
+ Log.d(this, "Sending deflect request with Phone id " + phoneId +
+ " to " + deflectCallNumber);
+ QtiImsExtManager.getInstance().sendCallDeflectRequest(phoneId,
+ deflectCallNumber, imsInterfaceListener);
+ } catch (QtiImsException e) {
+ Log.e(this, "sendCallDeflectRequest exception " + e);
+ QtiCallUtils.displayToast(getUi().getContext(),
+ R.string.qti_description_deflect_service_error);
}
}
@@ -486,4 +479,10 @@
Log.d(this, "No incoming call present for sub = " + subId + " " + this);
}
}
+
+ public void setDeflectCallId () {
+ if (mCalls != null) {
+ QtiCallUtils.setDeflectOrTransferCallId(mCalls.getIncomingCall().getId());
+ }
+ }
}
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java
index 5c1319f..332dbb4 100644
--- a/InCallUI/src/com/android/incallui/CallButtonFragment.java
+++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java
@@ -38,7 +38,10 @@
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_VO_VIDEO_CALL;
import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_ADD_PARTICIPANT;
+import android.app.Activity;
+import android.content.ActivityNotFoundException;
import android.content.Context;
+import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
@@ -88,6 +91,10 @@
// The button has been collapsed into the overflow menu
private static final int BUTTON_MENU = 3;
+ private static final int INVALID_CALL_TRANSFER_TYPE = 1000;
+
+ private int mCallTransferType = INVALID_CALL_TRANSFER_TYPE;
+
public interface Buttons {
public static final int BUTTON_AUDIO = 0;
@@ -274,11 +281,13 @@
getPresenter().pauseVideoClicked(
!mPauseVideoButton.isSelected() /* pause */);
} else if (id == R.id.blindTransfer) {
- getPresenter().callTransferClicked(QtiImsExtUtils.QTI_IMS_BLIND_TRANSFER);
+ mCallTransferType = QtiImsExtUtils.QTI_IMS_BLIND_TRANSFER;
+ onCallTransferNumberSelect(getContext());
} else if (id == R.id.assuredTransfer) {
- getPresenter().callTransferClicked(QtiImsExtUtils.QTI_IMS_ASSURED_TRANSFER);
+ mCallTransferType = QtiImsExtUtils.QTI_IMS_ASSURED_TRANSFER;
+ onCallTransferNumberSelect(getContext());
} else if (id == R.id.consultativeTransfer) {
- getPresenter().callTransferClicked(QtiImsExtUtils.QTI_IMS_CONSULTATIVE_TRANSFER);
+ getPresenter().callTransferClicked(QtiImsExtUtils.QTI_IMS_CONSULTATIVE_TRANSFER, null);
} else if (id == R.id.overflowButton) {
if (mOverflowPopup != null) {
updateRecordMenu();
@@ -310,6 +319,36 @@
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
+ public void onCallTransferNumberSelect(Context context) {
+ getPresenter().setCallTransferCallId();
+ Intent dialogIntent = new Intent("com.qti.editnumber.INTENT_ACTION_LAUNCH_DIALOG");
+ dialogIntent.putExtra(QtiCallUtils.INTENT_EXTRA_DIALOG_TITLE,
+ getResources().getString(R.string.qti_call_transfer_title));
+ try {
+ startActivityForResult(dialogIntent, QtiCallUtils.ACTIVITY_REQUEST_ENTER_NUMBER);
+ } catch (ActivityNotFoundException e) {
+ Log.e(this, "Unable to launch EditNumberUI Dialog");
+ }
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ String number = null;
+ if (data == null) {
+ Log.w(this, "Data is null from intent" );
+ return;
+ }
+
+ if ((requestCode == QtiCallUtils.ACTIVITY_REQUEST_ENTER_NUMBER) &&
+ (resultCode == Activity.RESULT_OK)) {
+ Bundle b = data.getExtras();
+ number = b.getString("Number");
+ }
+ if (mCallTransferType != INVALID_CALL_TRANSFER_TYPE) {
+ getPresenter().callTransferClicked(mCallTransferType, number);
+ }
+ }
+
private void updateRecordMenu() {
MenuItem item = mOverflowPopup.getMenu().findItem(BUTTON_RECORD);
if (item != null) {
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
index 41d6e9c..9738741 100644
--- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
@@ -425,22 +425,8 @@
getUi().setVideoPaused(pause);
}
- public void callTransferClicked(int type) {
- String number = null;
+ public void callTransferClicked(int type, String number) {
Context mContext = getUi().getContext();
- if (type != QtiImsExtUtils.QTI_IMS_CONSULTATIVE_TRANSFER) {
- /**
- * Since there are no editor options available to provide a number during
- * blind or assured transfer, for now, making use of the existing
- * call deflection editor to provide the required number.
- */
- number = QtiImsExtUtils.getCallDeflectNumber(mContext.getContentResolver());
- if (number == null) {
- QtiCallUtils.displayToast(mContext, R.string.qti_ims_transfer_num_error);
- return;
- }
- }
-
boolean status = mCall.sendCallTransferRequest(type, number);
if (!status) {
QtiCallUtils.displayToast(mContext, R.string.qti_ims_transfer_request_error);
@@ -670,4 +656,10 @@
ui.updateColors();
}
}
+
+ public void setCallTransferCallId() {
+ if (mCall != null) {
+ QtiCallUtils.setDeflectOrTransferCallId(mCall.getId());
+ }
+ }
}
diff --git a/InCallUI/src/com/android/incallui/GlowPadWrapper.java b/InCallUI/src/com/android/incallui/GlowPadWrapper.java
index c88a984..84efd7f 100644
--- a/InCallUI/src/com/android/incallui/GlowPadWrapper.java
+++ b/InCallUI/src/com/android/incallui/GlowPadWrapper.java
@@ -139,7 +139,7 @@
mAnswerFragment.onAnswer(VideoProfile.STATE_RX_ENABLED, getContext());
mTargetTriggered = true;
} else if (resId == R.drawable.qti_ic_lockscreen_deflect) {
- mAnswerFragment.onDeflect(getContext());
+ mAnswerFragment.onDeflectNumberSelect(getContext());
mTargetTriggered = true;
} else {
// Code should never reach here.
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index e440f32..d803a80 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -64,6 +64,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Locale;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -722,6 +723,13 @@
public void onDisconnect(Call call) {
maybeShowErrorDialogOnDisconnect(call);
+ // Send broadcast to dismiss deflect dialog.
+ if (Objects.equals(call.getId(), QtiCallUtils.getDeflectOrTransferCallId())) {
+ Intent intent = new Intent(QtiCallUtils.INTENT_ACTION_DIALOG_DISMISS);
+ mInCallActivity.sendBroadcast(intent);
+ QtiCallUtils.setDeflectOrTransferCallId(null);
+ }
+
// We need to do the run the same code as onCallListChange.
onCallListChange(mCallList);
diff --git a/InCallUI/src/com/android/incallui/QtiCallUtils.java b/InCallUI/src/com/android/incallui/QtiCallUtils.java
index 6a4383a..0c85a0b 100644
--- a/InCallUI/src/com/android/incallui/QtiCallUtils.java
+++ b/InCallUI/src/com/android/incallui/QtiCallUtils.java
@@ -61,6 +61,15 @@
private static String LOG_TAG = "QtiCallUtils";
/**
+ * Edit number variables for deflect/call transfer feature.
+ */
+ public static final int ACTIVITY_REQUEST_ENTER_NUMBER = 1;
+ public static final String INTENT_EXTRA_DIALOG_TITLE = "Title";
+ public static final String INTENT_ACTION_DIALOG_DISMISS =
+ "com.qti.editnumber.INTENT_ACTION_DIALOG_DISMISS";
+ private static String mEditNumberCallId;
+
+ /**
* Private constructor for QtiCallUtils as we don't want to instantiate this class
*/
private QtiCallUtils() {
@@ -542,4 +551,15 @@
return hasVoiceCapabilities(call) || hasTransmitVideoCapabilities(call)
|| hasReceiveVideoCapabilities(call);
}
+
+ public static String getDeflectOrTransferCallId() {
+ if (mEditNumberCallId != null) {
+ return mEditNumberCallId;
+ }
+ return null;
+ }
+
+ public static void setDeflectOrTransferCallId(String CallId) {
+ mEditNumberCallId = CallId;
+ }
}