summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2014-07-24 16:07:02 +0800
committerSteve Kondik <steve@cyngn.com>2015-11-24 14:07:50 -0800
commit97d3cea6240e8496f9399ef881bbbed6cc4871a3 (patch)
tree2b9cb06b6fb4ac5cc313648c4c262ec9e2ec89d0 /src
parent45f18329b099e743620c0c5abbaa294816f0d1b4 (diff)
downloadpackages_apps_Dialer-97d3cea6240e8496f9399ef881bbbed6cc4871a3.tar.gz
packages_apps_Dialer-97d3cea6240e8496f9399ef881bbbed6cc4871a3.tar.bz2
packages_apps_Dialer-97d3cea6240e8496f9399ef881bbbed6cc4871a3.zip
Dialer: add to support speed number dial
allow user to set speed dial number from 2~9, when long click these numbers, it will pop up a screen to set speed number or dial out directly if you have set it before. Change-Id: Iaab841933ad0e63dee70e7f4dc7f078507c425b3 Dialer: fix force close when speed dial When user sets the speed number and call speed number, will find force close. The reason is using wrong action in the DialpadFragment. We replace action ACTION_CALL_PRIVILEGE with ACTION_CALL. Change-Id: I0dc03ce7ac6bac86f9e9f2a7836546000b876bcd Dialer: fix wrong visible status of voice search button When user enters dialer main screen, it will prepare and check whether should show voice search button, but after back to non-search mode from search mode, it ignores to check and so the button status become wrong. We add to check whether should show voice search button in visibility updating function. Change-Id: I4374b3c44156294d00d5290316a7510e41a331a1 CRs-Fixed: 730644 Dialer: Start VoiceMail interface directly when click voice mail Start SelectSubscription when click voicemail in SpeedDialListActivity. Make an intent to start CallFeaturesSetting add a sub to decide which sim card's setting to start. CRs-Fixed: 731532 Change-Id: Ie5daf6e2c30580aaf9e74d274ee24dcf38092615 Dialer: fix force close in speed dial list The reason is that we use ACTION_CALL_PRIVILEGED which needs to use another permission in your manifest, so will cause SecurityException if you use this without the permission. We will use ACTION_CALL to replace ACTION_CALL_PRIVILEGED. Change-Id: I028d224521c8148874fee94d6f063306181b8f79 CRs-Fixed: 744880 Dialer: Input ,(pause) or ;(wait) when long press * or # There is no response when user long press * and # key. Add listener for these two key. Input ,(pause) or ;(wait) when long press * or #. CRs-Fixed: 641551 Change-Id: If25bcc546a299ef70343b409dbd6590d1655892a Rewrite speed dial feature. Change-Id: I346bcf4552cdf2ddfd3c9b1219bc07c20332d1a2 Tune fonts Change-Id: Ide2b39ea30476987a02f7532cc1d1955fbb3081a
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/dialer/SpeedDialListActivity.java340
-rw-r--r--src/com/android/dialer/SpeedDialUtils.java63
-rw-r--r--src/com/android/dialer/dialpad/DialpadFragment.java104
-rw-r--r--src/com/android/dialer/settings/DialerSettingsActivity.java6
-rw-r--r--src/com/android/dialer/widget/SearchEditTextLayout.java20
5 files changed, 532 insertions, 1 deletions
diff --git a/src/com/android/dialer/SpeedDialListActivity.java b/src/com/android/dialer/SpeedDialListActivity.java
new file mode 100755
index 000000000..e50b4017e
--- /dev/null
+++ b/src/com/android/dialer/SpeedDialListActivity.java
@@ -0,0 +1,340 @@
+/*
+ * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation, Inc. nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.dialer;
+
+import android.app.ActionBar;
+import android.app.ListActivity;
+import android.content.ActivityNotFoundException;
+import android.content.ContentUris;
+import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.provider.ContactsContract;
+import android.provider.Settings;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+import android.util.SparseArray;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
+import android.widget.PopupMenu;
+import android.widget.QuickContactBadge;
+import android.widget.TextView;
+
+import com.android.contacts.common.ContactPhotoManager;
+import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest;
+import com.android.internal.telephony.PhoneConstants;
+
+public class SpeedDialListActivity extends ListActivity implements
+ AdapterView.OnItemClickListener, PopupMenu.OnMenuItemClickListener {
+ private static final String TAG = "SpeedDial";
+ private static final String ACTION_ADD_VOICEMAIL =
+ "com.android.phone.CallFeaturesSetting.ADD_VOICEMAIL";
+ public static final String EXTRA_INITIAL_PICK_NUMBER = "initialPickNumber";
+
+ private static final String[] LOOKUP_PROJECTION = new String[] {
+ ContactsContract.Contacts._ID,
+ ContactsContract.Contacts.DISPLAY_NAME,
+ ContactsContract.Contacts.PHOTO_ID,
+ ContactsContract.PhoneLookup.NUMBER,
+ ContactsContract.PhoneLookup.NORMALIZED_NUMBER
+ };
+
+ private static final String[] PICK_PROJECTION = new String[] {
+ ContactsContract.Data.CONTACT_ID,
+ ContactsContract.Data.DISPLAY_NAME,
+ ContactsContract.Data.PHOTO_ID,
+ ContactsContract.CommonDataKinds.Phone.NUMBER,
+ ContactsContract.CommonDataKinds.Phone.NORMALIZED_NUMBER
+ };
+ private static final int COLUMN_ID = 0;
+ private static final int COLUMN_NAME = 1;
+ private static final int COLUMN_PHOTO = 2;
+ private static final int COLUMN_NUMBER = 3;
+ private static final int COLUMN_NORMALIZED = 4;
+
+ private static class Record {
+ long contactId;
+ String name;
+ String number;
+ String normalizedNumber;
+ long photoId;
+ public Record(String number) {
+ this.number = number;
+ this.contactId = -1;
+ }
+ }
+
+ private SparseArray<Record> mRecords;
+
+ private int mPickNumber;
+ private int mInitialPickNumber;
+ private SpeedDialAdapter mAdapter;
+
+ private static final int MENU_REPLACE = 0;
+ private static final int MENU_DELETE = 1;
+
+ private static final int PICK_CONTACT_RESULT = 0;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mInitialPickNumber = getIntent().getIntExtra(EXTRA_INITIAL_PICK_NUMBER, -1);
+ mRecords = new SparseArray<Record>();
+
+ //the first item is the "1.voice mail", it never changes
+ mRecords.put(1, new Record(getString(R.string.voicemail)));
+
+ ListView listview = getListView();
+ listview.setOnItemClickListener(this);
+
+ // compensate for action bar overlay specified in theme
+ int actionBarHeight = getResources().getDimensionPixelSize(R.dimen.action_bar_height);
+ listview.setPaddingRelative(0, actionBarHeight, 0, 0);
+
+ final ActionBar actionBar = getActionBar();
+ actionBar.setDisplayShowHomeEnabled(true);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
+ mAdapter = new SpeedDialAdapter();
+ setListAdapter(mAdapter);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ // get number from shared preferences
+ for (int i = 2; i <= 9; i++) {
+ String phoneNumber = SpeedDialUtils.getNumber(this, i);
+ Record record = null;
+ if (phoneNumber != null) {
+ Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
+ Uri.encode(phoneNumber));
+ record = getRecordFromQuery(uri, LOOKUP_PROJECTION);
+ if (record == null) {
+ record = new Record(phoneNumber);
+ }
+ }
+ mRecords.put(i, record);
+ }
+
+ mAdapter.notifyDataSetChanged();
+
+ if (mInitialPickNumber >= 2 && mInitialPickNumber <= 9) {
+ pickContact(mInitialPickNumber);
+ // we only want to trigger the picker once
+ mInitialPickNumber = -1;
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ private Record getRecordFromQuery(Uri uri, String[] projection) {
+ Record record = null;
+ Cursor cursor = null;
+ try {
+ cursor = getContentResolver().query(uri, projection, null, null, null);
+ if (cursor != null && cursor.moveToFirst()) {
+ record = new Record(cursor.getString(COLUMN_NUMBER));
+ record.contactId = cursor.getLong(COLUMN_ID);
+ record.photoId = cursor.getLong(COLUMN_PHOTO);
+ record.name = cursor.getString(COLUMN_NAME);
+ record.normalizedNumber = cursor.getString(COLUMN_NORMALIZED);
+ if (record.normalizedNumber == null) {
+ record.normalizedNumber = record.number;
+ }
+ }
+ } finally {
+ if (cursor != null) {
+ cursor.close();
+ }
+ }
+ return record;
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ if (position == 0) {
+ Intent intent = new Intent(ACTION_ADD_VOICEMAIL);
+ if (TelephonyManager.getDefault().getPhoneCount() > 1) {
+ long sub = SubscriptionManager.getDefaultVoiceSubId();
+ intent.setClassName("com.android.phone",
+ "com.android.phone.MSimCallFeaturesSubSetting");
+ intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, sub);
+ } else {
+ intent.setClassName("com.android.phone",
+ "com.android.phone.CallFeaturesSetting");
+ }
+ try {
+ startActivity(intent);
+ } catch(ActivityNotFoundException e) {
+ Log.w(TAG, "Could not find voice mail setup activity");
+ }
+ } else {
+ int number = position + 1;
+ final Record record = mRecords.get(number);
+ if (record == null) {
+ pickContact(number);
+ } else {
+ PopupMenu pm = new PopupMenu(this, view);
+ pm.getMenu().add(number, MENU_REPLACE, 0, R.string.speed_dial_replace);
+ pm.getMenu().add(number, MENU_DELETE, 0, R.string.speed_dial_delete);
+ pm.setOnMenuItemClickListener(this);
+ pm.show();
+ }
+ }
+ }
+
+ /*
+ * goto contacts, used to set or replace speed number
+ */
+ private void pickContact(int number) {
+ mPickNumber = number;
+ Intent intent = new Intent(Intent.ACTION_PICK);
+ intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
+ startActivityForResult(intent, PICK_CONTACT_RESULT);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode != PICK_CONTACT_RESULT) {
+ super.onActivityResult(requestCode, resultCode, data);
+ return;
+ }
+
+ if (resultCode == RESULT_OK) {
+ Record record = getRecordFromQuery(data.getData(), PICK_PROJECTION);
+ if (record != null) {
+ SpeedDialUtils.saveNumber(this, mPickNumber, record.normalizedNumber);
+ mRecords.put(mPickNumber, record);
+ mAdapter.notifyDataSetChanged();
+ }
+ }
+ }
+
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ int number = item.getGroupId();
+
+ switch (item.getItemId()) {
+ case MENU_REPLACE:
+ pickContact(number);
+ return true;
+ case MENU_DELETE:
+ mRecords.put(number, null);
+ SpeedDialUtils.saveNumber(this, number, null);
+ mAdapter.notifyDataSetChanged();
+ return true;
+ }
+ return false;
+ }
+
+ private class SpeedDialAdapter extends BaseAdapter {
+ private LayoutInflater mInflater;
+ private ContactPhotoManager mPhotoManager;
+
+ public SpeedDialAdapter() {
+ mInflater = LayoutInflater.from(SpeedDialListActivity.this);
+ mPhotoManager = ContactPhotoManager.getInstance(SpeedDialListActivity.this);
+ }
+
+ @Override
+ public int getCount() {
+ return mRecords.size();
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position + 1;
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return mRecords.get(position + 1);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) {
+ convertView = mInflater.inflate(R.layout.speed_dial_item, parent, false);
+ }
+
+ TextView index = (TextView) convertView.findViewById(R.id.index);
+ TextView name = (TextView) convertView.findViewById(R.id.name);
+ TextView number = (TextView) convertView.findViewById(R.id.number);
+ QuickContactBadge photo = (QuickContactBadge) convertView.findViewById(R.id.photo);
+ Record record = mRecords.get(position + 1);
+
+ index.setText(String.valueOf(position + 1));
+ if (record != null && record.name != null) {
+ name.setText(record.name);
+ number.setText(record.number);
+ number.setVisibility(View.VISIBLE);
+ } else {
+ name.setText(record != null ?
+ record.number : getString(R.string.speed_dial_not_set));
+ number.setVisibility(View.GONE);
+ }
+
+ if (record != null && record.contactId != -1) {
+ DefaultImageRequest request = new DefaultImageRequest(record.name,
+ record.normalizedNumber, true /* isCircular */);
+ mPhotoManager.removePhoto(photo);
+ mPhotoManager.loadThumbnail(photo, record.photoId,
+ false /* darkTheme */, true /* isCircular */, request);
+ photo.assignContactUri(ContentUris.withAppendedId(
+ ContactsContract.Contacts.CONTENT_URI, record.contactId));
+ photo.setVisibility(View.VISIBLE);
+ } else {
+ photo.setVisibility(View.GONE);
+ }
+ photo.setOverlay(null);
+
+ return convertView;
+ }
+ };
+}
diff --git a/src/com/android/dialer/SpeedDialUtils.java b/src/com/android/dialer/SpeedDialUtils.java
new file mode 100644
index 000000000..de8b53eff
--- /dev/null
+++ b/src/com/android/dialer/SpeedDialUtils.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.dialer;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+public class SpeedDialUtils {
+ private static final String NUMBER_KEY_PREFIX = "number_";
+
+ public static void saveNumber(Context context, int position, String phoneNumber) {
+ if (position < 2 || position > 9) {
+ return;
+ }
+ SharedPreferences.Editor editor = getPrefs(context).edit();
+ String key = NUMBER_KEY_PREFIX + position;
+ if (phoneNumber == null) {
+ editor.remove(key);
+ } else {
+ editor.putString(key, phoneNumber);
+ }
+ editor.commit();
+ }
+
+ public static String getNumber(Context context, int position) {
+ if (position < 2 || position > 9) {
+ return null;
+ }
+ String key = NUMBER_KEY_PREFIX + position;
+ return getPrefs(context).getString(key, null);
+ }
+
+ private static SharedPreferences getPrefs(Context context) {
+ return context.getSharedPreferences("speeddial", context.MODE_PRIVATE);
+ }
+}
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index b8c09fac1..109ba699c 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -81,6 +81,8 @@ import com.android.dialer.NeededForReflection;
import com.android.dialer.R;
import com.android.dialer.SpecialCharSequenceMgr;
import com.android.dialer.calllog.PhoneAccountUtils;
+import com.android.dialer.SpeedDialListActivity;
+import com.android.dialer.SpeedDialUtils;
import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.IntentUtil;
import com.android.phone.common.CallLogAsync;
@@ -584,6 +586,10 @@ public class DialpadFragment extends Fragment
for (int i = 0; i < buttonIds.length; i++) {
dialpadKey = (DialpadKeyButton) fragmentView.findViewById(buttonIds[i]);
dialpadKey.setOnPressedListener(this);
+ // Long-pressing button from two to nine will set up speed key dial.
+ if (i > 0 && i < buttonIds.length - 3) {
+ dialpadKey.setOnLongClickListener(this);
+ }
}
// Long-pressing one button will initiate Voicemail.
@@ -593,6 +599,14 @@ public class DialpadFragment extends Fragment
// Long-pressing zero button will enter '+' instead.
final DialpadKeyButton zero = (DialpadKeyButton) fragmentView.findViewById(R.id.zero);
zero.setOnLongClickListener(this);
+
+ // Long-pressing star button will enter ','(pause) instead.
+ final DialpadKeyButton star = (DialpadKeyButton) fragmentView.findViewById(R.id.star);
+ star.setOnLongClickListener(this);
+
+ // Long-pressing pound button will enter ';'(wait) instead.
+ final DialpadKeyButton pound = (DialpadKeyButton) fragmentView.findViewById(R.id.pound);
+ pound.setOnLongClickListener(this);
}
public void refreshKeypad() {
@@ -1003,6 +1017,53 @@ public class DialpadFragment extends Fragment
mDigits.setCursorVisible(true);
return false;
}
+ case R.id.star: {
+ if (mDigits.length() > 1) {
+ // Remove tentative input ('*') done by onTouch().
+ removePreviousDigitIfPossible();
+ keyPressed(KeyEvent.KEYCODE_COMMA);
+ stopTone();
+ mPressedDialpadKeys.remove(view);
+ return true;
+ }
+ return false;
+ }
+ case R.id.pound: {
+ if (mDigits.length() > 1) {
+ // Remove tentative input ('#') done by onTouch().
+ removePreviousDigitIfPossible();
+ keyPressed(KeyEvent.KEYCODE_SEMICOLON);
+ stopTone();
+ mPressedDialpadKeys.remove(view);
+ return true;
+ }
+ return false;
+ }
+ case R.id.two:
+ case R.id.three:
+ case R.id.four:
+ case R.id.five:
+ case R.id.six:
+ case R.id.seven:
+ case R.id.eight:
+ case R.id.nine: {
+ if (mDigits.length() == 1) {
+ removePreviousDigitIfPossible();
+ final boolean isAirplaneModeOn =
+ Settings.System.getInt(getActivity().getContentResolver(),
+ Settings.System.AIRPLANE_MODE_ON, 0) != 0;
+ if (isAirplaneModeOn) {
+ DialogFragment dialogFragment = ErrorDialogFragment.newInstance(
+ R.string.dialog_speed_dial_airplane_mode_message);
+ dialogFragment.show(getFragmentManager(),
+ "speed_dial_request_during_airplane_mode");
+ } else {
+ callSpeedNumber(id);
+ }
+ return true;
+ }
+ return false;
+ }
}
return false;
}
@@ -1710,4 +1771,47 @@ public class DialpadFragment extends Fragment
}
}
+ private void callSpeedNumber(int id) {
+ int number;
+
+ switch(id) {
+ case R.id.two: number = 2; break;
+ case R.id.three: number = 3; break;
+ case R.id.four: number = 4; break;
+ case R.id.five: number = 5; break;
+ case R.id.six: number = 6; break;
+ case R.id.seven: number = 7; break;
+ case R.id.eight: number = 8; break;
+ case R.id.nine: number = 9; break;
+ default: return;
+ }
+
+ String phoneNumber = SpeedDialUtils.getNumber(getActivity(), number);
+ if (phoneNumber == null) {
+ showNoSpeedNumberDialog(number);
+ } else {
+ final DialtactsActivity activity = getActivity() instanceof DialtactsActivity
+ ? (DialtactsActivity) getActivity() : null;
+ final Intent intent = CallUtil.getCallIntent(phoneNumber);
+ DialerUtils.startActivityWithErrorToast(getActivity(), intent);
+ getActivity().finish();
+ }
+ }
+
+ private void showNoSpeedNumberDialog(final int number) {
+ new AlertDialog.Builder(getActivity())
+ .setTitle(R.string.speed_dial_unassigned_dialog_title)
+ .setMessage(getString(R.string.speed_dial_unassigned_dialog_message, number))
+ .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ // go to speed dial setting screen to set speed dial number.
+ Intent intent = new Intent(getActivity(), SpeedDialListActivity.class);
+ intent.putExtra(SpeedDialListActivity.EXTRA_INITIAL_PICK_NUMBER, number);
+ startActivity(intent);
+ }
+ })
+ .setNegativeButton(R.string.no, null)
+ .show();
+ }
}
diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java
index e9c09095e..35ab02f10 100644
--- a/src/com/android/dialer/settings/DialerSettingsActivity.java
+++ b/src/com/android/dialer/settings/DialerSettingsActivity.java
@@ -96,6 +96,12 @@ public class DialerSettingsActivity extends PreferenceActivity {
accessibilitySettingsHeader.intent = accessibilitySettingsIntent;
target.add(accessibilitySettingsHeader);
}
+
+ Header speedDialHeader = new Header();
+ Intent speedDialIntent = new Intent("com.android.phone.action.SPEED_DIAL_SETTINGS");
+ speedDialHeader.titleRes = R.string.speed_dial_settings;
+ speedDialHeader.intent = speedDialIntent;
+ target.add(speedDialHeader);
}
}
diff --git a/src/com/android/dialer/widget/SearchEditTextLayout.java b/src/com/android/dialer/widget/SearchEditTextLayout.java
index 544749f33..bb3733fc0 100644
--- a/src/com/android/dialer/widget/SearchEditTextLayout.java
+++ b/src/com/android/dialer/widget/SearchEditTextLayout.java
@@ -19,6 +19,10 @@ package com.android.dialer.widget;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.speech.RecognizerIntent;
import android.util.AttributeSet;
import android.text.Editable;
import android.text.TextUtils;
@@ -32,6 +36,8 @@ import com.android.dialer.R;
import com.android.dialer.util.DialerUtils;
import com.android.phone.common.animation.AnimUtils;
+import java.util.List;
+
public class SearchEditTextLayout extends FrameLayout {
private static final float EXPAND_MARGIN_FRACTION_START = 0.8f;
private static final int ANIMATION_DURATION = 200;
@@ -268,7 +274,11 @@ public class SearchEditTextLayout extends FrameLayout {
mSearchIcon.setVisibility(collapsedViewVisibility);
mCollapsedSearchBox.setVisibility(collapsedViewVisibility);
- mVoiceSearchButtonView.setVisibility(collapsedViewVisibility);
+ if (!isExpand && canIntentBeHandled()) {
+ mVoiceSearchButtonView.setVisibility(collapsedViewVisibility);
+ } else {
+ mVoiceSearchButtonView.setVisibility(View.GONE);
+ }
mOverflowButtonView.setVisibility(collapsedViewVisibility);
mBackButtonView.setVisibility(expandedViewVisibility);
// TODO: Prevents keyboard from jumping up in landscape mode after exiting the
@@ -319,4 +329,12 @@ public class SearchEditTextLayout extends FrameLayout {
params.rightMargin = (int) (mRightMargin * fraction);
requestLayout();
}
+
+ private boolean canIntentBeHandled() {
+ final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
+ final PackageManager packageManager = getContext().getPackageManager();
+ final List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(voiceIntent,
+ PackageManager.MATCH_DEFAULT_ONLY);
+ return resolveInfo != null && resolveInfo.size() > 0;
+ }
}