diff options
author | Andrew Lee <anwlee@google.com> | 2015-03-18 21:34:19 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-18 21:34:19 +0000 |
commit | 5ef1ff8aad553aab1f2df0d05ccdb2f16370b46a (patch) | |
tree | be732ad17e3d66a10f74477d475cc1595740a3c5 | |
parent | 3e7ee92cd04fbb37745799c329294d54fa6526a3 (diff) | |
parent | ad3d871e15e615b0dc36045606452c54e94b93f8 (diff) |
Merge "Add "Send SMS" shortcut to Dialer."
4 files changed, 18 insertions, 2 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index 13bf845c3..2b100f6f8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -505,6 +505,9 @@ <!-- Shortcut item used to add a number directly from search --> <string name="search_shortcut_add_to_contacts">Add to contacts</string> + <!-- Shortcut item used to send a text message directly from search. [CHAR LIMIT=40] --> + <string name="search_shortcut_send_sms_message">Send SMS</string> + <!-- Shortcut item used to make a video call directly from search. --> <string name="search_shortcut_make_video_call">Make video call</string> diff --git a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java index da4f4a4c9..86e852846 100644 --- a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java +++ b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java @@ -28,9 +28,10 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { public final static int SHORTCUT_INVALID = -1; public final static int SHORTCUT_DIRECT_CALL = 0; public final static int SHORTCUT_ADD_NUMBER_TO_CONTACTS = 1; - public final static int SHORTCUT_MAKE_VIDEO_CALL = 2; + public final static int SHORTCUT_SEND_SMS_MESSAGE = 2; + public final static int SHORTCUT_MAKE_VIDEO_CALL = 3; - public final static int SHORTCUT_COUNT = 3; + public final static int SHORTCUT_COUNT = 4; private final boolean[] mShortcutEnabled = new boolean[SHORTCUT_COUNT]; @@ -146,6 +147,10 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { text = resources.getString(R.string.search_shortcut_add_to_contacts); drawableId = R.drawable.ic_search_add_contact; break; + case SHORTCUT_SEND_SMS_MESSAGE: + text = resources.getString(R.string.search_shortcut_send_sms_message); + drawableId = R.drawable.ic_textsms_24dp; + break; case SHORTCUT_MAKE_VIDEO_CALL: text = resources.getString(R.string.search_shortcut_make_video_call); drawableId = R.drawable.ic_videocam; diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java index e50d0d89e..ba014380c 100644 --- a/src/com/android/dialer/list/SearchFragment.java +++ b/src/com/android/dialer/list/SearchFragment.java @@ -18,6 +18,7 @@ package com.android.dialer.list; import android.app.Activity; import android.content.Intent; import android.content.res.Resources; +import android.net.Uri; import android.os.Bundle; import android.text.TextUtils; import android.view.View; @@ -38,6 +39,7 @@ import com.android.dialer.util.DialerUtils; import com.android.phone.common.animation.AnimUtils; public class SearchFragment extends PhoneNumberPickerFragment { + private static final String SMS_URI_PREFIX = "sms:"; private OnListFragmentScrolledListener mActivityScrollListener; @@ -168,6 +170,11 @@ public class SearchFragment extends PhoneNumberPickerFragment { DialerUtils.startActivityWithErrorToast(getActivity(), intent, R.string.add_contact_not_available); break; + case DialerPhoneNumberListAdapter.SHORTCUT_SEND_SMS_MESSAGE: + final Intent sendSmsIntent = new Intent( + Intent.ACTION_VIEW, Uri.parse(SMS_URI_PREFIX + getQueryString())); + DialerUtils.startActivityWithErrorToast(getActivity(), sendSmsIntent); + break; case DialerPhoneNumberListAdapter.SHORTCUT_MAKE_VIDEO_CALL: listener = getOnPhoneNumberPickerListener(); if (listener != null) { diff --git a/src/com/android/dialer/list/SmartDialNumberListAdapter.java b/src/com/android/dialer/list/SmartDialNumberListAdapter.java index db9668267..3696fb900 100644 --- a/src/com/android/dialer/list/SmartDialNumberListAdapter.java +++ b/src/com/android/dialer/list/SmartDialNumberListAdapter.java @@ -117,6 +117,7 @@ public class SmartDialNumberListAdapter extends DialerPhoneNumberListAdapter { final boolean showNumberShortcuts = !TextUtils.isEmpty(getFormattedQueryString()); boolean changed = false; changed |= setShortcutEnabled(SHORTCUT_ADD_NUMBER_TO_CONTACTS, showNumberShortcuts); + changed |= setShortcutEnabled(SHORTCUT_SEND_SMS_MESSAGE, showNumberShortcuts); changed |= setShortcutEnabled(SHORTCUT_MAKE_VIDEO_CALL, showNumberShortcuts && CallUtil.isVideoEnabled(getContext())); if (changed) { |