summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2013-07-30 17:21:28 -0700
committerYorke Lee <yorkelee@google.com>2013-07-30 17:26:21 -0700
commit191df33b47d28586652582499847ca3a2683cfcd (patch)
tree97735b9359750b40bce045677c90688bcc98f942
parent114ac7c63c9cc53a2c5159f5f34fb9390d28cc85 (diff)
Add voice search button in Dialer
Change-Id: Ic8dcf4a1f886d3292af438e5995474539e88b179
-rw-r--r--res/drawable-hdpi/ic_voice_search.pngbin0 -> 1271 bytes
-rw-r--r--res/drawable-mdpi/ic_voice_search.pngbin0 -> 913 bytes
-rw-r--r--res/drawable-xhdpi/ic_voice_search.pngbin0 -> 1603 bytes
-rw-r--r--res/layout/new_dialtacts_activity.xml10
-rw-r--r--res/values/strings.xml3
-rw-r--r--src/com/android/dialer/NewDialtactsActivity.java32
6 files changed, 44 insertions, 1 deletions
diff --git a/res/drawable-hdpi/ic_voice_search.png b/res/drawable-hdpi/ic_voice_search.png
new file mode 100644
index 000000000..6caf4a43d
--- /dev/null
+++ b/res/drawable-hdpi/ic_voice_search.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_voice_search.png b/res/drawable-mdpi/ic_voice_search.png
new file mode 100644
index 000000000..e290f9277
--- /dev/null
+++ b/res/drawable-mdpi/ic_voice_search.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_voice_search.png b/res/drawable-xhdpi/ic_voice_search.png
new file mode 100644
index 000000000..614758188
--- /dev/null
+++ b/res/drawable-xhdpi/ic_voice_search.png
Binary files differ
diff --git a/res/layout/new_dialtacts_activity.xml b/res/layout/new_dialtacts_activity.xml
index 7845d0fef..b9d417b36 100644
--- a/res/layout/new_dialtacts_activity.xml
+++ b/res/layout/new_dialtacts_activity.xml
@@ -49,8 +49,18 @@
android:layout_width="40dp"
android:padding="6dp"
android:src="@drawable/ic_close_dk"
+ android:clickable="true"
android:background="?android:attr/selectableItemBackground"
android:visibility="gone" />
+ <ImageView
+ android:id="@+id/voice_search_button"
+ android:layout_height="40dp"
+ android:layout_width="40dp"
+ android:padding="6dp"
+ android:src="@drawable/ic_voice_search"
+ android:clickable="true"
+ android:contentDescription="@string/description_start_voice_search"
+ android:background="?android:attr/selectableItemBackground" />
</LinearLayout>
<FrameLayout
android:layout_height="0dp"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7d4a4d9b4..3845e2dd4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -452,6 +452,9 @@
-->
<string name="description_call_log_unheard_voicemail">Unheard voicemail</string>
+ <!-- String describing the icon used to start a voice search -->
+ <string name="description_start_voice_search">Start voice search</string>
+
<!-- The string used to represent an unknown location for a phone number in the call log [CHAR LIMIT=3] -->
<string name="call_log_empty_gecode">-</string>
diff --git a/src/com/android/dialer/NewDialtactsActivity.java b/src/com/android/dialer/NewDialtactsActivity.java
index 6d2bb3fdb..05d7e0313 100644
--- a/src/com/android/dialer/NewDialtactsActivity.java
+++ b/src/com/android/dialer/NewDialtactsActivity.java
@@ -38,6 +38,7 @@ import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents.UI;
import android.provider.Settings;
+import android.speech.RecognizerIntent;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.TextUtils;
@@ -74,6 +75,8 @@ import com.android.dialer.list.OnListFragmentScrolledListener;
import com.android.dialer.list.SmartDialSearchFragment;
import com.android.internal.telephony.ITelephony;
+import java.util.ArrayList;
+
/**
* The dialer tab's title is 'phone', a more common name (see strings.xml).
*
@@ -110,6 +113,8 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie
private static final int SUBACTIVITY_ACCOUNT_FILTER = 1;
+ private static final int ACTIVITY_REQUEST_CODE_VOICE_SEARCH = 1;
+
private String mFilterText;
/**
@@ -146,6 +151,7 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie
private boolean mInSearchUi;
private View mSearchViewContainer;
private View mSearchViewCloseButton;
+ private View mVoiceSearchButton;
private EditText mSearchView;
/**
@@ -349,6 +355,10 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie
mSearchView.setText("");
}
break;
+ case R.id.voice_search_button:
+ final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
+ startActivityForResult(voiceIntent, ACTIVITY_REQUEST_CODE_VOICE_SEARCH);
+ break;
default: {
Log.wtf(TAG, "Unexpected onClick event from " + view);
break;
@@ -356,6 +366,25 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie
}
}
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) {
+ if (resultCode == RESULT_OK) {
+ final ArrayList<String> matches = data.getStringArrayListExtra(
+ RecognizerIntent.EXTRA_RESULTS);
+ if (matches.size() > 0) {
+ final String match = matches.get(0);
+ mSearchView.setText(match);
+ } else {
+ Log.e(TAG, "Voice search - nothing heard");
+ }
+ } else {
+ Log.e(TAG, "Voice search failed");
+ }
+ }
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
private void showDialpadFragment(boolean animate) {
final FragmentTransaction ft = getFragmentManager().beginTransaction();
if (animate) {
@@ -377,8 +406,9 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie
private void prepareSearchView() {
mSearchViewContainer = findViewById(R.id.search_view_container);
mSearchViewCloseButton = findViewById(R.id.search_close_button);
- mSearchViewCloseButton.setClickable(true);
mSearchViewCloseButton.setOnClickListener(this);
+ mVoiceSearchButton = findViewById(R.id.voice_search_button);
+ mVoiceSearchButton.setOnClickListener(this);
mSearchView = (EditText) findViewById(R.id.search_view);
mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
mSearchView.setHint(getString(R.string.dialer_hint_find_contact));