Merge "Fix connection-determination code." into honeycomb
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9ceaf82..1dc53f6 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -189,9 +189,9 @@
                   android:configChanges="orientation|keyboardHidden" android:windowSoftInputMode="stateHidden">
         </activity>
 
-        <!-- Bookmark list homescreen widget -->
+        <!-- Bookmark thumbnail homescreen widget -->
         <receiver
-            android:name=".widget.BookmarkListWidgetProvider"
+            android:name=".widget.BookmarkThumbnailWidgetProvider"
             android:label="@string/bookmarks">
             <intent-filter>
                 <action
@@ -201,10 +201,10 @@
             </intent-filter>
             <meta-data
                 android:name="android.appwidget.provider"
-                android:resource="@xml/bookmarklistwidget_info" />
+                android:resource="@xml/bookmarkthumbnailwidget_info" />
         </receiver>
         <service
-            android:name=".widget.BookmarkListWidgetService"
+            android:name=".widget.BookmarkThumbnailWidgetService"
             android:exported="true" />
 
         <!-- Makes .BrowserActivity the search target for any activity in Browser -->
diff --git a/res/drawable-hdpi/bookmarks_widget_thumb_selector_pressed.9.png b/res/drawable-hdpi/bookmarks_widget_thumb_selector_pressed.9.png
new file mode 100644
index 0000000..a329b19
--- /dev/null
+++ b/res/drawable-hdpi/bookmarks_widget_thumb_selector_pressed.9.png
Binary files differ
diff --git a/res/drawable-hdpi/border_thumb_bookmarks_widget_holo.9.png b/res/drawable-hdpi/border_thumb_bookmarks_widget_holo.9.png
new file mode 100644
index 0000000..ab0ece8
--- /dev/null
+++ b/res/drawable-hdpi/border_thumb_bookmarks_widget_holo.9.png
Binary files differ
diff --git a/res/drawable-hdpi/gradient_overlay_bg_bookmark_widget_holo.png b/res/drawable-hdpi/gradient_overlay_bg_bookmark_widget_holo.png
deleted file mode 100644
index c530cc5..0000000
--- a/res/drawable-hdpi/gradient_overlay_bg_bookmark_widget_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/ic_bookmark_widget_bookmark_holo_dark.png b/res/drawable-hdpi/ic_bookmark_widget_bookmark_holo_dark.png
new file mode 100644
index 0000000..d7c9bd9
--- /dev/null
+++ b/res/drawable-hdpi/ic_bookmark_widget_bookmark_holo_dark.png
Binary files differ
diff --git a/res/drawable-hdpi/overlay_url_bookmark_widget_holo.9.png b/res/drawable-hdpi/overlay_url_bookmark_widget_holo.9.png
new file mode 100644
index 0000000..570d238
--- /dev/null
+++ b/res/drawable-hdpi/overlay_url_bookmark_widget_holo.9.png
Binary files differ
diff --git a/res/drawable-hdpi/thumb_bookmark_widget_folder_back_holo.png b/res/drawable-hdpi/thumb_bookmark_widget_folder_back_holo.png
new file mode 100644
index 0000000..9ca04c1
--- /dev/null
+++ b/res/drawable-hdpi/thumb_bookmark_widget_folder_back_holo.png
Binary files differ
diff --git a/res/drawable-hdpi/thumb_bookmark_widget_folder_holo.png b/res/drawable-hdpi/thumb_bookmark_widget_folder_holo.png
new file mode 100644
index 0000000..e221fd2
--- /dev/null
+++ b/res/drawable-hdpi/thumb_bookmark_widget_folder_holo.png
Binary files differ
diff --git a/res/drawable-mdpi/app_web_browser_sm.png b/res/drawable-mdpi/app_web_browser_sm.png
index dbb460a..21245c2 100644
--- a/res/drawable-mdpi/app_web_browser_sm.png
+++ b/res/drawable-mdpi/app_web_browser_sm.png
Binary files differ
diff --git a/res/drawable-mdpi/bg_bookmark_widget_holo.9.png b/res/drawable-mdpi/bg_bookmark_widget_holo.9.png
index ac56bbe..d95f8d3 100644
--- a/res/drawable-mdpi/bg_bookmark_widget_holo.9.png
+++ b/res/drawable-mdpi/bg_bookmark_widget_holo.9.png
Binary files differ
diff --git a/res/drawable-mdpi/bookmarks_widget_thumb_selector_pressed.9.png b/res/drawable-mdpi/bookmarks_widget_thumb_selector_pressed.9.png
new file mode 100644
index 0000000..6ec1576
--- /dev/null
+++ b/res/drawable-mdpi/bookmarks_widget_thumb_selector_pressed.9.png
Binary files differ
diff --git a/res/drawable-mdpi/border_thumb_bookmarks_widget_holo.9.png b/res/drawable-mdpi/border_thumb_bookmarks_widget_holo.9.png
new file mode 100644
index 0000000..486e5e8
--- /dev/null
+++ b/res/drawable-mdpi/border_thumb_bookmarks_widget_holo.9.png
Binary files differ
diff --git a/res/drawable-mdpi/gradient_overlay_bg_bookmark_widget_holo.png b/res/drawable-mdpi/gradient_overlay_bg_bookmark_widget_holo.png
deleted file mode 100644
index 1673338..0000000
--- a/res/drawable-mdpi/gradient_overlay_bg_bookmark_widget_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/header_bg_bookmark_widget_holo.png b/res/drawable-mdpi/header_bg_bookmark_widget_holo.png
deleted file mode 100644
index 9c3f7a6..0000000
--- a/res/drawable-mdpi/header_bg_bookmark_widget_holo.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_bookmark_widget_bookmark_holo_dark.png b/res/drawable-mdpi/ic_bookmark_widget_bookmark_holo_dark.png
new file mode 100644
index 0000000..70477aa
--- /dev/null
+++ b/res/drawable-mdpi/ic_bookmark_widget_bookmark_holo_dark.png
Binary files differ
diff --git a/res/drawable-mdpi/overlay_url_bookmark_widget_holo.9.png b/res/drawable-mdpi/overlay_url_bookmark_widget_holo.9.png
new file mode 100644
index 0000000..a72900d
--- /dev/null
+++ b/res/drawable-mdpi/overlay_url_bookmark_widget_holo.9.png
Binary files differ
diff --git a/res/drawable-mdpi/stripes_overlay_bg_bookmark_widget_holo.png b/res/drawable-mdpi/stripes_overlay_bg_bookmark_widget_holo.png
index 8c9614b..6b387a0 100644
--- a/res/drawable-mdpi/stripes_overlay_bg_bookmark_widget_holo.png
+++ b/res/drawable-mdpi/stripes_overlay_bg_bookmark_widget_holo.png
Binary files differ
diff --git a/res/drawable-mdpi/thumb_bookmark_widget_folder_back_holo.png b/res/drawable-mdpi/thumb_bookmark_widget_folder_back_holo.png
new file mode 100644
index 0000000..e75e53f
--- /dev/null
+++ b/res/drawable-mdpi/thumb_bookmark_widget_folder_back_holo.png
Binary files differ
diff --git a/res/drawable-mdpi/thumb_bookmark_widget_folder_holo.png b/res/drawable-mdpi/thumb_bookmark_widget_folder_holo.png
new file mode 100644
index 0000000..58ad3a0
--- /dev/null
+++ b/res/drawable-mdpi/thumb_bookmark_widget_folder_holo.png
Binary files differ
diff --git a/res/drawable/bookmark_widget_thumb_selector.xml b/res/drawable/bookmark_widget_thumb_selector.xml
new file mode 100644
index 0000000..d9b8171
--- /dev/null
+++ b/res/drawable/bookmark_widget_thumb_selector.xml
@@ -0,0 +1,21 @@
+<?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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true" android:drawable="@drawable/bookmarks_widget_thumb_selector_pressed" />
+    <item android:drawable="@android:color/transparent" />
+</selector>
+
diff --git a/res/drawable/browser_widget_preview.png b/res/drawable/browser_widget_preview.png
old mode 100755
new mode 100644
index a3f48dd..4923978
--- a/res/drawable/browser_widget_preview.png
+++ b/res/drawable/browser_widget_preview.png
Binary files differ
diff --git a/res/drawable/widget_background.xml b/res/drawable/widget_background.xml
index de6c3f2..4c59d60 100644
--- a/res/drawable/widget_background.xml
+++ b/res/drawable/widget_background.xml
@@ -16,14 +16,8 @@
 
 <layer-list
     xmlns:android="http://schemas.android.com/apk/res/android">
-    <item>
-        <bitmap
-            android:src="@drawable/gradient_overlay_bg_bookmark_widget_holo"
-            android:gravity="top|fill_horizontal" />
+    <item
+        android:drawable="@drawable/bg_bookmark_widget_holo">
     </item>
-    <item>
-        <bitmap
-            android:src="@drawable/stripes_overlay_bg_bookmark_widget_holo"
-            android:gravity="top|fill_horizontal" />
-    </item>
+
 </layer-list>
diff --git a/res/layout/bookmarklistwidget.xml b/res/layout/bookmarklistwidget.xml
deleted file mode 100644
index f3857f8..0000000
--- a/res/layout/bookmarklistwidget.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-<FrameLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:paddingTop="4dip"
-    android:paddingBottom="20dip"
-    android:paddingLeft="12dip"
-    android:paddingRight="12dip">
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical"
-        android:background="@drawable/bg_bookmark_widget_holo"
-        android:paddingLeft="0dip"
-        android:paddingRight="0dip"
-        android:paddingBottom="0dip">
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="42dip"
-            android:orientation="horizontal"
-            android:background="@drawable/header_bg_bookmark_widget_holo"
-            android:layout_marginLeft="5dip"
-            android:layout_marginRight="5dip">
-            <LinearLayout
-                android:id="@+id/header_browser"
-                android:layout_width="0dip"
-                android:layout_height="match_parent"
-                android:layout_weight="1"
-                android:orientation="horizontal"
-                android:paddingLeft="16dip"
-                android:focusable="true"
-                android:clickable="true"
-                android:background="@drawable/widget_header_selector">
-                <ImageView
-                    android:id="@+id/logo"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_gravity="center_vertical"
-                    android:src="@drawable/ic_browser_bookmark_widget_holo" />
-                <TextView
-                    android:layout_width="0dip"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-                    android:layout_gravity="center_vertical"
-                    android:text="@string/application_name"
-                    android:textAppearance="?android:attr/textAppearanceMedium"
-                    android:textStyle="bold"
-                    android:paddingLeft="8dip" />
-            </LinearLayout>
-            <ImageView
-                android:id="@+id/header_bookmarks"
-                android:layout_width="wrap_content"
-                android:layout_height="match_parent"
-                android:src="@drawable/btn_ic_bookmark_bookmark_widget_holo_dark"
-                android:scaleType="centerInside"
-                android:focusable="true"
-                android:clickable="true"
-                android:background="@drawable/widget_header_selector"
-                android:paddingLeft="8dip"
-                android:paddingRight="8dip" />
-        </LinearLayout>
-        <ImageView android:background="@drawable/list_div_top_btm_bookmark_widget_holo"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            android:layout_marginLeft="2dip"
-            android:layout_marginRight="2dip" />
-        <ListView
-            android:id="@+id/bookmarks_list"
-            android:layout_width="match_parent"
-            android:layout_height="0dip"
-            android:layout_weight="1"
-            android:background="@drawable/widget_background"
-            android:cacheColorHint="@android:color/transparent"
-            android:divider="@drawable/list_div_bookmark_widget_holo"
-            android:layout_marginLeft="5dip"
-            android:layout_marginRight="5dip" />
-        <ImageView android:background="@drawable/list_div_top_btm_bookmark_widget_holo"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            android:layout_marginLeft="2dip"
-            android:layout_marginRight="2dip"
-            android:layout_marginBottom="2dip" />
-    </LinearLayout>
-</FrameLayout>
diff --git a/res/layout/bookmarklistwidget_item.xml b/res/layout/bookmarklistwidget_item.xml
deleted file mode 100644
index 2f64054..0000000
--- a/res/layout/bookmarklistwidget_item.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/list_item"
-    android:layout_width="match_parent"
-    android:layout_height="48dp"
-    android:orientation="horizontal"
-    android:background="@drawable/row_activated_bookmark_widget_holo">
-    <ImageView
-        android:id="@+id/thumb"
-        android:src="@drawable/browser_thumbnail"
-        android:layout_height="@dimen/bookmark_widget_thumb_size"
-        android:layout_width="@dimen/bookmark_widget_thumb_size"
-        android:layout_gravity="center_vertical"
-        android:layout_marginLeft="16dp"
-        android:scaleType="centerInside"/>
-    <TextView
-        android:id="@+id/label"
-        android:layout_width="0dip"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center_vertical"
-        android:layout_weight="1"
-        android:textAppearance="?android:attr/textAppearanceSmall"
-        android:paddingLeft="8dip"
-        android:maxLines="1"
-        android:scrollHorizontally="true"
-        android:ellipsize="marquee"/>
-</LinearLayout>
diff --git a/res/layout/bookmarkthumbnailwidget.xml b/res/layout/bookmarkthumbnailwidget.xml
new file mode 100644
index 0000000..2c94d32
--- /dev/null
+++ b/res/layout/bookmarkthumbnailwidget.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<FrameLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingTop="4dip"
+    android:paddingBottom="22dip"
+    android:paddingLeft="13dip"
+    android:paddingRight="13dip">
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical"
+        android:padding="0dip">
+        <ImageView android:background="@drawable/list_div_top_btm_bookmark_widget_holo"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:layout_marginTop="2dip"
+            android:layout_marginLeft="1dip"
+            android:layout_marginRight="1dip"
+            android:visibility="invisible" />
+        <GridView
+            android:id="@+id/bookmarks_list"
+            android:layout_width="match_parent"
+            android:layout_height="0dip"
+            android:layout_weight="1"
+            android:layout_marginLeft="5dip"
+            android:layout_marginRight="5dip"
+            android:numColumns="2"
+            android:paddingTop="1dip"
+            android:paddingBottom="1dip"
+            android:paddingRight="0dip"
+            android:paddingLeft="0dip"
+            android:stretchMode="columnWidth"
+            android:horizontalSpacing="@dimen/widgetHorizontalSpacing"
+            android:verticalSpacing="@dimen/widgetVerticalSpacing"
+            android:drawSelectorOnTop="true"
+            android:listSelector="@drawable/bookmark_widget_thumb_selector"
+            android:fadingEdgeLength="24dp" />
+        <ImageView android:background="@drawable/list_div_top_btm_bookmark_widget_holo"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:layout_marginBottom="3dip"
+            android:layout_marginLeft="1dip"
+            android:layout_marginRight="1dip"
+            android:visibility="invisible" />
+    </LinearLayout>
+</FrameLayout>
diff --git a/res/layout/bookmarkthumbnailwidget_item.xml b/res/layout/bookmarkthumbnailwidget_item.xml
new file mode 100644
index 0000000..b67b386
--- /dev/null
+++ b/res/layout/bookmarkthumbnailwidget_item.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/list_item"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+    <ImageView
+        android:id="@+id/thumb"
+        android:src="@drawable/browser_thumbnail"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/widgetThumbnailHeight"
+        android:scaleType="centerCrop"
+        android:cropToPadding="true"
+        android:background="@drawable/border_thumb_bookmarks_widget_holo" />
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignBottom="@id/thumb"
+        android:background="@drawable/overlay_url_bookmark_widget_holo"
+        android:layout_marginLeft="2dip"
+        android:layout_marginRight="2dip"
+        android:layout_marginBottom="2dip">
+        <ImageView
+            android:id="@+id/favicon"
+            android:src="@drawable/app_web_browser_sm"
+            android:layout_width="@dimen/favicon_size"
+            android:layout_height="@dimen/favicon_size"
+            android:layout_gravity="center_vertical"
+            android:layout_marginLeft="4dip"
+            android:layout_marginRight="8dip"
+            android:layout_marginTop="4dip"
+            android:layout_marginBottom="4dip"
+            android:scaleType="centerInside" />
+        <TextView
+            android:id="@+id/label"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
+            android:singleLine="true"
+            android:ellipsize="end"
+            android:textSize="14sp"
+            android:typeface="sans"
+            android:textStyle="bold"
+            android:textColor="@android:color/white" />
+    </LinearLayout>
+</RelativeLayout>
diff --git a/res/layout/tab_bar.xml b/res/layout/tab_bar.xml
index e8f146c..0f636cd 100644
--- a/res/layout/tab_bar.xml
+++ b/res/layout/tab_bar.xml
@@ -24,8 +24,9 @@
     >
     <com.android.browser.TabScrollView
         android:id="@+id/tabs"
-        android:layout_width="wrap_content"
+        android:layout_width="0dip"
         android:layout_height="44dip"
+        android:layout_weight="1.0"
         android:orientation="horizontal" />
     <ImageButton
         android:id="@+id/newtab"
diff --git a/res/values-xlarge-port/dimensions.xml b/res/values-xlarge-port/dimensions.xml
new file mode 100644
index 0000000..46e7272
--- /dev/null
+++ b/res/values-xlarge-port/dimensions.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright (C) 2010 The Android Open Source Project Licensed under the
+    Apache License, Version 2.0 (the "License"); you may not use this file
+    except in compliance with the License. You may obtain a copy of the
+    License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+    applicable law or agreed to in writing, software distributed under the
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+    CONDITIONS OF ANY KIND, either express or implied. See the License for
+    the specific language governing permissions and limitations under the
+    License.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <dimen name="widgetThumbnailHeight">72dip</dimen>
+    <dimen name="widgetHorizontalSpacing">0dip</dimen>
+    <dimen name="widgetVerticalSpacing">4dip</dimen>
+</resources>
diff --git a/res/values-xlarge/dimensions.xml b/res/values-xlarge/dimensions.xml
index 9f5a602..d56146b 100644
--- a/res/values-xlarge/dimensions.xml
+++ b/res/values-xlarge/dimensions.xml
@@ -13,6 +13,9 @@
 <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <dimen name="bookmarkThumbnailWidth">180dip</dimen>
     <dimen name="bookmarkThumbnailHeight">120dip</dimen>
+    <dimen name="widgetThumbnailHeight">100dip</dimen>
+    <dimen name="widgetHorizontalSpacing">12dip</dimen>
+    <dimen name="widgetVerticalSpacing">12dip</dimen>
     <dimen name="favicon_padded_size">24dip</dimen>
     <!-- For the most visited page -->
     <dimen name="mv_max_width">1010dp</dimen>
diff --git a/res/xml/bookmarklistwidget_info.xml b/res/xml/bookmarkthumbnailwidget_info.xml
similarity index 94%
rename from res/xml/bookmarklistwidget_info.xml
rename to res/xml/bookmarkthumbnailwidget_info.xml
index c39ce8f..6797f85 100644
--- a/res/xml/bookmarklistwidget_info.xml
+++ b/res/xml/bookmarkthumbnailwidget_info.xml
@@ -21,5 +21,5 @@
     android:minHeight="219dip"
     android:updatePeriodMillis="0"
     android:previewImage="@drawable/browser_widget_preview"
-    android:initialLayout="@layout/bookmarklistwidget">
+    android:initialLayout="@layout/bookmarkthumbnailwidget">
 </appwidget-provider>
diff --git a/src/com/android/browser/CombinedBookmarkHistoryView.java b/src/com/android/browser/CombinedBookmarkHistoryView.java
index 426b34d..0f12353 100644
--- a/src/com/android/browser/CombinedBookmarkHistoryView.java
+++ b/src/com/android/browser/CombinedBookmarkHistoryView.java
@@ -29,8 +29,10 @@
 import android.os.Bundle;
 import android.provider.Browser;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.view.View.OnTouchListener;
 import android.view.ViewGroup;
 import android.webkit.WebIconDatabase;
 import android.webkit.WebIconDatabase.IconListener;
@@ -46,7 +48,7 @@
 }
 
 public class CombinedBookmarkHistoryView extends LinearLayout
-        implements OnClickListener {
+        implements OnClickListener, OnTouchListener {
 
     final static String STARTING_FRAGMENT = "fragment";
 
@@ -115,6 +117,7 @@
         mActivity = activity;
         mExtras = extras;
         View v = LayoutInflater.from(activity).inflate(R.layout.bookmarks_history, this);
+        v.setOnTouchListener(this);
         Resources res = activity.getResources();
 
 //        setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
@@ -258,4 +261,13 @@
         }
         return false;
     }
+
+    /**
+     * capture touch events to prevent them from going to the underlying
+     * WebView
+     */
+    @Override
+    public boolean onTouch(View v, MotionEvent event) {
+        return true;
+    }
 }
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 23594f2..02f1e7c 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -1111,6 +1111,10 @@
         if (mTabControl.getCurrentWebView() == null) {
             return;
         }
+        // clear action mode
+        if (isInCustomActionMode()) {
+            endActionMode();
+        }
         Bundle extras = new Bundle();
         // Disable opening in a new window if we have maxed out the windows
         extras.putBoolean(BrowserBookmarksPage.EXTRA_DISABLE_WINDOW,
diff --git a/src/com/android/browser/TabBar.java b/src/com/android/browser/TabBar.java
index ba123d0..f1cdf2f 100644
--- a/src/com/android/browser/TabBar.java
+++ b/src/com/android/browser/TabBar.java
@@ -33,7 +33,6 @@
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.LayerDrawable;
 import android.graphics.drawable.PaintDrawable;
-import android.util.Log;
 import android.view.ContextMenu;
 import android.view.Gravity;
 import android.view.LayoutInflater;
@@ -136,7 +135,7 @@
 
         mInactiveShaderPaint.setStyle(Paint.Style.FILL);
         mInactiveShaderPaint.setAntiAlias(true);
-        
+
     }
 
     void setUseQuickControls(boolean useQuickControls) {
@@ -174,18 +173,22 @@
         // use paddingLeft and paddingTop
         int pl = getPaddingLeft();
         int pt = getPaddingTop();
-        if (mButtonWidth == -1) {
-            mButtonWidth = mNewTab.getMeasuredWidth() - mTabOverlap;
-        }
         int sw = mTabs.getMeasuredWidth();
         int w = right - left - pl;
-        if (w-sw < mButtonWidth) {
-            sw = w - mButtonWidth;
+        if (mUseQuickControls) {
+            mButtonWidth = 0;
+        } else {
+            mButtonWidth = mNewTab.getMeasuredWidth() - mTabOverlap;
+            if (w-sw < mButtonWidth) {
+                sw = w - mButtonWidth;
+            }
         }
         mTabs.layout(pl, pt, pl + sw, bottom - top);
         // adjust for overlap
-        mNewTab.layout(pl + sw - mTabOverlap, pt,
-                pl + sw + mButtonWidth - mTabOverlap, bottom - top);
+        if (!mUseQuickControls) {
+            mNewTab.layout(pl + sw - mTabOverlap, pt,
+                    pl + sw + mButtonWidth - mTabOverlap, bottom - top);
+        }
     }
 
     public void onClick(View view) {
@@ -286,8 +289,8 @@
         drawable.setBounds(0, 0, width, height);
         drawable.draw(c);
         return b;
-    }    
-    
+    }
+
     /**
      * View used in the tab bar
      */
@@ -420,7 +423,7 @@
             super.onLayout(changed, l, t, r, b);
             setTabPath(mPath, 0, 0, r - l, b - t);
         }
-        
+
         @Override
         protected void dispatchDraw(Canvas canvas) {
             if (mCurrentTextureWidth != mUi.getContentWidth() ||
@@ -437,13 +440,13 @@
                     mActiveShader = new BitmapShader(activeTexture,
                             Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
                     mActiveShaderPaint.setShader(mActiveShader);
-    
+
                     mInactiveShader = new BitmapShader(inactiveTexture,
                             Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
                     mInactiveShaderPaint.setShader(mInactiveShader);
                 }
             }
-            
+
             int state = canvas.save();
             getLocationInWindow(mWindowPos);
             Paint paint = mSelected ? mActiveShaderPaint : mInactiveShaderPaint;
diff --git a/src/com/android/browser/UrlHandler.java b/src/com/android/browser/UrlHandler.java
index cd0afeb..f39ac4b 100644
--- a/src/com/android/browser/UrlHandler.java
+++ b/src/com/android/browser/UrlHandler.java
@@ -120,7 +120,7 @@
                 // AsyncTask. Although we are not overriding the URL load synchronously,
                 // we guarantee that we will handle this URL load after the task executes,
                 // so it's safe to just return true to WebCore now to stop its own loading.
-                new RLZTask(siteUri, view).execute();
+                new RLZTask(tab, siteUri, view).execute();
                 return true;
             }
         }
@@ -137,9 +137,7 @@
             return true;
         }
 
-        if (mController.isMenuDown()) {
-            mController.openTab(tab, url, false);
-            mActivity.closeOptionsMenu();
+        if (handleMenuClick(tab, url)) {
             return true;
         }
 
@@ -198,6 +196,19 @@
       return false;
     }
 
+    // In case a physical keyboard is attached, handle clicks with the menu key
+    // depressed by opening in a new tab
+    boolean handleMenuClick(Tab tab, String url)
+    {
+        if (mController.isMenuDown()) {
+            mController.openTab(tab, url, false);
+            mActivity.closeOptionsMenu();
+            return true;
+        }
+
+        return false;
+    }
+
     // Url for issuing the uber token.
     private final static Uri ISSUE_AUTH_TOKEN_URL = Uri.parse(
             "https://www.google.com/accounts/IssueAuthToken?service=gaia&Session=false");
@@ -355,10 +366,12 @@
     }
 
     private class RLZTask extends AsyncTask<Void, Void, String> {
+        private Tab mTab;
         private Uri mSiteUri;
         private WebView mWebView;
 
-        public RLZTask(Uri uri, WebView webView) {
+        public RLZTask(Tab tab, Uri uri, WebView webView) {
+            mTab = tab;
             mSiteUri = uri;
             mWebView = webView;
         }
@@ -383,7 +396,12 @@
         }
 
         protected void onPostExecute(String result) {
-            startActivityForUrl(result);
+            // If the Activity Manager is not invoked, load the URL directly
+            if (!startActivityForUrl(result)) {
+                if (!handleMenuClick(mTab, result)) {
+                    mController.loadUrl(mWebView, result);
+                }
+            }
         }
     }
 
diff --git a/src/com/android/browser/widget/BookmarkListWidgetProvider.java b/src/com/android/browser/widget/BookmarkThumbnailWidgetProvider.java
similarity index 71%
rename from src/com/android/browser/widget/BookmarkListWidgetProvider.java
rename to src/com/android/browser/widget/BookmarkThumbnailWidgetProvider.java
index 99daaa1..14e1c89 100644
--- a/src/com/android/browser/widget/BookmarkListWidgetProvider.java
+++ b/src/com/android/browser/widget/BookmarkThumbnailWidgetProvider.java
@@ -16,7 +16,6 @@
 
 package com.android.browser.widget;
 
-import com.android.browser.BrowserActivity;
 import com.android.browser.R;
 
 import android.app.PendingIntent;
@@ -31,7 +30,7 @@
 /**
  * Widget that shows a preview of the user's bookmarks.
  */
-public class BookmarkListWidgetProvider extends AppWidgetProvider {
+public class BookmarkThumbnailWidgetProvider extends AppWidgetProvider {
     static final String ACTION_BOOKMARK_APPWIDGET_UPDATE =
         "com.android.browser.BOOKMARK_APPWIDGET_UPDATE";
 
@@ -60,46 +59,37 @@
     @Override
     public void onEnabled(Context context) {
         // Start the backing service
-        context.startService(new Intent(context, BookmarkListWidgetService.class));
+        context.startService(new Intent(context, BookmarkThumbnailWidgetService.class));
     }
 
     @Override
     public void onDisabled(Context context) {
         // Stop the backing service
-        context.stopService(new Intent(context, BookmarkListWidgetService.class));
+        context.stopService(new Intent(context, BookmarkThumbnailWidgetService.class));
     }
 
     @Override
     public void onDeleted(Context context, int[] appWidgetIds) {
         super.onDeleted(context, appWidgetIds);
-        context.startService(new Intent(BookmarkListWidgetService.ACTION_REMOVE_FACTORIES,
-                null, context, BookmarkListWidgetService.class)
+        context.startService(new Intent(BookmarkThumbnailWidgetService.ACTION_REMOVE_FACTORIES,
+                null, context, BookmarkThumbnailWidgetService.class)
                 .putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds));
     }
 
     private void performUpdate(Context context,
             AppWidgetManager appWidgetManager, int[] appWidgetIds) {
-        Intent launchBrowser = new Intent(BrowserActivity.ACTION_SHOW_BROWSER,
-                null, context, BrowserActivity.class);
-        Intent launchBookmarks = new Intent(BrowserActivity.ACTION_SHOW_BOOKMARKS,
-                null, context, BrowserActivity.class);
-        // Update the widgets
         for (int appWidgetId : appWidgetIds) {
-            Intent updateIntent = new Intent(context, BookmarkListWidgetService.class);
+            Intent updateIntent = new Intent(context, BookmarkThumbnailWidgetService.class);
             updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
             updateIntent.setData(Uri.parse(updateIntent.toUri(Intent.URI_INTENT_SCHEME)));
             RemoteViews views = new RemoteViews(context.getPackageName(),
-                    R.layout.bookmarklistwidget);
+                    R.layout.bookmarkthumbnailwidget);
             views.setRemoteAdapter(R.id.bookmarks_list, updateIntent);
             appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.bookmarks_list);
-            Intent ic = new Intent(context, BookmarkListWidgetService.class);
+            Intent ic = new Intent(context, BookmarkThumbnailWidgetService.class);
             views.setPendingIntentTemplate(R.id.bookmarks_list,
                     PendingIntent.getService(context, 0, ic,
                     PendingIntent.FLAG_UPDATE_CURRENT));
-            views.setOnClickPendingIntent(R.id.header_browser, PendingIntent
-                    .getActivity(context, 0, launchBrowser, PendingIntent.FLAG_CANCEL_CURRENT));
-            views.setOnClickPendingIntent(R.id.header_bookmarks, PendingIntent
-                    .getActivity(context, 0, launchBookmarks, PendingIntent.FLAG_CANCEL_CURRENT));
             appWidgetManager.updateAppWidget(appWidgetId, views);
         }
     }
@@ -109,6 +99,6 @@
      * {@link AppWidgetProvider}
      */
     static ComponentName getComponentName(Context context) {
-        return new ComponentName(context, BookmarkListWidgetProvider.class);
+        return new ComponentName(context, BookmarkThumbnailWidgetProvider.class);
     }
 }
diff --git a/src/com/android/browser/widget/BookmarkListWidgetService.java b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
similarity index 87%
rename from src/com/android/browser/widget/BookmarkListWidgetService.java
rename to src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
index 4d72d41..51ba2ca 100644
--- a/src/com/android/browser/widget/BookmarkListWidgetService.java
+++ b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
@@ -16,7 +16,6 @@
 
 package com.android.browser.widget;
 
-import com.android.browser.BookmarkUtils;
 import com.android.browser.BrowserBookmarksPage;
 import com.android.browser.R;
 
@@ -49,9 +48,9 @@
 import java.util.Map;
 import java.util.Stack;
 
-public class BookmarkListWidgetService extends RemoteViewsService {
+public class BookmarkThumbnailWidgetService extends RemoteViewsService {
 
-    static final String TAG = "BookmarkListWidgetService";
+    static final String TAG = "BookmarkThumbnailWidgetService";
     static final boolean USE_FOLDERS = true;
 
     static final String ACTION_REMOVE_FACTORIES
@@ -66,13 +65,15 @@
             BrowserContract.Bookmarks.FAVICON,
             BrowserContract.Bookmarks.IS_FOLDER,
             BrowserContract.Bookmarks.TOUCH_ICON,
-            BrowserContract.Bookmarks.POSITION /* needed for order by */};
+            BrowserContract.Bookmarks.POSITION, /* needed for order by */
+            BrowserContract.Bookmarks.THUMBNAIL};
     private static final int BOOKMARK_INDEX_ID = 0;
     private static final int BOOKMARK_INDEX_TITLE = 1;
     private static final int BOOKMARK_INDEX_URL = 2;
     private static final int BOOKMARK_INDEX_FAVICON = 3;
     private static final int BOOKMARK_INDEX_IS_FOLDER = 4;
     private static final int BOOKMARK_INDEX_TOUCH_ICON = 5;
+    private static final int BOOKMARK_INDEX_THUMBNAIL = 7;
 
     private Map<Integer, BookmarkFactory> mFactories;
     private Handler mUiHandler;
@@ -223,12 +224,12 @@
             Breadcrumb folder = mBreadcrumbs.empty() ? null : mBreadcrumbs.peek();
 
             RemoteViews views = new RemoteViews(
-                    mContext.getPackageName(), R.layout.bookmarklistwidget_item);
+                    mContext.getPackageName(), R.layout.bookmarkthumbnailwidget_item);
             Intent fillin;
             if (res.mIsFolder) {
                 long nfi = res.mId;
                 fillin = new Intent(ACTION_CHANGE_FOLDER, null,
-                        mContext, BookmarkListWidgetService.class)
+                        mContext, BookmarkThumbnailWidgetService.class)
                         .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mWidgetId)
                         .putExtra(Bookmarks._ID, nfi);
             } else {
@@ -244,21 +245,28 @@
                 displayTitle = res.mUrl;
             }
             views.setTextViewText(R.id.label, displayTitle);
-            views.setDrawableParameters(R.id.list_item, true, 0, -1, null, -1);
             if (res.mIsFolder) {
                 if (folder != null && res.mId == folder.mId) {
-                    views.setImageViewResource(R.id.thumb, R.drawable.btn_ic_back_bookmark_widget_holo_dark);
-                    views.setDrawableParameters(R.id.list_item, true, 255, -1, null, -1);
+                    views.setImageViewResource(R.id.thumb, R.drawable.thumb_bookmark_widget_folder_back_holo);
                 } else {
-                    views.setImageViewResource(R.id.thumb, R.drawable.ic_folder_bookmark_widget_holo_dark);
+                    views.setImageViewResource(R.id.thumb, R.drawable.thumb_bookmark_widget_folder_holo);
                 }
+                views.setImageViewResource(R.id.favicon, R.drawable.ic_bookmark_widget_bookmark_holo_dark);
+                views.setDrawableParameters(R.id.thumb, true, 0, -1, null, -1);
             } else {
-                if (res.mBitmap != null) {
-                    views.setImageViewBitmap(R.id.thumb, res.mBitmap);
+                views.setDrawableParameters(R.id.thumb, true, 255, -1, null, -1);
+                if (res.mThumbnail != null) {
+                    views.setImageViewBitmap(R.id.thumb, res.mThumbnail);
                 } else {
                     views.setImageViewResource(R.id.thumb,
                             R.drawable.browser_thumbnail);
                 }
+                if (res.mIcon != null) {
+                    views.setImageViewBitmap(R.id.favicon, res.mIcon);
+                } else {
+                    views.setImageViewResource(R.id.favicon,
+                            R.drawable.app_web_browser_sm);
+                }
             }
             return views;
         }
@@ -364,35 +372,19 @@
                             // RemoteViews require a valid bitmap config
                             Options options = new Options();
                             options.inPreferredConfig = Config.ARGB_8888;
-                            Bitmap favIcon = null;
-                            Bitmap touchIcon = null;
-                            byte[] blob = c.getBlob(BOOKMARK_INDEX_TOUCH_ICON);
+                            Bitmap thumbnail = null, favicon = null;
+                            byte[] blob = c.getBlob(BOOKMARK_INDEX_THUMBNAIL);
                             if (blob != null && blob.length > 0) {
-                                touchIcon = BitmapFactory.decodeByteArray(
+                                thumbnail = BitmapFactory.decodeByteArray(
                                         blob, 0, blob.length, options);
-                            } else {
-                                blob = c.getBlob(BOOKMARK_INDEX_FAVICON);
-                                if (blob != null && blob.length > 0) {
-                                    favIcon = BitmapFactory.decodeByteArray(
-                                            blob, 0, blob.length, options);
-                                }
                             }
-
-                            if (favIcon == null) {
-                                favIcon = BitmapFactory.decodeResource(
-                                        mContext.getResources(),
-                                        R.drawable.app_web_browser_sm);
+                            blob = c.getBlob(BOOKMARK_INDEX_FAVICON);
+                            if (blob != null && blob.length > 0) {
+                                favicon = BitmapFactory.decodeByteArray(
+                                        blob, 0, blob.length, options);
                             }
-                            if (touchIcon != null || favIcon != null) {
-                                res.mBitmap = BookmarkUtils.createListWidgetIcon(
-                                        mContext, touchIcon, favIcon);
-                            }
-                            if (touchIcon != null) {
-                                touchIcon.recycle();
-                            }
-                            if (favIcon != null) {
-                                favIcon.recycle();
-                            }
+                            res.mThumbnail = thumbnail;
+                            res.mIcon = favicon;
                         }
                         bookmarks.add(res);
                     }
@@ -412,9 +404,9 @@
             // Do a bit of house cleaning for the system
             if (mBookmarks != null) {
                 for (RenderResult res : mBookmarks) {
-                    if (res.mBitmap != null) {
-                        res.mBitmap.recycle();
-                        res.mBitmap = null;
+                    if (res.mThumbnail != null) {
+                        res.mThumbnail.recycle();
+                        res.mThumbnail = null;
                     }
                 }
             }
@@ -440,7 +432,8 @@
     private static class RenderResult {
         final String mTitle;
         final String mUrl;
-        Bitmap mBitmap;
+        Bitmap mThumbnail;
+        Bitmap mIcon;
         boolean mIsFolder;
         long mId;