Closed
Bug 724756
Opened 13 years ago
Closed 13 years ago
removeBookmark can remove an arbitrary number of bookmarks
Categories
(Firefox for Android Graveyard :: General, defect, P1)
Tracking
(firefox11 affected, firefox12 affected, firefox13 verified, fennec11+)
VERIFIED
FIXED
Firefox 13
People
(Reporter: rnewman, Assigned: Margaret)
Details
Attachments
(1 file, 1 obsolete file)
8.25 KB,
patch
|
lucasr
:
review+
|
Details | Diff | Splinter Review |
public void removeBookmark(ContentResolver cr, String uri) {
cr.delete(appendProfile(Bookmarks.CONTENT_URI),
Bookmarks.URL + " = ?",
new String[] { uri });
}
Remove Slashdot from somewhere in your bookmarks menu, and it'll disappear from your toolbar. Not cool. "removeBookmark" should remove 0 or 1 bookmarks.
This should take a bookmark ID, not a URI.
Potential for confusing data loss here.
Updated•13 years ago
|
Assignee: nobody → lucasr.at.mozilla
Updated•13 years ago
|
tracking-fennec: ? → 11+
Comment 1•13 years ago
|
||
So, same URL can be bookmarked several times and reside on multiple directories on desktop?
Right now, once you access a web page, we check if the there's any bookmark entry pointing to that URL and update the main menu accordingly (enable/disable the bookmark menu item). It works like a simple toggle so we don't really know "which" bookmark entry is being considered.
This is different than, say, directly removing a specific bookmark in awesomebar (in which you have some context as to which specific bookmark entry you're removing).
Assignee | ||
Comment 2•13 years ago
|
||
I'm going to take this from Lucas, but we'll have to figure out the issue in comment 1.
Assignee: lucasr.at.mozilla → margaret.leibovic
Reporter | ||
Comment 3•13 years ago
|
||
(In reply to Lucas Rocha (:lucasr) from comment #1)
> So, same URL can be bookmarked several times and reside on multiple
> directories on desktop?
Correct -- or even multiple times in the same folder, right next to each other. (Try it!)
> Right now, once you access a web page, we check if the there's any bookmark
> entry pointing to that URL and update the main menu accordingly
> (enable/disable the bookmark menu item). It works like a simple toggle so we
> don't really know "which" bookmark entry is being considered.
Which is like the Star on desktop. That behaves like this:
http://people.mozilla.com/~rnewman/bugs/724756/remove.png
"Remove 2 bookmarks" button when you try to un-star.
> This is different than, say, directly removing a specific bookmark in
> awesomebar (in which you have some context as to which specific bookmark
> entry you're removing).
Or in the bookmark menu.
Reporter | ||
Comment 4•13 years ago
|
||
I view this as three pieces:
* Ensuring that there's an API that works in terms of identifiers, rather than the URL attribute.
* If we keep it around, rejigging the "by URL" version to have the same hooks as the identifier version: for example, bumping the modified time of each parent folder. (Bug 724745.)
* Deciding how the UI uses the available API to delete one or all bookmarks. I imagine tap-and-hold in the bookmarks UI, versus an equivalent to Star > Remove all.
Comment 5•13 years ago
|
||
(In reply to Richard Newman [:rnewman] from comment #4)
> I view this as three pieces:
>
> * Ensuring that there's an API that works in terms of identifiers, rather
> than the URL attribute.
>
> * If we keep it around, rejigging the "by URL" version to have the same
> hooks as the identifier version: for example, bumping the modified time of
> each parent folder. (Bug 724745.)
>
> * Deciding how the UI uses the available API to delete one or all bookmarks.
> I imagine tap-and-hold in the bookmarks UI, versus an equivalent to Star >
> Remove all.
Those are exactly the conclusions we reached after discussing a bit on IRC. The plan is to rename the current removeBookmark to removeBookmarksWithURL and add a new removeBookmark that takes an ID instead of URL. The removeBookmarksWithURL will be used on the star menu item. And the removeBookmark(id) will be used when tapping-and-holding on awesomebar's bookmarks tab.
Reporter | ||
Comment 6•13 years ago
|
||
(In reply to Lucas Rocha (:lucasr) from comment #5)
> Those are exactly the conclusions we reached after discussing a bit on IRC.
> The plan is to rename the current removeBookmark to removeBookmarksWithURL
> and add a new removeBookmark that takes an ID instead of URL. The
> removeBookmarksWithURL will be used on the star menu item. And the
> removeBookmark(id) will be used when tapping-and-holding on awesomebar's
> bookmarks tab.
\o/
I'd better finish up my parent-timestamp patch, mm? :D
Assignee | ||
Comment 7•13 years ago
|
||
This is hard to test right now because bug 716918 broke the functionality added in bug 721776, but hopefully bug 722413 will fix that soon. (Gah, too many bug numbers!)
Attachment #595477 -
Flags: feedback?(lucasr.at.mozilla)
Comment 8•13 years ago
|
||
Comment on attachment 595477 [details] [diff] [review]
patch
Review of attachment 595477 [details] [diff] [review]:
-----------------------------------------------------------------
::: mobile/android/base/AwesomeBar.java
@@ +472,5 @@
> public boolean onContextItemSelected(MenuItem item) {
> if (mContextMenuSubject == null)
> return false;
>
> + Cursor cursor = null;
Maybe it would cleaner if you have something like a Long id = null here and you only assign a value to it when mContextMenuSubject is a cursor.
@@ +499,5 @@
> Toast.makeText(this, R.string.new_tab_opened, Toast.LENGTH_SHORT).show();
> break;
> }
> case R.id.remove_bookmark: {
> + if (cursor == null) {
Why is this check necessary? What are the cases where cursor is null when removing a bookmark? Replace that with the "id" idea above?
::: mobile/android/base/db/BrowserDB.java
@@ +89,5 @@
> public void addBookmark(ContentResolver cr, String title, String uri);
>
> + public void removeBookmark(ContentResolver cr, int id);
> +
> + public void removeBookmarkWithURL(ContentResolver cr, String uri);
removeBookmarksWithURL (plural) would be slightly better.
Attachment #595477 -
Flags: feedback?(lucasr.at.mozilla) → feedback+
Assignee | ||
Comment 9•13 years ago
|
||
(In reply to Lucas Rocha (:lucasr) from comment #8)
> @@ +499,5 @@
> > Toast.makeText(this, R.string.new_tab_opened, Toast.LENGTH_SHORT).show();
> > break;
> > }
> > case R.id.remove_bookmark: {
> > + if (cursor == null) {
>
> Why is this check necessary? What are the cases where cursor is null when
> removing a bookmark? Replace that with the "id" idea above?
I did this as a safety precaution, since a check in onCreateContextMenu is the only thing making sure we don't show R.id.remove_bookmarks for non-bookmark items. I realize now that ensuring that we have a cursor doesn't actually prevent possible error cases - if we have a top sites cursor, the id wouldn't be correct for the bookmark row, so this could cause problems. I think we may want to look into more robust ways to ensure we're not doing bad things like accidentally removing the wrong bookmarks.
I initially tried the "id" idea, but I was getting warnings about the variable potentially not being initialized down below. Because id needs to be final, I can't initialize it then just set the value if mContextMenuSubject is a Cursor. Given these constraints, this is what I came up with - let me know if you can think of a better way to do this.
Attachment #595796 -
Flags: review?(lucasr.at.mozilla)
Assignee | ||
Updated•13 years ago
|
Attachment #595477 -
Attachment is obsolete: true
Updated•13 years ago
|
Attachment #595796 -
Flags: review?(lucasr.at.mozilla) → review+
Comment 10•13 years ago
|
||
(In reply to Margaret Leibovic [:margaret] from comment #9)
> Created attachment 595796 [details] [diff] [review]
> patch
>
> (In reply to Lucas Rocha (:lucasr) from comment #8)
>
> > @@ +499,5 @@
> > > Toast.makeText(this, R.string.new_tab_opened, Toast.LENGTH_SHORT).show();
> > > break;
> > > }
> > > case R.id.remove_bookmark: {
> > > + if (cursor == null) {
> >
> > Why is this check necessary? What are the cases where cursor is null when
> > removing a bookmark? Replace that with the "id" idea above?
>
> I did this as a safety precaution, since a check in onCreateContextMenu is
> the only thing making sure we don't show R.id.remove_bookmarks for
> non-bookmark items. I realize now that ensuring that we have a cursor
> doesn't actually prevent possible error cases - if we have a top sites
> cursor, the id wouldn't be correct for the bookmark row, so this could cause
> problems. I think we may want to look into more robust ways to ensure we're
> not doing bad things like accidentally removing the wrong bookmarks.
I only asked because I'm always suspicious of null checks :-) They often hide bugs instead of actually fixing them. If something is null when it shouldn't, this is probably a bug somewhere else—the null check will only make things worse.
Assignee | ||
Comment 11•13 years ago
|
||
(In reply to Lucas Rocha (:lucasr) from comment #10)
> I only asked because I'm always suspicious of null checks :-) They often
> hide bugs instead of actually fixing them. If something is null when it
> shouldn't, this is probably a bug somewhere else—the null check will only
> make things worse.
True enough!
Pushed to inbound:
https://hg.mozilla.org/integration/mozilla-inbound/rev/01827d3f5693
Comment 12•13 years ago
|
||
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 13
Updated•13 years ago
|
status-firefox13:
affected → ---
Comment 13•13 years ago
|
||
Verified fixed on:
Firefox 13.0a1 (2012-03-02)
20120302031112
http://hg.mozilla.org/mozilla-central/rev/3a7b9e61c263
--
Device: Samsung Galaxy S2
OS: Android 2.3.4
Status: RESOLVED → VERIFIED
status-firefox13:
--- → verified
Updated•5 years ago
|
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•