Closed Bug 814587 Opened 12 years ago Closed 12 years ago

Add "Add to Reading List" to link context menu

Categories

(Firefox for Android Graveyard :: General, defect)

ARM
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 23

People

(Reporter: wesj, Assigned: lucasr)

References

Details

(Whiteboard: [mentor=lucasr][lang=java][lang=js])

Attachments

(3 files, 1 obsolete file)

It might be useful to long tap on a link on a page and add the article to your reading list. We could add pages to a queue and download/check them one by one in the background. A toast or notification could notify the user if that was successful or not. Seems useful on pages with lists of articles and also as a way to provide a reading list/save for later functionality on low memory/power devices.
Is this not more or less the same as a "Open in new background tab" feature?
(In reply to Michael Kohler [:mkohler] from comment #1) > Is this not more or less the same as a "Open in new background tab" feature? Oh, we already have a "Reading list" we can use.. nothing at all like background tab :) It seems like we already download the content and already inform the user about adding it when adding it from Reader Mode. We could probably use the same function.
Assignee: nobody → michaelkohler
(In reply to Michael Kohler [:mkohler] from comment #2) > (In reply to Michael Kohler [:mkohler] from comment #1) > > Is this not more or less the same as a "Open in new background tab" feature? > > Oh, we already have a "Reading list" we can use.. nothing at all like > background tab :) > > It seems like we already download the content and already inform the user > about adding it when adding it from Reader Mode. We could probably use the > same function. It's slightly more complicated than that. We only enable reading list on pages that can actually be converted by reader mode. So, we'd have to run the readability check on the target URL before being able to tell if we can add the page to reading list or not. The problem is that the readability check might take a few seconds depending on the size of the page. So, we'd need some sort of progress feedback while all these things are happening in background.
We could take an alternative design: Always show the menu. When selected, try to add to reading list. If succeeded, tell the user "Page was added to Reading List". If we failed, tell the user "Unable to add page to Reading List". I don't like needing to run the check each time the context menu is opened on a link. What do we think?
(In reply to Mark Finkle (:mfinkle) from comment #4) > We could take an alternative design: Always show the menu. When selected, > try to add to reading list. If succeeded, tell the user "Page was added to > Reading List". If we failed, tell the user "Unable to add page to Reading > List". > > I don't like needing to run the check each time the context menu is opened > on a link. > > What do we think? That's actually what I meant :-) My point about the progress feedback is for when you tap on the menu option and wait until the readability check finishes.
I'd be fine with a notification for that. "Adding <url>/<pages> to reading list" (with a number indicator if there's more than one?... I've been in the mood to extend nsIAlertsService for JB stuff lately). We don't even necessarily need to load the page in a browser either. To save memory we could just xhr the url and try to parse that. If it works, yay! Otherwise we fail.
Assignee: michaelkohler → nobody
Whiteboard: [mentor=lucasr][lang=java][lang=js]
lucasr, this looks like an interesting bug to work on. Can you give me some info on where I can find the code for reader mode?
Sriram: We initialize the context menu actions here: http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js#326 You should be able to mimic the "Open Link in New Tab" code for most of the menu action. You'll want a different implementation of the action callback though. You probably want to use Reader.parseDocumentFromURL, found here: http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js#7354 The callback passed to parseDocumentFromURL can be used to determine if reader mode was able to handle the link or not. You still need to add the article to the Reading List, which seems to be done with Reader.storeArticleInCache(). Lucas can fill in more details, but this might get you started.
Assignee: nobody → sriram_r
Status: NEW → ASSIGNED
OS: Linux → Android
Hardware: x86 → ARM
This is just a proposed patch. I have used the existing Toast Messages to display success and failure. Please let me know if I have to use notifications. I know I have hard coded the string. Was too lazy to get them into browser.properties. I would take care of that in my next patch. :)
Attachment #696612 - Flags: review?(lucasr.at.mozilla)
Comment on attachment 696612 [details] [diff] [review] Proposed patch for "Add to Reading List" feature Review of attachment 696612 [details] [diff] [review]: ----------------------------------------------------------------- Look generally good. Just needs to handle the error case properly. ::: mobile/android/chrome/content/browser.js @@ +343,5 @@ > + NativeWindow.contextmenus.linkOpenableContext, > + function(aTarget) { > + let url = NativeWindow.contextmenus._getLinkURL(aTarget); > + Reader.parseDocumentFromURL(url, > + function(article) { nit: move the "function(article) {" to the same line as Reader.parseDocument... @@ +346,5 @@ > + Reader.parseDocumentFromURL(url, > + function(article) { > + if(article) { > + Reader.storeArticleInCache(article, > + function(result) { nit: move the "function (resullt) {" to the same line as Reader.storeArticleInCache... Also, rename "result" to "success" for clarity. @@ +357,5 @@ > + } > + }); > + }); > + } else { > + NativeWindow.toast.show("Cannot add article", "short"); You should just send a "Reader:Added" message with "success: false" here. A toast notification will be shown for you.
Attachment #696612 - Flags: review?(lucasr.at.mozilla) → review-
Contacted sriram and taking over this bug with his consent. Builds on previous patch, and made changes as per last comment. I'm not sure if this would suffice
Attachment #696612 - Attachment is obsolete: true
Attachment #725562 - Flags: review?(lucasr.at.mozilla)
Comment on attachment 725562 [details] [diff] [review] Patch that adds "Add to reading list" to link context menu Review of attachment 725562 [details] [diff] [review]: ----------------------------------------------------------------- Looks good overall but still needs work. Let me know if you have any questions. ::: mobile/android/chrome/content/browser.js @@ +358,5 @@ > }); > > + NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.addToReadingList"), > + NativeWindow.contextmenus.linkOpenableContext, > + function(aTarget) { You'll have to check if the article is already stored in cache before doing anything here. Otherwise the storeArticleInCache() will fail when when the article is already in the reading list. You can use Reader.getArticleFromCache() to do it. We should replace the current 'success' boolean property (sent with the Reader:Added message) with a more fine-grained result id. See my comment on bug 784387 about this same case in another context: https://bugzilla.mozilla.org/show_bug.cgi?id=784387#c21 @@ +361,5 @@ > + NativeWindow.contextmenus.linkOpenableContext, > + function(aTarget) { > + let url = NativeWindow.contextmenus._getLinkURL(aTarget); > + Reader.parseDocumentFromURL(url, > + function(article) { "function(article) {" should be on the same line than the parseDocumentFromURL method call. @@ +364,5 @@ > + Reader.parseDocumentFromURL(url, > + function(article) { > + if(article) { > + Reader.storeArticleInCache(article, > + function(success) { Same here. Move "function(success) {" to the same line than the storeArticleInCache call.
Attachment #725562 - Flags: review?(lucasr.at.mozilla) → review-
Shriram, I'm going to take over this bug for now just make to sure it lands asap.
Assignee: sriram_r → lucasr.at.mozilla
Attachment #738078 - Flags: review?(bnicholson)
Attachment #738079 - Flags: review?(bnicholson)
(In reply to Lucas Rocha (:lucasr) from comment #14) > Created attachment 738078 [details] [diff] [review] > Add "Add to Reading List" to link context menu The summary is actually: "Change Reader:Add to handle tabID and URL as input". This builds a bit on top of Mark Capella's patch on bug 800899 btw.
Comment on attachment 738078 [details] [diff] [review] Add "Add to Reading List" to link context menu Review of attachment 738078 [details] [diff] [review]: ----------------------------------------------------------------- ::: mobile/android/chrome/content/browser.js @@ +6518,5 @@ > + url = uri.spec; > + urlWithoutRef = uri.specIgnoringRef; > + } else { > + // Nothing can be done here. > + return; This shouldn't happen, so I'd log an error in case we have any bugs so it's easier to track down.
Attachment #738078 - Flags: review?(bnicholson) → review+
Attachment #738079 - Flags: review?(bnicholson) → review+
(In reply to Brian Nicholson (:bnicholson) from comment #17) > Comment on attachment 738078 [details] [diff] [review] > Add "Add to Reading List" to link context menu > > Review of attachment 738078 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: mobile/android/chrome/content/browser.js > @@ +6518,5 @@ > > + url = uri.spec; > > + urlWithoutRef = uri.specIgnoringRef; > > + } else { > > + // Nothing can be done here. > > + return; > > This shouldn't happen, so I'd log an error in case we have any bugs so it's > easier to track down. Done.
Hey everybody, just wanted to thank Shriram for picking this up and doing the hard work to get it moving again, and to Lucas and Brian for landing it.
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 23
Depends on: 864376
Blocks: 866766
Depends on: 872005
Note: Bug 872005 has removed this feature. Well, it removed the context menu, but left the rest of the changes.
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: