Add smart dialling capabilities to dialer
Layout changes to dialpad fragment to make space for smart dial suggestions.
This feature does not appear in landscape mode.
SmartDialTextView automatically resizes text to fit within the bounds of the view.
SmartDialAdapter highlights certain portions of the matching name based on match
positions provided by SmartDialNameMatcher.
SmartDialLoaderTask is an AsyncTask that caches all contacts with a phone number
into memory, or matches all contact names against a provided query to return a
list of matches (maximum of 3).
SmartDialNameMatcher contains utility functions to remove accents from accented
characters and normalize a phone number. It also contains the matching logic that
determines if a contact's display name matches a numeric query.
Added some tests for SmartDialNameMatcher
Bug: 6977981
Change-Id: I43e1a70d8d0d46e02fc67fe1caaec9a1769124f5
diff --git a/res/layout/dialpad_fragment.xml b/res/layout/dialpad_fragment.xml
index 6423638..e672551 100644
--- a/res/layout/dialpad_fragment.xml
+++ b/res/layout/dialpad_fragment.xml
@@ -56,13 +56,23 @@
android:src="@drawable/ic_dial_action_delete" />
</LinearLayout>
+ <View style="@style/DialpadHorizontalSeparator"/>
+
+ <!-- Smard dial suggestion section -->
+ <GridView
+ android:id="@+id/dialpad_smartdial_list"
+ android:layout_width="match_parent"
+ android:layout_height="42sp"
+ android:columnWidth="0dp"
+ android:numColumns="3"
+ android:stretchMode="columnWidth"
+ android:gravity="center"
+ android:background="@drawable/dialpad_background"/>
+
<!-- Keypad section -->
<include layout="@layout/dialpad" />
- <View
- android:layout_width="match_parent"
- android:layout_height="@dimen/dialpad_vertical_margin"
- android:background="#66000000"/>
+ <View style="@style/DialpadHorizontalSeparator"/>
<!-- left and right paddings will be modified by the code. See DialpadFragment. -->
<FrameLayout
diff --git a/res/layout/dialpad_smartdial_item.xml b/res/layout/dialpad_smartdial_item.xml
new file mode 100644
index 0000000..eed2570
--- /dev/null
+++ b/res/layout/dialpad_smartdial_item.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<com.android.dialer.dialpad.SmartDialTextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/contact_name"
+ android:layout_width="match_parent"
+ android:layout_height="42sp"
+ android:padding="@dimen/smartdial_suggestions_padding"
+ android:textColor="#39caff"
+ android:textSize="16sp"
+ android:singleLine="true"
+ android:ellipsize="none"
+ android:gravity="center"
+ />
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 9f3e3a2..2828725 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -18,5 +18,7 @@
<!-- Secondary text color in the Phone app -->
<color name="dialtacts_secondary_text_color">#888888</color>
+ <color name="smartdial_confidence_drawable_color">#39caff</color>
+ <color name="smartdial_highlighted_text_color">#ffffff</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 2c8d596..4034f73 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -50,4 +50,9 @@
<!-- Min with of fake menu buttons, which should be same as ActionBar's one -->
<dimen name="fake_menu_button_min_width">56dip</dimen>
+
+ <!-- Smart Dial -->
+ <dimen name="smartdial_suggestions_padding">4dp</dimen>
+ <dimen name="smartdial_suggestions_extra_padding">2dp</dimen>
+ <dimen name="smartdial_confidence_hint_text_size">27dp</dimen>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6f36bf1..4f64cb3 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -104,6 +104,12 @@
<item name="android:soundEffectsEnabled">false</item>
</style>
+ <style name="DialpadHorizontalSeparator">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">@dimen/dialpad_vertical_margin</item>
+ <item name="android:background">#66000000</item>
+ </style>
+
<style name="DialtactsActionBarStyle" parent="android:Widget.Holo.ActionBar">
<item name="android:backgroundSplit">@null</item>
<item name="android:backgroundStacked">@drawable/ab_stacked_opaque_dark_holo</item>