Reconcile with ics-mr1-release
Change-Id: Ib05412a0777079563891bfdc8a5590a472e63364
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 60a9336..30b1d6f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -41,6 +41,8 @@
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
+ <uses-permission android:name="android.permission.READ_PROFILE" />
+ <uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
<uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/>
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
diff --git a/res/layout-port/autofill_settings_fragment.xml b/res/layout-port/autofill_settings_fragment.xml
index 63dba4d..16f674d 100644
--- a/res/layout-port/autofill_settings_fragment.xml
+++ b/res/layout-port/autofill_settings_fragment.xml
@@ -43,35 +43,19 @@
android:layout_width="match_parent" />
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_name" />
<EditText android:id="@+id/autofill_profile_editor_name_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:inputType="textPersonName|textCapWords"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textPersonName|textCapWords" />
+
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_company_name" />
<EditText android:id="@+id/autofill_profile_editor_company_name_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:inputType="textCapWords"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -91,13 +75,9 @@
android:text="@string/autofill_profile_editor_address_line_1_hint" />
</LinearLayout>
<EditText android:id="@+id/autofill_profile_editor_address_line_1_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:inputType="textCapWords"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -117,115 +97,50 @@
android:text="@string/autofill_profile_editor_address_line_2_hint" />
</LinearLayout>
<EditText android:id="@+id/autofill_profile_editor_address_line_2_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="bottom"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:inputType="textCapWords"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
+
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_city" />
<EditText android:id="@+id/autofill_profile_editor_city_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:inputType="textCapWords"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
+
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_state" />
<EditText android:id="@+id/autofill_profile_editor_state_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:inputType="textCapWords"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
+
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_zip_code" />
<EditText android:id="@+id/autofill_profile_editor_zip_code_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:inputType="textCapCharacters"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapCharacters" />
+
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_country" />
<EditText android:id="@+id/autofill_profile_editor_country_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:inputType="textCapWords"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
+
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_phone_number" />
<EditText android:id="@+id/autofill_profile_editor_phone_number_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true"
+ style="@style/AutofillProfileEditText"
android:phoneNumber="true" />
+
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_email_address" />
<EditText android:id="@+id/autofill_profile_editor_email_address_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:inputType="textEmailAddress"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textEmailAddress" />
</LinearLayout>
</ScrollView>
-
- <View
- android:layout_height="12dip"
- android:layout_width="match_parent" />
-
- <Button
- android:id="@+id/autofill_profile_editor_save_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/autofill_profile_editor_save_profile"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
</LinearLayout>
diff --git a/res/layout/autofill_settings_fragment.xml b/res/layout/autofill_settings_fragment.xml
index 8c90dd7..ab23ffb 100644
--- a/res/layout/autofill_settings_fragment.xml
+++ b/res/layout/autofill_settings_fragment.xml
@@ -49,37 +49,19 @@
android:stretchColumns="1">
<TableRow>
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_name" />
<EditText android:id="@+id/autofill_profile_editor_name_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:inputType="textPersonName|textCapWords"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textPersonName|textCapWords" />
</TableRow>
<TableRow>
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_company_name" />
<EditText android:id="@+id/autofill_profile_editor_company_name_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:inputType="textCapWords"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
</TableRow>
<TableRow>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -101,13 +83,8 @@
android:text="@string/autofill_profile_editor_address_line_1_hint" />
</LinearLayout>
<EditText android:id="@+id/autofill_profile_editor_address_line_1_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:inputType="textCapWords"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
</TableRow>
<TableRow>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
@@ -129,130 +106,59 @@
android:text="@string/autofill_profile_editor_address_line_2_hint" />
</LinearLayout>
<EditText android:id="@+id/autofill_profile_editor_address_line_2_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="bottom"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:inputType="textCapWords"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
</TableRow>
<TableRow>
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_city" />
<EditText android:id="@+id/autofill_profile_editor_city_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:inputType="textCapWords"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
</TableRow>
<TableRow>
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_state" />
<EditText android:id="@+id/autofill_profile_editor_state_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:inputType="textCapWords"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
</TableRow>
<TableRow>
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_zip_code" />
<EditText android:id="@+id/autofill_profile_editor_zip_code_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:inputType="textCapCharacters"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapCharacters" />
</TableRow>
<TableRow>
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_country" />
<EditText android:id="@+id/autofill_profile_editor_country_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:inputType="textCapWords"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textCapWords" />
</TableRow>
<TableRow>
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_phone_number" />
<EditText android:id="@+id/autofill_profile_editor_phone_number_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:singleLine="true"
+ style="@style/AutofillProfileEditText"
android:phoneNumber="true" />
</TableRow>
<TableRow>
<TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
+ style="@style/AutofillProfileTextView"
android:text="@string/autofill_profile_editor_email_address" />
<EditText android:id="@+id/autofill_profile_editor_email_address_edit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:inputType="textEmailAddress"
- android:singleLine="true" />
+ style="@style/AutofillProfileEditText"
+ android:inputType="textEmailAddress" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
-
- <View
- android:layout_height="12dip"
- android:layout_width="match_parent" />
-
- <Button
- android:id="@+id/autofill_profile_editor_save_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/autofill_profile_editor_save_profile"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
</LinearLayout>
diff --git a/res/menu/autofill_profile_editor.xml b/res/menu/autofill_profile_editor.xml
index 4e746e5..9dab635 100644
--- a/res/menu/autofill_profile_editor.xml
+++ b/res/menu/autofill_profile_editor.xml
@@ -15,6 +15,11 @@
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/autofill_profile_editor_save_profile_menu_id"
+ android:title="@string/autofill_profile_editor_save_profile"
+ android:icon="@android:drawable/ic_menu_save"
+ android:showAsAction="ifRoom|withText" />
+
<item android:id="@+id/autofill_profile_editor_delete_profile_menu_id"
android:title="@string/autofill_profile_editor_delete_profile"
android:icon="@android:drawable/ic_menu_delete"
diff --git a/res/menu/browser.xml b/res/menu/browser.xml
index bf95574..2886aa7 100644
--- a/res/menu/browser.xml
+++ b/res/menu/browser.xml
@@ -91,10 +91,6 @@
android:id="@+id/dump_nav_menu_id"
android:title="@string/dump_nav"
android:visible="false" />
- <item
- android:id="@+id/dump_counters_menu_id"
- android:title="@string/dump_counters"
- android:visible="false" />
</group>
<group android:id="@+id/MAIN_SHORTCUT_MENU" android:visible="false">
<item android:id="@+id/view_downloads_menu_id"
diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml
index 4dc836b..50dfb53 100644
--- a/res/values-hi/strings.xml
+++ b/res/values-hi/strings.xml
@@ -52,7 +52,7 @@
<string name="ssl_unknown" msgid="5679243486524754571">"अज्ञात प्रमाणपत्र त्रुटि."</string>
<string name="stopping" msgid="4839698519340302982">"रोका जा रहा है…"</string>
<string name="stop" msgid="5687251076030630074">"रोकें"</string>
- <string name="reload" msgid="8585220783228408062">"रीफ़्रेश करें"</string>
+ <string name="reload" msgid="8585220783228408062">"रीफ़्रेश करें"</string>
<string name="back" msgid="8414603107175713668">"वापस जाएं"</string>
<string name="forward" msgid="4288210890526641577">"अग्रेषित करें"</string>
<string name="save" msgid="5922311934992468496">"ठीक"</string>
@@ -116,7 +116,7 @@
<string name="contextmenu_view_image" msgid="3870625602053600905">"छवि देखें"</string>
<string name="contextmenu_set_wallpaper" msgid="3691902960115350686">"वॉलपेपर के रूप में सेट करें"</string>
<string name="contextmenu_dial_dot" msgid="5856550683415933806">"डायल करें…"</string>
- <string name="contextmenu_add_contact" msgid="3183511922223645716">"संपर्क जोड़ें"</string>
+ <string name="contextmenu_add_contact" msgid="3183511922223645716">"संपर्क जोड़ें"</string>
<string name="contextmenu_send_mail" msgid="1014513374828775660">"ईमेल भेजें"</string>
<string name="contextmenu_map" msgid="7471390435434034912">"मानचित्र"</string>
<string name="choosertitle_sharevia" msgid="4600490613341909086">"इसके द्वारा शेयर करें"</string>
@@ -148,7 +148,7 @@
<item msgid="6092441301001006473">"सर्वाधिक देखी गई साइटें"</item>
<item msgid="6569304572171444894">"अन्य"</item>
</string-array>
- <string name="pref_content_autofit" msgid="8260474534053660809">"स्वतः फ़िट पृष्ठ"</string>
+ <string name="pref_content_autofit" msgid="8260474534053660809">"स्वतः फ़िट पृष्ठ"</string>
<string name="pref_content_autofit_summary" msgid="324810555822572112">"स्क्रीन में फ़िट करने के लिए वेबपृष्ठों को प्रारूपित करें"</string>
<string name="pref_general_title" msgid="1946872771219249323">"सामान्य"</string>
<string name="pref_general_sync_title" msgid="3138637035975860324">"समन्वयित करें"</string>
@@ -378,7 +378,7 @@
<string name="accessibility_button_closetab" msgid="6954807842756927737">"टैब बंद करें"</string>
<string name="accessibility_button_newtab" msgid="4116986240706315748">"नया टैब खोलें"</string>
<string name="accessibility_button_newincognitotab" msgid="5254901889040012964">"नया गुप्त टैब खोलें"</string>
- <string name="accessibility_button_clear" msgid="6943152307986161598">"इनपुट साफ़ करें"</string>
+ <string name="accessibility_button_clear" msgid="6943152307986161598">"इनपुट साफ़ करें"</string>
<string name="accessibility_button_uaswitch" msgid="6286804719724282339">"उपयोगकर्ता एजेंट स्विच करें"</string>
<string name="accessibility_button_go" msgid="1182818872083055958">"जाएं"</string>
<string name="accessibility_button_navscreen" msgid="9142904748728713075">"पृष्ठ प्रबंधक"</string>
diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml
index 5032737..718f936 100644
--- a/res/values-in/strings.xml
+++ b/res/values-in/strings.xml
@@ -190,7 +190,7 @@
<string name="pref_privacy_clear_cache_dlg" msgid="4344512581716422465">"Hapus basis data dan konten dalam tembolok lokal?"</string>
<string name="pref_privacy_cookies_title" msgid="6763274282214830526">"Kuki"</string>
<string name="pref_privacy_clear_cookies" msgid="3095583579133780331">"Hapus semua data kuki"</string>
- <string name="pref_privacy_clear_cookies_summary" msgid="6962742063990677520">"Menghapus semua kuki peramban"</string>
+ <string name="pref_privacy_clear_cookies_summary" msgid="6962742063990677520">"Hapus semua kuki peramban"</string>
<string name="pref_privacy_clear_cookies_dlg" msgid="1493252163164621278">"Hapus semua kuki?"</string>
<string name="pref_privacy_clear_history" msgid="8723795508825198477">"Hapus riwayat"</string>
<string name="pref_privacy_clear_history_summary" msgid="6868501330708940734">"Hapus riwayat navigasi peramban"</string>
diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml
index 8b52381..9d5825a 100644
--- a/res/values-iw/strings.xml
+++ b/res/values-iw/strings.xml
@@ -22,7 +22,7 @@
<string name="new_tab" msgid="7971857320679510529">"כרטיסייה חדשה"</string>
<string name="new_incognito_tab" msgid="3606197964239039478">"כרטיסייה חדשה של גלישה בסתר"</string>
<string name="tab_bookmarks" msgid="2305793036003473653">"סימניות"</string>
- <string name="tab_most_visited" msgid="1077402532455000703">"אתרים שבהם אתה מבקר הכי הרבה"</string>
+ <string name="tab_most_visited" msgid="1077402532455000703">"אתרים שבהם אתה מבקר בתדירות הגבוהה ביותר"</string>
<string name="tab_history" msgid="1979267558744613746">"היסטוריה"</string>
<string name="tab_snapshots" msgid="1449241204980265186">"דפים שמורים"</string>
<string name="added_to_bookmarks" msgid="4028710765672851635">"נוסף לסימניות."</string>
diff --git a/res/values-th/strings.xml b/res/values-th/strings.xml
index a15fd2b..767bc5c 100644
--- a/res/values-th/strings.xml
+++ b/res/values-th/strings.xml
@@ -22,7 +22,7 @@
<string name="new_tab" msgid="7971857320679510529">"แท็บใหม่"</string>
<string name="new_incognito_tab" msgid="3606197964239039478">"แท็บใหม่ที่ไม่ระบุตัวตน"</string>
<string name="tab_bookmarks" msgid="2305793036003473653">"บุ๊กมาร์ก"</string>
- <string name="tab_most_visited" msgid="1077402532455000703">"เข้าชมบ่อยที่สุด"</string>
+ <string name="tab_most_visited" msgid="1077402532455000703">"เข้าชมมากที่สุด"</string>
<string name="tab_history" msgid="1979267558744613746">"ประวัติ"</string>
<string name="tab_snapshots" msgid="1449241204980265186">"หน้าที่บันทึกไว้"</string>
<string name="added_to_bookmarks" msgid="4028710765672851635">"เพิ่มลงในบุ๊กมาร์กแล้ว"</string>
diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml
index 5ef5241..90e03c0 100644
--- a/res/values-vi/strings.xml
+++ b/res/values-vi/strings.xml
@@ -25,8 +25,8 @@
<string name="tab_most_visited" msgid="1077402532455000703">"Truy cập nhiều nhất"</string>
<string name="tab_history" msgid="1979267558744613746">"Lịch sử"</string>
<string name="tab_snapshots" msgid="1449241204980265186">"Trang đã lưu"</string>
- <string name="added_to_bookmarks" msgid="4028710765672851635">"Đã thêm vào dấu trang."</string>
- <string name="removed_from_bookmarks" msgid="546648923924996722">"Đã xóa khỏi dấu trang."</string>
+ <string name="added_to_bookmarks" msgid="4028710765672851635">"Đã thêm vào dấu trang."</string>
+ <string name="removed_from_bookmarks" msgid="546648923924996722">"Đã xóa khỏi dấu trang."</string>
<string name="sign_in_to" msgid="5939425800148759165">"Đăng nhập vào <xliff:g id="HOSTNAME">%s1</xliff:g> \"<xliff:g id="REALM">%s2</xliff:g>\""</string>
<string name="username" msgid="5057566336518215922">"Tên"</string>
<string name="password" msgid="1177138552305184404">"Mật khẩu"</string>
@@ -34,12 +34,12 @@
<string name="bookmarks_search" msgid="5229596268214362873">"Trình duyệt"</string>
<string name="cancel" msgid="3017274947407233702">"Hủy"</string>
<string name="ok" msgid="1509280796718850364">"OK"</string>
- <string name="title_bar_loading" msgid="7438217780834640678">"Đang tải…"</string>
+ <string name="title_bar_loading" msgid="7438217780834640678">"Đang tải…"</string>
<string name="page_info" msgid="4048529256302257195">"Thông tin trang"</string>
<string name="page_info_view" msgid="5303490449842635158">"Xem thông tin trang"</string>
<string name="page_info_address" msgid="2222306609532903254">"Địa chỉ:"</string>
<string name="ssl_warnings_header" msgid="79744901983636370">"Có sự cố với chứng chỉ bảo mật cho trang web này."</string>
- <string name="ssl_continue" msgid="8031515015829358457">"Tiếp tục"</string>
+ <string name="ssl_continue" msgid="8031515015829358457">"Tiếp tục"</string>
<string name="security_warning" msgid="6607795404322797541">"Cảnh báo bảo mật"</string>
<string name="view_certificate" msgid="1472768887529093862">"Xem chứng chỉ"</string>
<string name="ssl_go_back" msgid="4598951822061593819">"Quay lại"</string>
@@ -69,17 +69,17 @@
<string name="add_to_other_folder_menu_option" msgid="5947586525822134105">"Thư mục khác"</string>
<string name="name" msgid="5462672162695365387">"Nhãn"</string>
<string name="http" msgid="2163722670597250102">"http://"</string>
- <string name="save_to_bookmarks" msgid="1679286010089780932">"Lưu vào dấu trang"</string>
+ <string name="save_to_bookmarks" msgid="1679286010089780932">"Lưu vào dấu trang"</string>
<string name="bookmark_this_page" msgid="7530739804320811054">"Đánh dấu trang này"</string>
<string name="remove" msgid="7820112494467011374">"Xóa"</string>
- <string name="edit_bookmark" msgid="5024089053490231905">"Chỉnh sửa dấu trang"</string>
+ <string name="edit_bookmark" msgid="5024089053490231905">"Chỉnh sửa dấu trang"</string>
<string name="create_shortcut_bookmark" msgid="1995095662095484289">"Thêm lối tắt tới màn hình trang chủ"</string>
- <string name="open_bookmark" msgid="8473581305759935790">"Mở"</string>
+ <string name="open_bookmark" msgid="8473581305759935790">"Mở"</string>
<string name="remove_bookmark" msgid="8407495852801410891">"Xoá dấu trang"</string>
- <string name="remove_from_bookmarks" msgid="4374080666576982775">"Xoá khỏi dấu trang"</string>
+ <string name="remove_from_bookmarks" msgid="4374080666576982775">"Xoá khỏi dấu trang"</string>
<string name="remove_history_item" msgid="5021424935726728618">"Xoá khỏi lịch sử"</string>
<string name="set_as_homepage" msgid="4752937379414905560">"Đặt làm trang chủ"</string>
- <string name="bookmark_saved" msgid="2766434679871317557">"Đã lưu vào dấu trang."</string>
+ <string name="bookmark_saved" msgid="2766434679871317557">"Đã lưu vào dấu trang."</string>
<string name="bookmark_not_saved" msgid="1077732557310662080">"Không thể lưu dấu trang."</string>
<string name="homepage_set" msgid="8768087280310966395">"Đã đặt trang chủ."</string>
<string name="bookmark_needs_title" msgid="6245900436119218187">"Dấu trang phải có tên."</string>
@@ -99,26 +99,26 @@
<string name="shortcut_bookmark_title" msgid="7570786275916681296">"Chọn dấu trang"</string>
<string name="history" msgid="2451240511251410032">"Lịch sử"</string>
<string name="menu_view_download" msgid="2124570321712995120">"Nội dung tải xuống"</string>
- <string name="copy_page_url" msgid="1188679152608889555">"Sao chép url của trang"</string>
+ <string name="copy_page_url" msgid="1188679152608889555">"Sao chép url của trang"</string>
<string name="share_page" msgid="593756995297268343">"Chia sẻ trang"</string>
<string name="menu_save_snapshot" msgid="6935080344031126139">"Lưu để đọc ngoại tuyến"</string>
<string name="snapshot_failed" msgid="4584580873565876033">"Không thể lưu để đọc ngoại tuyến."</string>
<string name="contextheader_folder_bookmarkcount" msgid="353987136645619089">"<xliff:g id="BOOKMARK_COUNT">%d</xliff:g> dấu trang"</string>
<string name="contextheader_folder_empty" msgid="974171637803391651">"Thư mục trống"</string>
- <string name="contextmenu_openlink" msgid="7237961252214188935">"Mở"</string>
- <string name="contextmenu_openlink_newwindow" msgid="1205313604181761403">"Mở trong tab mới"</string>
+ <string name="contextmenu_openlink" msgid="7237961252214188935">"Mở"</string>
+ <string name="contextmenu_openlink_newwindow" msgid="1205313604181761403">"Mở trong tab mới"</string>
<string name="contextmenu_openlink_newwindow_background" msgid="4690381019116746687">"Mở trong tab nền mới"</string>
<string name="contextmenu_savelink" msgid="5508554930832538184">"Lưu liên kết"</string>
<string name="contextmenu_sharelink" msgid="5392275392280130331">"Chia sẻ liên kết"</string>
- <string name="contextmenu_copy" msgid="398860586635404030">"Sao chép"</string>
- <string name="contextmenu_copylink" msgid="5153657160294534270">"Sao chép URL liên kết"</string>
+ <string name="contextmenu_copy" msgid="398860586635404030">"Sao chép"</string>
+ <string name="contextmenu_copylink" msgid="5153657160294534270">"Sao chép URL liên kết"</string>
<string name="contextmenu_download_image" msgid="4243829645180686912">"Lưu hình ảnh"</string>
<string name="contextmenu_view_image" msgid="3870625602053600905">"Xem hình ảnh"</string>
<string name="contextmenu_set_wallpaper" msgid="3691902960115350686">"Đặt làm hình nền"</string>
<string name="contextmenu_dial_dot" msgid="5856550683415933806">"Quay số…"</string>
<string name="contextmenu_add_contact" msgid="3183511922223645716">"Thêm liên hệ"</string>
<string name="contextmenu_send_mail" msgid="1014513374828775660">"Gửi email"</string>
- <string name="contextmenu_map" msgid="7471390435434034912">"Bản đồ"</string>
+ <string name="contextmenu_map" msgid="7471390435434034912">"Bản đồ"</string>
<string name="choosertitle_sharevia" msgid="4600490613341909086">"Chia sẻ qua"</string>
<string name="clear" msgid="7070043081700011461">"Xoá"</string>
<string name="replace" msgid="4843033491070384047">"Thay thế"</string>
@@ -129,7 +129,7 @@
<string name="pref_content_load_images_summary" msgid="5055874125248398584">"Hiển thị hình ảnh trên trang web"</string>
<string name="pref_content_block_popups" msgid="4158524847764470895">"Chặn cửa sổ bật lên"</string>
<string name="pref_content_javascript" msgid="4570972030299516843">"Bật JavaScript"</string>
- <string name="pref_content_open_in_background" msgid="824123779725118663">"Mở dưới nền"</string>
+ <string name="pref_content_open_in_background" msgid="824123779725118663">"Mở dưới nền"</string>
<string name="pref_content_plugins" msgid="7231944644794301582">"Bật trình cắm"</string>
<string-array name="pref_content_plugins_choices">
<item msgid="6745108155096660725">"Luôn bật"</item>
@@ -175,7 +175,7 @@
<string name="autofill_profile_editor_state" msgid="2150403366835080407">"Tiểu bang/Tỉnh/Vùng:"</string>
<string name="autofill_profile_editor_zip_code" msgid="283668573295656671">"Mã zip:"</string>
<string name="autofill_profile_editor_country" msgid="7234470301239156656">"Quốc gia:"</string>
- <string name="autofill_profile_editor_phone_number" msgid="4938852821413729276">"Điện thoại:"</string>
+ <string name="autofill_profile_editor_phone_number" msgid="4938852821413729276">"Điện thoại:"</string>
<string name="autofill_profile_editor_phone_number_invalid" msgid="6795411298467068957">"Số điện thoại không hợp lệ."</string>
<string name="autofill_profile_editor_save_profile" msgid="3230301454458581157">"Lưu"</string>
<string name="autofill_profile_successful_save" msgid="5691459703493331983">"Đã lưu văn bản tự động điền."</string>
@@ -219,9 +219,9 @@
<string name="pref_security_accept_cookies_summary" msgid="1907951236154433751">"Cho phép trang web lưu và đọc dữ liệu cookie"</string>
<string-array name="pref_text_size_choices">
<item msgid="4952686548944739548">"Rất nhỏ"</item>
- <item msgid="1950030433642671460">"Nhỏ"</item>
+ <item msgid="1950030433642671460">"Nhỏ"</item>
<item msgid="4338347520133294584">"Thường"</item>
- <item msgid="5043128215356351184">"Lớn"</item>
+ <item msgid="5043128215356351184">"Lớn"</item>
<item msgid="7201512237890458902">"Rất lớn"</item>
</string-array>
<string name="pref_min_font_size" msgid="8811125835817449131">"Kích thước phông chữ tối thiểu"</string>
@@ -238,10 +238,10 @@
<string-array name="pref_default_zoom_choices">
<item msgid="549583171195154919">"Xa"</item>
<item msgid="5619034257768161024">"Trung bình"</item>
- <item msgid="3840999588443167001">"Đóng"</item>
+ <item msgid="3840999588443167001">"Đóng"</item>
</string-array>
<string name="pref_default_zoom_dialogtitle" msgid="6095974367125109021">"Thu phóng mặc định"</string>
- <string name="pref_content_load_page" msgid="2219810141690955452">"Mở các trang trong chế độ xem tổng quan"</string>
+ <string name="pref_content_load_page" msgid="2219810141690955452">"Mở các trang trong chế độ xem tổng quan"</string>
<string name="pref_content_load_page_summary" msgid="9168803276420332955">"Hiển thị tổng quan về các trang mới mở"</string>
<string name="pref_extras_title" msgid="7075456173747370647">"Nâng cao"</string>
<string name="pref_extras_website_settings" msgid="67866640052455549">"Cài đặt trang web"</string>
@@ -260,7 +260,7 @@
<item msgid="891615911084608570">"Tiếng Nhật (ISO-2022-JP)"</item>
<item msgid="5589150448475151241">"Tiếng Nhật (SHIFT_JIS)"</item>
<item msgid="7356792686950371843">"Tiếng Nhật (EUC-JP)"</item>
- <item msgid="2193955365569270096">"Tiếng Hàn (EUC-KR)"</item>
+ <item msgid="2193955365569270096">"Tiếng Hàn (EUC-KR)"</item>
</string-array>
<string name="pref_default_text_encoding_dialogtitle" msgid="5508255018084978547">"Mã hoá văn bản"</string>
<string name="pref_accessibility_title" msgid="5127836981587423215">"Khả năng truy cập"</string>
@@ -360,7 +360,7 @@
<string name="menu_share_url" msgid="5851814357333739700">"Chia sẻ"</string>
<string name="max_tabs_warning" msgid="4122034303809457570">"Không có thêm tab nào"</string>
<string name="instant_search_label" msgid="8769284297650716935">"Google với tính năng Instant (Labs)"</string>
- <string name="preview" msgid="6450823514561689038">"Xem trước"</string>
+ <string name="preview" msgid="6450823514561689038">"Xem trước"</string>
<string name="local_bookmarks" msgid="533816851415228520">"Địa phương"</string>
<string name="ua_switcher_desktop" msgid="220097077327558435">"Yêu cầu trang web dành cho máy tính"</string>
<string name="permission_preload_label" msgid="4856971662337877316">"Tải trước kết quả"</string>
diff --git a/res/values-zu/strings.xml b/res/values-zu/strings.xml
index 8674734..75a94d6 100644
--- a/res/values-zu/strings.xml
+++ b/res/values-zu/strings.xml
@@ -42,7 +42,7 @@
<string name="ssl_continue" msgid="8031515015829358457">"Qhubeka"</string>
<string name="security_warning" msgid="6607795404322797541">"Isexwayiso sokuvikeleka"</string>
<string name="view_certificate" msgid="1472768887529093862">"Buka isitifiketi"</string>
- <string name="ssl_go_back" msgid="4598951822061593819">"Emuva"</string>
+ <string name="ssl_go_back" msgid="4598951822061593819">"Phindela emuva"</string>
<string name="ssl_untrusted" msgid="7754507359360636447">"Lesi sitifiketi asiphumi embusweni othembekile."</string>
<string name="ssl_mismatch" msgid="3809794439740523641">"Igama lale ngosi alifani negama elikusitifiketi."</string>
<string name="ssl_expired" msgid="5739349389499575559">"Lesi sitifiketi siphelelwe yisikhathi"</string>
@@ -127,10 +127,10 @@
<string name="pref_content_title" msgid="3834107397725342174">"Okuqukethwe ekhasini"</string>
<string name="pref_content_load_images" msgid="2125616852957377561">"Hlohla izithombe"</string>
<string name="pref_content_load_images_summary" msgid="5055874125248398584">"Bonisa izithombe emakhasini lewebhu"</string>
- <string name="pref_content_block_popups" msgid="4158524847764470895">"Vimba ama-pop-ups"</string>
+ <string name="pref_content_block_popups" msgid="4158524847764470895">"Vimba okuzivulakelayo"</string>
<string name="pref_content_javascript" msgid="4570972030299516843">"Vumela i-JavaScript"</string>
<string name="pref_content_open_in_background" msgid="824123779725118663">"Vula emuva"</string>
- <string name="pref_content_plugins" msgid="7231944644794301582">"Nika amandla ama-plugin"</string>
+ <string name="pref_content_plugins" msgid="7231944644794301582">"Nika amandla intshutheko"</string>
<string-array name="pref_content_plugins_choices">
<item msgid="6745108155096660725">"Njalo ivuliwe"</item>
<item msgid="2484126708670016519">"Kuyadingeka kakhulu"</item>
@@ -155,7 +155,7 @@
<string name="pref_general_autofill_title" msgid="547881256865816858">"Ukufaka-okuzenzakalelayo"</string>
<string name="pref_autofill_enabled" msgid="1015751713312396713">"Ukufaka-okuzenzakalelayo kweFomu"</string>
<string name="pref_autofill_enabled_summary" msgid="7659954073892471496">"Gcwalisa amafomu ewebhu ngokuthinta kanye"</string>
- <string name="pref_autofill_profile_editor" msgid="8934844472922113166">"Umbhalo ofakwe ngokuzenzakalelayo"</string>
+ <string name="pref_autofill_profile_editor" msgid="8934844472922113166">"Ubhalo ozenzakalelayo"</string>
<string name="pref_autofill_profile_editor_summary" msgid="4864447251676856190">"Setha ukuzilayisha kombhalo emafomini ewebhu"</string>
<string name="pref_autologin_title" msgid="4421187193809267096">"Ukusayinda ku-Google okuzenzakalelayo"</string>
<string name="pref_autologin_progress" msgid="8333244467048833461">"Ingena ngemvume kumasayithi e-Google isebenzisa i-<xliff:g id="ID_1">%s</xliff:g>"</string>
@@ -163,7 +163,7 @@
<string name="autologin_bar_login_text" msgid="3336615320510851879">"Ngena ngemvume"</string>
<string name="autologin_bar_hide_text" msgid="3629355974385859580">"Fihla"</string>
<string name="autologin_bar_error" msgid="7470001207395920811">"Ayikwazanga ukungena ngemvume."</string>
- <string name="autofill_profile_editor_heading" msgid="4798644544927738078">"Bhala umbhalo owufunayo ukuzigcwalisela amafomu ewebhu."</string>
+ <string name="autofill_profile_editor_heading" msgid="4798644544927738078">"Bhala umbhalo owufunayo ukuzigcwalisela aafomu ewebhu."</string>
<string name="autofill_profile_editor_name" msgid="8566130291459685955">"Igama eliphelele:"</string>
<string name="autofill_profile_editor_email_address" msgid="7967585896612797173">"I-imeyili:"</string>
<string name="autofill_profile_editor_company_name" msgid="2813443159949210417">"Igama lenkampani:"</string>
@@ -182,7 +182,7 @@
<string name="autofill_profile_successful_delete" msgid="1790262652460723127">"Ukuzifakekela kwamagama kususiwe."</string>
<string name="autofill_profile_editor_delete_profile" msgid="3098369314558164153">"Susa"</string>
<string name="autofill_setup_dialog_message" msgid="1096164985825394616">"Isiphequluli singazigcwalisela amafomu ewebhu afana nalawa. Ungathanda ukulungisa uhlelo lokuzigcwalisela umbhalo?"</string>
- <string name="autofill_setup_dialog_negative_toast" msgid="3288881675232206984">"Ungakwazi njalo ukuthi usethe ukuzifakekela kombhalo usuka Esipheqululini; Izilungiselelosetho; Iskrini esijwayelekile."</string>
+ <string name="autofill_setup_dialog_negative_toast" msgid="3288881675232206984">"Ungakwazi njalo ukuthi usethe ukuzifakekela kombhalo usuka Esipheqululini > Izisetho > Iskrini esijwayelekile."</string>
<string name="disable_autofill" msgid="8305901059849400354">"Khubaza ukufaka-okuzenzakalelayo"</string>
<string name="pref_privacy_security_title" msgid="3480313968942160914">"Ubumfihlo nokuvikela"</string>
<string name="pref_privacy_clear_cache" msgid="3380316479925886998">"Sula inqolobane"</string>
@@ -191,7 +191,7 @@
<string name="pref_privacy_cookies_title" msgid="6763274282214830526">"Amakhukhi"</string>
<string name="pref_privacy_clear_cookies" msgid="3095583579133780331">"Sula yonke idatha yekhukhi"</string>
<string name="pref_privacy_clear_cookies_summary" msgid="6962742063990677520">"Sula wonke amakhukhi okuphequlula"</string>
- <string name="pref_privacy_clear_cookies_dlg" msgid="1493252163164621278">"Susa wonke amakhukhi?"</string>
+ <string name="pref_privacy_clear_cookies_dlg" msgid="1493252163164621278">"Susa wonke ama-cookie?"</string>
<string name="pref_privacy_clear_history" msgid="8723795508825198477">"Sula umlando"</string>
<string name="pref_privacy_clear_history_summary" msgid="6868501330708940734">"Sula umlando wokuzulazula isiphequluli"</string>
<string name="pref_privacy_clear_history_dlg" msgid="6934317391642846227">"Susa umlando wokubheka umlando?"</string>
@@ -220,13 +220,13 @@
<string-array name="pref_text_size_choices">
<item msgid="4952686548944739548">"Ncane"</item>
<item msgid="1950030433642671460">"Ncane"</item>
- <item msgid="4338347520133294584">"Jwayelekile"</item>
+ <item msgid="4338347520133294584">"Kuvamile"</item>
<item msgid="5043128215356351184">"Okukhulu"</item>
- <item msgid="7201512237890458902">"Nkulu kakhulu"</item>
+ <item msgid="7201512237890458902">"Kukhulu kakhulu"</item>
</string-array>
<string name="pref_min_font_size" msgid="8811125835817449131">"Usayizi wefonti olinganiselwe ophansi"</string>
<string name="pref_min_font_size_value" msgid="2924708480509060209">"<xliff:g id="FONT_SIZE">%d</xliff:g>pt"</string>
- <string name="pref_text_zoom" msgid="5171056101805125497">"Ukukekela kombhalo"</string>
+ <string name="pref_text_zoom" msgid="5171056101805125497">"Umbhalo uyakekela"</string>
<string name="pref_zoom_on_double_tap" msgid="902786475250741795">"Sondeza ithephu ephindwe kabili"</string>
<string name="pref_force_userscalable" msgid="5641500562399892621">"Phoqelela ukuvumela ukusondeza"</string>
<string name="pref_force_userscalable_summary" msgid="3613242300617172230">"Shintsha isicelo sewebusayithi ukulawula indlela yokwandisa"</string>
@@ -247,7 +247,7 @@
<string name="pref_extras_website_settings" msgid="67866640052455549">"Izilungiselelo zewebhusayithi"</string>
<string name="pref_extras_website_settings_summary" msgid="1656771443223494406">"Izilungiselelo ezithuthukisiwe zamawebhusayithi omuntu ngamunye"</string>
<string name="pref_extras_reset_default_title" msgid="3579760449455761762">"Setha kabusha okumisiwe"</string>
- <string name="pref_extras_reset_default" msgid="8904000515846202110">"Setha kabusha kube okumisiwe"</string>
+ <string name="pref_extras_reset_default" msgid="8904000515846202110">"Setha kabusha kube okuzenzakalelayo"</string>
<string name="pref_extras_reset_default_summary" msgid="4247870778270414501">"Buyisela esimweni izilungiselelo ezizenzakalelayo"</string>
<string name="pref_extras_reset_default_dlg" msgid="7922814420184322450">"Buyisela izisetho kokumisiwe?"</string>
<string name="pref_development_title" msgid="3263854204533056480">"Lungisa amaphutha"</string>
@@ -272,7 +272,7 @@
<string name="pref_use_instant_search_summary" msgid="839320474961917522">"Sebenzisa i-Google Instant uma usebenzisa Usesho lwe-Google, ukubonisa imiphumelo njengoba uthayipha (lokhu kungakhuphula ukusetshenziswa kwedatha)."</string>
<string name="pref_lab_fullscreen" msgid="8173609016657987973">"Isikrini esigcwele"</string>
<string name="pref_lab_fullscreen_summary" msgid="7694738112219376740">"Sebenzisa imodi yesikrini esiphelele ukuze ufihle umudwa ochaza ngesimo."</string>
- <string name="pref_data_title" msgid="7255058703417796578">"Ukuphathwa kwebhendiwithi"</string>
+ <string name="pref_data_title" msgid="7255058703417796578">"Ukuphathwa Komkhawulokudonsa"</string>
<string name="pref_data_preload_title" msgid="4479320472980292873">"Imiphumela yosesho iyafaka"</string>
<string-array name="pref_data_preload_choices">
<item msgid="5180466923190095508">"Akusoze"</item>
@@ -352,7 +352,7 @@
<string name="import_bookmarks_dialog_confirm_add" msgid="8942794112340838111">"Engeza amabhukimakhi akuledivayisi okwamanje bese uqalisa ukuvumelanisa amabhukimakhi nge <xliff:g id="GOOGLE_ACCOUNT">%s</xliff:g>?"</string>
<string name="import_bookmarks_dialog_remove" msgid="5984607822851800902">"Susa amabhukimakhi"</string>
<string name="import_bookmarks_wizard_next" msgid="7578143961884352676">"Okulandelayo"</string>
- <string name="import_bookmarks_wizard_previous" msgid="8551440353688257031">"Okwandulele"</string>
+ <string name="import_bookmarks_wizard_previous" msgid="8551440353688257031">"Okwangaphambilini"</string>
<string name="import_bookmarks_wizard_cancel" msgid="4936061122806506634">"Khansela"</string>
<string name="import_bookmarks_wizard_done" msgid="1446247092194489191">"Kwenziwe"</string>
<string name="import_bookmarks_dialog_add" msgid="1743359725294101189">"Engeza amabhukimaka e-Akhawuntini ye-Google"</string>
@@ -367,7 +367,7 @@
<string name="empty_snapshots_folder" msgid="7675378008107026013">"Awekho amakhasi alondoloziwe."</string>
<string name="remove_snapshot" msgid="1624447424544976849">"Susa ikhasi elilondiwe"</string>
<string name="snapshot_go_live" msgid="1209542802541168497">"Iya bukhoma"</string>
- <string name="accessibility_button_back" msgid="6194680634245279407">"Emuva"</string>
+ <string name="accessibility_button_back" msgid="6194680634245279407">"Phindela emuva"</string>
<string name="accessibility_button_forward" msgid="1236827218480658168">"Iya phambili"</string>
<string name="accessibility_button_refresh" msgid="1023441396241841313">"Vuselela ikhasi"</string>
<string name="accessibility_button_stop" msgid="6793644120043222148">"Misa ukulayisha ikhasi"</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1e5f68f..1daa43f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -762,8 +762,6 @@
<!-- Do not translate. Testing only -->
<string name="dump_nav" translatable="false">Dump navigation cache</string>
- <!-- Do not translate. Testing only -->
- <string name="dump_counters" translatable="false">Dump V8 counters</string>
<!-- The default homepage. If it starts with "http://www.google" and the
user signs up the device with a Google sites account, the site's
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 361702e..3c87e22 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -80,4 +80,17 @@
<item name="android:textColor">?android:attr/textColorSecondary</item>
<item name="android:textStyle">normal</item>
</style>
+
+ <style name="AutofillProfileTextView">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:gravity">center_vertical</item>
+ <item name="android:layout_margin">2dip</item>
+ <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+ </style>
+ <style name="AutofillProfileEditText" parent="@style/AutofillProfileTextView">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:imeOptions">flagNoExtractUi</item>
+ <item name="android:singleLine">true</item>
+ </style>
</resources>
diff --git a/res/xml-sw600dp/lab_preferences.xml b/res/xml-sw600dp/lab_preferences.xml
index 0edc919..a7151e0 100644
--- a/res/xml-sw600dp/lab_preferences.xml
+++ b/res/xml-sw600dp/lab_preferences.xml
@@ -21,9 +21,4 @@
android:defaultValue="false"
android:title="@string/pref_lab_quick_controls"
android:summary="@string/pref_lab_quick_controls_summary" />
- <CheckBoxPreference
- android:key="use_instant_search"
- android:defaultValue="false"
- android:title="@string/pref_use_instant_search"
- android:summary="@string/pref_use_instant_search_summary" />
</PreferenceScreen>
diff --git a/src/com/android/browser/AutoFillSettingsFragment.java b/src/com/android/browser/AutoFillSettingsFragment.java
index 04f45b5..7be657d 100644
--- a/src/com/android/browser/AutoFillSettingsFragment.java
+++ b/src/com/android/browser/AutoFillSettingsFragment.java
@@ -52,7 +52,9 @@
private EditText mCountryEdit;
private EditText mPhoneEdit;
- private Button mSaveButton;
+ private MenuItem mSaveMenuItem;
+
+ private boolean mInitialised;
// Used to display toast after DB interactions complete.
private Handler mHandler;
@@ -87,7 +89,7 @@
mPhoneEdit.setError(null);
}
- updateButtonState();
+ updateSaveMenuItemState();
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -99,7 +101,7 @@
private class FieldChangedListener implements TextWatcher {
public void afterTextChanged(Editable s) {
- updateButtonState();
+ updateSaveMenuItemState();
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -147,11 +149,14 @@
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.autofill_profile_editor, menu);
+ mSaveMenuItem = menu.findItem(R.id.autofill_profile_editor_save_profile_menu_id);
+ updateSaveMenuItemState();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == R.id.autofill_profile_editor_delete_profile_menu_id) {
+ switch (item.getItemId()) {
+ case R.id.autofill_profile_editor_delete_profile_menu_id:
// Clear the UI.
mFullNameEdit.setText("");
mEmailEdit.setText("");
@@ -168,10 +173,30 @@
// trigger the current profile to get deleted from the DB.
mSettings.setAutoFillProfile(null,
mHandler.obtainMessage(PROFILE_DELETED_MSG));
- updateButtonState();
+ updateSaveMenuItemState();
return true;
+
+ case R.id.autofill_profile_editor_save_profile_menu_id:
+ AutoFillProfile newProfile = new AutoFillProfile(
+ mUniqueId,
+ mFullNameEdit.getText().toString(),
+ mEmailEdit.getText().toString(),
+ mCompanyEdit.getText().toString(),
+ mAddressLine1Edit.getText().toString(),
+ mAddressLine2Edit.getText().toString(),
+ mCityEdit.getText().toString(),
+ mStateEdit.getText().toString(),
+ mZipEdit.getText().toString(),
+ mCountryEdit.getText().toString(),
+ mPhoneEdit.getText().toString());
+
+ mSettings.setAutoFillProfile(newProfile,
+ mHandler.obtainMessage(PROFILE_SAVED_MSG));
+ return true;
+
+ default:
+ return false;
}
- return false;
}
@Override
@@ -203,27 +228,6 @@
mCountryEdit.addTextChangedListener(mFieldChangedListener);
mPhoneEdit.addTextChangedListener(new PhoneNumberValidator());
- mSaveButton = (Button)v.findViewById(R.id.autofill_profile_editor_save_button);
- mSaveButton.setOnClickListener(new OnClickListener() {
- public void onClick(View button) {
- AutoFillProfile newProfile = new AutoFillProfile(
- mUniqueId,
- mFullNameEdit.getText().toString(),
- mEmailEdit.getText().toString(),
- mCompanyEdit.getText().toString(),
- mAddressLine1Edit.getText().toString(),
- mAddressLine2Edit.getText().toString(),
- mCityEdit.getText().toString(),
- mStateEdit.getText().toString(),
- mZipEdit.getText().toString(),
- mCountryEdit.getText().toString(),
- mPhoneEdit.getText().toString());
-
- mSettings.setAutoFillProfile(newProfile,
- mHandler.obtainMessage(PROFILE_SAVED_MSG));
- }
- });
-
// Populate the text boxes with any pre existing AutoFill data.
AutoFillProfile activeProfile = mSettings.getAutoFillProfile();
if (activeProfile != null) {
@@ -239,14 +243,25 @@
mPhoneEdit.setText(activeProfile.getPhoneNumber());
}
- updateButtonState();
+ mInitialised = true;
+
+ updateSaveMenuItemState();
return v;
}
- public void updateButtonState() {
+ private void updateSaveMenuItemState() {
+ if (mSaveMenuItem == null) {
+ return;
+ }
- boolean valid = (mFullNameEdit.getText().toString().length() > 0 ||
+ if (!mInitialised) {
+ mSaveMenuItem.setEnabled(false);
+ return;
+ }
+
+ boolean currentState = mSaveMenuItem.isEnabled();
+ boolean newState = (mFullNameEdit.getText().toString().length() > 0 ||
mEmailEdit.getText().toString().length() > 0 ||
mCompanyEdit.getText().toString().length() > 0 ||
mAddressLine1Edit.getText().toString().length() > 0 ||
@@ -257,9 +272,9 @@
mCountryEdit.getText().toString().length() > 0) &&
mPhoneEdit.getError() == null;
- // Only enable the save buttons if we have at least one field completed
- // and the phone number (if present is valid).
- mSaveButton.setEnabled(valid);
+ if (currentState != newState) {
+ mSaveMenuItem.setEnabled(newState);
+ }
}
private void closeEditor() {
diff --git a/src/com/android/browser/AutofillHandler.java b/src/com/android/browser/AutofillHandler.java
index c4b14d7..dc23d00 100644
--- a/src/com/android/browser/AutofillHandler.java
+++ b/src/com/android/browser/AutofillHandler.java
@@ -21,9 +21,11 @@
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.database.Cursor;
+import android.net.Uri;
import android.os.AsyncTask;
import android.os.Message;
import android.preference.PreferenceManager;
+import android.provider.ContactsContract;
import android.webkit.WebSettings.AutoFillProfile;
import java.util.concurrent.CountDownLatch;
@@ -114,8 +116,58 @@
c.close();
autoFillDb.close();
+ if (mAutoFillProfile == null) {
+ // We did not load a profile from disk. Try to populate one with the user's
+ // "me" contact.
+ final Uri profileUri = Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
+ ContactsContract.Contacts.Data.CONTENT_DIRECTORY);
+
+ String name = getContactField(profileUri,
+ ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME,
+ ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE);
+ // Only attempt to read other data and set a profile if we could successfully
+ // get a name.
+ if (name != null) {
+ String email = getContactField(profileUri,
+ ContactsContract.CommonDataKinds.Email.ADDRESS,
+ ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE);
+ String phone = getContactField(profileUri,
+ ContactsContract.CommonDataKinds.Phone.NUMBER,
+ ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
+ String company = getContactField(profileUri,
+ ContactsContract.CommonDataKinds.Organization.COMPANY,
+ ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE);
+
+ // Can't easily get structured postal address information (even using
+ // CommonDataKinds.StructuredPostal) so omit prepopulating that for now.
+ // When querying structured postal data, it often all comes back as a string
+ // inside the "street" field.
+
+ mAutoFillProfile = new AutoFillProfile(
+ 1, name, email, company, null, null, null, null,
+ null, null, phone);
+ }
+ }
+
mLoaded.countDown();
}
+
+ private String getContactField(Uri uri, String field, String itemType) {
+ String result = null;
+
+ Cursor c = mContext.getContentResolver().query(uri, new String[] { field },
+ ContactsContract.Data.MIMETYPE + "=?", new String[] { itemType }, null);
+
+ try {
+ // Just use the first returned value if we get more than one.
+ if (c.moveToFirst()) {
+ result = c.getString(0);
+ }
+ } finally {
+ c.close();
+ }
+ return result;
+ }
}
public void setAutoFillProfile(AutoFillProfile profile, Message msg) {
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index ee308f9..e3b620a 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -493,11 +493,6 @@
}
@Override
- public void registerDropdownChangeListener(DropdownChangeListener d) {
- mNavigationBar.registerDropdownChangeListener(d);
- }
-
- @Override
public void showComboView(ComboViews startingView, Bundle extras) {
Intent intent = new Intent(mActivity, ComboViewActivity.class);
intent.putExtra(ComboViewActivity.EXTRA_INITIAL_VIEW, startingView.name());
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 0b8191a..2369554 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -146,10 +146,6 @@
if (sInitialized) {
syncSharedSettings();
}
-
- if (mController != null && (mSearchEngine instanceof InstantSearchEngine)) {
- ((InstantSearchEngine) mSearchEngine).setController(mController);
- }
}
public void startManagingSettings(WebSettings settings) {
@@ -355,9 +351,6 @@
if (PREF_SEARCH_ENGINE.equals(key)) {
updateSearchEngine(false);
}
- if (PREF_USE_INSTANT_SEARCH.equals(key)) {
- updateSearchEngine(true);
- }
if (PREF_FULLSCREEN.equals(key)) {
if (mController.getUi() != null) {
mController.getUi().setFullscreen(useFullscreen());
@@ -426,10 +419,6 @@
mSearchEngine.close();
}
mSearchEngine = SearchEngines.get(mContext, searchEngineName);
-
- if (mController != null && (mSearchEngine instanceof InstantSearchEngine)) {
- ((InstantSearchEngine) mSearchEngine).setController(mController);
- }
}
}
@@ -794,10 +783,6 @@
return HomeProvider.MOST_VISITED.equals(getHomePage());
}
- public boolean useInstantSearch() {
- return mPrefs.getBoolean(PREF_USE_INSTANT_SEARCH, false);
- }
-
public boolean useFullscreen() {
return mPrefs.getBoolean(PREF_FULLSCREEN, false);
}
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 9402a77..c9756da 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -80,7 +80,6 @@
import com.android.browser.IntentHandler.UrlData;
import com.android.browser.UI.ComboViews;
-import com.android.browser.UI.DropdownChangeListener;
import com.android.browser.provider.BrowserProvider;
import com.android.browser.provider.BrowserProvider2.Thumbnails;
import com.android.browser.provider.SnapshotProvider.Snapshots;
@@ -1512,9 +1511,6 @@
nav.setEnabled(isNavDump);
boolean showDebugSettings = mSettings.isDebugEnabled();
- final MenuItem counter = menu.findItem(R.id.dump_counters_menu_id);
- counter.setVisible(showDebugSettings);
- counter.setEnabled(showDebugSettings);
final MenuItem uaSwitcher = menu.findItem(R.id.ua_desktop_menu_id);
uaSwitcher.setChecked(isDesktopUa);
menu.setGroupVisible(R.id.LIVE_MENU, isLive);
@@ -1669,10 +1665,6 @@
getCurrentTopWebView().debugDump();
break;
- case R.id.dump_counters_menu_id:
- getCurrentTopWebView().dumpV8Counters();
- break;
-
case R.id.zoom_in_menu_id:
getCurrentTopWebView().zoomIn();
break;
@@ -2109,7 +2101,7 @@
manager.addCompletedDownload(target.getName(),
mActivity.getTitle().toString(), false,
uri.getMimeType(), target.getAbsolutePath(),
- (long)uri.getData().length, false);
+ (long)uri.getData().length, true);
} catch (IOException e) {
Log.e(LOGTAG, "Could not save data URL");
} finally {
@@ -2744,11 +2736,6 @@
mActivity.startActivityForResult(intent, AUTOFILL_SETUP);
}
- @Override
- public void registerDropdownChangeListener(DropdownChangeListener d) {
- mUi.registerDropdownChangeListener(d);
- }
-
public boolean onSearchRequested() {
mUi.editUrl(false);
return true;
diff --git a/src/com/android/browser/InstantSearchEngine.java b/src/com/android/browser/InstantSearchEngine.java
deleted file mode 100644
index 7176c0a..0000000
--- a/src/com/android/browser/InstantSearchEngine.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.browser;
-
-import com.android.browser.Controller;
-import com.android.browser.R;
-import com.android.browser.UI.DropdownChangeListener;
-import com.android.browser.provider.BrowserProvider;
-import com.android.browser.search.SearchEngine;
-
-import android.app.SearchManager;
-import android.content.Context;
-import android.database.AbstractCursor;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.Log;
-import android.util.LruCache;
-import android.webkit.SearchBox;
-import android.webkit.WebView;
-
-import java.util.Collections;
-import java.util.List;
-
-public class InstantSearchEngine implements SearchEngine, DropdownChangeListener {
- private static final String TAG = "Browser.InstantSearchEngine";
- private static final boolean DBG = false;
-
- private Controller mController;
- private SearchBox mSearchBox;
- private final BrowserSearchboxListener mListener = new BrowserSearchboxListener();
- private int mHeight;
-
- private String mInstantBaseUrl;
- private final Context mContext;
- // Used for startSearch( ) calls if for some reason instant
- // is off, or no searchbox is present.
- private final SearchEngine mWrapped;
-
- public InstantSearchEngine(Context context, SearchEngine wrapped) {
- mContext = context.getApplicationContext();
- mWrapped = wrapped;
- }
-
- public void setController(Controller controller) {
- mController = controller;
- }
-
- @Override
- public String getName() {
- return SearchEngine.GOOGLE;
- }
-
- @Override
- public CharSequence getLabel() {
- return mContext.getResources().getString(R.string.instant_search_label);
- }
-
- @Override
- public void startSearch(Context context, String query, Bundle appData, String extraData) {
- if (DBG) Log.d(TAG, "startSearch(" + query + ")");
-
- switchSearchboxIfNeeded();
-
- // If for some reason we are in a bad state, ensure that the
- // user gets default search results at the very least.
- if (mSearchBox == null || !isInstantPage()) {
- mWrapped.startSearch(context, query, appData, extraData);
- return;
- }
-
- mSearchBox.setQuery(query);
- mSearchBox.setVerbatim(true);
- mSearchBox.onsubmit(null);
- }
-
- private final class BrowserSearchboxListener extends SearchBox.SearchBoxListener {
- /*
- * The maximum number of out of order suggestions we accept
- * before giving up the wait.
- */
- private static final int MAX_OUT_OF_ORDER = 5;
-
- /*
- * We wait for suggestions in increments of 600ms. This is primarily to
- * guard against suggestions arriving out of order.
- */
- private static final int WAIT_INCREMENT_MS = 600;
-
- /*
- * A cache of suggestions received, keyed by the queries they were
- * received for.
- */
- private final LruCache<String, List<String>> mSuggestions =
- new LruCache<String, List<String>>(20);
-
- /*
- * The last set of suggestions received. We use this reduce UI flicker
- * in case there is a delay in recieving suggestions.
- */
- private List<String> mLatestSuggestion = Collections.emptyList();
-
- @Override
- public synchronized void onSuggestionsReceived(String query, List<String> suggestions) {
- if (DBG) Log.d(TAG, "onSuggestionsReceived(" + query + ")");
-
- if (!TextUtils.isEmpty(query)) {
- mSuggestions.put(query, suggestions);
- mLatestSuggestion = suggestions;
- }
-
- notifyAll();
- }
-
- public synchronized List<String> tryWaitForSuggestions(String query) {
- if (DBG) Log.d(TAG, "tryWait(" + query + ")");
-
- int numWaitReturns = 0;
-
- // This slightly unusual waiting construct is used to safeguard
- // to some extent against suggestions arriving out of order. We
- // wait for upto 5 notifyAll( ) calls to check if we received
- // suggestions for a given query.
- while (mSuggestions.get(query) == null) {
- try {
- wait(WAIT_INCREMENT_MS);
- ++numWaitReturns;
- if (numWaitReturns > MAX_OUT_OF_ORDER) {
- // We've waited too long for suggestions to be returned.
- // return the last available suggestion.
- break;
- }
- } catch (InterruptedException e) {
- return Collections.emptyList();
- }
- }
-
- List<String> suggestions = mSuggestions.get(query);
- if (suggestions == null) {
- return mLatestSuggestion;
- }
-
- return suggestions;
- }
-
- public synchronized void clear() {
- mSuggestions.evictAll();
- }
- }
-
- private WebView getCurrentWebview() {
- if (mController != null) {
- return mController.getTabControl().getCurrentTopWebView();
- }
-
- return null;
- }
-
- /**
- * Attaches the searchbox to the right browser page, i.e, the currently
- * visible tab.
- */
- private void switchSearchboxIfNeeded() {
- final WebView current = getCurrentWebview();
- if (current == null) {
- return;
- }
-
- final SearchBox searchBox = current.getSearchBox();
- if (searchBox != mSearchBox) {
- if (mSearchBox != null) {
- mSearchBox.removeSearchBoxListener(mListener);
- mListener.clear();
- }
- mSearchBox = searchBox;
- if (mSearchBox != null) {
- mSearchBox.addSearchBoxListener(mListener);
- }
- }
- }
-
- private boolean isInstantPage() {
- final WebView current = getCurrentWebview();
- if (current == null) {
- return false;
- }
-
- final String currentUrl = mController.getCurrentTab().getUrl();
-
- if (currentUrl != null) {
- Uri uri = Uri.parse(currentUrl);
- final String host = uri.getHost();
- final String path = uri.getPath();
-
- // Is there a utility class that does this ?
- if (path != null && host != null) {
- return host.startsWith("www.google.") &&
- (path.startsWith("/search") || path.startsWith("/webhp"));
- }
- return false;
- }
-
- return false;
- }
-
- private void loadInstantPage() {
- mController.getActivity().runOnUiThread(new Runnable() {
- @Override
- public void run() {
- final WebView current = getCurrentWebview();
- if (current != null) {
- current.loadUrl(getInstantBaseUrl());
- }
- }
- });
- }
-
- /**
- * Queries for a given search term and returns a cursor containing
- * suggestions ordered by best match.
- */
- @Override
- public Cursor getSuggestions(Context context, String query) {
- if (DBG) Log.d(TAG, "getSuggestions(" + query + ")");
- if (query == null) {
- return null;
- }
-
- if (!isInstantPage()) {
- loadInstantPage();
- }
-
- switchSearchboxIfNeeded();
-
- mController.registerDropdownChangeListener(this);
-
- if (mSearchBox == null) {
- return mWrapped.getSuggestions(context, query);
- }
-
- mSearchBox.setDimensions(0, 0, 0, mHeight);
- mSearchBox.onresize(null);
-
- if (TextUtils.isEmpty(query)) {
- // To force the SRP to render an empty (no results) page.
- mSearchBox.setVerbatim(true);
- } else {
- mSearchBox.setVerbatim(false);
- }
- mSearchBox.setQuery(query);
- mSearchBox.onchange(null);
-
- // Don't bother waiting for suggestions for an empty query. We still
- // set the query so that the SRP clears itself.
- if (TextUtils.isEmpty(query)) {
- return new SuggestionsCursor(Collections.<String>emptyList());
- } else {
- return new SuggestionsCursor(mListener.tryWaitForSuggestions(query));
- }
- }
-
- @Override
- public boolean supportsSuggestions() {
- return true;
- }
-
- @Override
- public void close() {
- if (mController != null) {
- mController.registerDropdownChangeListener(null);
- }
- if (mSearchBox != null) {
- mSearchBox.removeSearchBoxListener(mListener);
- }
- mListener.clear();
- mWrapped.close();
- }
-
- @Override
- public boolean supportsVoiceSearch() {
- return false;
- }
-
- @Override
- public String toString() {
- return "InstantSearchEngine {" + hashCode() + "}";
- }
-
- @Override
- public boolean wantsEmptyQuery() {
- return true;
- }
-
- private int rescaleHeight(int height) {
- final WebView current = getCurrentWebview();
- if (current == null) {
- return 0;
- }
-
- final float scale = current.getScale();
- if (scale != 0) {
- return (int) (height / scale);
- }
-
- return height;
- }
-
- @Override
- public void onNewDropdownDimensions(int height) {
- final int rescaledHeight = rescaleHeight(height);
-
- if (rescaledHeight != mHeight) {
- mHeight = rescaledHeight;
- if (mSearchBox != null) {
- mSearchBox.setDimensions(0, 0, 0, rescaledHeight);
- mSearchBox.onresize(null);
- }
- }
- }
-
- private String getInstantBaseUrl() {
- if (mInstantBaseUrl == null) {
- String url = mContext.getResources().getString(R.string.instant_base);
- if (url.indexOf("{CID}") != -1) {
- url = url.replace("{CID}",
- BrowserProvider.getClientId(mContext.getContentResolver()));
- }
- mInstantBaseUrl = url;
- }
-
- return mInstantBaseUrl;
- }
-
- // Indices of the columns in the below arrays.
- private static final int COLUMN_INDEX_ID = 0;
- private static final int COLUMN_INDEX_QUERY = 1;
- private static final int COLUMN_INDEX_ICON = 2;
- private static final int COLUMN_INDEX_TEXT_1 = 3;
-
- private static final String[] COLUMNS_WITHOUT_DESCRIPTION = new String[] {
- "_id",
- SearchManager.SUGGEST_COLUMN_QUERY,
- SearchManager.SUGGEST_COLUMN_ICON_1,
- SearchManager.SUGGEST_COLUMN_TEXT_1,
- };
-
- private static class SuggestionsCursor extends AbstractCursor {
- private final List<String> mSuggestions;
-
- public SuggestionsCursor(List<String> suggestions) {
- mSuggestions = suggestions;
- }
-
- @Override
- public int getCount() {
- return mSuggestions.size();
- }
-
- @Override
- public String[] getColumnNames() {
- return COLUMNS_WITHOUT_DESCRIPTION;
- }
-
- private String format(String suggestion) {
- if (TextUtils.isEmpty(suggestion)) {
- return "";
- }
- return suggestion;
- }
-
- @Override
- public String getString(int column) {
- if (mPos >= 0 && mPos < mSuggestions.size()) {
- if ((column == COLUMN_INDEX_QUERY) || (column == COLUMN_INDEX_TEXT_1)) {
- return format(mSuggestions.get(mPos));
- } else if (column == COLUMN_INDEX_ICON) {
- return String.valueOf(R.drawable.magnifying_glass);
- }
- }
- return null;
- }
-
- @Override
- public double getDouble(int column) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public float getFloat(int column) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getInt(int column) {
- if (column == COLUMN_INDEX_ID) {
- return mPos;
- }
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getLong(int column) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public short getShort(int column) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isNull(int column) {
- throw new UnsupportedOperationException();
- }
- }
-}
diff --git a/src/com/android/browser/NavTabView.java b/src/com/android/browser/NavTabView.java
index 4eec702..b15e828 100644
--- a/src/com/android/browser/NavTabView.java
+++ b/src/com/android/browser/NavTabView.java
@@ -74,11 +74,6 @@
return v == mImage;
}
- protected void setHighlighted(boolean highlighted) {
- if (highlighted == mHighlighted) return;
- mHighlighted = highlighted;
- }
-
private void setTitle() {
if (mTab == null) return;
if (mHighlighted) {
@@ -112,23 +107,18 @@
return mHighlighted;
}
- protected void setWebView(WebView w) {
- mContent.addView(w, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
- }
-
protected void setWebView(Tab tab) {
mTab = tab;
setTitle();
Bitmap image = tab.getScreenshot();
if (image != null) {
mImage.setImageBitmap(image);
+ if (tab != null) {
+ mImage.setContentDescription(tab.getTitle());
+ }
}
}
- protected void hideTitle() {
- mTitleBar.setVisibility(View.INVISIBLE);
- }
-
@Override
public void setOnClickListener(OnClickListener listener) {
mClickListener = listener;
diff --git a/src/com/android/browser/NavigationBarBase.java b/src/com/android/browser/NavigationBarBase.java
index 6a1b340..128304c 100644
--- a/src/com/android/browser/NavigationBarBase.java
+++ b/src/com/android/browser/NavigationBarBase.java
@@ -22,6 +22,8 @@
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.speech.RecognizerResultsIntent;
+import android.text.Editable;
+import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
@@ -31,15 +33,13 @@
import android.widget.ImageView;
import android.widget.LinearLayout;
-import com.android.browser.UI.DropdownChangeListener;
import com.android.browser.UrlInputView.UrlInputListener;
-import com.android.browser.autocomplete.SuggestedTextController.TextChangeWatcher;
import java.util.List;
public class NavigationBarBase extends LinearLayout implements
OnClickListener, UrlInputListener, OnFocusChangeListener,
- TextChangeWatcher {
+ TextWatcher {
protected BaseUi mBaseUi;
protected TitleBar mTitleBar;
@@ -71,7 +71,7 @@
mUrlInput.setUrlInputListener(this);
mUrlInput.setOnFocusChangeListener(this);
mUrlInput.setSelectAllOnFocus(true);
- mUrlInput.addQueryTextWatcher(this);
+ mUrlInput.addTextChangedListener(this);
}
public void setTitleBar(TitleBar titleBar) {
@@ -145,16 +145,6 @@
}
}
- // UrlInput text watcher
-
- @Override
- public void onTextChanged(String newText) {
- if (mUrlInput.hasFocus()) {
- // clear voice mode when user types
- setInVoiceMode(false, null);
- }
- }
-
// voicesearch
public void setInVoiceMode(boolean voicemode, List<String> voiceResults) {
@@ -167,7 +157,7 @@
}
void clearCompletions() {
- mUrlInput.setSuggestedText(null);
+ mUrlInput.dismissDropDown();
}
// UrlInputListener implementation
@@ -254,10 +244,6 @@
return super.dispatchKeyEventPreIme(evt);
}
- void registerDropdownChangeListener(DropdownChangeListener d) {
- mUrlInput.registerDropdownChangeListener(d);
- }
-
/**
* called from the Ui when the user wants to edit
* @param clearInput clear the input field
@@ -291,4 +277,17 @@
public void onTabDataChanged(Tab tab) {
}
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ if (mUrlInput.hasFocus()) {
+ // clear voice mode when user types
+ setInVoiceMode(false, null);
+ }
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) { }
}
diff --git a/src/com/android/browser/NavigationBarTablet.java b/src/com/android/browser/NavigationBarTablet.java
index ef29a49..04f372a 100644
--- a/src/com/android/browser/NavigationBarTablet.java
+++ b/src/com/android/browser/NavigationBarTablet.java
@@ -195,7 +195,7 @@
}
private void clearOrClose() {
- if (TextUtils.isEmpty(mUrlInput.getUserText())) {
+ if (TextUtils.isEmpty(mUrlInput.getText())) {
// close
mUrlInput.clearFocus();
} else {
@@ -278,7 +278,7 @@
}
protected void updateSearchMode(boolean userEdited) {
- setSearchMode(!userEdited || TextUtils.isEmpty(mUrlInput.getUserText()));
+ setSearchMode(!userEdited || TextUtils.isEmpty(mUrlInput.getText()));
}
@Override
diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java
index 15ccfe5..ecab008 100644
--- a/src/com/android/browser/PreferenceKeys.java
+++ b/src/com/android/browser/PreferenceKeys.java
@@ -81,7 +81,6 @@
// Keys for lab_preferences.xml
// ----------------------
static final String PREF_ENABLE_QUICK_CONTROLS = "enable_quick_controls";
- static final String PREF_USE_INSTANT_SEARCH = "use_instant_search";
static final String PREF_FULLSCREEN = "fullscreen";
// ----------------------
diff --git a/src/com/android/browser/SuggestionsAdapter.java b/src/com/android/browser/SuggestionsAdapter.java
index ca3754c..7400b5d 100644
--- a/src/com/android/browser/SuggestionsAdapter.java
+++ b/src/com/android/browser/SuggestionsAdapter.java
@@ -563,10 +563,6 @@
}
- private boolean useInstant() {
- return mSettings.useInstantSearch();
- }
-
public void clearCache() {
mFilterResults = null;
mSuggestResults = null;
diff --git a/src/com/android/browser/UI.java b/src/com/android/browser/UI.java
index a9cbd7b..2bd3754 100644
--- a/src/com/android/browser/UI.java
+++ b/src/com/android/browser/UI.java
@@ -140,11 +140,6 @@
boolean dispatchKey(int code, KeyEvent event);
- public static interface DropdownChangeListener {
- void onNewDropdownDimensions(int height);
- }
- void registerDropdownChangeListener(DropdownChangeListener d);
-
void showAutoLogin(Tab tab);
void hideAutoLogin(Tab tab);
diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java
index 9b48c46..e7a8953 100644
--- a/src/com/android/browser/UiController.java
+++ b/src/com/android/browser/UiController.java
@@ -23,7 +23,6 @@
import android.webkit.WebView;
import com.android.browser.UI.ComboViews;
-import com.android.browser.UI.DropdownChangeListener;
import java.util.List;
@@ -92,8 +91,6 @@
void updateMenuState(Tab tab, Menu menu);
- void registerDropdownChangeListener(DropdownChangeListener d);
-
boolean onOptionsItemSelected(MenuItem item);
SnapshotTab createNewSnapshotTab(long snapshotId, boolean setActive);
diff --git a/src/com/android/browser/UrlInputView.java b/src/com/android/browser/UrlInputView.java
index 96ab864..3c0de30 100644
--- a/src/com/android/browser/UrlInputView.java
+++ b/src/com/android/browser/UrlInputView.java
@@ -19,27 +19,25 @@
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
-import android.database.DataSetObserver;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.text.Editable;
import android.text.TextUtils;
+import android.text.TextWatcher;
import android.util.AttributeSet;
import android.util.Patterns;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
-import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
+import android.widget.AutoCompleteTextView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import com.android.browser.SuggestionsAdapter.CompletionListener;
import com.android.browser.SuggestionsAdapter.SuggestItem;
-import com.android.browser.UI.DropdownChangeListener;
-import com.android.browser.autocomplete.SuggestedTextController.TextChangeWatcher;
-import com.android.browser.autocomplete.SuggestiveAutoCompleteTextView;
import com.android.browser.search.SearchEngine;
import com.android.browser.search.SearchEngineInfo;
import com.android.browser.search.SearchEngines;
@@ -51,9 +49,9 @@
* url/search input view
* handling suggestions
*/
-public class UrlInputView extends SuggestiveAutoCompleteTextView
+public class UrlInputView extends AutoCompleteTextView
implements OnEditorActionListener,
- CompletionListener, OnItemClickListener, TextChangeWatcher {
+ CompletionListener, OnItemClickListener, TextWatcher {
static final String TYPED = "browser-type";
static final String SUGGESTED = "browser-suggest";
@@ -76,7 +74,6 @@
private boolean mLandscape;
private boolean mIncognitoMode;
private boolean mNeedsUpdate;
- private DropdownChangeListener mDropdownListener;
private int mState;
private StateListener mStateListener;
@@ -113,23 +110,8 @@
setThreshold(1);
setOnItemClickListener(this);
mNeedsUpdate = false;
- mDropdownListener = null;
- addQueryTextWatcher(this);
+ addTextChangedListener(this);
- mAdapter.registerDataSetObserver(new DataSetObserver() {
- @Override
- public void onChanged() {
- if (!isPopupShowing()) {
- return;
- }
- dispatchChange();
- }
-
- @Override
- public void onInvalidated() {
- dispatchChange();
- }
- });
mState = StateListener.STATE_NORMAL;
}
@@ -225,7 +207,7 @@
mAdapter.setLandscapeMode(mLandscape);
if (isPopupShowing() && (getVisibility() == View.VISIBLE)) {
setupDropDown();
- performFiltering(getUserText(), 0);
+ performFiltering(getText(), 0);
}
}
@@ -256,21 +238,11 @@
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- if (BrowserSettings.getInstance().useInstantSearch() &&
- (actionId == EditorInfo.IME_ACTION_NEXT)) {
- // When instant is turned on AND the user chooses to complete
- // using the tab key, then use the completion rather than the
- // text that the user has typed.
- finishInput(getText().toString(), null, TYPED);
- } else {
- finishInput(getUserText(), null, TYPED);
- }
-
+ finishInput(getText().toString(), null, TYPED);
return true;
}
void forceFilter() {
- performForcedFiltering();
showDropDown();
}
@@ -365,19 +337,6 @@
return mAdapter;
}
- private void dispatchChange() {
- final Rect popupRect = new Rect();
- getPopupDrawableRect(popupRect);
-
- if (mDropdownListener != null) {
- mDropdownListener.onNewDropdownDimensions(popupRect.height());
- }
- }
-
- void registerDropdownChangeListener(DropdownChangeListener d) {
- mDropdownListener = d;
- }
-
/*
* no-op to prevent scrolling of webview when embedded titlebar
* gets edited
@@ -388,10 +347,16 @@
}
@Override
- public void onTextChanged(String newText) {
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
if (StateListener.STATE_HIGHLIGHTED == mState) {
changeState(StateListener.STATE_EDITED);
}
}
+ @Override
+ public void afterTextChanged(Editable s) { }
+
}
diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java
index b4afb6f..556e88d 100644
--- a/src/com/android/browser/XLargeUi.java
+++ b/src/com/android/browser/XLargeUi.java
@@ -130,9 +130,7 @@
@Override
public void onResume() {
super.onResume();
- if (!BrowserSettings.getInstance().useInstantSearch()) {
- mNavBar.clearCompletions();
- }
+ mNavBar.clearCompletions();
}
@Override
diff --git a/src/com/android/browser/autocomplete/SuggestedSpan.java b/src/com/android/browser/autocomplete/SuggestedSpan.java
deleted file mode 100644
index dc04cb2..0000000
--- a/src/com/android/browser/autocomplete/SuggestedSpan.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.browser.autocomplete;
-
-import android.os.Parcel;
-import android.text.style.ForegroundColorSpan;
-
-/**
- * Class used to mark the portion of text within {@link SuggestiveEditText} that is suggested.
- */
-class SuggestedSpan extends ForegroundColorSpan {
-
- public SuggestedSpan(Parcel src) {
- super(src);
- }
-
- public SuggestedSpan(int color) {
- super(color);
- }
-
-}
diff --git a/src/com/android/browser/autocomplete/SuggestedTextController.java b/src/com/android/browser/autocomplete/SuggestedTextController.java
deleted file mode 100644
index 95dfcab..0000000
--- a/src/com/android/browser/autocomplete/SuggestedTextController.java
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-package com.android.browser.autocomplete;
-
-import com.google.common.annotations.VisibleForTesting;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.text.Editable;
-import android.text.Selection;
-import android.text.SpanWatcher;
-import android.text.Spannable;
-import android.text.Spanned;
-import android.text.TextUtils;
-import android.text.TextWatcher;
-import android.util.Log;
-import android.view.View;
-import android.widget.EditText;
-
-import java.util.ArrayList;
-
-import junit.framework.Assert;
-
-
-/**
- * The query editor can show a suggestion, grayed out following the query that the user has
- * entered so far. As the user types new characters, these should replace the grayed suggestion
- * text. This class manages this logic, displaying the suggestion when the user entered text is a
- * prefix of it, and hiding it otherwise.
- *
- * Note, the text in the text view will contain the entire suggestion, not just what the user
- * entered. Instead of retrieving the text from the text view, {@link #getUserText()} should be
- * called on this class.
- */
-public class SuggestedTextController {
- private static final boolean DBG = false;
- private static final String TAG = "Browser.SuggestedTextController";
-
- private final BufferTextWatcher mBufferTextWatcher = new BufferTextWatcher();
- private final BufferSpanWatcher mBufferSpanWatcher = new BufferSpanWatcher();
- private final ArrayList<TextChangeWatcher> mTextWatchers;
- private final TextOwner mTextOwner;
- private final StringBuffer mUserEntered;
- private final SuggestedSpan mSuggested;
- private String mSuggestedText;
- private TextChangeAttributes mCurrentTextChange;
- private boolean mSuspended = false;
-
- /**
- * While this is non-null, any changes made to the cursor position or selection are ignored. Is
- * stored the selection state at the moment when selection change processing was disabled.
- */
- private BufferSelection mTextSelectionBeforeIgnoringChanges;
-
- public SuggestedTextController(final EditText textView, int color) {
- this(new TextOwner() {
- @Override
- public Editable getText() {
- return textView.getText();
- }
- @Override
- public void addTextChangedListener(TextWatcher watcher) {
- textView.addTextChangedListener(watcher);
- }
- @Override
- public void removeTextChangedListener(TextWatcher watcher) {
- textView.removeTextChangedListener(watcher);
- }
- @Override
- public void setText(String text) {
- textView.setText(text);
- }
- }, color);
- }
-
- private void initialize(String userText, int selStart, int selEnd, String suggested) {
- Editable text = mTextOwner.getText();
-
- if (userText == null) userText = "";
- String allText = userText;
- int suggestedStart = allText.length();
- if (suggested != null && userText != null) {
- if (suggested.startsWith(userText.toLowerCase())) {
- allText = suggested;
- }
- }
-
- // allText is at this point either "userText" (not null) or
- // "suggested" if thats not null and starts with userText.
- text.replace(0, text.length(), allText);
- Selection.setSelection(text, selStart, selEnd);
- mUserEntered.replace(0, mUserEntered.length(), userText);
- mSuggestedText = suggested;
- if (suggestedStart < text.length()) {
- text.setSpan(mSuggested, suggestedStart, text.length(),
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- } else {
- text.removeSpan(mSuggested);
- }
- text.setSpan(mBufferSpanWatcher, 0, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
- mTextOwner.addTextChangedListener(mBufferTextWatcher);
- if (DBG) checkInvariant(text);
- }
-
- private void assertNotIgnoringSelectionChanges() {
- if (mTextSelectionBeforeIgnoringChanges != null) {
- throw new IllegalStateException(
- "Illegal operation while cursor movement processing suspended");
- }
- }
-
- public boolean isCursorHandlingSuspended() {
- return mSuspended;
- }
-
- public Parcelable saveInstanceState(Parcelable superState) {
- assertNotIgnoringSelectionChanges();
- SavedState ss = new SavedState(superState);
- Editable buffer = mTextOwner.getText();
- ss.mUserText = getUserText();
- ss.mSuggestedText = mSuggestedText;
- ss.mSelStart = Selection.getSelectionStart(buffer);
- ss.mSelEnd = Selection.getSelectionEnd(buffer);
- return ss;
- }
-
- public Parcelable restoreInstanceState(Parcelable state) {
- assertNotIgnoringSelectionChanges();
- if (!(state instanceof SavedState)) return state;
- SavedState ss = (SavedState) state;
- if (DBG) {
- Log.d(TAG, "restoreInstanceState t='" + ss.mUserText + "' suggestion='" +
- ss.mSuggestedText + " sel=" + ss.mSelStart + ".." + ss.mSelEnd);
- }
- // remove our listeners so we don't get notifications while re-initialising
- mTextOwner.getText().removeSpan(mBufferSpanWatcher);
- mTextOwner.removeTextChangedListener(mBufferTextWatcher);
- // and initialise will re-add the watchers
- initialize(ss.mUserText, ss.mSelStart, ss.mSelEnd, ss.mSuggestedText);
- notifyUserEnteredChanged();
- return ss.getSuperState();
- }
-
- /**
- * Temporarily stop processing cursor movements and selection changes. While cursor movements
- * are being ignored, the text in the buffer must NOT be changed; doing so will result in an
- * {@link IllegalStateException} being thrown.
- *
- * To stop ignoring cursor movements, call
- * {@link #resumeCursorMovementHandlingAndApplyChanges()}.
- */
- public void suspendCursorMovementHandling() {
- assertNotIgnoringSelectionChanges();
- Editable buffer = mTextOwner.getText();
- mTextSelectionBeforeIgnoringChanges = new BufferSelection(buffer);
- mSuspended = true;
- }
-
- /**
- * Start responding to cursor movements and selection changes again. If the cursor or selection
- * moved while it was being ignored, these changes will be processed now.
- */
- public void resumeCursorMovementHandlingAndApplyChanges() {
- Editable buffer = mTextOwner.getText();
- BufferSelection oldSelection = mTextSelectionBeforeIgnoringChanges;
- mTextSelectionBeforeIgnoringChanges = null;
- BufferSelection newSelection = new BufferSelection(buffer);
- if (oldSelection.mStart != newSelection.mStart) {
- mBufferSpanWatcher.onSpanChanged(buffer, Selection.SELECTION_START,
- oldSelection.mStart, oldSelection.mStart,
- newSelection.mStart, newSelection.mStart);
- }
- if (oldSelection.mEnd != newSelection.mEnd) {
- mBufferSpanWatcher.onSpanChanged(buffer, Selection.SELECTION_END,
- oldSelection.mEnd, oldSelection.mEnd,
- newSelection.mEnd, newSelection.mEnd);
- }
- mSuspended = false;
- }
-
- /**
- * Sets the current suggested text. A portion of this will be added to the user entered text if
- * that is a prefix of the suggestion.
- */
- public void setSuggestedText(String text) {
- assertNotIgnoringSelectionChanges();
- if (!TextUtils.equals(text, mSuggestedText)) {
- if (DBG) Log.d(TAG, "setSuggestedText(" + text + ")");
- mSuggestedText = text;
- if (mCurrentTextChange == null) {
- mCurrentTextChange = new TextChangeAttributes(0, 0, 0);
- Editable buffer = mTextOwner.getText();
- handleTextChanged(buffer);
- }
- }
- }
-
- /**
- * Gets the portion of displayed text that is not suggested.
- */
- public String getUserText() {
- assertNotIgnoringSelectionChanges();
- return mUserEntered.toString();
- }
-
- /**
- * Sets the given text as if it has been entered by the user.
- */
- public void setText(String text) {
- assertNotIgnoringSelectionChanges();
- if (text == null) text = "";
- Editable buffer = mTextOwner.getText();
- buffer.removeSpan(mSuggested);
- // this will cause a handleTextChanged call
- buffer.replace(0, text.length(), text);
- }
-
- public void addUserTextChangeWatcher(TextChangeWatcher watcher) {
- mTextWatchers.add(watcher);
- }
-
- private void handleTextChanged(Editable newText) {
- // When we make changes to the buffer from within this function, it results in recursive
- // calls to beforeTextChanges(), afterTextChanged(). We want to ignore the changes we're
- // making ourself:
- if (mCurrentTextChange.isHandled()) return;
- mCurrentTextChange.setHandled();
- final int pos = mCurrentTextChange.mPos;
- final int countBefore = mCurrentTextChange.mCountBefore;
- final int countAfter = mCurrentTextChange.mCountAfter;
- final int cursorPos = Selection.getSelectionEnd(newText);
- if (DBG) {
- Log.d(TAG, "pos=" + pos +"; countBefore=" + countBefore + "; countAfter=" +
- countAfter + "; cursor=" + cursorPos);
- }
- mUserEntered.replace(pos, pos + countBefore,
- newText.subSequence(pos, pos + countAfter).toString());
- if (DBG) Log.d(TAG, "User entered: '" + mUserEntered + "' all='" + newText + "'");
- final int userLen = mUserEntered.length();
- boolean haveSuggested = newText.getSpanStart(mSuggested) != -1;
- if (mSuggestedText != null &&
- mSuggestedText.startsWith(mUserEntered.toString().toLowerCase())) {
- if (haveSuggested) {
- if (!mSuggestedText.equalsIgnoreCase(newText.toString())) {
- if (countAfter > countBefore) {
- // net insertion
- int len = countAfter - countBefore;
- newText.delete(pos + len, pos + len + len);
- } else {
- // net deletion
- newText.replace(userLen, newText.length(),
- mSuggestedText.substring(userLen));
- if (countBefore == 0) {
- // no change to the text - likely just suggested change
- Selection.setSelection(newText, cursorPos);
- }
- }
- }
- } else {
- // no current suggested text - add it
- newText.insert(userLen, mSuggestedText.substring(userLen));
- // keep the cursor at the end of the user entered text, if that where it was
- // before.
- if (cursorPos == userLen) {
- Selection.setSelection(newText, userLen);
- }
- }
- if (userLen == newText.length()) {
- newText.removeSpan(mSuggested);
- } else {
- newText.setSpan(mSuggested, userLen, newText.length(),
- Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- }
- } else {
- if (newText.getSpanStart(mSuggested) != -1) {
- newText.removeSpan(mSuggested);
- newText.delete(mUserEntered.length(), newText.length());
- }
- }
- if (DBG) checkInvariant(newText);
- mCurrentTextChange = null;
- if (countBefore > 0 || countAfter > 0) {
- notifyUserEnteredChanged();
- }
- }
-
- private void notifyUserEnteredChanged() {
- for (TextChangeWatcher watcher : mTextWatchers) {
- watcher.onTextChanged(mUserEntered.toString());
- }
- }
-
- /**
- * Basic interface for being notified of changes to some text.
- */
- public interface TextChangeWatcher {
- void onTextChanged(String newText);
- }
-
- /**
- * Interface class to wrap required methods from {@link EditText}, or some other class used
- * to test without needing an @{link EditText}.
- */
- public interface TextOwner {
- Editable getText();
- void addTextChangedListener(TextWatcher watcher);
- void removeTextChangedListener(TextWatcher watcher);
- void setText(String text);
- }
-
- /**
- * This class stores the parameters passed to {@link BufferTextWatcher#beforeTextChanged},
- * together with a flag indicating if this invocation has been dealt with yet. We need this
- * information, together with the parameters passed to
- * {@link BufferTextWatcher#afterTextChanged}, to restore our internal state when the buffer is
- * edited.
- *
- * Since the changes we make from within {@link BufferTextWatcher#afterTextChanged} also trigger
- * further recursive calls to {@link BufferTextWatcher#beforeTextChanged} and
- * {@link BufferTextWatcher#afterTextChanged}, this class helps detect these recursive calls so
- * they can be ignored.
- */
- private static class TextChangeAttributes {
- public final int mPos;
- public final int mCountAfter;
- public final int mCountBefore;
- private boolean mHandled;
-
- public TextChangeAttributes(int pos, int countAfter, int countBefore) {
- mPos = pos;
- mCountAfter = countAfter;
- mCountBefore = countBefore;
- }
-
- public void setHandled() {
- mHandled = true;
- }
-
- public boolean isHandled() {
- return mHandled;
- }
- }
-
- /**
- * Encapsulates the state of the text selection (and cursor) within a text buffer.
- */
- private static class BufferSelection {
- final int mStart;
- final int mEnd;
- public BufferSelection(CharSequence text) {
- mStart = Selection.getSelectionStart(text);
- mEnd = Selection.getSelectionEnd(text);
- }
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof BufferSelection)) return super.equals(other);
- BufferSelection otherSel = (BufferSelection) other;
- return this.mStart == otherSel.mStart && this.mEnd == otherSel.mEnd;
- }
- }
-
- private class BufferTextWatcher implements TextWatcher {
- @Override
- public void afterTextChanged(Editable newText) {
- if (DBG) {
- Log.d(TAG, "afterTextChanged('" + newText + "')");
- }
- assertNotIgnoringSelectionChanges();
- handleTextChanged(newText);
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- assertNotIgnoringSelectionChanges();
- if (mCurrentTextChange == null) {
- mCurrentTextChange = new TextChangeAttributes(start, after, count);
- }
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
- }
-
- private class BufferSpanWatcher implements SpanWatcher {
- @Override
- public void onSpanAdded(Spannable text, Object what, int start, int end) {
- }
-
- @Override
- public void onSpanChanged(
- Spannable text, Object what, int ostart, int oend, int nstart, int nend) {
- if (mCurrentTextChange != null) return;
- if (mTextSelectionBeforeIgnoringChanges != null) return;
- if (what == Selection.SELECTION_END) {
- if (DBG) Log.d(TAG, "cursor move to " + nend);
- if (nend > mUserEntered.length()) {
- mUserEntered.replace(0, mUserEntered.length(), text.toString());
- text.removeSpan(mSuggested);
- }
- if (DBG) checkInvariant(text);
- }
- }
-
- @Override
- public void onSpanRemoved(Spannable text, Object what, int start, int end) {
- }
- }
-
- public static class SavedState extends View.BaseSavedState {
- String mUserText;
- String mSuggestedText;
- int mSelStart;
- int mSelEnd;
-
- public SavedState(Parcelable superState) {
- super(superState);
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- super.writeToParcel(out, flags);
- out.writeString(mUserText);
- out.writeString(mSuggestedText);
- out.writeInt(mSelStart);
- out.writeInt(mSelEnd);
- }
-
- @SuppressWarnings("hiding")
- public static final Parcelable.Creator<SavedState> CREATOR
- = new Parcelable.Creator<SavedState>() {
- @Override
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- @Override
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
-
- private SavedState(Parcel in) {
- super(in);
- mUserText = in.readString();
- mSuggestedText = in.readString();
- mSelStart = in.readInt();
- mSelEnd = in.readInt();
- }
- }
-
- /*
- * The remaining functions are used for testing purposes only.
- * -----------------------------------------------------------
- */
-
- /**
- * Verify that the internal state of this class is consistent.
- */
- @VisibleForTesting
- void checkInvariant(final Spannable s) {
- int suggestedStart = s.getSpanStart(mSuggested);
- int suggestedEnd = s.getSpanEnd(mSuggested);
- int cursorPos = Selection.getSelectionEnd(s);
- if (suggestedStart == -1 || suggestedEnd == -1) {
- suggestedStart = suggestedEnd = s.length();
- }
- String userEntered = getUserText();
- Log.d(TAG, "checkInvariant all='" + s + "' (len " + s.length() + ") sug="
- + suggestedStart + ".." + suggestedEnd + " cursor=" + cursorPos +
- " ue='" + userEntered + "' (len " + userEntered.length() + ")");
- int suggestedLen = suggestedEnd - suggestedStart;
- Assert.assertEquals("Sum of user and suggested text lengths doesn't match total length",
- s.length(), userEntered.length() + suggestedLen);
- Assert.assertEquals("End of user entered text doesn't match start of suggested",
- suggestedStart, userEntered.length());
- Assert.assertTrue("user entered text does not match start of buffer",
- userEntered.toString().equalsIgnoreCase(
- s.subSequence(0, suggestedStart).toString()));
- if (mSuggestedText != null && suggestedStart < s.length()) {
- Assert.assertTrue("User entered is not a prefix of suggested",
- mSuggestedText.startsWith(userEntered.toString().toLowerCase()));
- Assert.assertTrue("Suggested text does not match buffer contents",
- mSuggestedText.equalsIgnoreCase(s.toString().toLowerCase()));
- }
- if (mSuggestedText == null) {
- Assert.assertEquals("Non-zero suggention length with null suggestion", 0, suggestedLen);
- } else {
- Assert.assertTrue("Suggestion text longer than suggestion (" + mSuggestedText.length() +
- ">" + suggestedLen + ")", suggestedLen <= mSuggestedText.length());
- }
- Assert.assertTrue("Cursor within suggested part", cursorPos <= suggestedStart);
- }
-
- @VisibleForTesting
- SuggestedTextController(TextOwner textOwner, int color) {
- mUserEntered = new StringBuffer();
- mSuggested = new SuggestedSpan(color);
- mTextOwner = textOwner;
- mTextWatchers = new ArrayList<TextChangeWatcher>();
- initialize(null, 0, 0, null);
- }
-}
diff --git a/src/com/android/browser/autocomplete/SuggestiveAutoCompleteTextView.java b/src/com/android/browser/autocomplete/SuggestiveAutoCompleteTextView.java
deleted file mode 100644
index 50ba758..0000000
--- a/src/com/android/browser/autocomplete/SuggestiveAutoCompleteTextView.java
+++ /dev/null
@@ -1,849 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.browser.autocomplete;
-
-import com.android.browser.BrowserSettings;
-import com.android.browser.SuggestionsAdapter;
-import com.android.browser.SuggestionsAdapter.SuggestItem;
-import com.android.browser.autocomplete.SuggestedTextController.TextChangeWatcher;
-import com.android.internal.R;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.database.DataSetObserver;
-import android.graphics.Rect;
-import android.os.Parcelable;
-import android.text.Editable;
-import android.text.Html;
-import android.text.Selection;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.AbsSavedState;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.view.inputmethod.CompletionInfo;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.AdapterView;
-import android.widget.EditText;
-import android.widget.Filter;
-import android.widget.Filterable;
-import android.widget.ListAdapter;
-import android.widget.ListPopupWindow;
-import android.widget.TextView;
-
-
-/**
- * This is a stripped down version of the framework AutoCompleteTextView
- * class with added support for displaying completions in-place. Note that
- * this cannot be implemented as a subclass of the above without making
- * substantial changes to it and its descendants.
- *
- * @see android.widget.AutoCompleteTextView
- */
-public class SuggestiveAutoCompleteTextView extends EditText implements Filter.FilterListener {
- private static final boolean DEBUG = false;
- private static final String TAG = "SuggestiveAutoCompleteTextView";
-
- private CharSequence mHintText;
- private TextView mHintView;
- private int mHintResource;
-
- private SuggestionsAdapter mAdapter;
- private Filter mFilter;
- private int mThreshold;
-
- private ListPopupWindow mPopup;
- private int mDropDownAnchorId;
-
- private AdapterView.OnItemClickListener mItemClickListener;
-
- private boolean mDropDownDismissedOnCompletion = true;
-
- private int mLastKeyCode = KeyEvent.KEYCODE_UNKNOWN;
-
- // Set to true when text is set directly and no filtering shall be performed
- private boolean mBlockCompletion;
-
- // When set, an update in the underlying adapter will update the result list popup.
- // Set to false when the list is hidden to prevent asynchronous updates to popup the list again.
- private boolean mPopupCanBeUpdated = true;
-
- private PassThroughClickListener mPassThroughClickListener;
- private PopupDataSetObserver mObserver;
- private SuggestedTextController mController;
-
- public SuggestiveAutoCompleteTextView(Context context) {
- this(context, null);
- }
-
- public SuggestiveAutoCompleteTextView(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.autoCompleteTextViewStyle);
- }
-
- public SuggestiveAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
-
- // The completions are always shown in the same color as the hint
- // text.
- mController = new SuggestedTextController(this, getHintTextColors().getDefaultColor());
- mPopup = new ListPopupWindow(context, attrs,
- R.attr.autoCompleteTextViewStyle);
- mPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
- mPopup.setPromptPosition(ListPopupWindow.POSITION_PROMPT_BELOW);
-
- TypedArray a = context.obtainStyledAttributes(
- attrs, R.styleable.AutoCompleteTextView, defStyle, 0);
-
- mThreshold = a.getInt(
- R.styleable.AutoCompleteTextView_completionThreshold, 2);
-
- mPopup.setListSelector(a.getDrawable(R.styleable.AutoCompleteTextView_dropDownSelector));
- mPopup.setVerticalOffset((int)
- a.getDimension(R.styleable.AutoCompleteTextView_dropDownVerticalOffset, 0.0f));
- mPopup.setHorizontalOffset((int)
- a.getDimension(R.styleable.AutoCompleteTextView_dropDownHorizontalOffset, 0.0f));
-
- // Get the anchor's id now, but the view won't be ready, so wait to actually get the
- // view and store it in mDropDownAnchorView lazily in getDropDownAnchorView later.
- // Defaults to NO_ID, in which case the getDropDownAnchorView method will simply return
- // this TextView, as a default anchoring point.
- mDropDownAnchorId = a.getResourceId(
- R.styleable.AutoCompleteTextView_dropDownAnchor, View.NO_ID);
-
- // For dropdown width, the developer can specify a specific width, or MATCH_PARENT
- // (for full screen width) or WRAP_CONTENT (to match the width of the anchored view).
- mPopup.setWidth(a.getLayoutDimension(
- R.styleable.AutoCompleteTextView_dropDownWidth,
- ViewGroup.LayoutParams.WRAP_CONTENT));
- mPopup.setHeight(a.getLayoutDimension(
- R.styleable.AutoCompleteTextView_dropDownHeight,
- ViewGroup.LayoutParams.WRAP_CONTENT));
-
- mHintResource = a.getResourceId(R.styleable.AutoCompleteTextView_completionHintView,
- R.layout.simple_dropdown_hint);
-
- mPopup.setOnItemClickListener(new DropDownItemClickListener());
- setCompletionHint(a.getText(R.styleable.AutoCompleteTextView_completionHint));
-
- // Always turn on the auto complete input type flag, since it
- // makes no sense to use this widget without it.
- int inputType = getInputType();
- if ((inputType&EditorInfo.TYPE_MASK_CLASS)
- == EditorInfo.TYPE_CLASS_TEXT) {
- inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE;
- setRawInputType(inputType);
- }
-
- a.recycle();
-
- setFocusable(true);
-
- mController.addUserTextChangeWatcher(new MyWatcher());
-
- mPassThroughClickListener = new PassThroughClickListener();
- super.setOnClickListener(mPassThroughClickListener);
- }
-
- @Override
- public void setOnClickListener(OnClickListener listener) {
- mPassThroughClickListener.mWrapped = listener;
- }
-
- /**
- * Private hook into the on click event, dispatched from {@link PassThroughClickListener}
- */
- private void onClickImpl() {
- // If the dropdown is showing, bring the keyboard to the front
- // when the user touches the text field.
- if (isPopupShowing()) {
- ensureImeVisible(true);
- }
- }
-
- /**
- * <p>Sets the optional hint text that is displayed at the bottom of the
- * the matching list. This can be used as a cue to the user on how to
- * best use the list, or to provide extra information.</p>
- *
- * @param hint the text to be displayed to the user
- *
- * @attr ref android.R.styleable#AutoCompleteTextView_completionHint
- */
- private void setCompletionHint(CharSequence hint) {
- mHintText = hint;
- if (hint != null) {
- if (mHintView == null) {
- final TextView hintView = (TextView) LayoutInflater.from(getContext()).inflate(
- mHintResource, null).findViewById(R.id.text1);
- hintView.setText(mHintText);
- mHintView = hintView;
- mPopup.setPromptView(hintView);
- } else {
- mHintView.setText(hint);
- }
- } else {
- mPopup.setPromptView(null);
- mHintView = null;
- }
- }
-
- protected int getDropDownWidth() {
- return mPopup.getWidth();
- }
-
- public void setDropDownWidth(int width) {
- mPopup.setWidth(width);
- }
-
- protected void setDropDownVerticalOffset(int offset) {
- mPopup.setVerticalOffset(offset);
- }
-
- public void setDropDownHorizontalOffset(int offset) {
- mPopup.setHorizontalOffset(offset);
- }
-
- protected int getDropDownHorizontalOffset() {
- return mPopup.getHorizontalOffset();
- }
-
- public void setThreshold(int threshold) {
- if (threshold <= 0) {
- threshold = 1;
- }
-
- mThreshold = threshold;
- }
-
- protected void setOnItemClickListener(AdapterView.OnItemClickListener l) {
- mItemClickListener = l;
- }
-
- public void setAdapter(SuggestionsAdapter adapter) {
- if (mObserver == null) {
- mObserver = new PopupDataSetObserver();
- } else if (mAdapter != null) {
- mAdapter.unregisterDataSetObserver(mObserver);
- }
- mAdapter = adapter;
- if (mAdapter != null) {
- mFilter = mAdapter.getFilter();
- adapter.registerDataSetObserver(mObserver);
- } else {
- mFilter = null;
- }
-
- mPopup.setAdapter(mAdapter);
- }
-
- @Override
- public boolean onKeyPreIme(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && isPopupShowing()
- && !mPopup.isDropDownAlwaysVisible()) {
- // special case for the back key, we do not even try to send it
- // to the drop down list but instead, consume it immediately
- if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
- KeyEvent.DispatcherState state = getKeyDispatcherState();
- if (state != null) {
- state.startTracking(event, this);
- }
- return true;
- } else if (event.getAction() == KeyEvent.ACTION_UP) {
- KeyEvent.DispatcherState state = getKeyDispatcherState();
- if (state != null) {
- state.handleUpEvent(event);
- }
- if (event.isTracking() && !event.isCanceled()) {
- dismissDropDown();
- return true;
- }
- }
- }
- return super.onKeyPreIme(keyCode, event);
- }
-
- @Override
- public boolean onKeyUp(int keyCode, KeyEvent event) {
- boolean consumed = mPopup.onKeyUp(keyCode, event);
- if (consumed) {
- switch (keyCode) {
- // if the list accepts the key events and the key event
- // was a click, the text view gets the selected item
- // from the drop down as its content
- case KeyEvent.KEYCODE_ENTER:
- case KeyEvent.KEYCODE_DPAD_CENTER:
- case KeyEvent.KEYCODE_TAB:
- if (event.hasNoModifiers()) {
- performCompletion();
- }
- return true;
- }
- }
-
- if (isPopupShowing() && keyCode == KeyEvent.KEYCODE_TAB && event.hasNoModifiers()) {
- performCompletion();
- return true;
- }
-
- return super.onKeyUp(keyCode, event);
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (mPopup.onKeyDown(keyCode, event)) {
- return true;
- }
-
- if (!isPopupShowing()) {
- switch(keyCode) {
- case KeyEvent.KEYCODE_DPAD_DOWN:
- if (event.hasNoModifiers()) {
- performValidation();
- }
- }
- }
-
- if (isPopupShowing() && keyCode == KeyEvent.KEYCODE_TAB && event.hasNoModifiers()) {
- return true;
- }
-
- mLastKeyCode = keyCode;
- boolean handled = super.onKeyDown(keyCode, event);
- mLastKeyCode = KeyEvent.KEYCODE_UNKNOWN;
-
- if (handled && isPopupShowing()) {
- clearListSelection();
- }
-
- return handled;
- }
-
- /**
- * Returns <code>true</code> if the amount of text in the field meets
- * or exceeds the {@link #getThreshold} requirement. You can override
- * this to impose a different standard for when filtering will be
- * triggered.
- */
- private boolean enoughToFilter() {
- if (DEBUG) Log.v(TAG, "Enough to filter: len=" + getUserText().length()
- + " threshold=" + mThreshold);
- return getUserText().length() >= mThreshold;
- }
-
- /**
- * This is used to watch for edits to the text view. Note that we call
- * to methods on the auto complete text view class so that we can access
- * private vars without going through thunks.
- */
- private class MyWatcher implements TextChangeWatcher {
- @Override
- public void onTextChanged(String newText) {
- doAfterTextChanged();
- }
- }
-
- /**
- * @hide
- */
- protected void setBlockCompletion(boolean block) {
- mBlockCompletion = block;
- }
-
- void doAfterTextChanged() {
- if (DEBUG) Log.d(TAG, "doAfterTextChanged(" + getText() + ")");
- if (mBlockCompletion) return;
-
- // the drop down is shown only when a minimum number of characters
- // was typed in the text view
- if (enoughToFilter()) {
- if (mFilter != null) {
- mPopupCanBeUpdated = true;
- performFiltering(getUserText(), mLastKeyCode);
- buildImeCompletions();
- }
- } else {
- // drop down is automatically dismissed when enough characters
- // are deleted from the text view
- if (!mPopup.isDropDownAlwaysVisible()) {
- dismissDropDown();
- }
- if (mFilter != null) {
- performFiltering(null, mLastKeyCode);
- }
- }
- }
-
- /**
- * <p>Indicates whether the popup menu is showing.</p>
- *
- * @return true if the popup menu is showing, false otherwise
- */
- public boolean isPopupShowing() {
- return mPopup.isShowing();
- }
-
- /**
- * <p>Converts the selected item from the drop down list into a sequence
- * of character that can be used in the edit box.</p>
- *
- * @param selectedItem the item selected by the user for completion
- *
- * @return a sequence of characters representing the selected suggestion
- */
- protected CharSequence convertSelectionToString(Object selectedItem) {
- return mFilter.convertResultToString(selectedItem);
- }
-
- /**
- * <p>Clear the list selection. This may only be temporary, as user input will often bring
- * it back.
- */
- private void clearListSelection() {
- mPopup.clearListSelection();
- }
-
- /**
- * <p>Starts filtering the content of the drop down list. The filtering
- * pattern is the content of the edit box. Subclasses should override this
- * method to filter with a different pattern, for instance a substring of
- * <code>text</code>.</p>
- *
- * @param text the filtering pattern
- * @param keyCode the last character inserted in the edit box; beware that
- * this will be null when text is being added through a soft input method.
- */
- @SuppressWarnings({ "UnusedDeclaration" })
- protected void performFiltering(CharSequence text, int keyCode) {
- if (DEBUG) Log.d(TAG, "performFiltering(" + text + ")");
-
- mFilter.filter(text, this);
- }
-
- protected void performForcedFiltering() {
- boolean wasSuspended = false;
- if (mController.isCursorHandlingSuspended()) {
- mController.resumeCursorMovementHandlingAndApplyChanges();
- wasSuspended = true;
- }
-
- mFilter.filter(getUserText().toString(), this);
-
- if (wasSuspended) {
- mController.suspendCursorMovementHandling();
- }
- }
-
- /**
- * <p>Performs the text completion by converting the selected item from
- * the drop down list into a string, replacing the text box's content with
- * this string and finally dismissing the drop down menu.</p>
- */
- private void performCompletion() {
- performCompletion(null, -1, -1);
- }
-
- @Override
- public void onCommitCompletion(CompletionInfo completion) {
- if (isPopupShowing()) {
- mBlockCompletion = true;
- replaceText(completion.getText());
- mBlockCompletion = false;
-
- mPopup.performItemClick(completion.getPosition());
- }
- }
-
- private void performCompletion(View selectedView, int position, long id) {
- if (isPopupShowing()) {
- Object selectedItem;
- if (position < 0) {
- selectedItem = mPopup.getSelectedItem();
- } else {
- selectedItem = mAdapter.getItem(position);
- }
- if (selectedItem == null) {
- Log.w(TAG, "performCompletion: no selected item");
- return;
- }
-
- mBlockCompletion = true;
- replaceText(convertSelectionToString(selectedItem));
- mBlockCompletion = false;
-
- if (mItemClickListener != null) {
- final ListPopupWindow list = mPopup;
-
- if (selectedView == null || position < 0) {
- selectedView = list.getSelectedView();
- position = list.getSelectedItemPosition();
- id = list.getSelectedItemId();
- }
- mItemClickListener.onItemClick(list.getListView(), selectedView, position, id);
- }
- }
-
- if (mDropDownDismissedOnCompletion && !mPopup.isDropDownAlwaysVisible()) {
- dismissDropDown();
- }
- }
-
- /**
- * <p>Performs the text completion by replacing the current text by the
- * selected item. Subclasses should override this method to avoid replacing
- * the whole content of the edit box.</p>
- *
- * @param text the selected suggestion in the drop down list
- */
- protected void replaceText(CharSequence text) {
- clearComposingText();
-
- setText(text);
- // make sure we keep the caret at the end of the text view
- Editable spannable = getText();
- Selection.setSelection(spannable, spannable.length());
- }
-
- /** {@inheritDoc} */
- @Override
- public void onFilterComplete(int count) {
- updateDropDownForFilter(count);
- }
-
- private void updateDropDownForFilter(int count) {
- // Not attached to window, don't update drop-down
- if (getWindowVisibility() == View.GONE) return;
-
- /*
- * This checks enoughToFilter() again because filtering requests
- * are asynchronous, so the result may come back after enough text
- * has since been deleted to make it no longer appropriate
- * to filter.
- */
-
- final boolean dropDownAlwaysVisible = mPopup.isDropDownAlwaysVisible();
- if ((count > 0 || dropDownAlwaysVisible) && enoughToFilter() &&
- getUserText().length() > 0) {
- if (hasFocus() && hasWindowFocus() && mPopupCanBeUpdated) {
- showDropDown();
- }
- } else if (!dropDownAlwaysVisible && isPopupShowing()) {
- dismissDropDown();
- // When the filter text is changed, the first update from the adapter may show an empty
- // count (when the query is being performed on the network). Future updates when some
- // content has been retrieved should still be able to update the list.
- mPopupCanBeUpdated = true;
- }
- }
-
- @Override
- public void onWindowFocusChanged(boolean hasWindowFocus) {
- super.onWindowFocusChanged(hasWindowFocus);
- if (!hasWindowFocus && !mPopup.isDropDownAlwaysVisible()) {
- dismissDropDown();
- }
- }
-
- @Override
- protected void onDisplayHint(int hint) {
- super.onDisplayHint(hint);
- switch (hint) {
- case INVISIBLE:
- if (!mPopup.isDropDownAlwaysVisible()) {
- dismissDropDown();
- }
- break;
- }
- }
-
- @Override
- protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
- // TextView makes several cursor movements when gaining focus, and this interferes with
- // the suggested vs user entered text. Tell the controller to temporarily ignore cursor
- // movements while this is going on.
- mController.suspendCursorMovementHandling();
-
- super.onFocusChanged(focused, direction, previouslyFocusedRect);
- // Perform validation if the view is losing focus.
- if (!focused) {
- performValidation();
- }
- if (!focused && !mPopup.isDropDownAlwaysVisible()) {
- dismissDropDown();
- }
-
- mController.resumeCursorMovementHandlingAndApplyChanges();
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- }
-
- @Override
- protected void onDetachedFromWindow() {
- dismissDropDown();
- super.onDetachedFromWindow();
- }
-
- /**
- * <p>Closes the drop down if present on screen.</p>
- */
- protected void dismissDropDown() {
- InputMethodManager imm = InputMethodManager.peekInstance();
- if (imm != null) {
- imm.displayCompletions(this, null);
- }
- mPopup.dismiss();
- mPopupCanBeUpdated = false;
- }
-
- @Override
- protected boolean setFrame(final int l, int t, final int r, int b) {
- boolean result = super.setFrame(l, t, r, b);
-
- if (isPopupShowing()) {
- showDropDown();
- }
-
- return result;
- }
-
- /**
- * Ensures that the drop down is not obscuring the IME.
- * @param visible whether the ime should be in front. If false, the ime is pushed to
- * the background.
- * @hide internal used only here and SearchDialog
- */
- private void ensureImeVisible(boolean visible) {
- mPopup.setInputMethodMode(visible
- ? ListPopupWindow.INPUT_METHOD_NEEDED : ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
- showDropDown();
- }
-
- /**
- * <p>Displays the drop down on screen.</p>
- */
- protected void showDropDown() {
- if (mPopup.getAnchorView() == null) {
- if (mDropDownAnchorId != View.NO_ID) {
- mPopup.setAnchorView(getRootView().findViewById(mDropDownAnchorId));
- } else {
- mPopup.setAnchorView(this);
- }
- }
- if (!isPopupShowing()) {
- // Make sure the list does not obscure the IME when shown for the first time.
- mPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NEEDED);
- }
- mPopup.show();
- }
-
- private void buildImeCompletions() {
- final ListAdapter adapter = mAdapter;
- if (adapter != null) {
- InputMethodManager imm = InputMethodManager.peekInstance();
- if (imm != null) {
- final int count = Math.min(adapter.getCount(), 20);
- CompletionInfo[] completions = new CompletionInfo[count];
- int realCount = 0;
-
- for (int i = 0; i < count; i++) {
- if (adapter.isEnabled(i)) {
- realCount++;
- Object item = adapter.getItem(i);
- long id = adapter.getItemId(i);
- completions[i] = new CompletionInfo(id, i,
- convertSelectionToString(item));
- }
- }
-
- if (realCount != count) {
- CompletionInfo[] tmp = new CompletionInfo[realCount];
- System.arraycopy(completions, 0, tmp, 0, realCount);
- completions = tmp;
- }
-
- imm.displayCompletions(this, completions);
- }
- }
- }
-
- private void performValidation() {
- }
-
- /**
- * Returns the Filter obtained from {@link Filterable#getFilter},
- * or <code>null</code> if {@link #setAdapter} was not called with
- * a Filterable.
- */
- protected Filter getFilter() {
- return mFilter;
- }
-
- private class DropDownItemClickListener implements AdapterView.OnItemClickListener {
- @Override
- public void onItemClick(AdapterView parent, View v, int position, long id) {
- performCompletion(v, position, id);
- }
- }
-
- /**
- * Allows us a private hook into the on click event without preventing users from setting
- * their own click listener.
- */
- private class PassThroughClickListener implements OnClickListener {
-
- private View.OnClickListener mWrapped;
-
- /** {@inheritDoc} */
- @Override
- public void onClick(View v) {
- onClickImpl();
-
- if (mWrapped != null) mWrapped.onClick(v);
- }
- }
-
- private class PopupDataSetObserver extends DataSetObserver {
- @Override
- public void onChanged() {
- if (mAdapter != null) {
- // If the popup is not showing already, showing it will cause
- // the list of data set observers attached to the adapter to
- // change. We can't do it from here, because we are in the middle
- // of iterating through the list of observers.
- post(new Runnable() {
- @Override
- public void run() {
- final SuggestionsAdapter adapter = mAdapter;
- if (adapter != null) {
- // This will re-layout, thus resetting mDataChanged, so that the
- // listView click listener stays responsive
- updateDropDownForFilter(adapter.getCount());
- }
-
- updateText(adapter);
- }
- });
- }
- }
- }
-
- public String getUserText() {
- return mController.getUserText();
- }
-
- private void updateText(SuggestionsAdapter adapter) {
- if (!BrowserSettings.getInstance().useInstantSearch()) {
- return;
- }
-
- if (!isPopupShowing()) {
- setSuggestedText(null);
- return;
- }
-
- if (mAdapter.getCount() > 0 && !TextUtils.isEmpty(getUserText())) {
- for (int i = 0; i < mAdapter.getCount(); ++i) {
- SuggestItem current = mAdapter.getItem(i);
- if (current.type == SuggestionsAdapter.TYPE_SUGGEST) {
- setSuggestedText(current.title);
- break;
- }
- }
- }
- }
-
- @Override
- public void setText(CharSequence text, BufferType type) {
- Editable buffer = getEditableText();
- if (text == null) text = "";
- // if we already have a buffer, we must not replace it with a new one as this will break
- // mController. Write the new text into the existing buffer instead.
- if (buffer == null) {
- super.setText(text, type);
- } else {
- buffer.replace(0, buffer.length(), text);
- invalidate();
- }
- }
-
- public void setText(CharSequence text, boolean filter) {
- if (filter) {
- setText(text);
- } else {
- mBlockCompletion = true;
- // If cursor movement handling was suspended (the view is
- // not in focus), resume it and apply the pending change.
- // Since we don't want to perform any filtering, this change
- // is safe.
- boolean wasSuspended = false;
- if (mController.isCursorHandlingSuspended()) {
- mController.resumeCursorMovementHandlingAndApplyChanges();
- wasSuspended = true;
- }
-
- setText(text);
-
- if (wasSuspended) {
- mController.suspendCursorMovementHandling();
- }
- mBlockCompletion = false;
- }
- }
-
- @Override
- public Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
- if (superState instanceof TextView.SavedState) {
- // get rid of TextView's saved state, we override it.
- superState = ((TextView.SavedState) superState).getSuperState();
- }
- if (superState == null) {
- superState = AbsSavedState.EMPTY_STATE;
- }
- return mController.saveInstanceState(superState);
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- super.onRestoreInstanceState(mController.restoreInstanceState(state));
- }
-
- public void addQueryTextWatcher(final SuggestedTextController.TextChangeWatcher watcher) {
- mController.addUserTextChangeWatcher(watcher);
- }
-
- public void setSuggestedText(String text) {
- if (!TextUtils.isEmpty(text)) {
- String htmlStripped = Html.fromHtml(text).toString();
- mController.setSuggestedText(htmlStripped);
- } else {
- mController.setSuggestedText(null);
- }
- }
-
- public void getPopupDrawableRect(Rect rect) {
- if (mPopup.getListView() != null) {
- mPopup.getListView().getDrawingRect(rect);
- }
- }
-}
diff --git a/src/com/android/browser/preferences/LabPreferencesFragment.java b/src/com/android/browser/preferences/LabPreferencesFragment.java
index ca3a86a..222b5fa 100644
--- a/src/com/android/browser/preferences/LabPreferencesFragment.java
+++ b/src/com/android/browser/preferences/LabPreferencesFragment.java
@@ -26,35 +26,11 @@
import com.android.browser.search.SearchEngine;
public class LabPreferencesFragment extends PreferenceFragment {
- private BrowserSettings mBrowserSettings;
- private Preference useInstantPref;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
- mBrowserSettings = BrowserSettings.getInstance();
-
// Load the XML preferences file
addPreferencesFromResource(R.xml.lab_preferences);
- useInstantPref = findPreference(PreferenceKeys.PREF_USE_INSTANT_SEARCH);
}
-
- @Override
- public void onResume() {
- super.onResume();
- if (useInstantPref != null) {
- useInstantPref.setEnabled(false);
-
- // Enable the "use instant" preference only if the selected
- // search engine is google.
- if (mBrowserSettings.getSearchEngine() != null) {
- final String currentName = mBrowserSettings.getSearchEngine().getName();
- if (SearchEngine.GOOGLE.equals(currentName)) {
- useInstantPref.setEnabled(true);
- }
- }
- }
- }
-
}
diff --git a/src/com/android/browser/search/SearchEngines.java b/src/com/android/browser/search/SearchEngines.java
index fd967f9..433e877 100644
--- a/src/com/android/browser/search/SearchEngines.java
+++ b/src/com/android/browser/search/SearchEngines.java
@@ -15,8 +15,6 @@
*/
package com.android.browser.search;
-import com.android.browser.BrowserSettings;
-import com.android.browser.InstantSearchEngine;
import com.android.browser.R;
import android.content.Context;
@@ -32,10 +30,6 @@
private static final String TAG = "SearchEngines";
public static SearchEngine getDefaultSearchEngine(Context context) {
- if (BrowserSettings.getInstance().useInstantSearch()) {
- return new InstantSearchEngine(context, DefaultSearchEngine.create(context));
- }
-
return DefaultSearchEngine.create(context);
}
diff --git a/tests/assets/bindings_test.html b/tests/assets/bindings_test.html
deleted file mode 100755
index 7218f58..0000000
--- a/tests/assets/bindings_test.html
+++ /dev/null
@@ -1,239 +0,0 @@
-<html>
-<head>
-<script type="text/javascript">
-
-function testPrimitiveTypes() {
- return JNIBindingsTest.testPrimitiveTypes(100, 'c', 123.34567890, 456.789, 1234567, 1234567890, 6000, true);
-}
-
-function testObjectTypes() {
- return JNIBindingsTest.testObjectTypes("Foo", "", null, {"foo":"bar"}, {});
-}
-
-function testArray() {
- return JNIBindingsTest.testArray([1,2,3], ['d', 'o', 'g'], [1.2, 2.3, 3.4], [4.5,5.6,6.7], [1,2,3], [4,5,6], [7,8,9], [true, false]);
-}
-
-function testObjectArray() {
- return JNIBindingsTest.testObjectArray(['Hello', 'World', '!'], [], [{"foo":"bar"}]);
-}
-
-function testObjectMembers() {
- var foo = {"bool":true,
- "byte":101,
- "char":'d',
- "double":123.456,
- "float":456.789,
- "int":102,
- "long":103,
- "short":104,
- "string":"Hello World",
- "array": [1,2,3],
- "objArray":["foo", "bar", "baz"],
- "object": {"foo":1}
- };
- return JNIBindingsTest.testObjectMembers(foo.bool, foo.byte, foo.char, foo.double, foo.float, foo.int, foo.long, foo.short, foo.string, foo.array, foo.objArray, foo.object);
-}
-
-function testJSPrimitivesToStringsInJava() {
- return JNIBindingsTest.testJSPrimitivesToStringsInJava(123, null, 456.789, true, 'd', undefined);
-}
-
-function testJavaReturnTypes() {
- var expectedBoolReturn = true;
- var expectedByteReturn = 1;
- var expectedCharReturn = 98; // 'b'; Currently bindings in JSC and V8 return chars as their ASCII equivalent.
- var expectedDoubleReturn = 123.456;
- var expectedFloatReturn = 456.789;
- var expectedIntReturn = 123;
- var expectedLongReturn = 1234;
- var expectedShortReturn = 12345;
- var expectedStringReturn = "Hello World!";
-
- var returned = JNIBindingsTest.returnBool();
- if (returned != expectedBoolReturn) {
- appendLog("returnBool() failed: expected "+ expectedBoolReturn +", got " + returned);
- return false;
- }
-
- returned = JNIBindingsTest.returnByte();
- if (returned != expectedByteReturn) {
- appendLog("returnByte() failed: expected "+ expectedByteReturn +", got " + returned);
- return false;
- }
-
- returned = JNIBindingsTest.returnChar();
- if (returned != expectedCharReturn) {
- appendLog("returnChar() failed: expected "+ expectedCharReturn +", got " + returned);
- return false;
- }
-
- returned = JNIBindingsTest.returnDouble();
- if (returned != expectedDoubleReturn) {
- appendLog("returnDouble() failed: expected "+ expectedDoubleReturn +", got " + returned);
- return false;
- }
-
- returned = JNIBindingsTest.returnFloat();
- if (Math.abs(returned - expectedFloatReturn) > 0.001) {
- appendLog("returnFloat() failed: expected "+ expectedFloatReturn +", got " + returned);
- return false;
- }
-
- returned = JNIBindingsTest.returnInt();
- if (returned != expectedIntReturn) {
- appendLog("returnInt() failed: expected "+ expectedIntReturn +", got " + returned);
- return false;
- }
-
- returned = JNIBindingsTest.returnLong();
- if (returned != expectedLongReturn) {
- appendLog("returnLong() failed: expected "+ expectedLongReturn +", got " + returned);
- return false;
- }
-
- returned = JNIBindingsTest.returnShort();
- if (returned != expectedShortReturn) {
- appendLog("returnShort() failed: expected "+ expectedShortReturn +", got " + returned);
- return false;
- }
-
- returned = JNIBindingsTest.returnString();
- if (returned != expectedStringReturn) {
- appendLog("returnString() failed: expected "+ expectedStringReturn +", got " + returned);
- return false;
- }
-
- returned = JNIBindingsTest.returnNullString();
- if (returned !== undefined) {
- appendLog("returnNullString() failed: expected undefined, got " + returned);
- return false;
- }
-
- returned = JNIBindingsTest.returnObject();
- if (returned == null) {
- appendLog("returnObject() failed: expected non-null, got " + returned);
- return false;
- } else if (returned.x != undefined) {
- // We do not support getting object properties.
- appendLog("returnObject() failed: expected 'x' property undefined, got " + returned.x)
- return false;
- } else if (returned.s != undefined) {
- // We do not support getting object properties.
- appendLog("returnObject() failed: expected 's' property undefined, got " + returned.s);
- return false;
- } else if (!returned.aMethod()) {
- appendLog("returnObject() failed: expected 'aMethod' method to return true, got " + returned.aMethod());
- return false;
- } else if (returned.anotherMethod() != "Hello World") {
- appendLog("returnObject() failed: expected 'anotherMethod' to return 'Hello World' got "+ returned.anotherMethod());
- return false;
- }
-
- returned = JNIBindingsTest.returnArray();
- if (returned != null) {
- appendLog("returnArray() failed: expected null, got " + returned);
- return false;
- }
-
- returned = JNIBindingsTest.returnVoid();
- if (returned != null) {
- appendLog("returnVoid() failed: expected null, got " + returned);
- return false;
- }
-
- return true;
-}
-
-function getIfaceProperties() {
- if (JNIBindingsTest.mInt != undefined) {
- // We do not support getting object properties.
- appendLog("getIfaceProperties() failed: expected mInt = undefined, got " + JNIBindingsTest.mInt);
- return false;
- }
-
- if (JNIBindingsTest.mString != undefined) {
- // We do not support getting object properties.
- appendLog("getIfaceProperties() failed: expected mString = undefined, got " + JNIBindingsTest.mString);
- return false;
- }
-
- return true;
-}
-
-function testParameterTypeMismatch() {
- return JNIBindingsTest.testParameterTypeMismatch("dog");
-}
-
-function appendLog(msg) {
- var log = document.getElementById("status");
- log.innerHTML += "<br/>" + msg;
-}
-
-function runTests() {
-
- // Assume that if the test isn't done after 10s that we failed.
- window.setTimeout(function() { JNIBindingsTest.notifyComplete(); }, 10000);
-
- if (testPrimitiveTypes()) {
- appendLog("testPrimitiveTypes passed!");
- } else {
- appendLog("testPrimtiveTypes failed!");
- }
-
- if (testObjectTypes()) {
- appendLog("testObjectTypes passed!");
- } else {
- appendLog("testObjectTypes failed!");
- }
-
- if (testArray()) {
- appendLog("testArray passed!");
- } else {
- appendLog("testArray failed!");
- }
-
- if (testObjectArray()) {
- appendLog("testObjectArray passed!");
- } else {
- appendLog("testObjectArray failed!");
- }
-
- if (testObjectMembers()) {
- appendLog("testObjectMembers passed!");
- } else {
- appendLog("<br/>testObjectMembers failed!");
- }
-
- if (testJSPrimitivesToStringsInJava()) {
- appendLog("testJSPrimitivesToStringsInJava passed!");
- } else {
- appendLog("testJSPrimitivesToStringsInJava failed!");
- }
-
- if (testJavaReturnTypes()) {
- appendLog("testJavaReturnTypes passed!");
- } else {
- appendLog("testJavaReturnTypes failed!");
- }
-
- if (getIfaceProperties()) {
- appendLog("getIfaceProperties passed!");
- } else {
- appendLog("getIfaceProperties failed!");
- }
-
- if (testParameterTypeMismatch()) {
- appendLog("testParameterTypeMismatch passed!");
- } else {
- appendLog("testParameterTypeMismatch failed!");
- }
-
- JNIBindingsTest.notifyComplete();
-}
-</script>
-
-<body onload="runTests();">
-<p id="status">Running JNI Bindings test...</p>
-</body>
-</html>
diff --git a/tests/src/com/android/browser/JNIBindingsTest.java b/tests/src/com/android/browser/JNIBindingsTest.java
deleted file mode 100644
index ae694c9..0000000
--- a/tests/src/com/android/browser/JNIBindingsTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.browser;
-
-import android.test.AndroidTestCase;
-import android.util.Log;
-
-import java.util.Arrays;
-
-import junit.framework.AssertionFailedError;
-
-public class JNIBindingsTest extends AndroidTestCase {
-
- private final static String LOGTAG = "JNIBindingsTest";
- private JNIBindingsTestApp mTestApp;
-
- public int mInt = 123;
- public String mString = "Hello World";
-
- public JNIBindingsTest(JNIBindingsTestApp testApp) {
- mTestApp = testApp;
- }
-
- public void notifyComplete() {
- Log.v(LOGTAG, "Completing the test.");
- mTestApp.notifyComplete();
- }
-
- public void printAssertionFailed(AssertionFailedError e) {
- Log.e(LOGTAG, "");
- Log.e(LOGTAG, "*** ASSERTION FAILED: " + e.getMessage());
- Log.e(LOGTAG, "*** Stack trace:");
- StackTraceElement[] trace = e.getStackTrace();
- for(StackTraceElement elem : trace) {
- Log.e(LOGTAG, "***\t" + elem.toString());
- }
- Log.e(LOGTAG, "");
- }
-
- public boolean testPrimitiveTypes(byte byteParam, char charParam, double doubleParam,
- float floatParam, int intParam, long longParam, short shortParam,
- boolean booleanParam) {
- byte expectedByteParam = 100;
- char expectedCharParam = 'c';
- double expectedDoubleParam = 123.34567890;
- float expectedFloatParam = 456.789f;
- int expectedIntParam = 1234567;
- long expectedLongParam = 1234567890L;
- short expectedShortParam = 6000;
- boolean expectedBooleanParam = true;
-
- try {
- assertEquals(expectedByteParam, byteParam);
-
- // EMULATE_JSC_BINDINGS: JSC does not pass chars correctly
- // assertEquals(expectedCharParam, charParam);
-
- assertEquals(expectedDoubleParam, doubleParam);
- assertEquals(expectedFloatParam, floatParam);
- assertEquals(expectedIntParam, intParam);
- assertEquals(expectedLongParam, longParam);
- assertEquals(expectedShortParam, shortParam);
- assertEquals(expectedBooleanParam, booleanParam);
- } catch (AssertionFailedError e) {
- printAssertionFailed(e);
- return false;
- }
- return true;
- }
-
- public boolean testObjectTypes(String stringParam, String emptyString, String nullString,
- Object objectParam, Object emptyObject) {
- String expectedString = "Foo";
- String expectedEmptyString = "";
-
- try {
- assertNotNull(stringParam);
- assertNotNull(emptyString);
- assertEquals(expectedString, stringParam);
- assertEquals(expectedEmptyString, emptyString);
- assertNull(nullString);
- assertNull(objectParam);
- assertNull(emptyObject);
- } catch (AssertionFailedError e) {
- printAssertionFailed(e);
- return false;
- }
- return true;
- }
-
- public boolean testArray(byte[] byteArray, char[] charArray, double[] doubleArray,
- float[] floatArray, int[] intArray, long[] longArray, short[] shortArray,
- boolean[] booleanArray) {
- byte[] expectedByteArray = { 1,2,3};
- char[] expectedCharArray = {'d', 'o', 'g'};
- double[] expectedDoubleArray = {1.2,2.3,3.4};
- float[] expectedFloatArray = {4.5F,5.6F,6.7F};
- int[] expectedIntArray = {1,2,3};
- long[] expectedLongArray = {4L,5L,6L};
- short[] expectedShortArray = {7,8,9};
- boolean[] expectedBooleanArray = {true, false};
-
- try {
- assertNotNull(byteArray);
- assertNotNull(charArray);
- assertNotNull(doubleArray);
- assertNotNull(floatArray);
- assertNotNull(intArray);
- assertNotNull(longArray);
- assertNotNull(shortArray);
- assertNotNull(booleanArray);
- assertEquals(Arrays.toString(expectedByteArray), Arrays.toString(byteArray));
- assertEquals(Arrays.toString(expectedCharArray), Arrays.toString(charArray));
- assertEquals(Arrays.toString(expectedDoubleArray), Arrays.toString(doubleArray));
- assertEquals(Arrays.toString(expectedFloatArray), Arrays.toString(floatArray));
- assertEquals(Arrays.toString(expectedIntArray), Arrays.toString(intArray));
- assertEquals(Arrays.toString(expectedLongArray), Arrays.toString(longArray));
- assertEquals(Arrays.toString(expectedShortArray), Arrays.toString(shortArray));
- assertEquals(Arrays.toString(expectedBooleanArray), Arrays.toString(booleanArray));
- } catch (AssertionFailedError e) {
- printAssertionFailed(e);
- return false;
- }
- return true;
- }
-
- public boolean testObjectArray(String[] stringArray, Object[] emptyArray,
- Object[] objectArray) {
- String[] expectedStringArray = {"Hello", "World", "!"};
- String expectedStringArrayClassName = "[Ljava.lang.String;";
- Object[] expectedObjectArray = {};
-
- try {
- assertNotNull(stringArray);
-
- // EMULATE_JSC_BINDINGS JSC pass null for object arrays that are not strings.
- // Should be an empty array?
- assertNull(emptyArray);
- assertNull(objectArray);
-
- assertEquals(Arrays.toString(expectedStringArray), Arrays.toString(stringArray));
- assertEquals(expectedStringArrayClassName, stringArray.getClass().getName());
-
- // EMULATE_JSC_BINDINGS
- // assertEquals(Arrays.toString(expectedObjectArray), Arrays.toString(emptyArray));
- // assertEquals(expectedObjectArrayClassName, emptyArray.getClass().getName());
- // assertEquals(Arrays.toString(expectedObjectArray), Arrays.toString(objectArray));
- // assertEquals(expectedStringObjectClassName, objectArray.getClass().getName());
-
- } catch (AssertionFailedError e) {
- printAssertionFailed(e);
- return false;
- }
- return true;
- }
-
- public boolean testObjectMembers(boolean boolParam, byte byteParam, char charParam,
- double doubleParam, float floatParam, int intParam, long longParam, short shortParam,
- String stringParam, int[] intArrayParam, String[] stringArrayParam,
- Object objectParam) {
- boolean expectedBoolParam = true;
- byte expectedByteParam = 101;
- char expectedCharParam = 'd';
- double expectedDoubleParam = 123.456;
- float expectedFloatParam = 456.789F;
- int expectedIntParam = 102;
- long expectedLongParam = 103L;
- short expectedShortParam = 104;
- String expectedStringParam = "Hello World";
- int[] expectedIntArray = {1,2,3};
- String[] expectedStringArrayParam = {"foo", "bar", "baz"};
- String expectedStringArrayClassName = "[Ljava.lang.String;";
-
- try {
- assertEquals(expectedBoolParam, boolParam);
- assertEquals(expectedByteParam, byteParam);
-
- // EMULATE_JSC_BINDINGS: JSC does not pass chars correctly. (chars are strings in JS)
- // assertEquals(expectedCharParam, charParam);
-
- assertEquals(expectedDoubleParam, doubleParam);
- assertEquals(expectedFloatParam, floatParam);
- assertEquals(expectedIntParam, intParam);
- assertEquals(expectedLongParam, longParam);
- assertEquals(expectedShortParam, shortParam);
- assertEquals(expectedStringParam, stringParam);
- assertEquals(Arrays.toString(expectedIntArray), Arrays.toString(intArrayParam));
- assertEquals(Arrays.toString(expectedStringArrayParam),
- Arrays.toString(stringArrayParam));
- assertEquals(expectedStringArrayClassName, stringArrayParam.getClass().getName());
- assertNull(objectParam);
- } catch (AssertionFailedError e) {
- printAssertionFailed(e);
- return false;
- }
- return true;
- }
-
- public boolean testJSPrimitivesToStringsInJava(String intParam, String nullParam,
- String doubleParam, String booleanParam, String charParam,
- String undefinedParam) {
- String expectedIntParam = "123";
- String expectedDoubleParam = "456.789";
- String expectedBooleanParam = "true";
- String expectedCharParam = "d";
-
- // EMULATE_JSC_BINDINGS JSC passes "undefined" for undefined types. Should be null?
- String expectedUndefinedParam = "undefined";
-
- try {
- assertNotNull(intParam);
- assertNull(nullParam);
- assertNotNull(doubleParam);
- assertNotNull(booleanParam);
- assertNotNull(charParam);
-
- // EMULATE_JSC_BINDINGS JSC passes "undefined" for undefined types.
- assertNotNull(undefinedParam);
-
- assertEquals(expectedIntParam, intParam);
- assertEquals(expectedDoubleParam, doubleParam);
- assertEquals(expectedBooleanParam, booleanParam);
- assertEquals(expectedCharParam, charParam);
-
- // EMULATE_JSC_BINDINGS JSC passes "undefined" for undefined types.
- assertEquals(expectedUndefinedParam, undefinedParam);
-
- } catch (AssertionFailedError e) {
- printAssertionFailed(e);
- return false;
- }
- return true;
- }
-
- public boolean testParameterTypeMismatch(String[] stringArrayParam) {
- // The JS test will pass a string, not an array to this test.
- try {
- assertNull(stringArrayParam);
- } catch (AssertionFailedError e) {
- printAssertionFailed(e);
- return false;
- }
-
- return true;
- }
-
- public boolean returnBool() { return true; }
- public byte returnByte() { return 1; }
- public char returnChar() { return 'b'; }
- public double returnDouble() { return 123.456; }
- public float returnFloat() { return 456.789F; }
- public int returnInt() { return 123; }
- public long returnLong() { return 1234L; }
- public short returnShort() { return 12345; }
- public String returnString() { return "Hello World!"; }
- public String returnNullString() { return null; }
-
- public class TestObject {
- public int x = 123;
- public String s = "Hello World!";
-
- public boolean aMethod() { return true; }
- public String anotherMethod() { return "Hello World"; }
- }
-
- public TestObject returnObject() { return new TestObject(); }
-
- public int[] returnArray() {
- int[] array = {1,2,3,4,5};
- return array;
- }
-
- public void returnVoid() { }
-}
diff --git a/tests/src/com/android/browser/JNIBindingsTestApp.java b/tests/src/com/android/browser/JNIBindingsTestApp.java
deleted file mode 100644
index 5d1fd0d..0000000
--- a/tests/src/com/android/browser/JNIBindingsTestApp.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-package com.android.browser;
-
-import android.app.Instrumentation;
-import android.net.http.SslError;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.test.ActivityInstrumentationTestCase2;
-import android.util.Log;
-import android.webkit.ClientCertRequestHandler;
-import android.webkit.JsPromptResult;
-import android.webkit.JsResult;
-import android.webkit.SslErrorHandler;
-import android.webkit.WebView;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Adds a JavaScript interface to the webview and calls functions on it to verify variables
- * are passed from JS to Java correctly.
- * To run this test, execute:
- * adb shell am instrument -w -e class com.android.browser.JNIBindingsTestApp#testJNIBindings \
- * com.android.browser.tests/android.test.InstrumentationTestRunner
- */
-public class JNIBindingsTestApp extends ActivityInstrumentationTestCase2<BrowserActivity> {
-
- private final static String TAG = "JNIBindingsTest";
-
- private static final String SDCARD_BINDINGS_TEST_HTML = "/sdcard/bindings_test.html";
-
- private static final int MSG_WEBKIT_DATA_READY = 101;
-
- private BrowserActivity mActivity = null;
- private Controller mController = null;
- private Instrumentation mInst = null;
-
- private boolean mTestDone = false;
- private String mWebKitResult;
-
- private String mExpectedWebKitResult = "Running JNI Bindings test...\n" +
- "testPrimitiveTypes passed!\n" +
- "testObjectTypes passed!\n" +
- "testArray passed!\n" +
- "testObjectArray passed!\n" +
- "testObjectMembers passed!\n" +
- "testJSPrimitivesToStringsInJava passed!\n" +
- "testJavaReturnTypes passed!\n" +
- "getIfaceProperties passed!\n" +
- "testParameterTypeMismatch passed!\n";
-
-
- private class GetWebKitDataThread extends Thread {
- private JNIBindingsTestApp mTestApp;
- private WebView mWebView;
- private Handler mHandler;
-
- GetWebKitDataThread(JNIBindingsTestApp testApp, WebView webView) {
- mTestApp = testApp;
- mWebView = webView;
- }
-
- @Override
- public void run() {
- Looper.prepare();
- mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_WEBKIT_DATA_READY: {
- mTestApp.setWebKitResult((String)msg.obj);
- Looper.myLooper().quit();
- }
- default: super.handleMessage(msg); break;
- }
- }
- };
- mWebView.documentAsText(mHandler.obtainMessage(MSG_WEBKIT_DATA_READY, 1, 0));
- Looper.loop();
- }
- }
-
- public synchronized void setWebKitResult(String result) {
- mWebKitResult = result;
- notify();
- }
-
- public JNIBindingsTestApp() {
- super(BrowserActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- mActivity = getActivity();
- mController = mActivity.getController();
- mInst = getInstrumentation();
- mInst.waitForIdleSync();
-
- extractAsset();
- }
-
- @Override
- protected void tearDown() throws Exception {
- removeAsset();
- super.tearDown();
- }
-
- protected void extractAsset() throws IOException {
- InputStream in = getInstrumentation().getContext().getAssets().open("bindings_test.html");
- OutputStream out = new FileOutputStream(SDCARD_BINDINGS_TEST_HTML);
-
- byte[] buf = new byte[2048];
- int len;
-
- while ((len = in.read(buf)) >= 0 ) {
- out.write(buf, 0, len);
- }
- out.close();
- in.close();
- }
-
- protected void removeAsset(){
- File fileToDelete = new File(SDCARD_BINDINGS_TEST_HTML);
- fileToDelete.delete();
- }
-
- /**
- * Gets the browser ready for testing by starting the application
- * and wrapping the WebView's helper clients.
- */
- void setUpBrowser() {
- Tab tab = mController.getTabControl().getCurrentTab();
- WebView webView = tab.getWebView();
- webView.addJavascriptInterface(new JNIBindingsTest(this), "JNIBindingsTest");
-
- webView.setWebChromeClient(new TestWebChromeClient(webView.getWebChromeClient()) {
-
- /**
- * Dismisses and logs Javascript alerts.
- */
- @Override
- public boolean onJsAlert(WebView view, String url, String message,
- JsResult result) {
- String logMsg = String.format("JS Alert '%s' received from %s", message, url);
- Log.w(TAG, logMsg);
- result.confirm();
-
- return true;
- }
-
- /**
- * Confirms and logs Javascript alerts.
- */
- @Override
- public boolean onJsConfirm(WebView view, String url, String message,
- JsResult result) {
- String logMsg = String.format("JS Confirmation '%s' received from %s",
- message, url);
- Log.w(TAG, logMsg);
- result.confirm();
-
- return true;
- }
-
- /**
- * Confirms and logs Javascript alerts, providing the default value.
- */
- @Override
- public boolean onJsPrompt(WebView view, String url, String message,
- String defaultValue, JsPromptResult result) {
- String logMsg = String.format("JS Prompt '%s' received from %s; " +
- "Giving default value '%s'", message, url, defaultValue);
- Log.w(TAG, logMsg);
- result.confirm(defaultValue);
-
- return true;
- }
- });
-
- webView.setWebViewClient(new TestWebViewClient(webView.getWebViewClient()) {
-
- /**
- * Bypasses and logs errors.
- */
- @Override
- public void onReceivedError(WebView view, int errorCode,
- String description, String failingUrl) {
- String message = String.format("Error '%s' (%d) loading url: %s",
- description, errorCode, failingUrl);
- Log.w(TAG, message);
- }
-
- /**
- * Ignores and logs SSL errors.
- */
- @Override
- public void onReceivedSslError(WebView view, SslErrorHandler handler,
- SslError error) {
- Log.w(TAG, "SSL error: " + error);
- handler.proceed();
- }
-
- /**
- * Ignores and logs SSL client certificate requests.
- */
- @Override
- public void onReceivedClientCertRequest(WebView view, ClientCertRequestHandler handler,
- String host_and_port) {
- Log.w(TAG, "SSL client certificate request: " + host_and_port);
- handler.cancel();
- }
-
- });
- }
-
- public synchronized void notifyComplete() {
- mTestDone = true;
- notify();
- }
-
- public void testJNIBindings() {
- setUpBrowser();
-
- Tab tab = mController.getTabControl().getCurrentTab();
- WebView webView = tab.getWebView();
- webView.loadUrl("file://" + SDCARD_BINDINGS_TEST_HTML);
- synchronized(this) {
- while(!mTestDone) {
- try {
- wait();
- } catch (InterruptedException e) {}
- }
- }
-
- // Now the tests are complete grab the DOM content and compare to the reference.
- GetWebKitDataThread getWKData = new GetWebKitDataThread(this, webView);
- mWebKitResult = null;
- getWKData.start();
-
- synchronized(this) {
- while(mWebKitResult == null) {
- try {
- wait();
- } catch (InterruptedException e) {}
- }
- }
-
- Log.v(TAG, "WebKit result:");
- Log.v(TAG, mWebKitResult);
- assertEquals("Bindings test failed! See logcat for more details!", mExpectedWebKitResult,
- mWebKitResult);
- }
-}
diff --git a/tests/src/com/android/browser/autocomplete/SuggestedTextControllerTest.java b/tests/src/com/android/browser/autocomplete/SuggestedTextControllerTest.java
deleted file mode 100644
index f162e3b..0000000
--- a/tests/src/com/android/browser/autocomplete/SuggestedTextControllerTest.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * Copyright (C) 2011 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.
- */
-package com.android.browser.autocomplete;
-
-import com.android.browser.autocomplete.SuggestedTextController.TextOwner;
-
-import android.graphics.Color;
-import android.os.Parcelable;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.text.Editable;
-import android.text.Selection;
-import android.text.Spannable;
-import android.text.SpannableStringBuilder;
-import android.text.TextWatcher;
-import android.view.AbsSavedState;
-
-/**
- * Test cases for {@link SuggestedTextController}.
- */
-@SmallTest
-public class SuggestedTextControllerTest extends AndroidTestCase {
-
- // these two must have a common prefix (but not be identical):
- private static final String RUBY_MURRAY = "ruby murray";
- private static final String RUBY_TUESDAY = "ruby tuesday";
- private static final String EXTRA_USER_TEXT = " curry";
- // no common prefix with the top two above:
- private static final String TOD_SLOAN = "tod sloan";
-
- private SuggestedTextController mController;
- private SpannableStringBuilder mString;
-
- private SuggestedTextController m2ndController;
- private SpannableStringBuilder m2ndString;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- mString = new SpannableStringBuilder();
- Selection.setSelection(mString, 0); // position cursor
- mController = new SuggestedTextController(new BufferTextOwner(mString), Color.GRAY);
- checkInvariant();
- }
-
- private void create2ndController() {
- m2ndString = new SpannableStringBuilder();
- Selection.setSelection(m2ndString, 0); // position cursor
- m2ndController = new SuggestedTextController(new BufferTextOwner(m2ndString), Color.GRAY);
- check2ndInvariant();
- }
-
- private int cursorPos(Spannable string) {
- int selStart = Selection.getSelectionStart(string);
- int selEnd = Selection.getSelectionEnd(string);
- assertEquals("Selection has non-zero length", selStart, selEnd);
- return selEnd;
- }
-
- private int cursorPos() {
- return cursorPos(mString);
- }
-
- private void insertAtCursor(String text) {
- mString.insert(cursorPos(), text);
- checkInvariant();
- }
-
- private void insertAtCursor(char ch) {
- insertAtCursor(Character.toString(ch));
- }
-
- private void insertAt2ndCursor(String text) {
- m2ndString.insert(cursorPos(m2ndString), text);
- check2ndInvariant();
- }
-
- private void insertAt2ndCursor(char ch) {
- insertAt2ndCursor(Character.toString(ch));
- }
-
- private void deleteBeforeCursor(int count) {
- int pos = cursorPos();
- count = Math.min(pos, count);
- mString.delete(pos - count, pos);
- checkInvariant();
- }
-
- private void replaceSelection(String withThis) {
- mString.replace(Selection.getSelectionStart(mString),
- Selection.getSelectionEnd(mString), withThis);
- checkInvariant();
- }
-
- private void setSuggested(String suggested) {
- mController.setSuggestedText(suggested);
- checkInvariant();
- }
-
- private void set2ndSuggested(String suggested) {
- m2ndController.setSuggestedText(suggested);
- check2ndInvariant();
- }
-
- private void checkInvariant() {
- mController.checkInvariant(mString);
- }
-
- private void check2ndInvariant() {
- m2ndController.checkInvariant(m2ndString);
- }
-
- private void assertUserEntered(String expected, SuggestedTextController controller) {
- assertEquals("User entered text not as expected", expected, controller.getUserText());
- }
-
- private void assertUserEntered(String expected) {
- assertUserEntered(expected, mController);
- }
-
- private void assertBuffer(String expected, Editable string) {
- assertEquals("Buffer contents not as expected", expected, string.toString());
- }
-
- private void assertBuffer(String expected) {
- assertBuffer(expected, mString);
- }
-
- private void assertCursorPos(int where, Spannable string) {
- assertEquals("Cursor not at expected position", where, cursorPos(string));
- }
-
- private void assertCursorPos(int where) {
- assertCursorPos(where, mString);
- }
-
- private static final String commonPrefix(String a, String b) {
- int pos = 0;
- while (a.charAt(pos) == b.charAt(pos)) {
- pos++;
- }
- assertTrue("No common prefix between '" + a + "' and '" + b + "'", pos > 0);
- return a.substring(0, pos);
- }
-
- public void testTypeNoSuggested() {
- for (int i = 0; i < RUBY_MURRAY.length(); ++i) {
- assertCursorPos(i);
- assertUserEntered(RUBY_MURRAY.substring(0, i));
- assertBuffer(RUBY_MURRAY.substring(0, i));
- insertAtCursor(RUBY_MURRAY.substring(i, i + 1));
- }
- }
-
- public void testTypeSuggested() {
- setSuggested(RUBY_MURRAY);
- assertCursorPos(0);
- assertBuffer(RUBY_MURRAY);
- for (int i = 0; i < RUBY_MURRAY.length(); ++i) {
- assertCursorPos(i);
- assertUserEntered(RUBY_MURRAY.substring(0, i));
- assertBuffer(RUBY_MURRAY);
- insertAtCursor(RUBY_MURRAY.charAt(i));
- }
- }
-
- public void testSetSuggestedAfterTextEntry() {
- final int count = RUBY_MURRAY.length() / 2;
- for (int i = 0; i < count; ++i) {
- assertCursorPos(i);
- assertUserEntered(RUBY_MURRAY.substring(0, i));
- insertAtCursor(RUBY_MURRAY.substring(i, i + 1));
- }
- setSuggested(RUBY_MURRAY);
- assertUserEntered(RUBY_MURRAY.substring(0, count));
- assertBuffer(RUBY_MURRAY);
- }
-
- public void testTypeSuggestedUpperCase() {
- setSuggested(RUBY_MURRAY);
- assertCursorPos(0);
- for (int i = 0; i < RUBY_MURRAY.length(); ++i) {
- assertCursorPos(i);
- assertUserEntered(RUBY_MURRAY.substring(0, i).toUpperCase());
- assertTrue("Buffer doesn't contain suggested text",
- RUBY_MURRAY.equalsIgnoreCase(mString.toString()));
- insertAtCursor(Character.toUpperCase(RUBY_MURRAY.charAt(i)));
- }
- }
-
- public void testChangeSuggestedText() {
- String pref = commonPrefix(RUBY_MURRAY, RUBY_TUESDAY);
- setSuggested(RUBY_MURRAY);
- insertAtCursor(pref);
- assertBuffer(RUBY_MURRAY);
- assertUserEntered(pref);
- setSuggested(RUBY_TUESDAY);
- assertBuffer(RUBY_TUESDAY);
- assertUserEntered(pref);
- }
-
- public void testTypeNonSuggested() {
- setSuggested(RUBY_MURRAY);
- insertAtCursor(RUBY_MURRAY.charAt(0));
- assertBuffer(RUBY_MURRAY);
- insertAtCursor('x');
- assertBuffer("rx");
- }
-
- public void testTypeNonSuggestedThenNewSuggestion() {
- final String pref = commonPrefix(RUBY_MURRAY, RUBY_TUESDAY);
- setSuggested(RUBY_MURRAY);
- assertCursorPos(0);
- insertAtCursor(pref);
- assertCursorPos(pref.length());
- assertUserEntered(pref);
- insertAtCursor(RUBY_TUESDAY.charAt(pref.length()));
- assertBuffer(RUBY_TUESDAY.substring(0, pref.length() + 1));
- setSuggested(RUBY_TUESDAY);
- assertBuffer(RUBY_TUESDAY);
- }
-
- public void testChangeSuggestedToNonUserEntered() {
- final String half = RUBY_MURRAY.substring(0, RUBY_MURRAY.length() / 2);
- setSuggested(RUBY_MURRAY);
- insertAtCursor(half);
- setSuggested(TOD_SLOAN);
- assertUserEntered(half);
- assertBuffer(half);
- }
-
- public void testChangeSuggestedToUserEntered() {
- setSuggested(RUBY_MURRAY);
- insertAtCursor(TOD_SLOAN);
- setSuggested(TOD_SLOAN);
- assertUserEntered(TOD_SLOAN);
- assertBuffer(TOD_SLOAN);
- }
-
- public void testChangeSuggestedToEmpty() {
- final String half = RUBY_MURRAY.substring(0, RUBY_MURRAY.length() / 2);
- setSuggested(RUBY_MURRAY);
- insertAtCursor(half);
- setSuggested(null);
- assertUserEntered(half);
- assertBuffer(half);
- }
-
- public void testChangeSuggestedToEmptyFromUserEntered() {
- setSuggested(RUBY_MURRAY);
- insertAtCursor(RUBY_MURRAY);
- setSuggested(null);
- assertUserEntered(RUBY_MURRAY);
- assertBuffer(RUBY_MURRAY);
- }
-
- public void typeNonSuggestedThenDelete() {
- final String half = RUBY_MURRAY.substring(0, RUBY_MURRAY.length() / 2);
- assertCursorPos(0);
- insertAtCursor(half);
- assertCursorPos(half.length());
- setSuggested(RUBY_MURRAY);
- insertAtCursor('x');
- assertBuffer(half + "x");
- deleteBeforeCursor(1);
- assertUserEntered(half);
- assertBuffer(RUBY_MURRAY);
- }
-
- public void testDeleteMultipleFromSuggested() {
- final String twoThirds = RUBY_MURRAY.substring(0, (RUBY_MURRAY.length() * 2) / 3);
- setSuggested(RUBY_MURRAY);
- insertAtCursor(twoThirds);
- assertCursorPos(twoThirds.length());
- // select some of the text just entered:
- Selection.setSelection(mString, RUBY_MURRAY.length() / 3, twoThirds.length());
- // and delete it:
- replaceSelection("");
- assertCursorPos(RUBY_MURRAY.length() / 3);
- assertUserEntered(RUBY_MURRAY.substring(0, RUBY_MURRAY.length() / 3));
- assertBuffer(RUBY_MURRAY);
- }
-
- public void testDeleteMultipleToFormSuggested() {
- final String pref = commonPrefix(RUBY_TUESDAY, RUBY_MURRAY);
- final int extra = (RUBY_TUESDAY.length() - pref.length()) / 2;
- setSuggested(RUBY_MURRAY);
- insertAtCursor(RUBY_TUESDAY.substring(0, pref.length() + extra));
- assertCursorPos(pref.length() + extra);
- // select and delete extra characters, leaving just prefix
- Selection.setSelection(mString, pref.length(), pref.length() + extra);
- replaceSelection("");
- assertCursorPos(pref.length());
- assertBuffer(RUBY_MURRAY);
- assertUserEntered(pref);
- }
-
- public void testBackspaceWithinUserTextFromSuggested() {
- StringBuffer half = new StringBuffer(RUBY_MURRAY.substring(0, RUBY_MURRAY.length() / 2));
- insertAtCursor(half.toString());
- int backSpaceFrom = half.length() / 2;
- Selection.setSelection(mString, backSpaceFrom);
- deleteBeforeCursor(1);
- assertCursorPos(backSpaceFrom - 1);
- half.delete(backSpaceFrom - 1, backSpaceFrom);
- assertUserEntered(half.toString());
- assertBuffer(half.toString());
- }
-
- public void testInsertWithinUserTextToFormSuggested() {
- final String half = RUBY_MURRAY.substring(0, RUBY_MURRAY.length() / 2);
- StringBuffer initial = new StringBuffer(half);
- int pos = initial.length() / 2;
- char toInsert = initial.charAt(pos);
- initial.delete(pos, pos + 1);
- insertAtCursor(initial.toString());
- setSuggested(RUBY_MURRAY);
- assertUserEntered(initial.toString());
- assertBuffer(initial.toString());
- Selection.setSelection(mString, pos);
- insertAtCursor(toInsert);
- assertCursorPos(pos + 1);
- assertUserEntered(half);
- assertBuffer(RUBY_MURRAY);
- }
-
- public void testEnterTextBeyondSuggested() {
- setSuggested(RUBY_MURRAY);
- int i = RUBY_MURRAY.length() / 2;
- insertAtCursor(RUBY_MURRAY.substring(0, i));
- String query = RUBY_MURRAY + EXTRA_USER_TEXT;
- for (; i < query.length(); ++i) {
- assertUserEntered(query.substring(0, i));
- if (i <= RUBY_MURRAY.length()) {
- assertBuffer(RUBY_MURRAY);
- }
- insertAtCursor(query.charAt(i));
- }
- assertUserEntered(query);
- }
-
- public void testDeleteFromLongerThanSuggested() {
- setSuggested(RUBY_MURRAY);
- final String entered = RUBY_MURRAY + EXTRA_USER_TEXT;
- insertAtCursor(entered);
- for (int i = entered.length(); i > (RUBY_MURRAY.length() / 2); --i) {
- assertCursorPos(i);
- assertUserEntered(entered.substring(0, i));
- if (i <= RUBY_MURRAY.length()) {
- assertBuffer(RUBY_MURRAY);
- }
- deleteBeforeCursor(1);
- }
- }
-
- public void testReplaceWithShorterToFormSuggested() {
- final String pref = commonPrefix(RUBY_TUESDAY, RUBY_MURRAY);
- final int extra = (RUBY_TUESDAY.length() - pref.length()) / 2;
- setSuggested(RUBY_MURRAY);
- insertAtCursor(RUBY_TUESDAY.substring(0, pref.length() + extra));
- assertCursorPos(pref.length() + extra);
- // select and replace extra characters, to match suggested
- Selection.setSelection(mString, pref.length(), pref.length() + extra);
- replaceSelection(RUBY_MURRAY.substring(pref.length(), pref.length() + extra - 1));
- assertBuffer(RUBY_MURRAY);
- assertUserEntered(RUBY_MURRAY.substring(0, pref.length() + extra - 1));
- }
-
- public void testReplaceWithSameLengthToFormSuggested() {
- final String pref = commonPrefix(RUBY_TUESDAY, RUBY_MURRAY);
- final int extra = (RUBY_TUESDAY.length() - pref.length()) / 2;
- setSuggested(RUBY_MURRAY);
- insertAtCursor(RUBY_TUESDAY.substring(0, pref.length() + extra));
- assertCursorPos(pref.length() + extra);
- // select and replace extra characters, to match suggested
- Selection.setSelection(mString, pref.length(), pref.length() + extra);
- replaceSelection(RUBY_MURRAY.substring(pref.length(), pref.length() + extra));
- assertBuffer(RUBY_MURRAY);
- assertUserEntered(RUBY_MURRAY.substring(0, pref.length() + extra));
- }
-
- public void testReplaceWithLongerToFormSuggested() {
- final String pref = commonPrefix(RUBY_TUESDAY, RUBY_MURRAY);
- final int extra = (RUBY_TUESDAY.length() - pref.length()) / 2;
- setSuggested(RUBY_MURRAY);
- insertAtCursor(RUBY_TUESDAY.substring(0, pref.length() + extra));
- assertCursorPos(pref.length() + extra);
- // select and replace extra characters, to match suggested
- Selection.setSelection(mString, pref.length(), pref.length() + extra);
- replaceSelection(RUBY_MURRAY.substring(pref.length(), pref.length() + extra + 1));
- assertBuffer(RUBY_MURRAY);
- assertUserEntered(RUBY_MURRAY.substring(0, pref.length() + extra + 1));
- }
-
- public void testMoveCursorIntoSuggested() {
- final String half = RUBY_MURRAY.substring(0, RUBY_MURRAY.length() / 2);
- insertAtCursor(half);
- setSuggested(RUBY_MURRAY);
- assertCursorPos(half.length());
- Selection.setSelection(mString, half.length() + 1);
- checkInvariant();
- assertUserEntered(RUBY_MURRAY);
- }
-
- public void testMoveCursorWithinUserEntered() {
- final String half = RUBY_MURRAY.substring(0, RUBY_MURRAY.length() / 2);
- insertAtCursor(half);
- setSuggested(RUBY_MURRAY);
- assertCursorPos(half.length());
- Selection.setSelection(mString, half.length() - 1);
- checkInvariant();
- assertUserEntered(half);
- }
-
- public void testSelectWithinSuggested() {
- final String half = RUBY_MURRAY.substring(0, RUBY_MURRAY.length() / 2);
- insertAtCursor(half);
- setSuggested(RUBY_MURRAY);
- assertCursorPos(half.length());
- Selection.setSelection(mString, half.length() + 1, half.length() + 2);
- checkInvariant();
- assertUserEntered(RUBY_MURRAY);
- }
-
- public void testSelectStraddlingSuggested() {
- final String half = RUBY_MURRAY.substring(0, RUBY_MURRAY.length() / 2);
- insertAtCursor(half);
- setSuggested(RUBY_MURRAY);
- assertCursorPos(half.length());
- Selection.setSelection(mString, half.length() - 1, half.length() + 1);
- checkInvariant();
- assertUserEntered(RUBY_MURRAY);
- }
-
- public void testSaveAndRestoreNoText() {
- create2ndController();
- Parcelable state = mController.saveInstanceState(AbsSavedState.EMPTY_STATE);
- m2ndController.restoreInstanceState(state);
- check2ndInvariant();
- assertBuffer("", m2ndString);
- }
-
- public void testSaveAndRestoreWithSuggestedText() {
- create2ndController();
- setSuggested(TOD_SLOAN);
- Parcelable state = mController.saveInstanceState(AbsSavedState.EMPTY_STATE);
- m2ndController.restoreInstanceState(state);
- check2ndInvariant();
- assertBuffer(TOD_SLOAN, m2ndString);
- assertUserEntered("", m2ndController);
- }
-
- public void testSaveAndRestoreWithUserEnteredAndSuggestedText() {
- final String half = TOD_SLOAN.substring(0, TOD_SLOAN.length() / 2);
- create2ndController();
- setSuggested(TOD_SLOAN);
- insertAtCursor(half);
- Parcelable state = mController.saveInstanceState(AbsSavedState.EMPTY_STATE);
- m2ndController.restoreInstanceState(state);
- check2ndInvariant();
- assertBuffer(TOD_SLOAN, m2ndString);
- assertUserEntered(half, m2ndController);
- assertCursorPos(half.length(), m2ndString);
- }
-
- public void testSaveAndRestoreWithNonSuggested() {
- final String half = TOD_SLOAN.substring(0, TOD_SLOAN.length() / 2);
- create2ndController();
- setSuggested(RUBY_MURRAY);
- insertAtCursor(half);
- Parcelable state = mController.saveInstanceState(AbsSavedState.EMPTY_STATE);
- m2ndController.restoreInstanceState(state);
- check2ndInvariant();
- assertBuffer(half, m2ndString);
- assertUserEntered(half, m2ndController);
- assertCursorPos(half.length(), m2ndString);
- }
-
- public void testSaveAndRestoreThenTypeSuggested() {
- final String half = TOD_SLOAN.substring(0, TOD_SLOAN.length() / 2);
- create2ndController();
- set2ndSuggested(TOD_SLOAN);
- insertAt2ndCursor(half);
- insertAt2ndCursor('x');
- Parcelable state = m2ndController.saveInstanceState(AbsSavedState.EMPTY_STATE);
- mController.restoreInstanceState(state);
- assertCursorPos(half.length() + 1);
- // delete the x
- deleteBeforeCursor(1);
- assertCursorPos(half.length());
- assertBuffer(TOD_SLOAN);
- assertUserEntered(half);
- }
-
- public void testSuspendAndResumeCursorProcessing() {
- final String half = TOD_SLOAN.substring(0, TOD_SLOAN.length() / 2);
- setSuggested(TOD_SLOAN);
- insertAtCursor(half);
- mController.suspendCursorMovementHandling();
- Selection.setSelection(mString, TOD_SLOAN.length());
- Selection.setSelection(mString, half.length());
- mController.resumeCursorMovementHandlingAndApplyChanges();
- assertCursorPos(half.length());
- assertUserEntered(half);
- assertBuffer(TOD_SLOAN);
- }
-
- private static class BufferTextOwner implements TextOwner {
-
- private final Editable mBuffer;
-
- public BufferTextOwner(Editable buffer) {
- mBuffer = buffer;
- }
-
- public void addTextChangedListener(TextWatcher watcher) {
- mBuffer.setSpan(watcher , 0, mBuffer.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
- }
-
- public void removeTextChangedListener(TextWatcher watcher) {
- mBuffer.removeSpan(watcher);
- }
-
- public Editable getText() {
- return mBuffer;
- }
-
- public void setText(String text) {
- mBuffer.replace(0, mBuffer.length(), text);
- }
-
- }
-
-}