Bug 707711 - No way to delete bookmarks r=mfinkle
authorMichael Kohler <michaelkohler@linux.com>
Sun, 15 Jan 2012 16:51:23 -0500
changeset 85792 1007541442b5da8170f8a7d5627210e75673ba88
parent 85791 fbf07f7e8c93f78c7062d9d90d5b3d700864df0c
child 85793 720f1f3c2c0f681fa42f0be907c2cefb4fc407dd
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs707711
milestone12.0a1
Bug 707711 - No way to delete bookmarks r=mfinkle
mobile/android/base/AwesomeBar.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/resources/menu/awesomebar_contextmenu.xml
mobile/android/base/strings.xml.in
--- a/mobile/android/base/AwesomeBar.java
+++ b/mobile/android/base/AwesomeBar.java
@@ -67,16 +67,17 @@ import android.view.inputmethod.EditorIn
 import android.widget.AdapterView;
 import android.widget.AdapterView.AdapterContextMenuInfo;
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.ExpandableListView;
 import android.widget.ImageButton;
 import android.widget.RelativeLayout;
 import android.widget.ListView;
+import android.widget.Toast;
 
 import java.util.Map;
 
 import org.mozilla.gecko.db.BrowserDB.URLColumns;
 import org.mozilla.gecko.db.BrowserDB;
 
 import org.json.JSONArray;
 import org.json.JSONObject;
@@ -426,16 +427,21 @@ public class AwesomeBar extends Activity
             mContextMenuSubject = null;
             return;
         }
 
         mContextMenuSubject = selectedItem;
 
         MenuInflater inflater = getMenuInflater();
         inflater.inflate(R.menu.awesomebar_contextmenu, menu);
+        
+        if (view != (ListView)findViewById(R.id.bookmarks_list)) {
+            MenuItem removeBookmarkItem = menu.findItem(R.id.remove_bookmark);
+            removeBookmarkItem.setVisible(false);
+        }
 
         menu.setHeaderTitle(title);
     }
 
     @Override
     public boolean onContextItemSelected(MenuItem item) {
         if (mContextMenuSubject == null)
             return false;
@@ -459,16 +465,22 @@ public class AwesomeBar extends Activity
 
         mContextMenuSubject = null;
 
         switch (item.getItemId()) {
             case R.id.open_new_tab: {
                 GeckoApp.mAppContext.loadUrl(url, AwesomeBar.Type.ADD);
                 break;
             }
+            case R.id.remove_bookmark: {
+                ContentResolver resolver = Tabs.getInstance().getContentResolver();
+                BrowserDB.removeBookmark(resolver, url);
+                Toast.makeText(this, R.string.bookmark_removed, Toast.LENGTH_SHORT).show();
+                break;
+            }
             case R.id.add_to_launcher: {
                 Bitmap bitmap = null;
                 if (b != null)
                     bitmap = BitmapFactory.decodeByteArray(b, 0, b.length);
     
                 GeckoAppShell.createShortcut(title, url, bitmap, "");
                 break;
             }
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -71,16 +71,17 @@
 
 <!ENTITY addons "Add-ons">
 <!ENTITY downloads "Downloads">
 
 <!ENTITY share "Share">
 <!ENTITY save_as_pdf "Save as PDF">
 
 <!ENTITY contextmenu_open_new_tab "Open in New Tab">
+<!ENTITY contextmenu_remove_bookmark "Remove">
 <!ENTITY contextmenu_add_to_launcher "Add to Home Screen">
 <!ENTITY contextmenu_share "Share">
 
 <!ENTITY site_settings_title        "Clear Site Settings">
 <!ENTITY site_settings_cancel       "Cancel">
 <!ENTITY site_settings_clear        "Clear">
 <!ENTITY site_settings_no_settings  "There are no settings to clear.">
 
--- a/mobile/android/base/resources/menu/awesomebar_contextmenu.xml
+++ b/mobile/android/base/resources/menu/awesomebar_contextmenu.xml
@@ -2,12 +2,15 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
 
     <item android:id="@+id/open_new_tab"
           android:title="@string/contextmenu_open_new_tab"/>
 
     <item android:id="@+id/share"
           android:title="@string/contextmenu_share"/>
 
+    <item android:id="@+id/remove_bookmark"
+          android:title="@string/contextmenu_remove_bookmark"/>
+
     <item android:id="@+id/add_to_launcher"
           android:title="@string/contextmenu_add_to_launcher"/>
 
 </menu>
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -79,16 +79,17 @@
   <string name="downloads">&downloads;</string>
 
   <string name="site_settings_title">&site_settings_title;</string>
   <string name="site_settings_cancel">&site_settings_cancel;</string>
   <string name="site_settings_clear">&site_settings_clear;</string>
   <string name="site_settings_no_settings">&site_settings_no_settings;</string>
 
   <string name="contextmenu_open_new_tab">&contextmenu_open_new_tab;</string>
+  <string name="contextmenu_remove_bookmark">&contextmenu_remove_bookmark;</string>
   <string name="contextmenu_add_to_launcher">&contextmenu_add_to_launcher;</string>
   <string name="contextmenu_share">&contextmenu_share;</string>
 
   <string name="pref_use_master_password">&pref_use_master_password;</string>
   <string name="masterpassword_create_title">&masterpassword_create_title;</string>
   <string name="masterpassword_remove_title">&masterpassword_remove_title;</string>
   <string name="masterpassword_password">&masterpassword_password;</string>
   <string name="masterpassword_confirm">&masterpassword_confirm;</string>