Merge "Monkey" into jb-dev
diff --git a/res/drawable-hdpi/ic_mobile.png b/res/drawable-hdpi/ic_mobile.png
new file mode 100644
index 0000000..cd688c8
--- /dev/null
+++ b/res/drawable-hdpi/ic_mobile.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_mobile.png b/res/drawable-mdpi/ic_mobile.png
new file mode 100644
index 0000000..6cf4283
--- /dev/null
+++ b/res/drawable-mdpi/ic_mobile.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_mobile.png b/res/drawable-xhdpi/ic_mobile.png
new file mode 100644
index 0000000..a055b07
--- /dev/null
+++ b/res/drawable-xhdpi/ic_mobile.png
Binary files differ
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index 39fe918..f7ae2f5 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -169,9 +169,9 @@
<string name="autofill_profile_editor_email_address" msgid="7967585896612797173">"Adresse e-mail :"</string>
<string name="autofill_profile_editor_company_name" msgid="2813443159949210417">"Nom de la société :"</string>
<string name="autofill_profile_editor_address_line_1" msgid="836433242509243081">"Ligne d\'adresse 1 :"</string>
- <string name="autofill_profile_editor_address_line_1_hint" msgid="5965659598509327172">"Adresse postale, boîte postale, \"À l\'attention de\""</string>
+ <string name="autofill_profile_editor_address_line_1_hint" msgid="5965659598509327172">"Adresse postale, boîte postale, \"Aux soins de\""</string>
<string name="autofill_profile_editor_address_line_2" msgid="8194745202893822479">"Ligne d\'adresse 2 :"</string>
- <string name="autofill_profile_editor_address_line_2_hint" msgid="8529642768127569254">"Résidence, bloc, bâtiment, appartement, étage, etc."</string>
+ <string name="autofill_profile_editor_address_line_2_hint" msgid="8529642768127569254">"Résidence, bâtiment, appartement, étage, etc."</string>
<string name="autofill_profile_editor_city" msgid="7306716145784997135">"Ville :"</string>
<string name="autofill_profile_editor_state" msgid="2150403366835080407">"État/Province/Région :"</string>
<string name="autofill_profile_editor_zip_code" msgid="283668573295656671">"Code postal :"</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 90ec428..7df2a91 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -284,6 +284,8 @@
<string name="menu_preferences">Settings</string>
<!-- Settings screen, section title -->
<string name="pref_content_title">Page content</string>
+ <!-- Settings label [CHAR LIMIT=40]-->
+ <string name="pref_allow_apptabs">Allow multiple tabs per app</string>
<!-- Settings label -->
<string name="pref_content_load_images">Load images</string>
<!-- Settings label -->
diff --git a/res/xml-sw600dp/advanced_preferences.xml b/res/xml-sw600dp/advanced_preferences.xml
new file mode 100644
index 0000000..73f145b
--- /dev/null
+++ b/res/xml-sw600dp/advanced_preferences.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <!-- Entries and values in this list are set dynamically. -->
+ <com.android.browser.search.SearchEnginePreference
+ android:key="search_engine"
+ android:title="@string/pref_content_search_engine"
+ android:defaultValue="google"
+ android:summary="@string/pref_content_search_engine_summary"
+ android:dialogTitle="@string/pref_content_search_engine" />
+
+ <CheckBoxPreference
+ android:key="open_in_background"
+ android:defaultValue="false"
+ android:title="@string/pref_content_open_in_background"
+ android:summary="@string/pref_content_open_in_background_summary" />
+
+ <CheckBoxPreference
+ android:key="enable_javascript"
+ android:defaultValue="true"
+ android:title="@string/pref_content_javascript" />
+
+ <ListPreference
+ android:key="plugin_state"
+ android:title="@string/pref_content_plugins"
+ android:defaultValue="ON"
+ android:entries="@array/pref_content_plugins_choices"
+ android:entryValues="@array/pref_content_plugins_values"
+ android:dialogTitle="@string/pref_content_plugins" />
+
+ <PreferenceScreen
+ android:key="website_settings"
+ android:title="@string/pref_extras_website_settings"
+ android:summary="@string/pref_extras_website_settings_summary" />
+
+ <PreferenceCategory android:title="@string/pref_content_title">
+
+ <ListPreference
+ android:key="default_zoom"
+ android:title="@string/pref_default_zoom"
+ android:defaultValue="MEDIUM"
+ android:entries="@array/pref_default_zoom_choices"
+ android:entryValues="@array/pref_default_zoom_values"
+ android:dialogTitle="@string/pref_default_zoom_dialogtitle" />
+
+ <CheckBoxPreference
+ android:key="load_page"
+ android:defaultValue="true"
+ android:title="@string/pref_content_load_page"
+ android:summary="@string/pref_content_load_page_summary" />
+
+ <CheckBoxPreference
+ android:key="autofit_pages"
+ android:defaultValue="true"
+ android:title="@string/pref_content_autofit"
+ android:summary="@string/pref_content_autofit_summary" />
+
+ <CheckBoxPreference
+ android:key="block_popup_windows"
+ android:defaultValue="true"
+ android:title="@string/pref_content_block_popups" />
+
+ <ListPreference
+ android:key="default_text_encoding"
+ android:title="@string/pref_default_text_encoding"
+ android:defaultValue="@string/pref_default_text_encoding_default"
+ android:entries="@array/pref_default_text_encoding_choices"
+ android:entryValues="@array/pref_default_text_encoding_values"
+ android:dialogTitle="@string/pref_default_text_encoding_dialogtitle" />
+
+ </PreferenceCategory>
+
+ <PreferenceCategory android:title="@string/pref_extras_reset_default_title">
+ <com.android.browser.BrowserYesNoPreference
+ android:key="reset_default_preferences"
+ android:title="@string/pref_extras_reset_default"
+ android:summary="@string/pref_extras_reset_default_summary"
+ android:dialogMessage="@string/pref_extras_reset_default_dlg"
+ android:dialogIcon="@android:drawable/ic_dialog_alert" />
+ </PreferenceCategory>
+
+</PreferenceScreen>
diff --git a/res/xml/advanced_preferences.xml b/res/xml/advanced_preferences.xml
index 4c5ecdf..e292b7d 100644
--- a/res/xml/advanced_preferences.xml
+++ b/res/xml/advanced_preferences.xml
@@ -36,6 +36,11 @@
android:defaultValue="true"
android:title="@string/pref_content_javascript" />
+ <CheckBoxPreference
+ android:key="allow_apptabs"
+ android:defaultValue="false"
+ android:title="@string/pref_allow_apptabs" />
+
<ListPreference
android:key="plugin_state"
android:title="@string/pref_content_plugins"
@@ -91,7 +96,7 @@
android:key="reset_default_preferences"
android:title="@string/pref_extras_reset_default"
android:summary="@string/pref_extras_reset_default_summary"
- android:dialogMessage="@string/pref_extras_reset_default_dlg"
+ android:dialogMessage="@string/pref_extras_reset_default_dlg"
android:dialogIcon="@android:drawable/ic_dialog_alert" />
</PreferenceCategory>
diff --git a/src/com/android/browser/AutofillHandler.java b/src/com/android/browser/AutofillHandler.java
index 99ee6a0..5b0320d 100644
--- a/src/com/android/browser/AutofillHandler.java
+++ b/src/com/android/browser/AutofillHandler.java
@@ -26,6 +26,7 @@
import android.os.Message;
import android.preference.PreferenceManager;
import android.provider.ContactsContract;
+import android.util.Log;
import android.webkit.WebSettingsClassic.AutoFillProfile;
import java.util.concurrent.CountDownLatch;
@@ -43,6 +44,8 @@
private CountDownLatch mLoaded = new CountDownLatch(1);
private Context mContext;
+ private static final String LOGTAG = "AutofillHandler";
+
public AutofillHandler(Context context) {
mContext = context.getApplicationContext();
}
@@ -62,18 +65,24 @@
new LoadFromDb().start();
}
- public void waitForLoad() {
+ private void waitForLoad() {
try {
mLoaded.await();
- } catch (InterruptedException e) {}
+ } catch (InterruptedException e) {
+ Log.w(LOGTAG, "Caught exception while waiting for AutofillProfile to load.");
+ }
}
private class LoadFromDb extends Thread {
@Override
public void run() {
- SharedPreferences p =
- PreferenceManager.getDefaultSharedPreferences(mContext);
+ // Note the lack of synchronization over mAutoFillActiveProfileId and
+ // mAutoFillProfile here. This is because we control all other access
+ // to these members through the public functions of this class, and they
+ // all wait for this thread via the mLoaded CountDownLatch.
+
+ SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(mContext);
// Read the last active AutoFill profile id.
mAutoFillActiveProfileId = p.getInt(
@@ -82,7 +91,9 @@
// Load the autofill profile data from the database. We use a database separate
// to the browser preference DB to make it easier to support multiple profiles
- // and switching between them.
+ // and switching between them. Note that this may block startup if this DB lookup
+ // is extremely slow. We do this to ensure that if there's a profile set, the
+ // user never sees the "setup Autofill" option.
AutoFillProfileDatabase autoFillDb = AutoFillProfileDatabase.getInstance(mContext);
Cursor c = autoFillDb.getProfile(mAutoFillActiveProfileId);
@@ -116,12 +127,19 @@
c.close();
autoFillDb.close();
+ // At this point we've loaded the profile if there was one, so let any thread
+ // waiting on initialization continue.
+ mLoaded.countDown();
+
+ // Synchronization note: strictly speaking, it's possible that mAutoFillProfile
+ // may get a value after we check below, but that's OK. This check is only an
+ // optimisation, and we do a proper synchronized check further down when it comes
+ // to actually setting the inferred profile.
if (mAutoFillProfile == null) {
- // We did not load a profile from disk. Try to populate one with the user's
+ // We did not load a profile from disk. Try to infer one from 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);
@@ -143,13 +161,16 @@
// 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);
+ synchronized(AutofillHandler.this) {
+ // Only use this profile if one hasn't been set inbetween the
+ // inital import and this thread getting to this point.
+ if (mAutoFillProfile == null) {
+ setAutoFillProfile(new AutoFillProfile(1, name, email, company,
+ null, null, null, null, null, null, phone), null);
+ }
+ }
}
}
-
- mLoaded.countDown();
}
private String getContactField(Uri uri, String field, String itemType) {
@@ -174,7 +195,8 @@
}
}
- public void setAutoFillProfile(AutoFillProfile profile, Message msg) {
+ public synchronized void setAutoFillProfile(AutoFillProfile profile, Message msg) {
+ waitForLoad();
int profileId = NO_AUTOFILL_PROFILE_SET;
if (profile != null) {
profileId = profile.getUniqueId();
@@ -193,11 +215,12 @@
setActiveAutoFillProfileId(profileId);
}
- public AutoFillProfile getAutoFillProfile() {
+ public synchronized AutoFillProfile getAutoFillProfile() {
+ waitForLoad();
return mAutoFillProfile;
}
- private void setActiveAutoFillProfileId(int activeProfileId) {
+ private synchronized void setActiveAutoFillProfileId(int activeProfileId) {
mAutoFillActiveProfileId = activeProfileId;
Editor ed = PreferenceManager.
getDefaultSharedPreferences(mContext).edit();
@@ -234,9 +257,11 @@
@Override
protected Void doInBackground(AutoFillProfile... values) {
mAutoFillProfileDb = AutoFillProfileDatabase.getInstance(mContext);
- assert mAutoFillActiveProfileId != NO_AUTOFILL_PROFILE_SET;
- AutoFillProfile newProfile = values[0];
- mAutoFillProfileDb.addOrUpdateProfile(mAutoFillActiveProfileId, newProfile);
+ synchronized (AutofillHandler.this) {
+ assert mAutoFillActiveProfileId != NO_AUTOFILL_PROFILE_SET;
+ AutoFillProfile newProfile = values[0];
+ mAutoFillProfileDb.addOrUpdateProfile(mAutoFillActiveProfileId, newProfile);
+ }
return null;
}
}
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 76dc48f..8dfd4d7 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -510,12 +510,10 @@
}
public AutoFillProfile getAutoFillProfile() {
- mAutofillHandler.waitForLoad();
return mAutofillHandler.getAutoFillProfile();
}
public void setAutoFillProfile(AutoFillProfile profile, Message msg) {
- mAutofillHandler.waitForLoad();
mAutofillHandler.setAutoFillProfile(profile, msg);
// Auto-fill will reuse the same profile ID when making edits to the profile,
// so we need to force a settings sync (otherwise the SharedPreferences
@@ -654,6 +652,10 @@
return mPrefs.getString(PREF_SEARCH_ENGINE, SearchEngine.GOOGLE);
}
+ public boolean allowAppTabs() {
+ return mPrefs.getBoolean(PREF_ALLOW_APP_TABS, false);
+ }
+
public boolean openInBackground() {
return mPrefs.getBoolean(PREF_OPEN_IN_BACKGROUND, false);
}
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 2fb465c..493583d 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -429,7 +429,8 @@
mUi = ui;
}
- BrowserSettings getSettings() {
+ @Override
+ public BrowserSettings getSettings() {
return mSettings;
}
diff --git a/src/com/android/browser/IntentHandler.java b/src/com/android/browser/IntentHandler.java
index 47cab70..e22c5dc 100644
--- a/src/com/android/browser/IntentHandler.java
+++ b/src/com/android/browser/IntentHandler.java
@@ -139,7 +139,8 @@
}
if (Intent.ACTION_VIEW.equals(action)
&& !mActivity.getPackageName().equals(appId)) {
- if (!BrowserActivity.isTablet(mActivity)) {
+ if (!BrowserActivity.isTablet(mActivity)
+ && !mSettings.allowAppTabs()) {
Tab appTab = mTabControl.getTabFromAppId(appId);
if (appTab != null) {
mController.reuseTab(appTab, urlData);
diff --git a/src/com/android/browser/PieControl.java b/src/com/android/browser/PieControl.java
index 7c4291c..a33f8c6 100644
--- a/src/com/android/browser/PieControl.java
+++ b/src/com/android/browser/PieControl.java
@@ -118,6 +118,15 @@
if (tab != null) {
mForward.setEnabled(tab.canGoForward());
}
+ WebView view = mUiController.getCurrentWebView();
+ if (view != null) {
+ ImageView icon = (ImageView) mRDS.getView();
+ if (mUiController.getSettings().hasDesktopUseragent(view)) {
+ icon.setImageResource(R.drawable.ic_mobile);
+ } else {
+ icon.setImageResource(R.drawable.ic_desktop_holo_dark);
+ }
+ }
return true;
}
diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java
index ff42aaf..1828032 100644
--- a/src/com/android/browser/PreferenceKeys.java
+++ b/src/com/android/browser/PreferenceKeys.java
@@ -46,6 +46,7 @@
static final String PREF_RESET_DEFAULT_PREFERENCES = "reset_default_preferences";
static final String PREF_SEARCH_ENGINE = "search_engine";
static final String PREF_WEBSITE_SETTINGS = "website_settings";
+ static final String PREF_ALLOW_APP_TABS = "allow_apptabs";
// ----------------------
// Keys for debug_preferences.xml
diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java
index 5be2343..b3d4631 100644
--- a/src/com/android/browser/UiController.java
+++ b/src/com/android/browser/UiController.java
@@ -105,4 +105,6 @@
void toggleUserAgent();
+ BrowserSettings getSettings();
+
}