Merge "Set home button enabled" into ics-mr1
diff --git a/res/layout/browser_subwindow.xml b/res/layout/browser_subwindow.xml
index a3868cd..a731f8d 100644
--- a/res/layout/browser_subwindow.xml
+++ b/res/layout/browser_subwindow.xml
@@ -14,34 +14,29 @@
      limitations under the License.
 -->
 
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/subwindow_container"
     android:layout_width="match_parent"
-    android:layout_height="match_parent" >
-    <FrameLayout
+    android:layout_height="match_parent"
+    android:background="@android:drawable/dialog_frame" >
+    <LinearLayout
+        android:id="@+id/inner_container"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
-        android:padding="10dip" >
-        <LinearLayout
-            android:id="@+id/inner_container"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:orientation="vertical"
-            android:background="@android:drawable/dialog_frame" >
-        </LinearLayout>
-    </FrameLayout>
+        android:orientation="vertical" >
+    </LinearLayout>
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="vertical"
         android:layout_gravity="right"
+        android:background="@color/black"
         android:gravity="right" >
         <ImageButton android:id="@+id/subwindow_close"
             android:focusable="true"
-            android:padding="0dip"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:background="@android:drawable/btn_default"
-            android:src="@android:drawable/ic_menu_close_clear_cancel" />
+            style="@style/HoloButton"
+            android:src="@drawable/ic_close_window_holo_dark" />
     </LinearLayout>
-</RelativeLayout>
+</FrameLayout>
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java
index ae5ae69..fdb34c4 100644
--- a/src/com/android/browser/AddBookmarkPage.java
+++ b/src/com/android/browser/AddBookmarkPage.java
@@ -145,6 +145,13 @@
     }
 
     private Uri getUriForFolder(long folder) {
+        BookmarkAccount account =
+                (BookmarkAccount) mAccountSpinner.getSelectedItem();
+        if (folder == mRootFolder && account != null) {
+            return BookmarksLoader.addAccount(
+                    BrowserContract.Bookmarks.CONTENT_URI_DEFAULT_FOLDER,
+                    account.accountType, account.accountName);
+        }
         return BrowserContract.Bookmarks.buildFolderUri(folder);
     }
 
@@ -437,8 +444,8 @@
             BookmarkAccount account = mAccountAdapter.getItem(i);
             if (TextUtils.equals(account.accountName, accountName)
                     && TextUtils.equals(account.accountType, accountType)) {
-                onRootFolderFound(account.rootFolderId);
                 mAccountSpinner.setSelection(i);
+                onRootFolderFound(account.rootFolderId);
                 return;
             }
         }
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 9710669..9402a77 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -1624,12 +1624,20 @@
                         @Override
                         protected Long doInBackground(Tab... params) {
                             Uri result = cr.insert(Snapshots.CONTENT_URI, values);
+                            if (result == null) {
+                                return null;
+                            }
                             long id = ContentUris.parseId(result);
                             return id;
                         }
 
                         @Override
                         protected void onPostExecute(Long id) {
+                            if (id == null) {
+                                Toast.makeText(mActivity, R.string.snapshot_failed,
+                                        Toast.LENGTH_SHORT).show();
+                                return;
+                            }
                             Bundle b = new Bundle();
                             b.putLong(BrowserSnapshotPage.EXTRA_ANIMATE_ID, id);
                             mUi.showComboView(ComboViews.Snapshots, b);