Incorporate save to home screen with add bookmark dialog.

Bug:2953515

Remove the initial popup menu when pressing the star that
selects between saving to home screen and saving to bookmarks.
Instead, once the add bookmark dialog is open, the user can
select between bookmarks and saving to home screen.

Change-Id: I35e8590ff6a2a7c2058e45e4f77ec6b5d209b0f9
diff --git a/res/layout/browser_add_bookmark_const_url.xml b/res/layout/browser_add_bookmark_const_url.xml
deleted file mode 100644
index 6a6d78f..0000000
--- a/res/layout/browser_add_bookmark_const_url.xml
+++ /dev/null
@@ -1,85 +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:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical"
-    >
-
-    <ImageView android:id="@+id/titleDivider"
-        android:layout_width="match_parent"
-        android:layout_height="1dip"
-        android:scaleType="fitXY"
-        android:gravity="fill_horizontal"
-        android:src="@drawable/dialog_divider_horizontal_light"
-        android:layout_marginLeft="10dip"
-        android:layout_marginRight="10dip"/>
-
-    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_weight="1"
-        android:orientation="vertical"
-        android:paddingTop="5dip"
-        android:paddingBottom="13dip"
-        android:paddingLeft="20dip"
-        android:paddingRight="20dip" >
-
-        <TextView
-            android:id="@+id/titleText"
-            android:layout_height="wrap_content"
-            android:layout_width="wrap_content"
-            android:text="@string/name"
-            android:gravity="left"
-            android:textAppearance="?android:attr/textAppearanceMedium" />
-
-        <EditText
-            android:id="@+id/title"
-            android:layout_height="wrap_content"
-            android:layout_width="250dip"
-            android:gravity="fill_horizontal"
-            android:inputType="textCapSentences"
-            android:selectAllOnFocus="true" />
-
-    </LinearLayout>
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:minHeight="54dip"
-        android:orientation="horizontal"
-        android:paddingTop="4dip"
-        android:paddingLeft="2dip"
-        android:paddingRight="2dip" >
-        <Button android:id="@+id/OK"
-            android:text="@string/save"
-            android:layout_width="0dip"
-            android:layout_gravity="left"
-            android:layout_weight="1"
-            android:maxLines="2"
-            android:layout_height="wrap_content" />
-        <Button android:id="@+id/cancel"
-            android:text="@string/do_not_save"
-            android:layout_width="0dip"
-            android:layout_gravity="right"
-            android:layout_weight="1"
-            android:maxLines="2"
-            android:layout_height="wrap_content" />
-    </LinearLayout>
-
-</LinearLayout>
-
diff --git a/res/menu/bookmark_shortcut.xml b/res/menu/folder_choice.xml
similarity index 64%
rename from res/menu/bookmark_shortcut.xml
rename to res/menu/folder_choice.xml
index 67cbddf..068b170 100644
--- a/res/menu/bookmark_shortcut.xml
+++ b/res/menu/folder_choice.xml
@@ -4,9 +4,9 @@
      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.
@@ -14,12 +14,11 @@
      limitations under the License.
 -->
 
-<menu
-    xmlns:android="http://schemas.android.com/apk/res/android">
-    <item
-        android:id="@+id/add_bookmark_menu_id"
-        android:title="@string/save_to_bookmarks" />
-    <item
-        android:id="@+id/shortcut_to_home_menu_id"
-        android:title="@string/create_shortcut_bookmark" />
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@+id/home_screen"
+        android:title="@string/add_to_homescreen_menu_option"/>
+    <item android:id="@+id/bookmarks"
+        android:title="@string/add_to_bookmarks_menu_option"/>
+    <item android:id="@+id/other"
+        android:title="@string/add_to_other_folder_menu_option"/>
 </menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ca14df6..3a3cab8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -131,6 +131,12 @@
     <!-- Label stating that the currently open folder has no subfolders
          in the add bookmark dialog [CHAR-LIMIT=none]-->
     <string name="no_subfolders">No subfolders</string>
+    <!-- Menu item to use the top level bookmarks folder to save a bookmark in. [CHAR-LIMIT=30]-->
+    <string name="add_to_bookmarks_menu_option">Bookmarks</string>
+    <!-- Menu item to save the newly created bookmark to the home screen. [CHAR-LIMIT=30]-->
+    <string name="add_to_homescreen_menu_option">Home screen</string>
+    <!-- Menu item to open a picker to determine which folder to save a bookmark in. [CHAR-LIMIT=30]-->
+    <string name="add_to_other_folder_menu_option">Other folder\u2026</string>
     <!-- Field label in Bookmark dialog box: title that the user wishes to use for the bookmark -->
     <string name="name">Label</string>
     <!-- Initial value in Location field in Bookmark dialog box -->
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java
index 9e5b349..fc480ee 100644
--- a/src/com/android/browser/AddBookmarkPage.java
+++ b/src/com/android/browser/AddBookmarkPage.java
@@ -42,6 +42,7 @@
 import android.text.TextUtils;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.Window;
@@ -52,6 +53,7 @@
 import android.widget.CursorAdapter;
 import android.widget.EditText;
 import android.widget.ListView;
+import android.widget.PopupMenu;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -63,7 +65,7 @@
 public class AddBookmarkPage extends Activity
         implements View.OnClickListener, TextView.OnEditorActionListener,
         AdapterView.OnItemClickListener, LoaderManager.LoaderCallbacks<Cursor>,
-        BreadCrumbView.Controller {
+        BreadCrumbView.Controller, PopupMenu.OnMenuItemClickListener {
 
     public static final long DEFAULT_FOLDER_ID = -1;
 
@@ -84,7 +86,6 @@
     private boolean     mEditingExisting;
     private Bundle      mMap;
     private String      mTouchIconUrl;
-    private Bitmap      mThumbnail;
     private String      mOriginalUrl;
     private TextView mFolder;
     private View mDefaultView;
@@ -98,6 +99,7 @@
     private TextView mFakeTitle;
     private View mCrumbHolder;
     private ListView mListView;
+    private boolean mSaveToHomeScreen;
 
     private static class Folder {
         String Name;
@@ -110,6 +112,7 @@
 
     // Message IDs
     private static final int SAVE_BOOKMARK = 100;
+    private static final int TOUCH_ICON_DOWNLOADED = 101;
 
     private Handler mHandler;
 
@@ -207,6 +210,7 @@
                     completeOrCancelFolderNaming(false);
                 } else {
                     // User has selected a folder.  Go back to the opening page
+                    mSaveToHomeScreen = false;
                     switchToDefaultView(true);
                 }
             } else if (save()) {
@@ -221,7 +225,14 @@
                 finish();
             }
         } else if (v == mFolder) {
-            switchToFolderSelector();
+            // FIXME: We want to use mFolder as an anchor, but cannot until we
+            // fix the issue that the PopupMenu will not extend past the edge of
+            // the dialog.
+            PopupMenu popup = new PopupMenu(this, mFakeTitle);
+            popup.getMenuInflater().inflate(R.menu.folder_choice,
+                    popup.getMenu());
+            popup.setOnMenuItemClickListener(this);
+            popup.show();
         } else if (v == mAddNewFolder) {
             mFolderNamer.setVisibility(View.VISIBLE);
             mFolderNamer.setText(R.string.new_folder);
@@ -234,6 +245,28 @@
         }
     }
 
+    @Override
+    public boolean onMenuItemClick(MenuItem item) {
+        switch(item.getItemId()) {
+            case R.id.bookmarks:
+                mCurrentFolder = getBookmarksBarId(this);
+                mFolder.setText(item.getTitle());
+                mSaveToHomeScreen = false;
+                break;
+            case R.id.home_screen:
+                // Create a short cut to the home screen
+                mSaveToHomeScreen = true;
+                mFolder.setText(item.getTitle());
+                break;
+            case R.id.other:
+                switchToFolderSelector();
+                break;
+            default:
+                return false;
+        }
+        return true;
+    }
+
     // Refresh the ListView to hide or show the empty view, as necessary.
     // Should be called after mFolderNamer is shown or hidden.
     private void updateList() {
@@ -462,7 +495,6 @@
             title = mMap.getString("title");
             url = mOriginalUrl = mMap.getString("url");
             mTouchIconUrl = mMap.getString("touch_icon_url");
-            mThumbnail = (Bitmap) mMap.getParcelable("thumbnail");
             mCurrentFolder = mMap.getLong(BrowserContract.Bookmarks.PARENT, DEFAULT_FOLDER_ID);
         }
         if (mCurrentFolder == DEFAULT_FOLDER_ID) {
@@ -609,6 +641,14 @@
                                         Toast.LENGTH_LONG).show();
                             }
                             break;
+                        case TOUCH_ICON_DOWNLOADED:
+                            Bundle b = msg.getData();
+                            sendBroadcast(BookmarkUtils.createAddToHomeIntent(
+                                    AddBookmarkPage.this, b.getString("url"),
+                                    b.getString("title"),
+                                    (Bitmap) b.getParcelable("touchIcon"),
+                                    (Bitmap) b.getParcelable("favicon")));
+                            break;
                     }
                 }
             };
@@ -671,27 +711,59 @@
             return false;
         }
 
+        if (mSaveToHomeScreen) {
+            mEditingExisting = false;
+        }
+
+        boolean urlUnmodified = url.equals(mOriginalUrl);
+
         if (mEditingExisting) {
             mMap.putString("title", title);
             mMap.putString("url", url);
-            mMap.putBoolean("invalidateThumbnail", !url.equals(mOriginalUrl));
+            mMap.putBoolean("invalidateThumbnail", !urlUnmodified);
             // FIXME: This does not work yet
             mMap.putLong(BrowserContract.Bookmarks.PARENT, mCurrentFolder);
             setResult(RESULT_OK, (new Intent()).setAction(
                     getIntent().toString()).putExtras(mMap));
         } else {
-            // Post a message to write to the DB.
+            Bitmap thumbnail;
+            Bitmap favicon;
+            if (urlUnmodified) {
+                thumbnail = (Bitmap) mMap.getParcelable("thumbnail");
+                favicon = (Bitmap) mMap.getParcelable("favicon");
+            } else {
+                thumbnail = null;
+                favicon = null;
+            }
+
             Bundle bundle = new Bundle();
             bundle.putString("title", title);
             bundle.putString("url", url);
-            bundle.putParcelable("thumbnail", mThumbnail);
-            bundle.putBoolean("invalidateThumbnail", !url.equals(mOriginalUrl));
-            bundle.putString("touchIconUrl", mTouchIconUrl);
-            Message msg = Message.obtain(mHandler, SAVE_BOOKMARK);
-            msg.setData(bundle);
-            // Start a new thread so as to not slow down the UI
-            Thread t = new Thread(new SaveBookmarkRunnable(getApplicationContext(), msg));
-            t.start();
+            bundle.putParcelable("favicon", favicon);
+
+            if (mSaveToHomeScreen) {
+                if (mTouchIconUrl != null && urlUnmodified) {
+                    Message msg = Message.obtain(mHandler,
+                            TOUCH_ICON_DOWNLOADED);
+                    msg.setData(bundle);
+                    DownloadTouchIcon icon = new DownloadTouchIcon(this, msg,
+                            mMap.getString("user_agent"));
+                    icon.execute(mTouchIconUrl);
+                } else {
+                    sendBroadcast(BookmarkUtils.createAddToHomeIntent(this, url,
+                            title, null /*touchIcon*/, favicon));
+                }
+            } else {
+                bundle.putParcelable("thumbnail", thumbnail);
+                bundle.putBoolean("invalidateThumbnail", !urlUnmodified);
+                bundle.putString("touchIconUrl", mTouchIconUrl);
+                // Post a message to write to the DB.
+                Message msg = Message.obtain(mHandler, SAVE_BOOKMARK);
+                msg.setData(bundle);
+                // Start a new thread so as to not slow down the UI
+                Thread t = new Thread(new SaveBookmarkRunnable(getApplicationContext(), msg));
+                t.start();
+            }
             setResult(RESULT_OK);
             LogTag.logBookmarkAdded(url, "bookmarkview");
         }
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 9683b31..bd50a77 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -103,11 +103,11 @@
 import android.webkit.WebChromeClient;
 import android.webkit.WebHistoryItem;
 import android.webkit.WebIconDatabase;
+import android.webkit.WebSettings;
 import android.webkit.WebView;
 import android.widget.EditText;
 import android.widget.FrameLayout;
 import android.widget.LinearLayout;
-import android.widget.PopupMenu;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -130,7 +130,7 @@
 
 public class BrowserActivity extends Activity
         implements View.OnCreateContextMenuListener, DownloadListener,
-        PopupMenu.OnMenuItemClickListener, BookmarksHistoryCallbacks {
+        BookmarksHistoryCallbacks {
 
     /* Define some aliases to make these debugging flags easier to refer to.
      * This file imports android.provider.Browser, so we can't just refer to "Browser.DEBUG".
@@ -1490,9 +1490,17 @@
         WebView w = getTopWindow();
         i.putExtra("url", w.getUrl());
         i.putExtra("title", w.getTitle());
-        i.putExtra("touch_icon_url", w.getTouchIconUrl());
+        String touchIconUrl = w.getTouchIconUrl();
+        if (touchIconUrl != null) {
+            i.putExtra("touch_icon_url", touchIconUrl);
+            WebSettings settings = w.getSettings();
+            if (settings != null) {
+                i.putExtra("user_agent", settings.getUserAgentString());
+            }
+        }
         i.putExtra("thumbnail", createScreenshot(w, getDesiredThumbnailWidth(this),
                 getDesiredThumbnailHeight(this)));
+        i.putExtra("favicon", w.getFavicon());
         i.putExtra(BrowserContract.Bookmarks.PARENT,
                 folderId);
         // Put the dialog at the upper right of the screen, covering the
@@ -2296,8 +2304,6 @@
 
     static final int UPDATE_BOOKMARK_THUMBNAIL       = 108;
 
-    private static final int TOUCH_ICON_DOWNLOADED   = 109;
-
     private static final int OPEN_BOOKMARKS = 201;
 
     // Private handler for handling javascript and saving passwords
@@ -2373,14 +2379,6 @@
                         updateScreenshot(view);
                     }
                     break;
-
-                case TOUCH_ICON_DOWNLOADED:
-                    Bundle b = msg.getData();
-                    showSaveToHomescreenDialog(b.getString("url"),
-                        b.getString("title"),
-                        (Bitmap) b.getParcelable("touchIcon"),
-                        (Bitmap) b.getParcelable("favicon"));
-                    break;
             }
         }
     };
@@ -3806,52 +3804,6 @@
         startActivity(intent);
     }
 
-    /* package */ void promptAddOrInstallBookmark(View anchor) {
-        PopupMenu popup = new PopupMenu(this, anchor);
-        popup.getMenuInflater().inflate(R.menu.bookmark_shortcut, popup.getMenu());
-        popup.setOnMenuItemClickListener(this);
-        popup.show();
-    }
-
-    /**
-     * popup menu item click listener
-     * @param item
-     */
-    public boolean onMenuItemClick(MenuItem item) {
-        switch(item.getItemId()) {
-            case R.id.add_bookmark_menu_id:
-                bookmarkCurrentPage(AddBookmarkPage.DEFAULT_FOLDER_ID);
-                return true;
-            case R.id.shortcut_to_home_menu_id:
-                Tab current = mTabControl.getCurrentTab();
-                current.populatePickerData();
-                String touchIconUrl = mTabControl.getCurrentWebView().getTouchIconUrl();
-                if (touchIconUrl != null) {
-                    // Download the touch icon for this site then save
-                    // it to the
-                    // homescreen.
-                    Bundle b = new Bundle();
-                    b.putString("url", current.getUrl());
-                    b.putString("title", current.getTitle());
-                    b.putParcelable("favicon", current.getFavicon());
-                    Message msg = mHandler.obtainMessage(TOUCH_ICON_DOWNLOADED);
-                    msg.setData(b);
-                    new DownloadTouchIcon(BrowserActivity.this, msg,
-                            mTabControl.getCurrentWebView().getSettings().getUserAgentString())
-                            .execute(touchIconUrl);
-                } else {
-                    // add to homescreen, can do it immediately as there
-                    // is no touch
-                    // icon.
-                    showSaveToHomescreenDialog(
-                            current.getUrl(), current.getTitle(), null, current.getFavicon());
-                }
-                return true;
-            default:
-                return false;
-        }
-    }
-
     /* package */Dialog makeAddOrInstallDialog() {
         final Tab current = mTabControl.getCurrentTab();
         Resources resources = getResources();
@@ -3918,32 +3870,6 @@
         mContentView.addView(mComboView, COVER_SCREEN_PARAMS);
     }
 
-    private void showSaveToHomescreenDialog(String url, String title, Bitmap touchIcon,
-            Bitmap favicon) {
-        Intent intent = new Intent(this, SaveToHomescreenDialog.class);
-
-        // Just in case the user tries to save before a page finishes loading
-        // so the current history item, and therefore the page, is null.
-        if (null == url) {
-            url = mLastEnteredUrl;
-            // This can happen.
-            if (null == url) {
-                url = mSettings.getHomePage();
-            }
-        }
-
-        // In case the web page has not yet received its associated title.
-        if (title == null) {
-            title = url;
-        }
-
-        intent.putExtra("title", title);
-        intent.putExtra("url", url);
-        intent.putExtra("favicon", favicon);
-        intent.putExtra("touchIcon", touchIcon);
-        startActivity(intent);
-    }
-
     // Called when loading from context menu or LOAD_URL message
     private void loadUrlFromContext(WebView view, String url) {
         // In case the user enters nothing.
diff --git a/src/com/android/browser/SaveToHomescreenDialog.java b/src/com/android/browser/SaveToHomescreenDialog.java
deleted file mode 100644
index 15f0aea..0000000
--- a/src/com/android/browser/SaveToHomescreenDialog.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.
- */
-
-package com.android.browser;
-
-import android.app.Activity;
-import android.content.ComponentName;
-import android.content.ContentResolver;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.net.ParseException;
-import android.net.Uri;
-import android.net.WebAddress;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.provider.Browser;
-import android.util.Log;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.EditText;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Date;
-
-public class SaveToHomescreenDialog extends Activity {
-
-    private EditText    mTitle;
-    private String      mUrl;
-    private Bitmap      mFavicon;
-    private Bitmap      mTouchIcon;
-
-    private View.OnClickListener mOk = new View.OnClickListener() {
-        public void onClick(View v) {
-            if (save()) {
-                finish();
-            }
-        }
-    };
-
-    private View.OnClickListener mCancel = new View.OnClickListener() {
-        public void onClick(View v) {
-            finish();
-        }
-    };
-
-    protected void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-        requestWindowFeature(Window.FEATURE_LEFT_ICON);
-        setContentView(R.layout.browser_add_bookmark_const_url);
-        setTitle(R.string.create_shortcut_bookmark);
-        getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
-                R.drawable.ic_list_bookmark);
-
-        String title = null;
-        String url = null;
-        Bundle map = getIntent().getExtras();
-        if (map != null) {
-            title = map.getString("title");
-        }
-
-        mUrl = map.getString("url");
-        mFavicon = (Bitmap)map.getParcelable("favicon");
-        mTouchIcon = (Bitmap)map.getParcelable("touchIcon");
-
-        Bitmap icon = BookmarkUtils.createIcon(this, mTouchIcon, mFavicon,
-               BookmarkUtils.BookmarkIconType.ICON_HOME_SHORTCUT);
-        getWindow().setFeatureDrawable(Window.FEATURE_LEFT_ICON, new BitmapDrawable(icon));
-
-        mTitle = (EditText) findViewById(R.id.title);
-        mTitle.setText(title);
-
-        Button okButton = (Button) findViewById(R.id.OK);
-        okButton.setOnClickListener(mOk);
-
-        Button cancelButton = (Button) findViewById(R.id.cancel);
-        cancelButton.setOnClickListener(mCancel);
-
-        if (!getWindow().getDecorView().isInTouchMode()) {
-            okButton.requestFocus();
-        }
-    }
-
-    /**
-     * Parse the data entered in the dialog and send an intent to create an
-     * icon on the homescreen.
-     */
-    private boolean save() {
-        String title = mTitle.getText().toString().trim();
-        String unfilteredUrl = BrowserActivity.fixUrl(mUrl);
-        if (title.length() == 0) {
-            mTitle.setError(getResources().getText(R.string.bookmark_needs_title));
-            return false;
-        }
-
-        String url = unfilteredUrl.trim();
-
-        sendBroadcast(BookmarkUtils.createAddToHomeIntent(this, url, title,
-                mTouchIcon, mFavicon));
-        setResult(RESULT_OK);
-        return true;
-    }
-}
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java
index bbb55ad..035dc34 100644
--- a/src/com/android/browser/TitleBar.java
+++ b/src/com/android/browser/TitleBar.java
@@ -205,7 +205,8 @@
                     } else if (mInLoad) {
                         mBrowserActivity.stopLoading();
                     } else {
-                        mBrowserActivity.promptAddOrInstallBookmark(button);
+                        mBrowserActivity.bookmarkCurrentPage(
+                                AddBookmarkPage.DEFAULT_FOLDER_ID);
                     }
                     button.setPressed(false);
                 } else if (mTitleBg.isPressed()) {
diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java
index 7310f75..b87ea78 100644
--- a/src/com/android/browser/TitleBarXLarge.java
+++ b/src/com/android/browser/TitleBarXLarge.java
@@ -127,7 +127,8 @@
         } else if (mForwardButton == v) {
             mBrowserActivity.getTopWindow().goForward();
         } else if (mStar == v) {
-            mBrowserActivity.promptAddOrInstallBookmark(mStar);
+            mBrowserActivity.bookmarkCurrentPage(
+                    AddBookmarkPage.DEFAULT_FOLDER_ID);
         } else if (mAllButton == v) {
             mBrowserActivity.bookmarksOrHistoryPicker(false);
         } else if (mSearchButton == v) {