Merge "Launch into browser when a URL is received over NFC."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2056176..51cf430 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -28,6 +28,7 @@
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
diff --git a/res/layout-port/autofill_settings_fragment.xml b/res/layout-port/autofill_settings_fragment.xml
new file mode 100644
index 0000000..63dba4d
--- /dev/null
+++ b/res/layout-port/autofill_settings_fragment.xml
@@ -0,0 +1,231 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="0px"
+ android:layout_weight="1">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <View
+ android:layout_height="10dip"
+ android:layout_width="match_parent" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/autofill_profile_editor_heading" />
+
+ <View
+ android:layout_height="12dip"
+ 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"
+ 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" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:layout_margin="2dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ 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" />
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="2dip"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/autofill_profile_editor_address_line_1" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ 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" />
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="2dip"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/autofill_profile_editor_address_line_2" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ 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" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:layout_margin="2dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ 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" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:layout_margin="2dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ 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" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:layout_margin="2dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ 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" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:layout_margin="2dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ 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" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:layout_margin="2dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ 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"
+ 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"
+ 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" />
+ </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 b92c149..8c90dd7 100644
--- a/res/layout/autofill_settings_fragment.xml
+++ b/res/layout/autofill_settings_fragment.xml
@@ -13,256 +13,246 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:orientation="vertical">
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <View
- android:layout_height="10dip"
- android:layout_width="match_parent" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/autofill_profile_editor_heading" />
-
- <View
- android:layout_height="12dip"
- android:layout_width="match_parent" />
-
- <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:shrinkColumns="1"
- 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"
- 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" />
- </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"
- 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" />
- </TableRow>
- <TableRow>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="2dip"
- android:orientation="vertical">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/autofill_profile_editor_address_line_1" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/autofill_profile_editor_address_line_1_hint" />
- </LinearLayout>
- <EditText android:id="@+id/autofill_profile_editor_address_line_1_edit"
- android:gravity="center_vertical"
- android:layout_margin="2dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:inputType="textCapWords"
- android:singleLine="true" />
- </TableRow>
- <TableRow>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_margin="2dip"
- android:orientation="vertical">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:text="@string/autofill_profile_editor_address_line_2" />
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center_vertical"
- android:textAppearance="?android:attr/textAppearanceSmall"
- 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" />
- </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"
- 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" />
- </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"
- 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" />
- </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"
- 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" />
- </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"
- 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" />
- </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"
- 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"
- 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"
- 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" />
- </TableRow>
- </TableLayout>
-
- <View
- android:layout_height="12dip"
- android:layout_width="match_parent" />
+ android:layout_height="0px"
+ android:layout_weight="1">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:gravity="center">
- <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" />
+ android:layout_height="match_parent"
+ android:orientation="vertical">
- <Button
- android:id="@+id/autofill_profile_editor_cancel_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/cancel"
- android:textAppearance="?android:attr/textAppearanceMedium" />
+ <View
+ android:layout_height="10dip"
+ android:layout_width="match_parent" />
- <Button
- android:id="@+id/autofill_profile_editor_delete_button"
+ <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/autofill_profile_editor_delete_profile"
- android:textAppearance="?android:attr/textAppearanceMedium" />
- </LinearLayout>
- </LinearLayout>
-</ScrollView>
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/autofill_profile_editor_heading" />
+
+ <View
+ android:layout_height="12dip"
+ android:layout_width="match_parent" />
+
+ <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:shrinkColumns="1"
+ 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"
+ 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" />
+ </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"
+ 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" />
+ </TableRow>
+ <TableRow>
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="2dip"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/autofill_profile_editor_address_line_1" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ 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" />
+ </TableRow>
+ <TableRow>
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="2dip"
+ android:orientation="vertical">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/autofill_profile_editor_address_line_2" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ 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" />
+ </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"
+ 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" />
+ </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"
+ 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" />
+ </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"
+ 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" />
+ </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"
+ 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" />
+ </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"
+ 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"
+ 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"
+ 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" />
+ </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/layout/font_size_widget.xml b/res/layout/font_size_widget.xml
new file mode 100644
index 0000000..296f5bf
--- /dev/null
+++ b/res/layout/font_size_widget.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:minWidth="50sp"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorSecondary"
+ android:layout_gravity="center_vertical"
+/>
+
diff --git a/res/layout/min_font_size.xml b/res/layout/min_font_size.xml
deleted file mode 100644
index d4d1314..0000000
--- a/res/layout/min_font_size.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingRight="6dip"
- android:paddingTop="6dip"
- android:paddingBottom="6dip"
- android:paddingLeft="8dip">
-
- <TextView
- android:text="@string/pref_min_font_size"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <SeekBar
- android:id="@+id/seekbar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
-</LinearLayout>
-
diff --git a/res/layout/webview_preview.xml b/res/layout/webview_preview.xml
index 6edbcce..8f8d810 100644
--- a/res/layout/webview_preview.xml
+++ b/res/layout/webview_preview.xml
@@ -17,22 +17,70 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingRight="6dip"
- android:paddingTop="6dip"
- android:paddingBottom="6dip"
- android:paddingLeft="8dip">
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:gravity="center_vertical"
+ android:paddingRight="?android:attr/scrollbarSize">
- <TextView
- android:text="@string/preview"
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:minWidth="@*android:dimen/preference_icon_minWidth"
+ android:orientation="horizontal">
+ <ImageView
+ android:id="@android:id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:minWidth="48dp"
+ />
+ </LinearLayout>
+
+ <RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium" />
+ android:layout_marginLeft="16dip"
+ android:layout_marginRight="8dip"
+ android:layout_marginTop="6dip"
+ android:layout_marginBottom="6dip"
+ android:layout_weight="1">
- <WebView
- android:id="@+id/webview"
- android:layout_width="match_parent"
- android:layout_height="180dp" />
+ <TextView android:id="@android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+
+ <TextView android:id="@android:id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@android:id/title"
+ android:layout_alignLeft="@android:id/title"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorSecondary"
+ android:maxLines="4" />
+
+ <!-- Preference should place its actual preference widget here. -->
+ <LinearLayout android:id="@android:id/widget_frame"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_below="@android:id/summary"
+ android:layout_alignLeft="@android:id/title"
+ android:minWidth="@dimen/preference_widget_width"
+ android:gravity="center"
+ android:orientation="vertical" />
+
+ <WebView
+ android:id="@+id/webview"
+ android:layout_width="match_parent"
+ android:layout_height="180dp"
+ android:layout_below="@android:id/summary"
+ android:layout_toRightOf="@android:id/widget_frame"
+ android:layout_alignParentRight="true" />
+
+ </RelativeLayout>
</LinearLayout>
diff --git a/res/menu/autofill_profile_editor.xml b/res/menu/autofill_profile_editor.xml
new file mode 100644
index 0000000..4e746e5
--- /dev/null
+++ b/res/menu/autofill_profile_editor.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <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"
+ android:showAsAction="ifRoom|withText" />
+</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1e92fb5..c846965 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -510,9 +510,7 @@
<string name="pref_security_accept_cookies">Accept cookies</string>
<!-- Settings summary -->
<string name="pref_security_accept_cookies_summary">Allow sites to save and read \"cookie\" data</string>
- <!-- Settings label -->
- <string name="pref_text_size">Text size</string>
- <!-- Settings text size options; appear in Text size dialog box -->
+ <!-- Settings text size options; appear in Text size dialog box [CHAR LIMIT=30] -->
<string-array name="pref_text_size_choices">
<item>Tiny</item>
<item>Small</item>
@@ -520,18 +518,12 @@
<item>Large</item>
<item>Huge</item>
</string-array>
- <!-- Title of dialog for setting the text size -->
- <string name="pref_text_size_dialogtitle">Text size</string>
- <!-- Do not translate -->
- <string-array name="pref_text_size_values" translatable="false">
- <item><xliff:g>SMALLEST</xliff:g></item>
- <item><xliff:g>SMALLER</xliff:g></item>
- <item><xliff:g>NORMAL</xliff:g></item>
- <item><xliff:g>LARGER</xliff:g></item>
- <item><xliff:g>LARGEST</xliff:g></item>
- </string-array>
<!-- Label for minimum font size [CHAR LIMIT=30] -->
<string name="pref_min_font_size">Minimum font size</string>
+ <!-- Label for the current minimum font size value [CHAR LIMIT=6] -->
+ <string name="pref_min_font_size_value"><xliff:g id="font_size">%d</xliff:g>pt</string>
+ <!-- Label for text zoom (percent) [CHAR LIMIT=30] -->
+ <string name="pref_text_zoom">Text zoom</string>
<!-- Label for whether or not to force-enable user scalablity (aka, zoom) [CHAR LIMIT=30] -->
<string name="pref_force_userscalable">Force enable zoom</string>
<!-- Summary for whether or not to force-enable user scalablity (aka, zoom) [CHAR LIMIT=30] -->
@@ -642,6 +634,8 @@
<string name="pref_default_text_encoding_default" translatable="false">Latin-1</string>
<!-- Title for accessibility settings [CHAR LIMIT=25] -->
<string name="pref_accessibility_title">Accessibility</string>
+ <!-- Font size settings category under accessibility settings [CHAR LIMIT=50] -->
+ <string name="pref_font_size_category">Font size</string>
<!-- Title for lab settings [CHAR LIMIT=25] -->
<string name="pref_lab_title">Labs</string>
<!-- Title for lab quick controls feature [CHAR LIMIT=40] -->
@@ -1005,8 +999,8 @@
<string name="recover_yes">Restore</string>
<!-- No, don't recover windows from last time [CHAR LIMIT=10] -->
<string name="recover_no">No</string>
- <!-- Font size preview label [CHAR LIMIT=30] -->
- <string name="preview">Preview:</string>
+ <!-- Font size preview label in settings [CHAR LIMIT=30] -->
+ <string name="preview">Preview</string>
<!-- Name for the user's unsynced, local bookmarks [CHAR LIMIT=50] -->
<string name="local_bookmarks">Local</string>
<!-- Popup menu option that allows the user to select the mobile version of a webpage [CHAR LIMIT=50] -->
diff --git a/res/xml/accessibility_preferences.xml b/res/xml/accessibility_preferences.xml
index 799d0e2..a7124f4 100644
--- a/res/xml/accessibility_preferences.xml
+++ b/res/xml/accessibility_preferences.xml
@@ -17,24 +17,27 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
- <com.android.browser.preferences.WebViewPreview />
-
- <ListPreference
- android:key="text_size"
- android:title="@string/pref_text_size"
- android:defaultValue="NORMAL"
- android:entries="@array/pref_text_size_choices"
- android:entryValues="@array/pref_text_size_values"
- android:dialogTitle="@string/pref_text_size_dialogtitle" />
-
- <com.android.browser.preferences.MinFontSizePreference
- android:key="min_font_size"
- android:title="@string/pref_min_font_size"
- android:defaultValue="1" />
-
<CheckBoxPreference android:key="force_userscalable"
android:title="@string/pref_force_userscalable"
android:summary="@string/pref_force_userscalable_summary"
android:defaultValue="false" />
+ <PreferenceCategory android:title="@string/pref_font_size_category">
+ <com.android.browser.preferences.WebViewPreview
+ android:title="@string/preview" />
+
+ <com.android.browser.preferences.FontSizePreference
+ android:key="text_zoom"
+ android:title="@string/pref_text_zoom"
+ android:defaultValue="10"
+ android:max="30" />
+
+ <com.android.browser.preferences.FontSizePreference
+ android:key="min_font_size"
+ android:title="@string/pref_min_font_size"
+ android:defaultValue="0"
+ android:max="20" />
+
+ </PreferenceCategory>
+
</PreferenceScreen>
diff --git a/src/com/android/browser/AutoFillSettingsFragment.java b/src/com/android/browser/AutoFillSettingsFragment.java
index e87645e..b282789 100644
--- a/src/com/android/browser/AutoFillSettingsFragment.java
+++ b/src/com/android/browser/AutoFillSettingsFragment.java
@@ -28,6 +28,9 @@
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebSettings.AutoFillProfile;
import android.widget.Button;
@@ -131,10 +134,41 @@
@Override
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
+ setHasOptionsMenu(true);
mSettings = BrowserSettings.getInstance();
}
@Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ inflater.inflate(R.menu.autofill_profile_editor, menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == R.id.autofill_profile_editor_delete_profile_menu_id) {
+ // Clear the UI.
+ mFullNameEdit.setText("");
+ mEmailEdit.setText("");
+ mCompanyEdit.setText("");
+ mAddressLine1Edit.setText("");
+ mAddressLine2Edit.setText("");
+ mCityEdit.setText("");
+ mStateEdit.setText("");
+ mZipEdit.setText("");
+ mCountryEdit.setText("");
+ mPhoneEdit.setText("");
+
+ // Update browser settings and native with a null profile. This will
+ // trigger the current profile to get deleted from the DB.
+ mSettings.setAutoFillProfile(null,
+ mHandler.obtainMessage(PROFILE_DELETED_MSG));
+ updateButtonState();
+ return true;
+ }
+ return false;
+ }
+
+ @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.autofill_settings_fragment, container, false);
@@ -185,37 +219,6 @@
}
});
- Button deleteButton = (Button)v.findViewById(R.id.autofill_profile_editor_delete_button);
- deleteButton.setOnClickListener(new OnClickListener() {
- public void onClick(View button) {
- // Clear the UI.
- mFullNameEdit.setText("");
- mEmailEdit.setText("");
- mCompanyEdit.setText("");
- mAddressLine1Edit.setText("");
- mAddressLine2Edit.setText("");
- mCityEdit.setText("");
- mStateEdit.setText("");
- mZipEdit.setText("");
- mCountryEdit.setText("");
- mPhoneEdit.setText("");
-
- // Update browser settings and native with a null profile. This will
- // trigger the current profile to get deleted from the DB.
- mSettings.setAutoFillProfile(null,
- mHandler.obtainMessage(PROFILE_DELETED_MSG));
-
- updateButtonState();
- }
- });
-
- Button cancelButton = (Button)v.findViewById(R.id.autofill_profile_editor_cancel_button);
- cancelButton.setOnClickListener(new OnClickListener() {
- public void onClick(View button) {
- closeEditor();
- }
- });
-
// Populate the text boxes with any pre existing AutoFill data.
AutoFillProfile activeProfile = mSettings.getAutoFillProfile();
if (activeProfile != null) {
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 101effa..fae59e2 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -83,6 +83,16 @@
HONEYCOMB_USERAGENT,
};
+ // The minimum min font size
+ // Aka, the lower bounds for the min font size range
+ // which is 1:5..24
+ private static final int MIN_FONT_SIZE_OFFSET = 5;
+ // The initial value in the text zoom range
+ // This is what represents 100% in the SeekBarPreference range
+ private static final int TEXT_ZOOM_START_VAL = 10;
+ // The size of a single step in the text zoom range, in percent
+ private static final int TEXT_ZOOM_STEP = 5;
+
private static BrowserSettings sInstance;
private Context mContext;
@@ -111,6 +121,31 @@
// This is a release build, always startup with debug disabled
setDebugEnabled(false);
}
+ if (mPrefs.contains(PREF_TEXT_SIZE)) {
+ /*
+ * Update from TextSize enum to zoom percent
+ * SMALLEST is 50%
+ * SMALLER is 75%
+ * NORMAL is 100%
+ * LARGER is 150%
+ * LARGEST is 200%
+ */
+ switch (getTextSize()) {
+ case SMALLEST:
+ setTextZoom(50);
+ break;
+ case SMALLER:
+ setTextZoom(75);
+ break;
+ case LARGER:
+ setTextZoom(150);
+ break;
+ case LARGEST:
+ setTextZoom(200);
+ break;
+ }
+ mPrefs.edit().remove(PREF_TEXT_SIZE).apply();
+ }
mAutofillHandler = new AutofillHandler(mContext);
mManagedSettings = new LinkedList<WeakReference<WebSettings>>();
mCustomUserAgents = new WeakHashMap<WebSettings, String>();
@@ -153,7 +188,7 @@
settings.setMinimumLogicalFontSize(getMinimumFontSize());
settings.setForceUserScalable(forceEnableUserScalable());
settings.setPluginState(getPluginState());
- settings.setTextSize(getTextSize());
+ settings.setTextZoom(getTextZoom());
settings.setAutoFillEnabled(isAutofillEnabled());
settings.setLayoutAlgorithm(getLayoutAlgorithm());
settings.setJavaScriptCanOpenWindowsAutomatically(blockPopupWindows());
@@ -412,24 +447,51 @@
}
}
+ public static int getAdjustedMinimumFontSize(int rawValue) {
+ rawValue++; // Preference starts at 0, min font at 1
+ if (rawValue > 1) {
+ rawValue += (MIN_FONT_SIZE_OFFSET - 2);
+ }
+ return rawValue;
+ }
+
+ public static int getAdjustedTextZoom(int rawValue) {
+ rawValue = (rawValue - TEXT_ZOOM_START_VAL) * TEXT_ZOOM_STEP;
+ return rawValue + 100;
+ }
+
+ static int getRawTextZoom(int percent) {
+ return (percent - 100) / TEXT_ZOOM_STEP + TEXT_ZOOM_START_VAL;
+ }
+
// -----------------------------
// getter/setters for accessibility_preferences.xml
// -----------------------------
- // TODO: Cache
- public TextSize getTextSize() {
+ @Deprecated
+ private TextSize getTextSize() {
String textSize = mPrefs.getString(PREF_TEXT_SIZE, "NORMAL");
return TextSize.valueOf(textSize);
}
public int getMinimumFontSize() {
- return mPrefs.getInt(PREF_MIN_FONT_SIZE, 1);
+ int minFont = mPrefs.getInt(PREF_MIN_FONT_SIZE, 0);
+ return getAdjustedMinimumFontSize(minFont);
}
public boolean forceEnableUserScalable() {
return mPrefs.getBoolean(PREF_FORCE_USERSCALABLE, false);
}
+ public int getTextZoom() {
+ int textZoom = mPrefs.getInt(PREF_TEXT_ZOOM, 10);
+ return getAdjustedTextZoom(textZoom);
+ }
+
+ public void setTextZoom(int percent) {
+ mPrefs.edit().putInt(PREF_TEXT_ZOOM, getRawTextZoom(percent)).apply();
+ }
+
// -----------------------------
// getter/setters for advanced_preferences.xml
// -----------------------------
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index faee0c7..911f724 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -38,6 +38,7 @@
import android.graphics.Picture;
import android.net.Uri;
import android.net.http.SslError;
+import android.nfc.NfcAdapter;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Environment;
@@ -155,6 +156,7 @@
private IntentHandler mIntentHandler;
private PageDialogsHandler mPageDialogsHandler;
private NetworkStateHandler mNetworkHandler;
+ private NfcHandler mNfcHandler;
private Message mAutoFillSetupMessage;
@@ -233,6 +235,7 @@
mUrlHandler = new UrlHandler(this);
mIntentHandler = new IntentHandler(mActivity, this);
mPageDialogsHandler = new PageDialogsHandler(mActivity, this);
+ mNfcHandler = new NfcHandler(mActivity, this);
PowerManager pm = (PowerManager) mActivity
.getSystemService(Context.POWER_SERVICE);
@@ -531,6 +534,11 @@
}
+
+ public Tab getCurrentTab() {
+ return mTabControl.getCurrentTab();
+ }
+
@Override
public void shareCurrentPage() {
shareCurrentPage(mTabControl.getCurrentTab());
@@ -616,9 +624,11 @@
}
mUi.onPause();
mNetworkHandler.onPause();
+ mNfcHandler.onPause();
WebView.disablePlatformNotifications();
mCrashRecoveryHandler.backupState();
+
}
void onSaveInstanceState(Bundle outState, boolean saveImages) {
@@ -649,8 +659,10 @@
mHandler.removeMessages(RELEASE_WAKELOCK);
mWakeLock.release();
}
+
mUi.onResume();
mNetworkHandler.onResume();
+ mNfcHandler.onResume();
WebView.enablePlatformNotifications();
}
@@ -820,6 +832,7 @@
mWakeLock.release();
}
}
+
// Performance probe
if (false) {
Performance.onPageFinished(tab.getUrl());
diff --git a/src/com/android/browser/NfcHandler.java b/src/com/android/browser/NfcHandler.java
new file mode 100644
index 0000000..bdfe25e
--- /dev/null
+++ b/src/com/android/browser/NfcHandler.java
@@ -0,0 +1,73 @@
+/*
+ * 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 android.app.Activity;
+import android.nfc.NdefMessage;
+import android.nfc.NdefRecord;
+import android.nfc.NfcAdapter;
+
+/** This class implements sharing the URL of the currently
+ * shown browser page over NFC. Sharing is only active
+ * when the activity is in the foreground and resumed.
+ * Incognito tabs will not be shared over NFC.
+ */
+public class NfcHandler implements NfcAdapter.NdefPushCallback {
+ private NfcAdapter mNfcAdapter;
+ private Activity mActivity;
+ private Controller mController;
+
+ public NfcHandler(Activity browser, Controller controller) {
+ mActivity = browser;
+ mController = controller;
+ mNfcAdapter = NfcAdapter.getDefaultAdapter(mActivity);
+ }
+
+ void onPause() {
+ if (mNfcAdapter != null) {
+ mNfcAdapter.disableForegroundNdefPush(mActivity);
+ }
+ }
+
+ void onResume() {
+ if (mNfcAdapter != null) {
+ mNfcAdapter.enableForegroundNdefPush(mActivity, this);
+ }
+ }
+
+ @Override
+ public NdefMessage createMessage() {
+ Tab currentTab = mController.getCurrentTab();
+ if (currentTab == null) {
+ return null;
+ }
+ String currentUrl = currentTab.getUrl();
+ if (currentUrl != null && currentTab.getWebView() != null &&
+ !currentTab.getWebView().isPrivateBrowsingEnabled()) {
+ NdefRecord record = new NdefRecord(NdefRecord.TNF_ABSOLUTE_URI,
+ NdefRecord.RTD_URI, new byte[] {}, currentUrl.getBytes());
+ NdefMessage msg = new NdefMessage(new NdefRecord[] { record });
+ return msg;
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void onMessagePushed() {
+ }
+}
diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java
index f7230df..c90213f 100644
--- a/src/com/android/browser/PreferenceKeys.java
+++ b/src/com/android/browser/PreferenceKeys.java
@@ -26,6 +26,7 @@
// ----------------------
static final String PREF_MIN_FONT_SIZE = "min_font_size";
static final String PREF_TEXT_SIZE = "text_size";
+ static final String PREF_TEXT_ZOOM = "text_zoom";
static final String PREF_FORCE_USERSCALABLE = "force_userscalable";
// ----------------------
diff --git a/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java b/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java
index 99bd687..b7d06a1 100644
--- a/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java
+++ b/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java
@@ -16,34 +16,44 @@
package com.android.browser.preferences;
-import com.android.browser.PreferenceKeys;
-import com.android.browser.R;
-
-import android.content.res.Resources;
+import android.content.Context;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
-import android.view.View;
+
+import com.android.browser.BrowserSettings;
+import com.android.browser.PreferenceKeys;
+import com.android.browser.R;
+
+import java.text.NumberFormat;
public class AccessibilityPreferencesFragment extends PreferenceFragment
implements Preference.OnPreferenceChangeListener {
+ NumberFormat mFormat;
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.accessibility_preferences);
+ BrowserSettings settings = BrowserSettings.getInstance();
+ mFormat = NumberFormat.getPercentInstance();
- Preference e = findPreference(PreferenceKeys.PREF_TEXT_SIZE);
+ Preference e = findPreference(PreferenceKeys.PREF_MIN_FONT_SIZE);
e.setOnPreferenceChangeListener(this);
- e.setSummary(getVisualTextSizeName(
- getPreferenceScreen().getSharedPreferences()
- .getString(PreferenceKeys.PREF_TEXT_SIZE, null)) );
+ updateMinFontSummary(e, settings.getMinimumFontSize());
+ e = findPreference(PreferenceKeys.PREF_TEXT_ZOOM);
+ e.setOnPreferenceChangeListener(this);
+ updateTextZoomSummary(e, settings.getTextZoom());
}
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
- getListView().setItemsCanFocus(true);
+ void updateMinFontSummary(Preference pref, int minFontSize) {
+ Context c = getActivity();
+ pref.setSummary(c.getString(R.string.pref_min_font_size_value, minFontSize));
+ }
+
+ void updateTextZoomSummary(Preference pref, int textZoom) {
+ pref.setSummary(mFormat.format(textZoom / 100.0));
}
@Override
@@ -54,31 +64,15 @@
return false;
}
- if (pref.getKey().equals(PreferenceKeys.PREF_TEXT_SIZE)) {
- pref.setSummary(getVisualTextSizeName((String) objValue));
- return true;
+ if (PreferenceKeys.PREF_MIN_FONT_SIZE.equals(pref.getKey())) {
+ updateMinFontSummary(pref, BrowserSettings
+ .getAdjustedMinimumFontSize((Integer) objValue));
}
- return false;
- }
-
- private CharSequence getVisualTextSizeName(String enumName) {
- Resources res = getActivity().getResources();
- CharSequence[] visualNames = res.getTextArray(R.array.pref_text_size_choices);
- CharSequence[] enumNames = res.getTextArray(R.array.pref_text_size_values);
-
- // Sanity check
- if (visualNames.length != enumNames.length) {
- return "";
+ if (PreferenceKeys.PREF_TEXT_ZOOM.equals(pref.getKey())) {
+ updateTextZoomSummary(pref, BrowserSettings
+ .getAdjustedTextZoom((Integer) objValue));
}
-
- int length = enumNames.length;
- for (int i = 0; i < length; i++) {
- if (enumNames[i].equals(enumName)) {
- return visualNames[i];
- }
- }
-
- return "";
+ return true;
}
}
\ No newline at end of file
diff --git a/src/com/android/browser/preferences/FontSizePreference.java b/src/com/android/browser/preferences/FontSizePreference.java
new file mode 100644
index 0000000..0ff1e6d
--- /dev/null
+++ b/src/com/android/browser/preferences/FontSizePreference.java
@@ -0,0 +1,89 @@
+/*
+ * 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.preferences;
+
+import android.content.Context;
+import android.preference.SeekBarPreference;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+import com.android.browser.R;
+
+public class FontSizePreference extends SeekBarPreference {
+
+ CharSequence mSummary;
+ TextView mSummaryView;
+
+ public FontSizePreference(
+ Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ init();
+ }
+
+ public FontSizePreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ public FontSizePreference(Context context) {
+ super(context);
+ init();
+ }
+
+ void init() {
+ setWidgetLayoutResource(R.layout.font_size_widget);
+ }
+
+ @Override
+ public void setSummary(CharSequence summary) {
+ mSummary = summary;
+ if (mSummaryView != null) {
+ mSummaryView.setText(mSummary);
+ }
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ return null;
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ mSummaryView = (TextView) view.findViewById(R.id.text);
+ if (TextUtils.isEmpty(mSummary)) {
+ mSummaryView.setVisibility(View.GONE);
+ } else {
+ mSummaryView.setVisibility(View.VISIBLE);
+ mSummaryView.setText(mSummary);
+ }
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ // Intentionally blank - prevent super.onStartTrackingTouch from running
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ // Intentionally blank - prevent onStopTrackingTouch from running
+ }
+
+}
diff --git a/src/com/android/browser/preferences/MinFontSizePreference.java b/src/com/android/browser/preferences/MinFontSizePreference.java
deleted file mode 100644
index 22092b0..0000000
--- a/src/com/android/browser/preferences/MinFontSizePreference.java
+++ /dev/null
@@ -1,170 +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.preferences;
-
-import com.android.browser.R;
-
-import android.content.Context;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.preference.Preference;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-
-public class MinFontSizePreference extends Preference implements OnSeekBarChangeListener {
-
- // range from 1:6..24
- static final int MIN = 5;
- static final int MAX = 23;
- private int mProgress;
- View mRoot;
-
- public MinFontSizePreference(
- Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- public MinFontSizePreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public MinFontSizePreference(Context context) {
- super(context);
- }
-
- @Override
- public View getView(View convertView, ViewGroup parent) {
- if (mRoot == null) {
- LayoutInflater inflater = LayoutInflater.from(getContext());
- mRoot = inflater.inflate(R.layout.min_font_size, parent, false);
- SeekBar seek = (SeekBar) mRoot.findViewById(R.id.seekbar);
- seek.setMax((MAX - MIN));
- seek.setProgress(mProgress);
- seek.setOnSeekBarChangeListener(this);
- }
- return mRoot;
- }
-
- @Override
- protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
- mProgress = restoreValue ? getPersistedInt(mProgress)
- : (Integer) defaultValue;
- mProgress -= 1;
- }
-
- @Override
- public void onProgressChanged(
- SeekBar seekBar, int progress, boolean fromUser) {
- if (fromUser) {
- if (progress == 0) {
- persistInt(1);
- } else {
- persistInt(progress + MIN + 1);
- }
- }
- mRoot.invalidate();
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- }
-
-
- @Override
- protected Parcelable onSaveInstanceState() {
- /*
- * Suppose a client uses this preference type without persisting. We
- * must save the instance state so it is able to, for example, survive
- * orientation changes.
- */
-
- final Parcelable superState = super.onSaveInstanceState();
- if (isPersistent()) {
- // No need to save instance state since it's persistent
- return superState;
- }
-
- // Save the instance state
- final SavedState myState = new SavedState(superState);
- myState.progress = mProgress;
- return myState;
- }
-
- @Override
- protected void onRestoreInstanceState(Parcelable state) {
- if (!state.getClass().equals(SavedState.class)) {
- // Didn't save state for us in onSaveInstanceState
- super.onRestoreInstanceState(state);
- return;
- }
-
- // Restore the instance state
- SavedState myState = (SavedState) state;
- super.onRestoreInstanceState(myState.getSuperState());
- mProgress = myState.progress;
- notifyChanged();
- }
-
- /**
- * SavedState, a subclass of {@link BaseSavedState}, will store the state
- * of MyPreference, a subclass of Preference.
- * <p>
- * It is important to always call through to super methods.
- */
- private static class SavedState extends BaseSavedState {
- int progress;
-
- public SavedState(Parcel source) {
- super(source);
-
- // Restore the click counter
- progress = source.readInt();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
-
- // Save the click counter
- dest.writeInt(progress);
- }
-
- public SavedState(Parcelable superState) {
- super(superState);
- }
-
- public static final Parcelable.Creator<SavedState> CREATOR =
- new Parcelable.Creator<SavedState>() {
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
-}
diff --git a/src/com/android/browser/preferences/WebViewPreview.java b/src/com/android/browser/preferences/WebViewPreview.java
index a269dbd..1886bed 100644
--- a/src/com/android/browser/preferences/WebViewPreview.java
+++ b/src/com/android/browser/preferences/WebViewPreview.java
@@ -26,7 +26,6 @@
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
-import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
@@ -34,11 +33,9 @@
public class WebViewPreview extends Preference implements OnSharedPreferenceChangeListener {
- // 80 char line width limit? Rules are made to be broken.
- static final String HTML_FORMAT = "<html><head><style type=\"text/css\">p { margin: 2px auto;}</style><body><p style=\"font-size: .4em\">%s</p><p style=\"font-size: .7em\">%s</p><p style=\"font-size: 1em\">%s</p><p style=\"font-size: 1.3em\">%s</p><p style=\"font-size: 1.6em\">%s</p></body></html>";
+ static final String HTML_FORMAT = "<html><head><style type=\"text/css\">p { margin: 2px auto;}</style><body><p style=\"font-size: 4pt\">%s</p><p style=\"font-size: 8pt\">%s</p><p style=\"font-size: 10pt\">%s</p><p style=\"font-size: 14pt\">%s</p><p style=\"font-size: 18pt\">%s</p></body></html>";
- String HTML;
- private View mRoot;
+ String mHtml;
private WebView mWebView;
public WebViewPreview(
@@ -60,7 +57,8 @@
void init(Context context) {
Resources res = context.getResources();
Object[] visualNames = res.getStringArray(R.array.pref_text_size_choices);
- HTML = String.format(HTML_FORMAT, visualNames);
+ mHtml = String.format(HTML_FORMAT, visualNames);
+ setLayoutResource(R.layout.webview_preview);
}
void updatePreview() {
@@ -69,20 +67,24 @@
WebSettings ws = mWebView.getSettings();
BrowserSettings bs = BrowserSettings.getInstance();
ws.setMinimumFontSize(bs.getMinimumFontSize());
- ws.setTextSize(bs.getTextSize());
- mWebView.loadData(HTML, "text/html", "utf-8");
+ ws.setTextZoom(bs.getTextZoom());
+ mWebView.loadData(mHtml, "text/html", "utf-8");
}
@Override
- public View getView(View convertView, ViewGroup parent) {
- if (mWebView == null) {
- LayoutInflater inflater = LayoutInflater.from(getContext());
- mRoot = inflater.inflate(R.layout.webview_preview, parent, false);
- mWebView = (WebView) mRoot.findViewById(R.id.webview);
- mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
- }
+ protected View onCreateView(ViewGroup parent) {
+ View root = super.onCreateView(parent);
+ WebView webView = (WebView) root.findViewById(R.id.webview);
+ webView.setFocusable(false);
+ webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+ return root;
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ mWebView = (WebView) view.findViewById(R.id.webview);
updatePreview();
- return mRoot;
}
@Override
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java
index 9f6e41c..445260f 100644
--- a/src/com/android/browser/provider/BrowserProvider2.java
+++ b/src/com/android/browser/provider/BrowserProvider2.java
@@ -1280,16 +1280,21 @@
values.put(Bookmarks.DATE_MODIFIED, now);
values.put(Bookmarks.DIRTY, 1);
+ boolean hasAccounts = values.containsKey(Bookmarks.ACCOUNT_TYPE)
+ || values.containsKey(Bookmarks.ACCOUNT_NAME);
String accountType = values
.getAsString(Bookmarks.ACCOUNT_TYPE);
String accountName = values
.getAsString(Bookmarks.ACCOUNT_NAME);
boolean hasParent = values.containsKey(Bookmarks.PARENT);
- if (hasParent) {
+ if (hasParent && hasAccounts) {
// Let's make sure it's valid
long parentId = values.getAsLong(Bookmarks.PARENT);
hasParent = isValidParent(
accountType, accountName, parentId);
+ } else if (hasParent && !hasAccounts) {
+ long parentId = values.getAsLong(Bookmarks.PARENT);
+ hasParent = setParentValues(parentId, values);
}
// If no parent is set default to the "Bookmarks Bar" folder
@@ -1377,12 +1382,11 @@
}
}
- private boolean isValidParent(String accountType, String accountName,
- long parentId) {
- if (parentId <= 0) {
- return false;
+ private String[] getAccountNameAndType(long id) {
+ if (id <= 0) {
+ return null;
}
- Uri uri = ContentUris.withAppendedId(Bookmarks.CONTENT_URI, parentId);
+ Uri uri = ContentUris.withAppendedId(Bookmarks.CONTENT_URI, id);
Cursor c = query(uri,
new String[] { Bookmarks.ACCOUNT_NAME, Bookmarks.ACCOUNT_TYPE },
null, null, null);
@@ -1390,17 +1394,35 @@
if (c.moveToFirst()) {
String parentName = c.getString(0);
String parentType = c.getString(1);
- if (TextUtils.equals(accountName, parentName)
- && TextUtils.equals(accountType, parentType)) {
- return true;
- }
+ return new String[] { parentName, parentType };
}
- return false;
+ return null;
} finally {
c.close();
}
}
+ private boolean setParentValues(long parentId, ContentValues values) {
+ String[] parent = getAccountNameAndType(parentId);
+ if (parent == null) {
+ return false;
+ }
+ values.put(Bookmarks.ACCOUNT_NAME, parent[0]);
+ values.put(Bookmarks.ACCOUNT_TYPE, parent[1]);
+ return true;
+ }
+
+ private boolean isValidParent(String accountType, String accountName,
+ long parentId) {
+ String[] parent = getAccountNameAndType(parentId);
+ if (parent != null
+ && TextUtils.equals(accountName, parent[0])
+ && TextUtils.equals(accountType, parent[1])) {
+ return true;
+ }
+ return false;
+ }
+
private void filterSearchClient(String[] selectionArgs) {
if (selectionArgs != null) {
for (int i = 0; i < selectionArgs.length; i++) {