Bug 1226238 - (Part 4) Remove reading list toggle button from reader view. r=ahunt,Gijs

MozReview-Commit-ID: 3pwOV5BjwC9

--HG--
extra : rebase_source : 66c2afd658320c5e5bd05e4b2a3278f2c871fee2
This commit is contained in:
Margaret Leibovic 2016-02-22 10:35:32 -05:00
parent db4aa097f5
commit 3a66695ff2
22 changed files with 4 additions and 266 deletions

View File

@ -23,12 +23,8 @@ var ReaderParent = {
_readerModeInfoPanelOpen: false,
MESSAGES: [
"Reader:AddToList",
"Reader:ArticleGet",
"Reader:FaviconRequest",
"Reader:ListStatusRequest",
"Reader:RemoveFromList",
"Reader:SystemUIVisibility",
"Reader:UpdateReaderButton",
"Reader:SetIntPref",
"Reader:SetCharPref",
@ -72,10 +68,6 @@ var ReaderParent = {
break;
}
case "Reader:SystemUIVisibility":
// XXX: To implement.
break;
case "Reader:UpdateReaderButton": {
let browser = message.target;
if (message.data && message.data.isArticle !== undefined) {

View File

@ -928,9 +928,6 @@ pref("reader.color_scheme.values", "[\"dark\",\"auto\",\"light\"]");
// Whether to use a vertical or horizontal toolbar.
pref("reader.toolbar.vertical", false);
// Whether or not to display buttons related to reading list in reader view.
pref("browser.readinglist.enabled", true);
// Telemetry settings.
// Whether to use the unified telemetry behavior, requires a restart.
pref("toolkit.telemetry.unified", false);

View File

@ -53,7 +53,7 @@ public final class ReadingListHelper implements NativeEventListener {
this.readingListAccessor = db.getReadingListAccessor();
EventDispatcher.getInstance().registerGeckoThreadListener((NativeEventListener) this,
"Reader:AddToList", "Reader:UpdateList", "Reader:FaviconRequest", "Reader:ListStatusRequest", "Reader:RemoveFromList");
"Reader:AddToList", "Reader:UpdateList", "Reader:FaviconRequest");
contentObserver = new ContentObserver(null) {
@ -72,7 +72,7 @@ public final class ReadingListHelper implements NativeEventListener {
public void uninit() {
EventDispatcher.getInstance().unregisterGeckoThreadListener((NativeEventListener) this,
"Reader:AddToList", "Reader:UpdateList", "Reader:FaviconRequest", "Reader:ListStatusRequest", "Reader:RemoveFromList");
"Reader:AddToList", "Reader:UpdateList", "Reader:FaviconRequest");
context.getContentResolver().unregisterContentObserver(contentObserver);
}
@ -81,6 +81,7 @@ public final class ReadingListHelper implements NativeEventListener {
public void handleMessage(final String event, final NativeJSObject message,
final EventCallback callback) {
switch(event) {
// Added from web context menu.
case "Reader:AddToList": {
handleAddToList(callback, message);
break;
@ -93,14 +94,6 @@ public final class ReadingListHelper implements NativeEventListener {
handleReaderModeFaviconRequest(callback, message.getString("url"));
break;
}
case "Reader:RemoveFromList": {
handleRemoveFromList(message.getString("url"));
break;
}
case "Reader:ListStatusRequest": {
handleReadingListStatusRequest(callback, message.getString("url"));
break;
}
}
}
@ -230,44 +223,6 @@ public final class ReadingListHelper implements NativeEventListener {
}).execute();
}
/**
* A page can be removed from the ReadingList by panel context menu,
* or by tapping the readinglist-remove icon in the ReaderMode banner.
*/
private void handleRemoveFromList(final String url) {
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
readingListAccessor.removeReadingListItemWithURL(context.getContentResolver(), url);
handleEvent(ReadingListEvent.REMOVED, url);
}
});
}
/**
* Gecko (ReaderMode) requests the page ReadingList status, to display
* the proper ReaderMode banner icon (readinglist-add / readinglist-remove).
*/
private void handleReadingListStatusRequest(final EventCallback callback, final String url) {
ThreadUtils.postToBackgroundThread(new Runnable() {
@Override
public void run() {
final int inReadingList = readingListAccessor.isReadingListItem(context.getContentResolver(), url) ? 1 : 0;
final JSONObject json = new JSONObject();
try {
json.put("url", url);
json.put("inReadingList", inReadingList);
} catch (JSONException e) {
Log.e(LOGTAG, "JSON error - failed to return inReadingList status", e);
}
// Return the json object to fulfill the promise.
callback.sendSuccess(json.toString());
}
});
}
/**
* Handle various reading list events (and display appropriate toasts).
*/

View File

@ -76,17 +76,8 @@ var Reader = {
break;
}
case "Reader:Added": {
let mm = window.getGroupMessageManager("browsers");
mm.broadcastAsyncMessage("Reader:Added", { url: aData });
break;
}
case "Reader:Removed": {
ReaderMode.removeArticleFromCache(aData).catch(e => Cu.reportError("Error removing article from cache: " + e));
let mm = window.getGroupMessageManager("browsers");
mm.broadcastAsyncMessage("Reader:Removed", { url: aData });
break;
}
}
@ -94,13 +85,6 @@ var Reader = {
receiveMessage: function(message) {
switch (message.name) {
case "Reader:AddToList": {
// If the article is coming from reader mode, we must have fetched it already.
let article = message.data.article;
article.status = this.STATUS_FETCHED_ARTICLE;
this._addArticleToReadingList(article);
break;
}
case "Reader:ArticleGet":
this._getArticle(message.data.url).then((article) => {
// Make sure the target browser is still alive before trying to send data back.
@ -147,22 +131,6 @@ var Reader = {
break;
}
case "Reader:ListStatusRequest":
Messaging.sendRequestForResult({
type: "Reader:ListStatusRequest",
url: message.data.url
}).then((data) => {
message.target.messageManager.sendAsyncMessage("Reader:ListStatusData", JSON.parse(data));
});
break;
case "Reader:RemoveFromList":
Messaging.sendRequest({
type: "Reader:RemoveFromList",
url: message.data.url
});
break;
case "Reader:SystemUIVisibility":
Messaging.sendRequest({
type: "SystemUI:Visibility",
@ -296,19 +264,6 @@ var Reader = {
return article;
}),
_addArticleToReadingList: function(article) {
Messaging.sendRequestForResult({
type: "Reader:AddToList",
url: truncate(article.url, MAX_URI_LENGTH),
title: truncate(article.title, MAX_TITLE_LENGTH),
length: article.length,
excerpt: article.excerpt,
status: article.status,
}).then((url) => {
ReaderMode.storeArticleInCache(article).catch(e => Cu.reportError("Error storing article in cache: " + e));
}).catch(Cu.reportError);
},
/**
* Gets an article for a given URL. This method will download and parse a document
* if it does not find the article in the cache.

View File

@ -155,7 +155,7 @@ var lazilyLoadedObserverScripts = [
["Feedback", ["Feedback:Show"], "chrome://browser/content/Feedback.js"],
["SelectionHandler", ["TextSelection:Get"], "chrome://browser/content/SelectionHandler.js"],
["EmbedRT", ["GeckoView:ImportScript"], "chrome://browser/content/EmbedRT.js"],
["Reader", ["Reader:FetchContent", "Reader:Added", "Reader:Removed"], "chrome://browser/content/Reader.js"],
["Reader", ["Reader:FetchContent", "Reader:Removed"], "chrome://browser/content/Reader.js"],
["PrintHelper", ["Print:PDF"], "chrome://browser/content/PrintHelper.js"],
];
if (AppConstants.NIGHTLY_BUILD) {
@ -191,13 +191,10 @@ lazilyLoadedObserverScripts.forEach(function (aScript) {
// Lazily-loaded browser scripts that use message listeners.
[
["Reader", [
["Reader:AddToList", false],
["Reader:ArticleGet", false],
["Reader:DropdownClosed", true], // 'true' allows us to survive mid-air cycle-collection.
["Reader:DropdownOpened", false],
["Reader:FaviconRequest", false],
["Reader:ListStatusRequest", false],
["Reader:RemoveFromList", false],
["Reader:ToolbarHidden", false],
["Reader:SystemUIVisibility", false],
["Reader:UpdateReaderButton", false],

View File

@ -65,7 +65,6 @@
list-style: none;
background-color: #EBEBF0;
border-top: 1px solid #D7D9DB;
display: none;
}
.toolbar[visible] {
@ -244,14 +243,6 @@
display: none;
}
.toggle-button.on {
background-image: url('chrome://browser/skin/images/reader-toggle-on-icon-mdpi.png');
}
.toggle-button {
background-image: url('chrome://browser/skin/images/reader-toggle-off-icon-mdpi.png');
}
.style-button {
background-image: url('chrome://browser/skin/images/reader-style-icon-mdpi.png');
}
@ -269,14 +260,6 @@
}
@media screen and (min-resolution: 1.25dppx) {
.toggle-button.on {
background-image: url('chrome://browser/skin/images/reader-toggle-on-icon-hdpi.png');
}
.toggle-button {
background-image: url('chrome://browser/skin/images/reader-toggle-off-icon-hdpi.png');
}
.style-button {
background-image: url('chrome://browser/skin/images/reader-style-icon-hdpi.png');
}
@ -295,14 +278,6 @@
}
@media screen and (min-resolution: 2dppx) {
.toggle-button.on {
background-image: url('chrome://browser/skin/images/reader-toggle-on-icon-xhdpi.png');
}
.toggle-button {
background-image: url('chrome://browser/skin/images/reader-toggle-off-icon-xhdpi.png');
}
.style-button {
background-image: url('chrome://browser/skin/images/reader-style-icon-xhdpi.png');
}
@ -321,14 +296,6 @@
}
@media screen and (min-resolution: 3dppx) {
.toggle-button.on {
background-image: url('chrome://browser/skin/images/reader-toggle-on-icon-xxhdpi.png');
}
.toggle-button {
background-image: url('chrome://browser/skin/images/reader-toggle-off-icon-xxhdpi.png');
}
.style-button {
background-image: url('chrome://browser/skin/images/reader-style-icon-xxhdpi.png');
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 738 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 985 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 B

View File

@ -98,14 +98,6 @@ chrome.jar:
skin/images/reader-plus-hdpi.png (images/reader-plus-hdpi.png)
skin/images/reader-plus-xhdpi.png (images/reader-plus-xhdpi.png)
skin/images/reader-plus-xxhdpi.png (images/reader-plus-xxhdpi.png)
skin/images/reader-toggle-on-icon-mdpi.png (images/reader-toggle-on-icon-mdpi.png)
skin/images/reader-toggle-on-icon-hdpi.png (images/reader-toggle-on-icon-hdpi.png)
skin/images/reader-toggle-on-icon-xhdpi.png (images/reader-toggle-on-icon-xhdpi.png)
skin/images/reader-toggle-on-icon-xxhdpi.png (images/reader-toggle-on-icon-xxhdpi.png)
skin/images/reader-toggle-off-icon-mdpi.png (images/reader-toggle-off-icon-mdpi.png)
skin/images/reader-toggle-off-icon-hdpi.png (images/reader-toggle-off-icon-hdpi.png)
skin/images/reader-toggle-off-icon-xhdpi.png (images/reader-toggle-off-icon-xhdpi.png)
skin/images/reader-toggle-off-icon-xxhdpi.png (images/reader-toggle-off-icon-xxhdpi.png)
skin/images/reader-style-icon-active-mdpi.png (images/reader-style-icon-active-mdpi.png)
skin/images/reader-style-icon-active-hdpi.png (images/reader-style-icon-active-hdpi.png)
skin/images/reader-style-icon-active-xhdpi.png (images/reader-style-icon-active-xhdpi.png)

View File

@ -32,8 +32,6 @@ var AboutReader = function(mm, win, articlePromise) {
let doc = win.document;
this._mm = mm;
this._mm.addMessageListener("Reader:Added", this);
this._mm.addMessageListener("Reader:Removed", this);
this._mm.addMessageListener("Reader:CloseDropdown", this);
this._mm.addMessageListener("Reader:AddButton", this);
this._mm.addMessageListener("Reader:RemoveButton", this);
@ -68,14 +66,6 @@ var AboutReader = function(mm, win, articlePromise) {
this._setupStyleDropdown();
this._setupButton("close-button", this._onReaderClose.bind(this), "aboutReader.toolbar.close");
try {
if (Services.prefs.getBoolPref("browser.readinglist.enabled")) {
this._setupButton("toggle-button", this._onReaderToggle.bind(this, "button"), "aboutReader.toolbar.addToReadingList");
}
} catch (e) {
// Pref doesn't exist.
}
const gIsFirefoxDesktop = Services.appinfo.ID == "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
if (gIsFirefoxDesktop) {
// we're ready for any external setup, send a signal for that.
@ -112,10 +102,6 @@ var AboutReader = function(mm, win, articlePromise) {
this._setupFontSizeButtons();
// Track status of reader toolbar add/remove toggle button
this._isReadingListItem = -1;
this._updateToggleButton();
this._loadArticle();
}
@ -179,17 +165,6 @@ AboutReader.prototype = {
receiveMessage: function (message) {
switch (message.name) {
case "Reader:Added": {
// Page can be added by long-press pageAction, or by tap on banner icon.
if (message.data.url == this._article.url) {
if (this._isReadingListItem != 1) {
this._isReadingListItem = 1;
this._updateToggleButton();
}
}
break;
}
// Triggered by Android user pressing BACK while the banner font-dropdown is open.
case "Reader:CloseDropdown": {
// Just close it.
@ -197,15 +172,6 @@ AboutReader.prototype = {
break;
}
case "Reader:Removed": {
if (message.data.url == this._article.url) {
if (this._isReadingListItem != 0) {
this._isReadingListItem = 0;
this._updateToggleButton();
}
}
break;
}
case "Reader:AddButton": {
if (message.data.id && message.data.image) {
let btn = this._doc.createElement("button");
@ -267,8 +233,6 @@ AboutReader.prototype = {
// Close the Banners Font-dropdown, cleanup Android BackPressListener.
this._closeDropdown();
this._mm.removeMessageListener("Reader:Added", this);
this._mm.removeMessageListener("Reader:Removed", this);
this._mm.removeMessageListener("Reader:CloseDropdown", this);
this._mm.removeMessageListener("Reader:AddButton", this);
this._mm.removeMessageListener("Reader:RemoveButton", this);
@ -277,63 +241,10 @@ AboutReader.prototype = {
}
},
_updateToggleButton: function() {
let button = this._doc.getElementById("toggle-button");
if (this._isReadingListItem == 1) {
button.classList.add("on");
button.setAttribute("title", gStrings.GetStringFromName("aboutReader.toolbar.removeFromReadingList"));
} else {
button.classList.remove("on");
button.setAttribute("title", gStrings.GetStringFromName("aboutReader.toolbar.addToReadingList"));
}
},
_requestReadingListStatus: function() {
let handleListStatusData = (message) => {
this._mm.removeMessageListener("Reader:ListStatusData", handleListStatusData);
let args = message.data;
if (args.url == this._article.url) {
if (this._isReadingListItem != args.inReadingList) {
let isInitialStateChange = (this._isReadingListItem == -1);
this._isReadingListItem = args.inReadingList;
this._updateToggleButton();
// Display the toolbar when all its initial component states are known
if (isInitialStateChange) {
// Toolbar display is updated here to avoid it appearing in the middle of the screen on page load. See bug 1145567.
this._win.setTimeout(() => {
this._toolbarElement.style.display = "block";
// Delay showing the toolbar to have a nice slide from bottom animation.
this._win.setTimeout(() => this._setToolbarVisibility(true), 200);
}, 500);
}
}
}
};
this._mm.addMessageListener("Reader:ListStatusData", handleListStatusData);
this._mm.sendAsyncMessage("Reader:ListStatusRequest", { url: this._article.url });
},
_onReaderClose: function() {
this._win.location.href = this._getOriginalUrl();
},
_onReaderToggle: function(aMethod) {
if (!this._article)
return;
if (this._isReadingListItem == 0) {
this._mm.sendAsyncMessage("Reader:AddToList", { article: this._article });
UITelemetry.addEvent("save.1", aMethod, null, "reading_list");
} else {
this._mm.sendAsyncMessage("Reader:RemoveFromList", { url: this._article.url });
UITelemetry.addEvent("unsave.1", aMethod, null, "reading_list");
}
},
_setFontSize: function(newFontSize) {
let containerClasses = this._doc.getElementById("container").classList;
@ -712,7 +623,6 @@ AboutReader.prototype = {
this._contentElement.style.display = "block";
this._updateImageMargins();
this._requestReadingListStatus();
this._requestFavicon();
this._doc.body.classList.add("loaded");

View File

@ -57,7 +57,6 @@
<div class="dropdown-arrow"/>
</li>
</ul>
<li><button id="toggle-button" class="button toggle-button" hidden="true"/></li>
</ul>
</body>

View File

@ -23,8 +23,6 @@ aboutReader.fontTypeSample=Aa
aboutReader.toolbar.close=Close Reader View
aboutReader.toolbar.typeControls=Type controls
aboutReader.toolbar.addToReadingList=Add to Reading List
aboutReader.toolbar.removeFromReadingList=Remove from Reading List
# These are used for the Reader View toolbar button and the menuitem within the
# View menu.

View File

@ -326,14 +326,6 @@
background-image: url("chrome://global/skin/reader/RM-Type-Controls-24x24.svg");
}
.toggle-button.on {
background-image: url("chrome://global/skin/reader/RM-Delete-24x24.svg");
}
.toggle-button {
background-image: url("chrome://global/skin/reader/RM-Add-24x24.svg");
}
.minus-button {
background-image: url("chrome://global/skin/reader/RM-Minus-24x24.svg");
}

View File

@ -36,9 +36,7 @@ toolkit.jar:
skin/classic/global/in-content/dropdown.svg (../../shared/in-content/dropdown.svg)
skin/classic/global/in-content/help-glyph.svg (../../shared/in-content/help-glyph.svg)
skin/classic/global/in-content/radio.svg (../../shared/in-content/radio.svg)
skin/classic/global/reader/RM-Add-24x24.svg (../../shared/reader/RM-Add-24x24.svg)
skin/classic/global/reader/RM-Close-24x24.svg (../../shared/reader/RM-Close-24x24.svg)
skin/classic/global/reader/RM-Delete-24x24.svg (../../shared/reader/RM-Delete-24x24.svg)
skin/classic/global/reader/RM-Minus-24x24.svg (../../shared/reader/RM-Minus-24x24.svg)
skin/classic/global/reader/RM-Plus-24x24.svg (../../shared/reader/RM-Plus-24x24.svg)
skin/classic/global/reader/RM-Type-Controls-24x24.svg (../../shared/reader/RM-Type-Controls-24x24.svg)

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill-rule="evenodd" fill="#808080" d="M12,2C6.477,2,2,6.477,2,12c0,5.523,4.477,10,10,10s10-4.477,10-10 C22,6.477,17.523,2,12,2z M17.714,12.714h-5v5h-1.429v-5h-5v-1.429h5v-5h1.429v5h5V12.714z"/>
</svg>

Before

Width:  |  Height:  |  Size: 528 B

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill-rule="evenodd" fill="#808080" d="M12,2C6.477,2,2,6.477,2,12c0,5.523,4.477,10,10,10s10-4.477,10-10 C22,6.477,17.523,2,12,2z M11.286,6.286 M6.286,12.714v-1.429h11.429v1.429H6.286z"/>
</svg>

Before

Width:  |  Height:  |  Size: 520 B