From ad3d871e15e615b0dc36045606452c54e94b93f8 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Wed, 18 Mar 2015 12:08:33 -0700 Subject: Add "Send SMS" shortcut to Dialer. Bug: 19372539 Change-Id: I8135a7e6fb7d5becdafcb0ecfb64d6f6c73aeb88 --- res/values/strings.xml | 3 +++ src/com/android/dialer/list/DialerPhoneNumberListAdapter.java | 9 +++++++-- src/com/android/dialer/list/SearchFragment.java | 7 +++++++ src/com/android/dialer/list/SmartDialNumberListAdapter.java | 1 + 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 @@ Add to contacts + + Send SMS + Make video call 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) { -- cgit v1.2.3