diff options
| author | Danesh M <daneshm90@gmail.com> | 2011-12-18 13:08:27 -0500 |
|---|---|---|
| committer | Danesh M <daneshm90@gmail.com> | 2011-12-18 13:17:47 -0500 |
| commit | 0104281a40eb08c9065425013513906cee5a07d2 (patch) | |
| tree | b33ad9227641e3e77602b0d331c5bfe87daa2cca | |
| parent | 0e9e4c9b5ef45da671417c943adb1c96dad344d1 (diff) | |
| download | packages_apps_Contacts-0104281a40eb08c9065425013513906cee5a07d2.tar.gz packages_apps_Contacts-0104281a40eb08c9065425013513906cee5a07d2.tar.bz2 packages_apps_Contacts-0104281a40eb08c9065425013513906cee5a07d2.zip | |
Dialpad : T9 Dialer
This adds t9 functionality to the dialer.
Patchset 2 : Fix layout issue in landscape
Change-Id: I141dc23e4a5833aec5ae23eb7426c5f0da60800d
| -rw-r--r-- | res/drawable/expander_close.9.png | bin | 0 -> 753 bytes | |||
| -rw-r--r-- | res/drawable/expander_close_pressed.9.png | bin | 0 -> 3578 bytes | |||
| -rw-r--r-- | res/drawable/expander_open.9.png | bin | 0 -> 821 bytes | |||
| -rw-r--r-- | res/drawable/expander_open_pressed.9.png | bin | 0 -> 3534 bytes | |||
| -rw-r--r-- | res/drawable/t9result_state.xml | 4 | ||||
| -rw-r--r-- | res/drawable/t9toggle_state.xml | 6 | ||||
| -rw-r--r-- | res/layout-finger/twelve_key_dialer.xml | 60 | ||||
| -rw-r--r-- | res/layout-land-finger/twelve_key_dialer.xml | 83 | ||||
| -rw-r--r-- | res/layout-land-finger/voicemail_dial_delete.xml | 73 | ||||
| -rw-r--r-- | res/layout-long-finger/dialpad.xml | 3 | ||||
| -rw-r--r-- | res/layout-long-finger/twelve_key_dialer.xml | 58 | ||||
| -rw-r--r-- | res/layout-long-land-finger/twelve_key_dialer.xml | 83 | ||||
| -rw-r--r-- | res/layout-long-land-finger/voicemail_dial_delete.xml | 51 | ||||
| -rw-r--r-- | res/layout/row.xml | 29 | ||||
| -rw-r--r-- | res/values/arrays.xml | 29 | ||||
| -rw-r--r-- | res/values/strings.xml | 20 | ||||
| -rw-r--r-- | res/xml/contacts_preferences.xml | 21 | ||||
| -rw-r--r-- | src/com/android/contacts/T9Search.java | 331 | ||||
| -rw-r--r-- | src/com/android/contacts/TwelveKeyDialer.java | 222 |
19 files changed, 956 insertions, 117 deletions
diff --git a/res/drawable/expander_close.9.png b/res/drawable/expander_close.9.png Binary files differnew file mode 100644 index 000000000..f56ef3118 --- /dev/null +++ b/res/drawable/expander_close.9.png diff --git a/res/drawable/expander_close_pressed.9.png b/res/drawable/expander_close_pressed.9.png Binary files differnew file mode 100644 index 000000000..8137bfb79 --- /dev/null +++ b/res/drawable/expander_close_pressed.9.png diff --git a/res/drawable/expander_open.9.png b/res/drawable/expander_open.9.png Binary files differnew file mode 100644 index 000000000..d2e8ae851 --- /dev/null +++ b/res/drawable/expander_open.9.png diff --git a/res/drawable/expander_open_pressed.9.png b/res/drawable/expander_open_pressed.9.png Binary files differnew file mode 100644 index 000000000..23f570173 --- /dev/null +++ b/res/drawable/expander_open_pressed.9.png diff --git a/res/drawable/t9result_state.xml b/res/drawable/t9result_state.xml new file mode 100644 index 000000000..a31764e4c --- /dev/null +++ b/res/drawable/t9result_state.xml @@ -0,0 +1,4 @@ +<selector xmlns:android="http://schemas.android.com/apk/res/android"> +<item android:state_pressed="true" + android:drawable="@drawable/btn_dial_textfield_pressed" /> +</selector> diff --git a/res/drawable/t9toggle_state.xml b/res/drawable/t9toggle_state.xml new file mode 100644 index 000000000..2c9157c1d --- /dev/null +++ b/res/drawable/t9toggle_state.xml @@ -0,0 +1,6 @@ +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_checked="true" android:state_pressed="true" android:drawable="@drawable/expander_close_pressed" /> + <item android:state_checked="false" android:state_pressed="true" android:drawable="@drawable/expander_open_pressed" /> + <item android:state_checked="true" android:drawable="@drawable/expander_close" /> + <item android:drawable="@drawable/expander_open" /> +</selector> diff --git a/res/layout-finger/twelve_key_dialer.xml b/res/layout-finger/twelve_key_dialer.xml index 18eb67dae..2db9c0735 100644 --- a/res/layout-finger/twelve_key_dialer.xml +++ b/res/layout-finger/twelve_key_dialer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2006 The Android Open Source Project +<!-- Copyright (C) 2009 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. @@ -29,7 +29,7 @@ <!-- TODO: Use a textAppearance to control the display of the number --> <EditText android:id="@+id/digits" android:layout_width="match_parent" - android:layout_height="67dip" + android:layout_height="0dp" android:gravity="center" android:maxLines="1" android:scrollHorizontally="true" @@ -40,12 +40,62 @@ android:focusableInTouchMode="true" android:editable="true" android:cursorVisible="false" - android:layout_weight="0" + android:layout_weight="1" android:contentDescription="@string/description_digits_edittext" /> - <!-- Keypad section --> - <include layout="@layout/dialpad" /> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="0px" + android:id="@+id/t9topbar" + android:layout_gravity="center" + android:gravity="center" + android:layout_weight="1"> + <QuickContactBadge + android:id="@+id/t9badge" + android:layout_width="40dp" + android:layout_marginLeft="5dp" + android:layout_marginRight="5dp" + android:layout_height="40dp" + android:visibility="invisible" + android:layout_centerVertical="true" + android:focusable="true" /> + <TextView + android:id="@+id/t9result" + android:layout_weight="1" + android:gravity="center" + android:layout_width="0dp" + android:background="@drawable/t9result_state" + android:clickable="true" + android:layout_height="match_parent" /> + <ToggleButton + android:id="@+id/t9toggle" + android:layout_width="48dp" + android:layout_height="48dp" + android:visibility="invisible" + android:scaleType="centerInside" + android:layout_marginRight="5dp" + android:layout_marginLeft="5dp" + android:textOn="" + android:textOff="" + android:background="@drawable/t9toggle_state" + android:layout_gravity="center"/> + </LinearLayout> + + <ViewSwitcher + android:id="@+id/t9flipper" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="5"> + <!-- Keypad section --> + <include layout="@layout/dialpad" /> + <ListView + android:layout_width="match_parent" + android:id="@+id/t9list" + android:visibility="gone" + android:scrollingCache="true" + android:layout_height="match_parent" /> + </ViewSwitcher> <!-- Horizontal row of buttons (Voicemail + DialButton + Delete.) --> <include layout="@layout/voicemail_dial_delete" /> diff --git a/res/layout-land-finger/twelve_key_dialer.xml b/res/layout-land-finger/twelve_key_dialer.xml index 4d14cd586..a7a569f19 100644 --- a/res/layout-land-finger/twelve_key_dialer.xml +++ b/res/layout-land-finger/twelve_key_dialer.xml @@ -27,24 +27,75 @@ android:gravity="center" android:orientation="vertical" android:layout_weight="1"> - <!-- Text field above the keypad where the digits are displayed. It's type - is set to PHONE (to put the keyboard in the right config) in the java code. --> - <!-- TODO: Use a textAppearance to control the display of the number --> - <EditText - android:id="@+id/digits" + <LinearLayout android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:layout_marginBottom="1dp" - android:layout_marginTop="1dp" + android:layout_height="0px" + android:id="@+id/t9topbar" + android:layout_gravity="center" android:gravity="center" - android:maxLines="1" - android:scrollHorizontally="true" - android:textSize="28sp" - android:freezesText="true" - android:background="@drawable/btn_dial_textfield" - android:textColor="@color/dialer_button_text" - android:hint="@string/dialerKeyboardHintText" /> + android:layout_weight="0.3"> + <QuickContactBadge + android:id="@+id/t9badge" + android:layout_width="40dp" + android:layout_marginLeft="5dp" + android:layout_marginRight="5dp" + android:layout_height="40dp" + android:visibility="invisible" + android:layout_centerVertical="true" + android:focusable="true" /> + <TextView + android:id="@+id/t9result" + android:layout_weight="1" + android:gravity="center" + android:visibility="invisible" + android:layout_width="0dp" + android:clickable="true" + android:background="@drawable/t9result_state" + android:layout_height="match_parent" /> + <ToggleButton + android:id="@+id/t9toggle" + android:layout_width="48dp" + android:layout_height="48dp" + android:visibility="invisible" + android:scaleType="centerInside" + android:layout_marginRight="5dp" + android:layout_marginLeft="5dp" + android:textOn="" + android:textOff="" + android:background="@drawable/t9toggle_state" + android:layout_gravity="center" /> + </LinearLayout> + <ViewSwitcher + android:id="@+id/t9flipper" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="0.7"> + <!-- Text field above the keypad where the digits are displayed. It's + type is set to PHONE (to put the keyboard in the right config) in the java + code. --> + <!-- TODO: Use a textAppearance to control the display of the number --> + <EditText + android:id="@+id/digits" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:layout_marginBottom="1dp" + android:layout_marginTop="1dp" + android:gravity="center" + android:maxLines="1" + android:scrollHorizontally="true" + android:textSize="28sp" + android:freezesText="true" + android:background="@drawable/btn_dial_textfield" + android:textColor="@color/dialer_button_text" + android:hint="@string/dialerKeyboardHintText" /> + <ListView + android:layout_width="match_parent" + android:id="@+id/t9list" + android:visibility="gone" + android:scrollingCache="true" + android:layout_height="match_parent" /> + </ViewSwitcher> <!-- Horizontal row of buttons (Voicemail + DialButton + Delete.) --> <include layout="@layout/voicemail_dial_delete" /> diff --git a/res/layout-land-finger/voicemail_dial_delete.xml b/res/layout-land-finger/voicemail_dial_delete.xml index 877424e0e..1d2069f06 100644 --- a/res/layout-land-finger/voicemail_dial_delete.xml +++ b/res/layout-land-finger/voicemail_dial_delete.xml @@ -14,45 +14,36 @@ limitations under the License. --> <LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/voicemailAndDialAndDelete" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> - <LinearLayout - android:layout_width="fill_parent" - android:layout_height="wrap_content"> - <!-- Onscreen "Voicemail" button. The width is 75 (from the mocks) + 12 - of padding from the 9patch, total is 87. --> - <ImageButton - android:id="@+id/voicemailButton" - android:layout_width="0dp" - android:layout_weight="1" - android:layout_height="wrap_content" - android:state_enabled="false" - android:background="@drawable/btn_dial_voicemail" - android:contentDescription="@string/description_voicemail_button" - android:src="@drawable/ic_dial_action_voice_mail" /> - <!-- Onscreen "Dial" button, used on all platforms by default. Its usage - can be disabled using resources (see config.xml.) --> - <!-- Onscreen "Backspace/Delete" button The width is 75 (from the mocks) - + 12 of padding from the 9patch, total is 87. --> - <ImageButton - android:id="@+id/deleteButton" - android:layout_width="0dp" - android:layout_weight="1" - android:layout_height="wrap_content" - android:state_enabled="false" - android:background="@drawable/btn_dial_delete" - android:contentDescription="@string/description_delete_button" - android:src="@drawable/ic_dial_action_delete" /> - </LinearLayout> - <ImageButton - android:id="@+id/dialButton" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:state_enabled="false" - android:background="@drawable/btn_dial_action" - android:contentDescription="@string/description_dial_button" - android:src="@drawable/ic_dial_action_call" /> + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/voicemailAndDialAndDelete" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + <ImageButton + android:id="@+id/voicemailButton" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:state_enabled="false" + android:background="@drawable/btn_dial_voicemail" + android:contentDescription="@string/description_voicemail_button" + android:src="@drawable/ic_dial_action_voice_mail" /> + <ImageButton + android:id="@+id/dialButton" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:state_enabled="false" + android:background="@drawable/btn_dial_action" + android:contentDescription="@string/description_dial_button" + android:src="@drawable/ic_dial_action_call" /> + <ImageButton + android:id="@+id/deleteButton" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:state_enabled="false" + android:background="@drawable/btn_dial_delete" + android:contentDescription="@string/description_delete_button" + android:src="@drawable/ic_dial_action_delete" /> </LinearLayout>
\ No newline at end of file diff --git a/res/layout-long-finger/dialpad.xml b/res/layout-long-finger/dialpad.xml index f21afd474..1c9d54707 100644 --- a/res/layout-long-finger/dialpad.xml +++ b/res/layout-long-finger/dialpad.xml @@ -17,8 +17,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/dialpad" android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="5" + android:layout_height="match_parent" android:gravity="center_vertical"> <TableRow android:layout_weight="1" android:gravity="center"> <ImageButton diff --git a/res/layout-long-finger/twelve_key_dialer.xml b/res/layout-long-finger/twelve_key_dialer.xml index bd90df4c0..9f07301a1 100644 --- a/res/layout-long-finger/twelve_key_dialer.xml +++ b/res/layout-long-finger/twelve_key_dialer.xml @@ -28,7 +28,7 @@ <!-- TODO: Use a textAppearance to control the display of the number --> <EditText android:id="@+id/digits" android:layout_width="match_parent" - android:layout_height="74dip" + android:layout_height="0dp" android:gravity="center" android:maxLines="1" android:scrollHorizontally="true" @@ -39,11 +39,61 @@ android:focusableInTouchMode="true" android:editable="true" android:cursorVisible="false" - android:layout_weight="0" + android:layout_weight="1" /> - <!-- Keypad section --> - <include layout="@layout/dialpad" /> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="0px" + android:id="@+id/t9topbar" + android:layout_gravity="center" + android:gravity="center" + android:layout_weight="1"> + <QuickContactBadge + android:id="@+id/t9badge" + android:layout_width="40dp" + android:layout_marginLeft="5dp" + android:layout_marginRight="5dp" + android:layout_height="40dp" + android:visibility="invisible" + android:layout_centerVertical="true" + android:focusable="true" /> + <TextView + android:id="@+id/t9result" + android:layout_weight="1" + android:gravity="center" + android:layout_width="0dp" + android:background="@drawable/t9result_state" + android:clickable="true" + android:layout_height="match_parent" /> + <ToggleButton + android:id="@+id/t9toggle" + android:layout_width="48dp" + android:layout_height="48dp" + android:visibility="invisible" + android:scaleType="centerInside" + android:layout_marginRight="5dp" + android:layout_marginLeft="5dp" + android:textOn="" + android:textOff="" + android:background="@drawable/t9toggle_state" + android:layout_gravity="center"/> + </LinearLayout> + + <ViewSwitcher + android:id="@+id/t9flipper" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="5"> + <!-- Keypad section --> + <include layout="@layout/dialpad" /> + <ListView + android:layout_width="match_parent" + android:id="@+id/t9list" + android:visibility="gone" + android:scrollingCache="true" + android:layout_height="match_parent" /> + </ViewSwitcher> <!-- Horizontal row of buttons (Voicemail + DialButton + Delete.) --> <include layout="@layout/voicemail_dial_delete" /> diff --git a/res/layout-long-land-finger/twelve_key_dialer.xml b/res/layout-long-land-finger/twelve_key_dialer.xml index 4c51ec12c..e5417e91b 100644 --- a/res/layout-long-land-finger/twelve_key_dialer.xml +++ b/res/layout-long-land-finger/twelve_key_dialer.xml @@ -27,24 +27,75 @@ android:gravity="center" android:orientation="vertical" android:layout_weight="1"> - <!-- Text field above the keypad where the digits are displayed. It's type - is set to PHONE (to put the keyboard in the right config) in the java code. --> - <!-- TODO: Use a textAppearance to control the display of the number --> - <EditText - android:id="@+id/digits" + <LinearLayout android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:layout_marginBottom="1dp" - android:layout_marginTop="1dp" + android:layout_height="0px" + android:id="@+id/t9topbar" + android:layout_gravity="center" android:gravity="center" - android:maxLines="1" - android:scrollHorizontally="true" - android:textSize="34sp" - android:freezesText="true" - android:background="@drawable/btn_dial_textfield" - android:textColor="@color/dialer_button_text" - android:hint="@string/dialerKeyboardHintText" /> + android:layout_weight="0.3"> + <QuickContactBadge + android:id="@+id/t9badge" + android:layout_width="40dp" + android:layout_marginLeft="5dp" + android:layout_marginRight="5dp" + android:layout_height="40dp" + android:visibility="invisible" + android:layout_centerVertical="true" + android:focusable="true" /> + <TextView + android:id="@+id/t9result" + android:layout_weight="1" + android:gravity="center" + android:visibility="invisible" + android:layout_width="0dp" + android:clickable="true" + android:background="@drawable/t9result_state" + android:layout_height="match_parent" /> + <ToggleButton + android:id="@+id/t9toggle" + android:layout_width="48dp" + android:layout_height="48dp" + android:visibility="invisible" + android:scaleType="centerInside" + android:layout_marginRight="5dp" + android:layout_marginLeft="5dp" + android:textOn="" + android:textOff="" + android:background="@drawable/t9toggle_state" + android:layout_gravity="center" /> + </LinearLayout> + <ViewSwitcher + android:id="@+id/t9flipper" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="0.7"> + <!-- Text field above the keypad where the digits are displayed. It's + type is set to PHONE (to put the keyboard in the right config) in the java + code. --> + <!-- TODO: Use a textAppearance to control the display of the number --> + <EditText + android:id="@+id/digits" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:layout_marginBottom="1dp" + android:layout_marginTop="1dp" + android:gravity="center" + android:maxLines="1" + android:scrollHorizontally="true" + android:textSize="34sp" + android:freezesText="true" + android:background="@drawable/btn_dial_textfield" + android:textColor="@color/dialer_button_text" + android:hint="@string/dialerKeyboardHintText" /> + <ListView + android:layout_width="match_parent" + android:id="@+id/t9list" + android:visibility="gone" + android:scrollingCache="true" + android:layout_height="match_parent" /> + </ViewSwitcher> <!-- Horizontal row of buttons (Voicemail + DialButton + Delete.) --> <include layout="@layout/voicemail_dial_delete" /> diff --git a/res/layout-long-land-finger/voicemail_dial_delete.xml b/res/layout-long-land-finger/voicemail_dial_delete.xml index 877424e0e..64ef7c4b5 100644 --- a/res/layout-long-land-finger/voicemail_dial_delete.xml +++ b/res/layout-long-land-finger/voicemail_dial_delete.xml @@ -18,41 +18,32 @@ android:id="@+id/voicemailAndDialAndDelete" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="vertical"> - <LinearLayout - android:layout_width="fill_parent" - android:layout_height="wrap_content"> - <!-- Onscreen "Voicemail" button. The width is 75 (from the mocks) + 12 - of padding from the 9patch, total is 87. --> - <ImageButton - android:id="@+id/voicemailButton" - android:layout_width="0dp" - android:layout_weight="1" - android:layout_height="wrap_content" - android:state_enabled="false" - android:background="@drawable/btn_dial_voicemail" - android:contentDescription="@string/description_voicemail_button" - android:src="@drawable/ic_dial_action_voice_mail" /> - <!-- Onscreen "Dial" button, used on all platforms by default. Its usage - can be disabled using resources (see config.xml.) --> - <!-- Onscreen "Backspace/Delete" button The width is 75 (from the mocks) - + 12 of padding from the 9patch, total is 87. --> - <ImageButton - android:id="@+id/deleteButton" - android:layout_width="0dp" - android:layout_weight="1" - android:layout_height="wrap_content" - android:state_enabled="false" - android:background="@drawable/btn_dial_delete" - android:contentDescription="@string/description_delete_button" - android:src="@drawable/ic_dial_action_delete" /> - </LinearLayout> + android:orientation="horizontal"> + <ImageButton + android:id="@+id/voicemailButton" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:state_enabled="false" + android:background="@drawable/btn_dial_voicemail" + android:contentDescription="@string/description_voicemail_button" + android:src="@drawable/ic_dial_action_voice_mail" /> <ImageButton android:id="@+id/dialButton" - android:layout_width="match_parent" + android:layout_width="0dp" + android:layout_weight="1" android:layout_height="wrap_content" android:state_enabled="false" android:background="@drawable/btn_dial_action" android:contentDescription="@string/description_dial_button" android:src="@drawable/ic_dial_action_call" /> + <ImageButton + android:id="@+id/deleteButton" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:state_enabled="false" + android:background="@drawable/btn_dial_delete" + android:contentDescription="@string/description_delete_button" + android:src="@drawable/ic_dial_action_delete" /> </LinearLayout>
\ No newline at end of file diff --git a/res/layout/row.xml b/res/layout/row.xml new file mode 100644 index 000000000..418a3de04 --- /dev/null +++ b/res/layout/row.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="wrap_content"> + <QuickContactBadge + android:id="@+id/rowBadge" + android:layout_width="40dp" + android:layout_height="40dp" + android:layout_marginLeft="5dp" + android:layout_marginRight="5dp" + android:focusable="false" /> + <LinearLayout + android:layout_weight="1" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:orientation="vertical"> + <TextView + android:id="@+id/rowName" + android:layout_weight="0.5" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + <TextView + android:id="@+id/rowNumber" + android:layout_weight="0.5" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + </LinearLayout> +</LinearLayout>
\ No newline at end of file diff --git a/res/values/arrays.xml b/res/values/arrays.xml index f1f1c63d9..438b6a4d9 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -77,4 +77,33 @@ <item>@string/default_phone_tab_favorites</item> </string-array> + <string-array name="t9_sort_entries" + translatable="false"> + <item>@string/t9_sort_name</item> + <item>@string/t9_sort_number</item> + </string-array> + + <string-array name="t9_sort_values" + translatable="false"> + <item>1</item> + <item>2</item> + </string-array> + + <string-array name="t9_map" + translatable="false"> + <item>0</item> + <item>1</item> + <item>@string/t9_map_row_2</item> + <item>@string/t9_map_row_3</item> + <item>@string/t9_map_row_4</item> + <item>@string/t9_map_row_5</item> + <item>@string/t9_map_row_6</item> + <item>@string/t9_map_row_7</item> + <item>@string/t9_map_row_8</item> + <item>@string/t9_map_row_9</item> + <item>*</item> + <item>#</item> + <item>+</item> + </string-array> + </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index c3a8deaa8..6d53598d3 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1296,5 +1296,23 @@ <string name="summary_about_version">1.2</string> <string name="title_about_credits">Credits</string> <string name="summary_about_credits">Wysie, ChainsDD, geesun, niuchl, rac2030, sileht and the rest of XDA! :)</string> - + + <string name="t9_default_sort">2</string> + <string name="t9_sort_title">T9 Sorting mode</string> + <string name="t9_sort_summary">Choose how to filter T9 results</string> + <string name="t9_sort_name">Name matches first</string> + <string name="t9_sort_number">Number matches first</string> + <string name="t9_state_title">Enable T9 dialer</string> + <string name="t9_state_summary">Enable T9 searching in dialer</string> + <string name="t9_dial_click_title">Dial selected contact</string> + <string name="t9_dial_click_summary">Dial the selected contact for T9</string> + <string name="t9_map_row_2">2abcàáâäåɑæçǽćčá</string> + <string name="t9_map_row_3">3deféèêë</string> + <string name="t9_map_row_4">4ghiíìïîǵ</string> + <string name="t9_map_row_5">5jklḱḱĺ</string> + <string name="t9_map_row_6">6mnoòóöôøñŋǿḿńő</string> + <string name="t9_map_row_7">7pqrsßɾṕŕśřš</string> + <string name="t9_map_row_8">8tuvúùüûű</string> + <string name="t9_map_row_9">9wxyzýẃź</string> + </resources> diff --git a/res/xml/contacts_preferences.xml b/res/xml/contacts_preferences.xml index 5b5ab8b9f..dcb658579 100644 --- a/res/xml/contacts_preferences.xml +++ b/res/xml/contacts_preferences.xml @@ -73,6 +73,27 @@ android:title="@string/title_digits_color_unselected" android:defaultValue="-1" /> </PreferenceScreen> + <CheckBoxPreference + android:key="t9_state" + android:title="@string/t9_state_title" + android:persistent="true" + android:defaultValue="true" + android:summary="@string/t9_state_summary" /> + <CheckBoxPreference + android:key="t9_dial_onclick" + android:title="@string/t9_dial_click_title" + android:persistent="true" + android:dependency="t9_state" + android:summary="@string/t9_dial_click_summary" /> + <ListPreference + android:key="t9_sort" + android:defaultValue="@string/t9_default_sort" + android:title="@string/t9_sort_title" + android:dependency="t9_state" + android:summary="@string/t9_sort_summary" + android:entries="@array/t9_sort_entries" + android:entryValues="@array/t9_sort_values" + android:dialogTitle="@string/t9_sort_title" /> </PreferenceCategory> <PreferenceCategory android:title="@string/recentCallsIconLabel"> <CheckBoxPreference diff --git a/src/com/android/contacts/T9Search.java b/src/com/android/contacts/T9Search.java new file mode 100644 index 000000000..5cba2888a --- /dev/null +++ b/src/com/android/contacts/T9Search.java @@ -0,0 +1,331 @@ +/* + * Copyright (C) 2011 The CyanogenMod 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. + */ + +package com.android.contacts; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedHashSet; +import java.util.Set; + +import android.content.ContentUris; +import android.content.Context; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.net.Uri; +import android.preference.PreferenceManager; +import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.provider.ContactsContract.Contacts; +import android.telephony.PhoneNumberUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.QuickContactBadge; +import android.widget.TextView; + +/** + * @author shade, Danesh, pawitp + */ +class T9Search { + + // List sort modes + private static final int NAME_FIRST = 1; + private static final int NUMBER_FIRST = 2; + + // Phone number queries + private static final String[] PHONE_PROJECTION = new String[] {Phone.NUMBER, Phone.CONTACT_ID, Phone.IS_SUPER_PRIMARY, Phone.TYPE, Phone.LABEL}; + private static final String PHONE_ID_SELECTION = Contacts.Data.MIMETYPE + " = ? "; + private static final String[] PHONE_ID_SELECTION_ARGS = new String[] {Phone.CONTENT_ITEM_TYPE}; + private static final String PHONE_SORT = Phone.CONTACT_ID + " ASC"; + private static final String[] CONTACT_PROJECTION = new String[] {Contacts._ID, Contacts.DISPLAY_NAME, Contacts.TIMES_CONTACTED}; + private static final String CONTACT_QUERY = Contacts.HAS_PHONE_NUMBER + " > 0"; + private static final String CONTACT_SORT = Contacts._ID + " ASC"; + + // Local variables + private Context mContext; + private int mSortMode; + private ArrayList<ContactItem> mNameResults = new ArrayList<ContactItem>(); + private ArrayList<ContactItem> mNumberResults = new ArrayList<ContactItem>(); + private Set<ContactItem> mAllResults = new LinkedHashSet<ContactItem>(); + private ArrayList<ContactItem> mContacts = new ArrayList<ContactItem>(); + private String mPrevInput; + private static char[][] sT9Map; + + public T9Search(Context context) { + mContext = context; + getAll(); + } + + private void getAll() { + if (sT9Map == null) + initT9Map(); + + Cursor contact = mContext.getContentResolver().query(Contacts.CONTENT_URI, CONTACT_PROJECTION, CONTACT_QUERY, null, CONTACT_SORT); + Cursor phone = mContext.getContentResolver().query(Phone.CONTENT_URI, PHONE_PROJECTION, PHONE_ID_SELECTION, PHONE_ID_SELECTION_ARGS, PHONE_SORT); + phone.moveToFirst(); + + while (contact.moveToNext()) { + long contactId = contact.getLong(0); + if (phone.isAfterLast()) { + break; + } + while (phone.getLong(1) == contactId) { + String num = phone.getString(0); + ContactItem contactInfo = new ContactItem(); + contactInfo.id = contactId; + contactInfo.name = contact.getString(1); + contactInfo.number = PhoneNumberUtils.formatNumber(num); + contactInfo.normalNumber = removeNonDigits(num); + contactInfo.normalName = nameToNumber(contact.getString(1)); + contactInfo.timesContacted = contact.getInt(2); + contactInfo.isSuperPrimary = phone.getInt(2) > 0; + contactInfo.groupType = Phone.getTypeLabel(mContext.getResources(), phone.getInt(3), phone.getString(4)); + Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId); + InputStream photoStream = Contacts.openContactPhotoInputStream(mContext.getContentResolver(), contactUri); + if (photoStream != null) { + contactInfo.photo = BitmapFactory.decodeStream(photoStream); + try { + photoStream.close(); + } catch (IOException e) { + } + } + mContacts.add(contactInfo); + if (!phone.moveToNext()) { + break; + } + } + } + contact.close(); + phone.close(); + } + + public static class T9SearchResult { + + private final ArrayList<ContactItem> mResults; + private ContactItem mTopContact = new ContactItem(); + + public T9SearchResult (final ArrayList<ContactItem> results, final Context mContext) { + mTopContact = results.get(0); + mResults = results; + mResults.remove(0); + } + + public int getNumResults() { + return mResults.size() + 1; + } + + public ContactItem getTopContact() { + return mTopContact; + } + + public ArrayList<ContactItem> getResults() { + return mResults; + } + } + + public static class ContactItem { + Bitmap photo; + String name; + String number; + String normalNumber; + String normalName; + int timesContacted; + int nameMatchId; + int numberMatchId; + CharSequence groupType; + long id; + boolean isSuperPrimary; + } + + public T9SearchResult search(String number) { + mNameResults.clear(); + mNumberResults.clear(); + number = removeNonDigits(number); + int pos = 0; + mSortMode = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(mContext).getString("t9_sort", "1")); + boolean newQuery = mPrevInput == null || number.length() <= mPrevInput.length(); + // Go through each contact + for (ContactItem item : (newQuery ? mContacts : mAllResults)) { + item.numberMatchId = -1; + item.nameMatchId = -1; + pos = item.normalNumber.indexOf(number); + if (pos != -1) { + item.numberMatchId = pos; + mNumberResults.add(item); + } + pos = item.normalName.indexOf(number); + if (pos != -1) { + int last_space = item.normalName.lastIndexOf("0", pos); + if (last_space == -1) { + last_space = 0; + } + item.nameMatchId = pos - last_space; + mNameResults.add(item); + } + } + mAllResults.clear(); + mPrevInput = number; + Collections.sort(mNumberResults, new NumberComparator()); + Collections.sort(mNameResults, new NameComparator()); + if (mNameResults.size() > 0 || mNumberResults.size() > 0) { + switch (mSortMode) { + case NAME_FIRST: + mAllResults.addAll(mNameResults); + mAllResults.addAll(mNumberResults); + break; + case NUMBER_FIRST: + mAllResults.addAll(mNumberResults); + mAllResults.addAll(mNameResults); + } + return new T9SearchResult(new ArrayList<ContactItem>(mAllResults), mContext); + } + return null; + } + + public static class NameComparator implements Comparator<ContactItem> { + @Override + public int compare(ContactItem lhs, ContactItem rhs) { + int ret = compareInt(lhs.nameMatchId, rhs.nameMatchId); + if (ret == 0) ret = compareInt(rhs.timesContacted, lhs.timesContacted); + if (ret == 0) ret = compareBool(rhs.isSuperPrimary, lhs.isSuperPrimary); + return ret; + } + } + + public static class NumberComparator implements Comparator<ContactItem> { + @Override + public int compare(ContactItem lhs, ContactItem rhs) { + int ret = compareInt(lhs.numberMatchId, rhs.numberMatchId); + if (ret == 0) ret = compareInt(rhs.timesContacted, lhs.timesContacted); + if (ret == 0) ret = compareBool(rhs.isSuperPrimary, lhs.isSuperPrimary); + return ret; + } + } + + public static int compareInt (int lhs, int rhs) { + return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1); + } + + public static int compareBool (boolean lhs, boolean rhs) { + return lhs == rhs ? 0 : lhs ? 1 : -1; + } + + private void initT9Map() { + String[] t9Array = mContext.getResources().getStringArray(R.array.t9_map); + sT9Map = new char[t9Array.length][]; + int rc = 0; + for (String item : t9Array) { + int cc = 0; + sT9Map[rc] = new char[item.length()]; + for (char ch : item.toCharArray()) { + sT9Map[rc][cc] = ch; + cc++; + } + rc++; + } + } + + private static String nameToNumber(String name) { + StringBuilder sb = new StringBuilder(); + int len = name.length(); + for (int i = 0; i < len; i++) { + boolean matched = false; + char ch = Character.toLowerCase(name.charAt(i)); + for (char[] row : sT9Map) { + for (char a : row) { + if (ch == a) { + matched = true; + sb.append(row[0]); + break; + } + } + if (matched) { + break; + } + } + if (!matched) { + sb.append(sT9Map[0][0]); + } + } + return sb.toString(); + } + + public static String removeNonDigits(String number) { + int len = number.length(); + StringBuilder sb = new StringBuilder(len); + for (int i = 0; i < len; i++) { + char ch = number.charAt(i); + if ((ch >= '0' && ch <= '9') || ch == '*' || ch == '#' || ch == '+') { + sb.append(ch); + } + } + return sb.toString(); + } + + protected static class T9Adapter extends ArrayAdapter<ContactItem> { + + private ArrayList<ContactItem> mItems; + private LayoutInflater mMenuInflate; + //private ContactPhotoManager mPhotoLoader; + + public T9Adapter(Context context, int textViewResourceId, ArrayList<ContactItem> items, LayoutInflater menuInflate) { + super(context, textViewResourceId, items); + mItems = items; + mMenuInflate = menuInflate; + //mPhotoLoader = photoLoader; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + ViewHolder holder; + + if (convertView == null) { + convertView = mMenuInflate.inflate(R.layout.row, null); + holder = new ViewHolder(); + holder.name = (TextView) convertView.findViewById(R.id.rowName); + holder.number = (TextView) convertView.findViewById(R.id.rowNumber); + holder.icon = (QuickContactBadge) convertView.findViewById(R.id.rowBadge); + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + + ContactItem o = mItems.get(position); + holder.name.setText(o.name); + holder.number.setText(o.number + " (" + o.groupType + ")"); + if (o.photo != null) + holder.icon.setImageBitmap(o.photo); + else + holder.icon.setImageResource(R.drawable.ic_contact_list_picture); + + holder.icon.assignContactFromPhone(o.number, true); + return convertView; + } + + static class ViewHolder { + TextView name; + TextView number; + QuickContactBadge icon; + } + + } + +}
\ No newline at end of file diff --git a/src/com/android/contacts/TwelveKeyDialer.java b/src/com/android/contacts/TwelveKeyDialer.java index 250b2651d..9147f0ac4 100644 --- a/src/com/android/contacts/TwelveKeyDialer.java +++ b/src/com/android/contacts/TwelveKeyDialer.java @@ -16,6 +16,9 @@ package com.android.contacts; +import com.android.contacts.T9Search.ContactItem; +import com.android.contacts.T9Search.T9Adapter; +import com.android.contacts.T9Search.T9SearchResult; import com.android.internal.telephony.ITelephony; import com.android.phone.CallLogAsync; import com.android.phone.HapticFeedback; @@ -48,9 +51,11 @@ import android.telephony.PhoneNumberUtils; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.text.Editable; +import android.text.Spannable; import android.text.TextUtils; import android.text.TextWatcher; import android.text.method.DialerKeyListener; +import android.text.style.ForegroundColorSpan; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -60,14 +65,22 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; +import android.view.ViewGroup.LayoutParams; import android.view.Window; +import android.view.animation.Animation; +import android.view.animation.DecelerateInterpolator; +import android.view.animation.TranslateAnimation; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.EditText; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.ListView; +import android.widget.QuickContactBadge; import android.widget.TextView; +import android.widget.ToggleButton; +import android.widget.ViewSwitcher; import com.android.internal.telephony.ITelephony; @@ -150,6 +163,14 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener, /** Identifier for the "Add Call" intent extra. */ static final String ADD_CALL_MODE_KEY = "add_call_mode"; + private static T9Search sT9Search; // Static to avoid reloading when class is destroyed and recreated + private ToggleButton mT9Toggle; + private ListView mT9List; + private TextView mT9Result; + private QuickContactBadge mT9ResultBadge; + private T9Adapter mT9Adapter; + private ViewSwitcher mT9Flipper; + private LinearLayout mT9Top; /** * Identifier for intent extra for sending an empty Flash message for @@ -240,7 +261,21 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener, mDigits.setKeyListener(DialerKeyListener.getInstance()); mDigits.setOnClickListener(this); mDigits.setOnKeyListener(this); - + mT9Result = (TextView) findViewById(R.id.t9result); + if (mT9Result != null) { + mT9Result.setOnClickListener(this); + } + mT9ResultBadge = (QuickContactBadge) findViewById(R.id.t9badge); + mT9List = (ListView) findViewById(R.id.t9list); + if (mT9List!= null) { + mT9List.setOnItemClickListener(this); + } + mT9Toggle = (ToggleButton) findViewById(R.id.t9toggle); + if (mT9Toggle != null) { + mT9Toggle.setOnClickListener(this); + } + mT9Flipper = (ViewSwitcher) findViewById(R.id.t9flipper); + mT9Top = (LinearLayout) findViewById(R.id.t9topbar); maybeAddNumberFormatting(); setupKeypad(true); @@ -467,7 +502,15 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener, @Override protected void onResume() { super.onResume(); - + if (sT9Search == null && isT9On()) { + Thread loadContacts = new Thread(new Runnable() { + public void run () { + sT9Search = new T9Search(getBaseContext()); + } + }); + loadContacts.start(); + } + hideT9(); // Query the last dialed number. Do it first because hitting // the DB is 'slow'. This call is asynchronous. queryLastOutgoingCall(); @@ -538,6 +581,153 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener, updateDialer(); } + + /** + * Hides the topresult layout + * Needed to reclaim the space when T9 is off. + */ + private void hideT9 () { + if (!isT9On()) { + mT9Top.setVisibility(View.GONE); + } else { + mT9Top.setVisibility(View.VISIBLE); + } + return; + } + + /** + * Toggles between expanded list and dialpad + */ + private void toggleT9() { + if (!isT9On()) { + hideT9(); + return; + } + if (mT9Flipper.getCurrentView() == mT9List) { + mT9Toggle.setChecked(false); + animateT9(); + } + } + + /** + * Initiates a search for the dialed digits + * Toggles view visibility based on results + */ + private void searchContacts() { + if (!isT9On()) + return; + final int length = mDigits.length(); + if (length > 0) { + if (sT9Search != null) { + T9SearchResult result = sT9Search.search(mDigits.getText().toString()); + if (result != null) { + T9Search.ContactItem contact = result.getTopContact(); + mT9Result.setText(contact.name + " : " + contact.normalNumber, TextView.BufferType.SPANNABLE); + Spannable WordtoSpan = (Spannable) mT9Result.getText(); + String normalizedInput = T9Search.removeNonDigits(mDigits.getText().toString()); + int normalizedLength = normalizedInput.length(); + if (contact.nameMatchId != -1) { + int nameStart = contact.normalName.indexOf(normalizedInput); + WordtoSpan.setSpan(new ForegroundColorSpan(getResources().getColor(android.R.color.white)), nameStart, + nameStart + normalizedLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE); + } + if (contact.numberMatchId != -1) { + int numberStart = contact.name.length() + 3 + contact.numberMatchId; + WordtoSpan.setSpan(new ForegroundColorSpan(getResources().getColor(android.R.color.white)), + numberStart, numberStart + normalizedLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE); + } + mT9Result.setText(WordtoSpan); + mT9ResultBadge.assignContactFromPhone(contact.number, true); + mT9ResultBadge.setTag(contact.number); + if (contact.photo != null) + mT9ResultBadge.setImageBitmap(contact.photo); + else + mT9ResultBadge.setImageResource(R.drawable.ic_contact_list_picture); + if (result.getNumResults()> 1) { + mT9Toggle.setVisibility(View.VISIBLE); + } else { + mT9Toggle.setVisibility(View.GONE); + } + if (mT9Adapter == null) { + mT9Adapter = new T9Adapter(this, 0, result.getResults(),getLayoutInflater()); + mT9Adapter.setNotifyOnChange(true); + mT9List.setAdapter(mT9Adapter); + } else { + mT9Adapter.clear(); + for (ContactItem item : result.getResults()) { + mT9Adapter.add(item); + } + } + if (mT9List.getAdapter() == null) { + mT9List.setAdapter(mT9Adapter); + } + mT9ResultBadge.setVisibility(View.VISIBLE); + mT9Result.setVisibility(View.VISIBLE); + } else { + mT9ResultBadge.setVisibility(View.INVISIBLE); + mT9Result.setVisibility(View.INVISIBLE); + mT9Toggle.setVisibility(View.INVISIBLE); + toggleT9(); + } + } + } else { + mT9ResultBadge.setVisibility(View.INVISIBLE); + mT9Result.setVisibility(View.INVISIBLE); + mT9Toggle.setVisibility(View.INVISIBLE); + toggleT9(); + } + } + + /** + * Returns preference value for T9Dialer + */ + private boolean isT9On() { + return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("t9_state", true); + } + + /** + * Returns preference for whether to dial + * upon clicking contact in listview/topbar + */ + private boolean dialOnTap() { + return PreferenceManager.getDefaultSharedPreferences(this).getBoolean("t9_dial_onclick", false); + } + + /** + * Animates the dialpad/listview + */ + private void animateT9() { + TranslateAnimation slidedown1 = new TranslateAnimation( + Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, + Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f); + TranslateAnimation slidedown2 = new TranslateAnimation( + Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, + Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f); + TranslateAnimation slideup1 = new TranslateAnimation( + Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, + Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f); + TranslateAnimation slideup2 = new TranslateAnimation( + Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, + Animation.RELATIVE_TO_PARENT, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f); + slidedown2.setDuration(500); + slidedown2.setInterpolator(new DecelerateInterpolator()); + slidedown1.setDuration(500); + slidedown1.setInterpolator(new DecelerateInterpolator()); + slideup1.setDuration(500); + slideup1.setInterpolator(new DecelerateInterpolator()); + slideup2.setDuration(500); + slideup2.setInterpolator(new DecelerateInterpolator()); + if (mT9Toggle.isChecked()) { + mT9Flipper.setOutAnimation(slidedown1); + mT9Flipper.setInAnimation(slidedown2); + } else { + mT9Flipper.setOutAnimation(slideup1); + mT9Flipper.setInAnimation(slideup2); + } + mT9Flipper.showNext(); + } + + @Override public void onWindowFocusChanged(boolean hasFocus) { if (hasFocus) { @@ -726,6 +916,7 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener, private void keyPressed(int keyCode) { KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode); mDigits.onKeyDown(keyCode, event); + searchContacts(); } public boolean onKey(View view, int keyCode, KeyEvent event) { @@ -839,6 +1030,17 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener, } break; } + case R.id.t9toggle: { + animateT9(); + return; + } + case R.id.t9result: { + mDigits.setText(mT9ResultBadge.getTag().toString()); + if (dialOnTap()) { + dialButtonPressed(); + } + return; + } } //Wysie: Set the "voicemail"/add button to be enabled/disabled according to if any number is displayed @@ -860,6 +1062,7 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener, switch (id) { case R.id.deleteButton: { digits.clear(); + searchContacts(); //Wysie: Invoke checkForNumber() to disable button checkForNumber(); // TODO: The framework forgets to clear the pressed @@ -1043,6 +1246,14 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener, mDialpadChooser.setAdapter(mDialpadChooserAdapter); } } else { + if (isT9On() && !mDigits.getText().toString().isEmpty()) { + if (mT9Flipper.getCurrentView() != mT9List) { + mT9Toggle.setChecked(false); + searchContacts(); + } else { + return; + } + } // Log.i(TAG, "Displaying normal Dialer UI."); mDigits.setVisibility(View.VISIBLE); if (mDialpad != null) mDialpad.setVisibility(View.VISIBLE); @@ -1157,6 +1368,13 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener, * Handle clicks from the dialpad chooser. */ public void onItemClick(AdapterView parent, View v, int position, long id) { + if (parent == mT9List) { + mDigits.setText(mT9Adapter.getItem(position).number); + if (dialOnTap()) { + dialButtonPressed(); + } + return; + } DialpadChooserAdapter.ChoiceItem item = (DialpadChooserAdapter.ChoiceItem) parent.getItemAtPosition(position); int itemId = item.id; |
