summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Braun <dabraun@google.com>2013-10-05 19:33:46 -0700
committerDavid Braun <dabraun@google.com>2013-10-05 19:33:46 -0700
commitef1b5e0afd8e824979d1acda015eda314e61955b (patch)
tree889209f7f25e9d1dcc01f2c4b9a9b9ec8120ef35
parent92728d020f5969878df73310f8594b12684d982b (diff)
downloadpackages_apps_InCallUI-ef1b5e0afd8e824979d1acda015eda314e61955b.tar.gz
packages_apps_InCallUI-ef1b5e0afd8e824979d1acda015eda314e61955b.tar.bz2
packages_apps_InCallUI-ef1b5e0afd8e824979d1acda015eda314e61955b.zip
Add custom message dialog for Respond via Message.
We don't want to require SMS applications to implement activities that show over lock just to handle the "respond via custom message" scenario for rejecting phone calls. This change adds an entry dialog into the phone call UI. A separate change removes the code in the Telephony service that would have asked the default SMS app to show UI. Bug: 11084719 Provide UI for "quick response" messages built into Phone app Change-Id: I7fcf20280fd3b741aa941cc6a24f5c262db1899b
-rwxr-xr-xres/values/strings.xml4
-rw-r--r--src/com/android/incallui/AnswerFragment.java73
-rw-r--r--src/com/android/incallui/AnswerPresenter.java13
3 files changed, 70 insertions, 20 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e7049e5b..7c588b34 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1280,6 +1280,10 @@
<string name="respond_via_sms_canned_response_4">Can\'t talk now. Call me later?</string>
<!-- "Respond via SMS" option that lets you compose a custom response. [CHAR LIMIT=30] -->
<string name="respond_via_sms_custom_message">Write your own...</string>
+ <!-- "Custom Message" Cancel alert dialog button -->
+ <string name="custom_message_cancel">Cancel</string>
+ <!-- "Custom Message" Send alert dialog button -->
+ <string name="custom_message_send">Send</string>
<!-- Title of settings screen for managing the "Respond via SMS" feature. [CHAR LIMIT=30] -->
<string name="respond_via_sms_setting_title">Quick responses</string>
diff --git a/src/com/android/incallui/AnswerFragment.java b/src/com/android/incallui/AnswerFragment.java
index 324d5228..29a45865 100644
--- a/src/com/android/incallui/AnswerFragment.java
+++ b/src/com/android/incallui/AnswerFragment.java
@@ -18,12 +18,18 @@ package com.android.incallui;
import android.app.AlertDialog;
import android.app.Dialog;
+import android.content.DialogInterface;
import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.EditText;
import android.widget.ListView;
import com.google.common.base.Preconditions;
@@ -106,12 +112,7 @@ public class AnswerFragment extends BaseFragment<AnswerPresenter, AnswerPresente
}
@Override
- public boolean isMessageDialogueShowing() {
- return mCannedResponsePopup != null && mCannedResponsePopup.isShowing();
- }
-
- @Override
- public void showMessageDialogue() {
+ public void showMessageDialog() {
final ListView lv = new ListView(getActivity());
Preconditions.checkNotNull(mTextResponsesAdapter);
@@ -130,16 +131,65 @@ public class AnswerFragment extends BaseFragment<AnswerPresenter, AnswerPresente
* This is safe to call even if the popup is already dismissed, and even if you never called
* showRespondViaSmsPopup() in the first place.
*/
- @Override
- public void dismissPopup() {
+ private void dismissPopup() {
if (mCannedResponsePopup != null) {
mCannedResponsePopup.dismiss(); // safe even if already dismissed
mCannedResponsePopup = null;
}
}
+ /**
+ * Shows the custom message entry dialog.
+ */
+ public void showCustomMessageDialog() {
+ // Create an alert dialog containing an EditText
+ final EditText et = new EditText(getActivity());
+ final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setCancelable(
+ true).setView(et)
+ .setPositiveButton(R.string.custom_message_send,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ getPresenter().rejectCallWithMessage(et.getText().toString().trim());
+ }
+ })
+ .setNegativeButton(R.string.custom_message_cancel,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ }
+ })
+ .setTitle(R.string.respond_via_sms_custom_message);
+ final AlertDialog customResponseDialog = builder.create();
+
+ // Enable/disable the send button based on whether there is a message in the EditText
+ et.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ }
+ @Override
+ public void afterTextChanged(Editable s) {
+ final Button sendButton = customResponseDialog.getButton(
+ DialogInterface.BUTTON_POSITIVE);
+ sendButton.setEnabled(s != null && s.toString().trim().length() != 0);
+ }
+ });
+
+ // Keyboard up, show the dialog
+ customResponseDialog.getWindow().setSoftInputMode(
+ WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+ customResponseDialog.show();
+
+ // Send button starts out disabled
+ final Button sendButton = customResponseDialog.getButton(DialogInterface.BUTTON_POSITIVE);
+ sendButton.setEnabled(false);
+ }
+
@Override
- public void configureMessageDialogue(ArrayList<String> textResponses) {
+ public void configureMessageDialog(ArrayList<String> textResponses) {
final ArrayList<String> textResponsesForDisplay = new ArrayList<String>(textResponses);
textResponsesForDisplay.add(getResources().getString(
@@ -178,12 +228,13 @@ public class AnswerFragment extends BaseFragment<AnswerPresenter, AnswerPresente
Log.d(this, "RespondViaSmsItemClickListener.onItemClick(" + position + ")...");
final String message = (String) parent.getItemAtPosition(position);
Log.v(this, "- message: '" + message + "'");
+ dismissPopup();
// The "Custom" choice is a special case.
// (For now, it's guaranteed to be the last item.)
if (position == (parent.getCount() - 1)) {
- // Take the user to the standard SMS compose UI.
- getPresenter().rejectCallWithMessage(null);
+ // Show the custom message dialog
+ showCustomMessageDialog();
} else {
getPresenter().rejectCallWithMessage(message);
}
diff --git a/src/com/android/incallui/AnswerPresenter.java b/src/com/android/incallui/AnswerPresenter.java
index b3deb641..6d70f818 100644
--- a/src/com/android/incallui/AnswerPresenter.java
+++ b/src/com/android/incallui/AnswerPresenter.java
@@ -93,7 +93,7 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi>
if (call.can(Call.Capabilities.RESPOND_VIA_TEXT) && textMsgs != null) {
getUi().showTextButton(true);
- getUi().configureMessageDialogue(textMsgs);
+ getUi().configureMessageDialog(textMsgs);
} else {
getUi().showTextButton(false);
}
@@ -134,24 +134,19 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi>
public void onText() {
if (getUi() != null) {
- getUi().showMessageDialogue();
+ getUi().showMessageDialog();
}
}
public void rejectCallWithMessage(String message) {
Log.d(this, "sendTextToDefaultActivity()...");
- if (getUi() != null) {
- getUi().dismissPopup();
- }
CallCommandClient.getInstance().rejectCall(mCallId, true, message);
}
interface AnswerUi extends Ui {
public void showAnswerUi(boolean show);
public void showTextButton(boolean show);
- public boolean isMessageDialogueShowing();
- public void showMessageDialogue();
- public void dismissPopup();
- public void configureMessageDialogue(ArrayList<String> textResponses);
+ public void showMessageDialog();
+ public void configureMessageDialog(ArrayList<String> textResponses);
}
}