Merge "Preloading support in browser"
diff --git a/res/drawable-hdpi/geolocation_permissions_prompt_background.9.png b/res/drawable-hdpi/geolocation_permissions_prompt_background.9.png
new file mode 100644
index 0000000..44a2e2f
--- /dev/null
+++ b/res/drawable-hdpi/geolocation_permissions_prompt_background.9.png
Binary files differ
diff --git a/res/layout/custom_screen.xml b/res/layout/custom_screen.xml
index 2105501..7a22530 100644
--- a/res/layout/custom_screen.xml
+++ b/res/layout/custom_screen.xml
@@ -14,7 +14,8 @@
      limitations under the License.
 -->
 
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android">
+<merge
+    xmlns:android="http://schemas.android.com/apk/res/android">
     <FrameLayout android:id="@+id/fullscreen_custom_content"
         android:visibility="gone"
         android:background="@color/black"
@@ -36,5 +37,5 @@
             android:layout_height="match_parent"
         />
     </LinearLayout>
-</FrameLayout>
+</merge>
 
diff --git a/res/layout/geolocation_permissions_prompt.xml b/res/layout/geolocation_permissions_prompt.xml
index babde3a..1920c05 100755
--- a/res/layout/geolocation_permissions_prompt.xml
+++ b/res/layout/geolocation_permissions_prompt.xml
@@ -18,74 +18,67 @@
 
 <com.android.browser.GeolocationPermissionsPrompt
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:fitsSystemWindows="true"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content">
+    android:layout_height="wrap_content"
+    android:background="@drawable/geolocation_permissions_prompt_background"
+    android:visibility="gone">
 
-    <!-- Use an inner element as we can't show a hidden outermost element -->
-    <LinearLayout android:id="@+id/inner"
-        android:orientation="vertical"
+    <!-- 'google.com wants to know your location' -->
+    <TextView android:id="@+id/message"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="@color/black"
-        android:paddingTop="1px"
-        android:visibility="gone">
+        android:singleLine="true"
+        android:scrollHorizontally="true"
+        android:padding="6dip"
+        android:textAppearance="?android:attr/textAppearanceSmall" />
 
-        <!-- White line -->
-        <View
-            android:orientation="vertical"
-            android:layout_width="match_parent"
-            android:layout_height="1px"
-            android:background="@color/white" />
+    <CheckBox android:id="@+id/remember"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/message"
+        android:layout_alignLeft="@id/message" />
+    <TextView
+        android:paddingLeft="4dip"
+        android:text="@string/geolocation_permissions_prompt_remember"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textAppearance="?android:attr/textAppearanceSmall"
+        android:layout_alignBaseline="@id/remember"
+        android:layout_toRightOf="@id/remember" />
 
-        <!-- Container for content -->
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/remember"
+        android:orientation="vertical"
+        android:divider="?android:attr/dividerHorizontal"
+        android:showDividers="beginning"
+        android:dividerPadding="16dip"
+        android:background="@null">
         <LinearLayout
-            android:orientation="vertical"
+            style="?android:attr/buttonBarStyle"
             android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:background="@color/geolocation_permissions_prompt_background"
-            android:padding="6dip">
-
-            <!-- 'google.com wants to know your location' -->
-            <TextView android:id="@+id/message"
-                android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:paddingLeft="2dip"
+            android:paddingRight="2dip"
+            android:measureWithLargestChild="true"
+            android:background="@null">
+            <Button
+                android:id="@+id/dont_share_button"
+                style="?android:attr/buttonBarButtonStyle"
+                android:layout_weight="1"
+                android:layout_width="0dip"
                 android:layout_height="wrap_content"
-                android:textSize="14dip"
-                android:textColor="@color/black" />
-
-            <!-- Checkbox -->
-            <LinearLayout
-                android:orientation="horizontal"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content">
-                <CheckBox android:id="@+id/remember"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content" />
-                <TextView
-                    android:paddingLeft="4dip"
-                    android:text="@string/geolocation_permissions_prompt_remember"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:textSize="14dip"
-                    android:textColor="@color/black" />
-            </LinearLayout>
-
-            <!-- Buttons -->
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content">
-                <Button android:id="@+id/share_button"
-                    android:text="@string/geolocation_permissions_prompt_share"
-                    android:layout_weight="1"
-                    android:layout_width="0dip"
-                    android:layout_height="wrap_content" />
-                <Button android:id="@+id/dont_share_button"
-                    android:text="@string/geolocation_permissions_prompt_dont_share"
-                    android:layout_weight="1"
-                    android:layout_width="0dip"
-                    android:layout_height="wrap_content" />
-            </LinearLayout>
-
+                android:text="@string/geolocation_permissions_prompt_dont_share" />
+            <Button
+                android:id="@+id/share_button"
+                style="?android:attr/buttonBarButtonStyle"
+                android:layout_weight="1"
+                android:layout_width="0dip"
+                android:layout_height="wrap_content"
+                android:text="@string/geolocation_permissions_prompt_share" />
         </LinearLayout>
     </LinearLayout>
+
 </com.android.browser.GeolocationPermissionsPrompt>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 322a80a..4ab971f 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -23,8 +23,6 @@
     <color name="white">#ffffffff</color>
     <color name="black">#ff000000</color>
     
-    <color name="geolocation_permissions_prompt_background">#ffdddddd</color>
-
     <color name="bookmarkWidgetHeader">#383847</color>
     <color name="bookmarkWidgetDivider">#383847</color>
     <color name="bookmarkWidgetItemBackground">#2b2b3c</color>
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 1836e6e..e577b1b 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -88,7 +88,6 @@
     private Drawable mMixLockIcon;
     protected Drawable mGenericFavicon;
 
-    private FrameLayout mBrowserFrameLayout;
     protected FrameLayout mContentView;
     protected FrameLayout mCustomViewContainer;
 
@@ -125,15 +124,14 @@
 
         FrameLayout frameLayout = (FrameLayout) mActivity.getWindow()
                 .getDecorView().findViewById(android.R.id.content);
-        mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(mActivity)
-                .inflate(R.layout.custom_screen, null);
-        mContentView = (FrameLayout) mBrowserFrameLayout.findViewById(
+        LayoutInflater.from(mActivity)
+                .inflate(R.layout.custom_screen, frameLayout);
+        mContentView = (FrameLayout) frameLayout.findViewById(
                 R.id.main_content);
-        mErrorConsoleContainer = (LinearLayout) mBrowserFrameLayout
+        mErrorConsoleContainer = (LinearLayout) frameLayout
                 .findViewById(R.id.error_console);
-        mCustomViewContainer = (FrameLayout) mBrowserFrameLayout
+        mCustomViewContainer = (FrameLayout) frameLayout
                 .findViewById(R.id.fullscreen_custom_content);
-        frameLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS);
         setFullscreen(BrowserSettings.getInstance().useFullscreen());
         mGenericFavicon = res.getDrawable(
                 R.drawable.app_web_browser_sm);
@@ -349,7 +347,7 @@
             // The tab consists of a container view, which contains the main
             // WebView, as well as any other UI elements associated with the tab.
             container = mActivity.getLayoutInflater().inflate(R.layout.tab,
-                    null);
+                    mContentView, false);
             tab.setViewContainer(container);
         }
         if (tab.getWebView() != webView) {
diff --git a/src/com/android/browser/Browser.java b/src/com/android/browser/Browser.java
index 909a50d..c4412e2 100644
--- a/src/com/android/browser/Browser.java
+++ b/src/com/android/browser/Browser.java
@@ -18,6 +18,7 @@
 
 import android.app.Application;
 import android.content.Intent;
+import android.os.AsyncTask;
 import android.util.Log;
 import android.webkit.CookieSyncManager;
 
@@ -52,6 +53,8 @@
         if (LOGV_ENABLED)
             Log.v(LOGTAG, "Browser.onCreate: this=" + this);
 
+        // Fix AsyncTask to use multiple threads
+        AsyncTask.setDefaultExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
         // Fix heap utilization for better heap size characteristics.
         VMRuntime.getRuntime().setTargetHeapUtilization(
                 TARGET_HEAP_UTILIZATION);
diff --git a/src/com/android/browser/GeolocationPermissionsPrompt.java b/src/com/android/browser/GeolocationPermissionsPrompt.java
index 95c5415..afbf39f 100755
--- a/src/com/android/browser/GeolocationPermissionsPrompt.java
+++ b/src/com/android/browser/GeolocationPermissionsPrompt.java
@@ -17,22 +17,18 @@
 package com.android.browser;
 
 import android.content.Context;
-import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.util.AttributeSet;
 import android.view.Gravity;
-import android.view.LayoutInflater;
 import android.view.View;
-import android.webkit.WebView;
 import android.webkit.GeolocationPermissions;
 import android.widget.Button;
 import android.widget.CheckBox;
-import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
 import android.widget.TextView;
 import android.widget.Toast;
 
-public class GeolocationPermissionsPrompt extends LinearLayout {
-    private LinearLayout mInner;
+public class GeolocationPermissionsPrompt extends RelativeLayout {
     private TextView mMessage;
     private Button mShareButton;
     private Button mDontShareButton;
@@ -48,22 +44,26 @@
         super(context, attrs);
     }
 
-    void init() {
-        mInner = (LinearLayout) findViewById(R.id.inner);
+    @Override
+    protected void onFinishInflate() {
+        super.onFinishInflate();
+        init();
+    }
+
+    private void init() {
         mMessage = (TextView) findViewById(R.id.message);
         mShareButton = (Button) findViewById(R.id.share_button);
         mDontShareButton = (Button) findViewById(R.id.dont_share_button);
         mRemember = (CheckBox) findViewById(R.id.remember);
 
-        final GeolocationPermissionsPrompt me = this;
         mShareButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
-                me.handleButtonClick(true);
+                handleButtonClick(true);
             }
         });
         mDontShareButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
-                me.handleButtonClick(false);
+                handleButtonClick(false);
             }
         });
     }
@@ -79,21 +79,21 @@
         setMessage("http".equals(uri.getScheme()) ?  mOrigin.substring(7) : mOrigin);
         // The checkbox should always be intially checked.
         mRemember.setChecked(true);
-        showDialog(true);
+        setVisibility(View.VISIBLE);
     }
 
     /**
      * Hides the prompt.
      */
     public void hide() {
-        showDialog(false);
+        setVisibility(View.GONE);
     }
 
     /**
      * Handles a click on one the buttons by invoking the callback.
      */
     private void handleButtonClick(boolean allow) {
-        showDialog(false);
+        hide();
 
         boolean remember = mRemember.isChecked();
         if (remember) {
@@ -117,11 +117,4 @@
             getResources().getString(R.string.geolocation_permissions_prompt_message),
             origin));
     }
-
-    /**
-     * Shows or hides the prompt.
-     */
-    private void showDialog(boolean shown) {
-        mInner.setVisibility(shown ? View.VISIBLE : View.GONE);
-    }
 }
diff --git a/src/com/android/browser/NfcHandler.java b/src/com/android/browser/NfcHandler.java
index bdfe25e..bbac640 100644
--- a/src/com/android/browser/NfcHandler.java
+++ b/src/com/android/browser/NfcHandler.java
@@ -58,8 +58,7 @@
         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());
+            NdefRecord record = NdefRecord.createUri(currentUrl);
             NdefMessage msg = new NdefMessage(new NdefRecord[] { record });
             return msg;
         } else {
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index f8687a8..334bd9d 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -1663,7 +1663,6 @@
                     .findViewById(R.id.geolocation_permissions_prompt);
             mGeolocationPermissionsPrompt = (GeolocationPermissionsPrompt) stub
                     .inflate();
-            mGeolocationPermissionsPrompt.init();
         }
         return mGeolocationPermissionsPrompt;
     }