am ccd78601: Merge "Set home button enabled" into ics-mr1
* commit 'ccd78601a934cf1ffafe5854a1d465c273727f69':
Set home button enabled
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/values-de/strings.xml b/res/values-de/strings.xml
index 00b314e..6654574 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -153,7 +153,7 @@
<string name="pref_general_title" msgid="1946872771219249323">"Allgemein"</string>
<string name="pref_general_sync_title" msgid="3138637035975860324">"Synchronisierung"</string>
<string name="pref_general_autofill_title" msgid="547881256865816858">"AutoFill"</string>
- <string name="pref_autofill_enabled" msgid="1015751713312396713">"Formular autom. ausf."</string>
+ <string name="pref_autofill_enabled" msgid="1015751713312396713">"Automatisch ausfüllen"</string>
<string name="pref_autofill_enabled_summary" msgid="7659954073892471496">"Webformulare mit einer einzigen Berührung ausfüllen"</string>
<string name="pref_autofill_profile_editor" msgid="8934844472922113166">"AutoFill-Text"</string>
<string name="pref_autofill_profile_editor_summary" msgid="4864447251676856190">"AutoFill-Text für Webformulare einrichten"</string>
diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml
index 656d1b1..9d5825a 100644
--- a/res/values-iw/strings.xml
+++ b/res/values-iw/strings.xml
@@ -69,7 +69,7 @@
<string name="add_to_other_folder_menu_option" msgid="5947586525822134105">"תיקיה אחרת"</string>
<string name="name" msgid="5462672162695365387">"תווית"</string>
<string name="http" msgid="2163722670597250102">"http://"</string>
- <string name="save_to_bookmarks" msgid="1679286010089780932">"שמור בסימניות."</string>
+ <string name="save_to_bookmarks" msgid="1679286010089780932">"שמור בסימניות"</string>
<string name="bookmark_this_page" msgid="7530739804320811054">"הוסף דף זה לסימניות"</string>
<string name="remove" msgid="7820112494467011374">"הסר"</string>
<string name="edit_bookmark" msgid="5024089053490231905">"ערוך סימניה"</string>
@@ -145,7 +145,7 @@
<item msgid="844041670142910837">"דף נוכחי"</item>
<item msgid="4430498748295169195">"דף ריק"</item>
<item msgid="5747608191946904074">"דף ברירת מחדל"</item>
- <item msgid="6092441301001006473">"האתרים שבהם ביקרת בתדירות גבוהה"</item>
+ <item msgid="6092441301001006473">"האתרים הפופולריים ביותר"</item>
<item msgid="6569304572171444894">"אחר"</item>
</string-array>
<string name="pref_content_autofit" msgid="8260474534053660809">"התאם דפים באופן אוטומטי"</string>
@@ -238,7 +238,7 @@
<string-array name="pref_default_zoom_choices">
<item msgid="549583171195154919">"רחוק"</item>
<item msgid="5619034257768161024">"בינוני"</item>
- <item msgid="3840999588443167001">"סגור"</item>
+ <item msgid="3840999588443167001">"קרוב"</item>
</string-array>
<string name="pref_default_zoom_dialogtitle" msgid="6095974367125109021">"ברירת מחדל של מרחק מתצוגה"</string>
<string name="pref_content_load_page" msgid="2219810141690955452">"פתח דפים בסקירה"</string>
@@ -303,14 +303,14 @@
<string name="too_many_windows_dialog_message" msgid="3644234634638290304">"לא ניתן לפתוח כרטיסיה חדשה עד לסגירת אחת הכרטיסיות."</string>
<string name="too_many_subwindows_dialog_title" msgid="3805453941587725944">"חלון קופץ כבר פתוח"</string>
<string name="too_many_subwindows_dialog_message" msgid="2164725447981195556">"רק חלון קופץ אחד יכול להיות פתוח בכל פעם."</string>
- <string name="download_no_sdcard_dlg_title" product="nosdcard" msgid="56777245081568508">"אמצעי אחסון מסוג USB אינו זמין"</string>
+ <string name="download_no_sdcard_dlg_title" product="nosdcard" msgid="56777245081568508">"אחסון USB אינו זמין"</string>
<string name="download_no_sdcard_dlg_title" product="default" msgid="605904452159416792">"אין כרטיס SD"</string>
- <string name="download_no_sdcard_dlg_msg" product="nosdcard" msgid="3144652102051031721">"דרוש אמצעי אחסון מסוג USB להורדה של <xliff:g id="FILENAME">%s</xliff:g>."</string>
+ <string name="download_no_sdcard_dlg_msg" product="nosdcard" msgid="3144652102051031721">"דרוש אחסון USB להורדה של <xliff:g id="FILENAME">%s</xliff:g>."</string>
<string name="download_no_sdcard_dlg_msg" product="default" msgid="2616399456116301518">"דרוש כרטיס SD כדי להוריד את <xliff:g id="FILENAME">%s</xliff:g>."</string>
- <string name="download_sdcard_busy_dlg_title" product="nosdcard" msgid="8081445664689818973">"אמצעי אחסון מסוג USB אינו זמין"</string>
+ <string name="download_sdcard_busy_dlg_title" product="nosdcard" msgid="8081445664689818973">"אחסון USB אינו זמין"</string>
<string name="download_sdcard_busy_dlg_title" product="default" msgid="6877712666046917741">"כרטיס SD לא זמין"</string>
- <string name="download_sdcard_busy_dlg_msg" product="nosdcard" msgid="8412543086906716875">"אחסון ה-USB אינו פנוי. כדי לאפשר הורדות, גע ב\"כבה אמצעי אחסון מסוג USB\" בהתראה."</string>
- <string name="download_sdcard_busy_dlg_msg" product="default" msgid="2629425950473358591">"כרטיס ה-SD אינו פנוי. כדי לאפשר הורדות, גע ב\"כבה אמצעי אחסון מסוג USB\" בהתראה."</string>
+ <string name="download_sdcard_busy_dlg_msg" product="nosdcard" msgid="8412543086906716875">"אחסון ה-USB אינו פנוי. כדי לאפשר הורדות, גע ב\"כבה אחסון USB\" בהתראה."</string>
+ <string name="download_sdcard_busy_dlg_msg" product="default" msgid="2629425950473358591">"כרטיס ה-SD אינו פנוי. כדי לאפשר הורדות, גע ב\"כבה אחסון USB\" בהתראה."</string>
<string name="cannot_download" msgid="8150552478556798780">"ניתן להוריד רק כתובות אתר המתחילות ב-\"http\" או \"https\"."</string>
<string name="download_pending" msgid="2599683668575349559">"מתחיל בהורדה..."</string>
<string name="help_page" msgid="2906208423557552540">"עזרה"</string>
diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml
index 4aa1f05..90e03c0 100644
--- a/res/values-vi/strings.xml
+++ b/res/values-vi/strings.xml
@@ -69,7 +69,7 @@
<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>
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/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/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);
- }
-}