diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index df6e0a78c9d..68867ecdf67 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -422,9 +422,6 @@ abstract public class BrowserApp extends GeckoApp public void run() { BrowserDB.removeReadingListItemWithURL(getContentResolver(), url); showToast(R.string.page_removed, Toast.LENGTH_SHORT); - - final int count = BrowserDB.getReadingListCount(getContentResolver()); - GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Reader:ListCountUpdated", Integer.toString(count))); } }); } diff --git a/mobile/android/base/home/HomeFragment.java b/mobile/android/base/home/HomeFragment.java index 9c8319706f4..0fdc33a604c 100644 --- a/mobile/android/base/home/HomeFragment.java +++ b/mobile/android/base/home/HomeFragment.java @@ -5,6 +5,8 @@ package org.mozilla.gecko.home; +import org.json.JSONException; +import org.json.JSONObject; import org.mozilla.gecko.EditBookmarkDialog; import org.mozilla.gecko.GeckoApp; import org.mozilla.gecko.GeckoAppShell; @@ -340,7 +342,16 @@ abstract class HomeFragment extends Fragment { BrowserDB.removeHistoryEntry(cr, mUrl); BrowserDB.removeReadingListItemWithURL(cr, mUrl); - GeckoEvent e = GeckoEvent.createBroadcastEvent("Reader:Remove", mUrl); + + final JSONObject json = new JSONObject(); + try { + json.put("url", mUrl); + json.put("notify", false); + } catch (JSONException e) { + Log.e(LOGTAG, "error building JSON arguments"); + } + + GeckoEvent e = GeckoEvent.createBroadcastEvent("Reader:Remove", json.toString()); GeckoAppShell.sendEventToGecko(e); return null; diff --git a/mobile/android/chrome/content/aboutReader.js b/mobile/android/chrome/content/aboutReader.js index cea0430ef0e..8fcf87d2e04 100644 --- a/mobile/android/chrome/content/aboutReader.js +++ b/mobile/android/chrome/content/aboutReader.js @@ -196,9 +196,9 @@ AboutReader.prototype = { } break; } - case "Reader:Remove": { - if (aData == this._article.url) { + let args = JSON.parse(aData); + if (args.url == this._article.url) { if (this._isReadingListItem != 0) { this._isReadingListItem = 0; this._updateToggleButton(); @@ -316,7 +316,8 @@ AboutReader.prototype = { // In addition to removing the article from the cache (handled in // browser.js), sending this message will cause the toggle button to be // updated (handled in this file). - Services.obs.notifyObservers(null, "Reader:Remove", this._article.url); + let json = JSON.stringify({ url: this._article.url, notify: true }); + Services.obs.notifyObservers(null, "Reader:Remove", json); UITelemetry.addEvent("unsave.1", "button", null, "reader"); } diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index 4a455ea4dc7..eb4f7ca83ed 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -7320,14 +7320,18 @@ let Reader = { } case "Reader:Remove": { - let url = aData; - this.removeArticleFromCache(url, function(success) { - this.log("Reader:Remove success=" + success + ", url=" + url); + let args = JSON.parse(aData); - if (success) { + if (!("url" in args)) { + throw new Error("Reader:Remove requires URL as an argument"); + } + + this.removeArticleFromCache(args.url, function(success) { + this.log("Reader:Remove success=" + success + ", url=" + args.url); + if (success && args.notify) { sendMessageToJava({ type: "Reader:Removed", - url: url + url: args.url }); } }.bind(this));