summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-04-12 18:53:33 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-04-12 18:53:33 +0000
commit6b0ebb255e2d23c4f95e649a680c892d2d08bed7 (patch)
tree61fbf66c296892c26bc7aebc27497a1df1e3c6ab
parent68d51ec195f609b1138402f9b446ec301e9c5f4c (diff)
parentc3f2621c65a0da3398b6ff0dcd39dcfdf6b6bbb8 (diff)
downloadDialer-6b0ebb255e2d23c4f95e649a680c892d2d08bed7.tar.gz
Merge "Add in search support in dialer."
-rw-r--r--AndroidManifest.xml4
-rw-r--r--res/drawable/ic_search.xml29
-rw-r--r--res/menu/options_menu.xml23
-rw-r--r--res/values/strings.xml3
-rw-r--r--res/values/styles.xml22
-rw-r--r--res/xml/searchable.xml24
-rw-r--r--src/com/android/car/dialer/TelecomActivity.java30
7 files changed, 114 insertions, 21 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 45b46b54..65ff7a2d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -49,8 +49,12 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
+ <action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
+
+ <meta-data android:name="android.app.searchable"
+ android:resource="@xml/searchable" />
</activity>
<service android:name="com.android.car.dialer.telecom.embedded.InCallServiceImpl"
diff --git a/res/drawable/ic_search.xml b/res/drawable/ic_search.xml
new file mode 100644
index 00000000..6c717183
--- /dev/null
+++ b/res/drawable/ic_search.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48">
+
+ <path
+ android:fillColor="#000000"
+ android:pathData="M31 28h-1.59l-.55-.55C30.82 25.18 32 22.23 32 19c0-7.18-5.82-13-13-13S6 11.82 6
+19s5.82 13 13 13c3.23 0 6.18-1.18 8.45-3.13l.55 .55 V31l10 9.98L40.98 38 31
+28zm-12 0c-4.97 0-9-4.03-9-9s4.03-9 9-9 9 4.03 9 9-4.03 9-9 9z" />
+ <path
+ android:pathData="M0 0h48v48H0z" />
+</vector>
diff --git a/res/menu/options_menu.xml b/res/menu/options_menu.xml
new file mode 100644
index 00000000..9557c6da
--- /dev/null
+++ b/res/menu/options_menu.xml
@@ -0,0 +1,23 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ <item android:id="@+id/search"
+ android:title="@string/search_title"
+ android:icon="@drawable/ic_search"
+ app:actionViewClass="android.support.v7.widget.SearchView"
+ app:showAsAction="always|collapseActionView" />
+</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d04aa6d0..108e08a2 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -102,4 +102,7 @@
<!-- Using spaces here so that the positioning of the number is consistent. -->
<string name="star_letters"> </string>
<string name="pound_letters"> </string>
+
+ <string name="search_title">Search contacts</string>
+ <string name="search_hint">Enter the name of a contact</string>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 19c6625c..f4aaafc2 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -13,27 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- >
-
- <style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar">
- <item name="android:colorControlHighlight">@color/car_card_ripple_background_light</item>
- <item name="android:windowBackground">@null</item>
- </style>
-
- <!-- Gearhead app themes -->
- <!-- Primary colors will be used as the list overscroll glow at 0x33 opacity. This is the only
- way to set the overscroll glow color. -->
- <style name="ProjectedTheme" parent="android:Theme.Material.Light.NoActionBar">
- <item name="android:colorPrimary">@color/car_overscroll_glow</item>
- <item name="android:windowBackground">@null</item>
- </style>
-
- <style name="TelecomTheme" parent="android:Theme.Material.Light.NoActionBar">
- <item name="android:colorPrimary">@color/phone_theme</item>
- <item name="android:colorPrimaryDark">@color/phone_theme_dark</item>
- <item name="android:windowBackground">@null</item>
- </style>
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Phone -->
<style name="DialpadKeyButtonStyle">
diff --git a/res/xml/searchable.xml b/res/xml/searchable.xml
new file mode 100644
index 00000000..dfa1d55f
--- /dev/null
+++ b/res/xml/searchable.xml
@@ -0,0 +1,24 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Copyright (C) 2017 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<searchable xmlns:android="http://schemas.android.com/apk/res/android"
+ android:label="@string/phone_app_name"
+ android:hint="@string/search_hint"
+ android:queryAfterZeroResults="true"
+ android:searchMode="queryRewriteFromText"
+ android:searchSettingsDescription="@string/search_hint"
+ android:searchSuggestAuthority="com.android.contacts"
+ android:searchSuggestIntentAction="android.provider.Contacts.SEARCH_SUGGESTION_CLICKED"
+ android:searchSuggestIntentData="content://com.android.contacts/contacts/lookup" />
diff --git a/src/com/android/car/dialer/TelecomActivity.java b/src/com/android/car/dialer/TelecomActivity.java
index 5c294b9b..bd6b9215 100644
--- a/src/com/android/car/dialer/TelecomActivity.java
+++ b/src/com/android/car/dialer/TelecomActivity.java
@@ -15,14 +15,22 @@
*/
package com.android.car.dialer;
+import android.app.SearchManager;
+import android.content.Context;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
+import android.support.v7.widget.SearchView;
+import android.support.v7.widget.Toolbar.LayoutParams;
import android.telecom.Call;
import android.telephony.PhoneNumberUtils;
import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.View;
+import android.widget.EditText;
import com.android.car.app.CarDrawerActivity;
import com.android.car.app.CarDrawerAdapter;
@@ -35,6 +43,8 @@ import com.android.car.dialer.telecom.UiCallManager.CallListener;
import java.util.List;
+import static android.support.v7.widget.Toolbar.LayoutParams.MATCH_PARENT;
+
/**
* Main activity for the Dialer app. Displays different fragments depending on call and
* connectivity status:
@@ -69,6 +79,8 @@ public class TelecomActivity extends CarDrawerActivity implements
private DialerFragment mDialerFragment;
private boolean mDialerFragmentOpened;
+ private SearchView mSearchView;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -92,6 +104,24 @@ public class TelecomActivity extends CarDrawerActivity implements
}
@Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ if (vdebug()) {
+ Log.d(TAG, "onCreateOptionsMenu");
+ }
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.options_menu, menu);
+
+ SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
+ SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
+ searchView.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
+
+ searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
+ mSearchView = searchView;
+
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
protected void onDestroy() {
super.onDestroy();
if (vdebug()) {