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)
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)
3.06 KB,
patch
|
lucasr
:
review-
|
Details | Diff | Splinter Review |
4.34 KB,
patch
|
bnicholson
:
review+
|
Details | Diff | Splinter Review |
2.57 KB,
patch
|
bnicholson
:
review+
|
Details | Diff | Splinter Review |
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.
Comment 1•12 years ago
|
||
Is this not more or less the same as a "Open in new background tab" feature?
Comment 2•12 years ago
|
||
(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
Assignee | ||
Comment 3•12 years ago
|
||
(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.
Comment 4•12 years ago
|
||
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?
Assignee | ||
Comment 5•12 years ago
|
||
(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.
Reporter | ||
Comment 6•12 years ago
|
||
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.
Updated•12 years ago
|
Assignee: michaelkohler → nobody
Assignee | ||
Updated•12 years ago
|
Whiteboard: [mentor=lucasr][lang=java][lang=js]
Comment 7•12 years ago
|
||
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?
Comment 8•12 years ago
|
||
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 | ||
Updated•12 years ago
|
Assignee: nobody → sriram_r
Updated•12 years ago
|
Status: NEW → ASSIGNED
Updated•12 years ago
|
OS: Linux → Android
Hardware: x86 → ARM
Comment 9•12 years ago
|
||
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)
Assignee | ||
Comment 10•12 years ago
|
||
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-
Comment 11•12 years ago
|
||
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
Updated•12 years ago
|
Attachment #725562 -
Flags: review?(lucasr.at.mozilla)
Assignee | ||
Comment 12•12 years ago
|
||
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-
Assignee | ||
Comment 13•12 years ago
|
||
Shriram, I'm going to take over this bug for now just make to sure it lands asap.
Assignee: sriram_r → lucasr.at.mozilla
Assignee | ||
Comment 14•12 years ago
|
||
Attachment #738078 -
Flags: review?(bnicholson)
Assignee | ||
Comment 15•12 years ago
|
||
Attachment #738079 -
Flags: review?(bnicholson)
Assignee | ||
Comment 16•12 years ago
|
||
(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 17•12 years ago
|
||
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+
Updated•12 years ago
|
Attachment #738079 -
Flags: review?(bnicholson) → review+
Assignee | ||
Comment 18•12 years ago
|
||
(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.
Assignee | ||
Comment 19•12 years ago
|
||
Comment 20•12 years ago
|
||
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.
Comment 21•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/3573bf02fda8
https://hg.mozilla.org/mozilla-central/rev/478ec73ea931
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 23
Comment 22•12 years ago
|
||
Note: Bug 872005 has removed this feature. Well, it removed the context menu, but left the rest of the changes.
Updated•4 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
•