Bug 1092011 - Re-instate Page-Already-In-ReadingList message, r=margaret
authorMark Capella <markcapella@twcny.rr.com>
Fri, 31 Oct 2014 23:31:20 -0400
changeset 213529 a9902edc4870d0a2d2acee34f5a13aa180d0b0e1
parent 213528 019609619a48bdf303c26de0e2a68d291c2c04a8
child 213530 c8eefd3e3ac36142c2519c7e2c407ae944211176
push id27754
push userphilringnalda@gmail.com
push dateSun, 02 Nov 2014 16:56:35 +0000
treeherdermozilla-central@6ca3405c22e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1092011
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1092011 - Re-instate Page-Already-In-ReadingList message, r=margaret
mobile/android/base/ReadingListHelper.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/strings.xml.in
--- a/mobile/android/base/ReadingListHelper.java
+++ b/mobile/android/base/ReadingListHelper.java
@@ -75,30 +75,36 @@ public final class ReadingListHelper imp
             }
         }
     }
 
     /**
      * A page can be added to the ReadingList by long-tap of the page-action
      * icon, or by tapping the readinglist-add icon in the ReaderMode banner.
      */
-    private void handleAddToList(JSONObject message) {
-        final ContentValues values = new ContentValues();
+    private void handleAddToList(final JSONObject message) {
+        final ContentResolver cr = context.getContentResolver();
         final String url = message.optString("url");
 
-        values.put(ReadingListItems.URL, url);
-        values.put(ReadingListItems.TITLE, message.optString("title"));
-        values.put(ReadingListItems.LENGTH, message.optInt("length"));
-        values.put(ReadingListItems.EXCERPT, message.optString("excerpt"));
-
         ThreadUtils.postToBackgroundThread(new Runnable() {
             @Override
             public void run() {
-                BrowserDB.addReadingListItem(context.getContentResolver(), values);
-                showToast(R.string.reading_list_added, Toast.LENGTH_SHORT);
+                if (BrowserDB.isReadingListItem(cr, url)) {
+                    showToast(R.string.reading_list_duplicate, Toast.LENGTH_SHORT);
+
+                } else {
+                    final ContentValues values = new ContentValues();
+                    values.put(ReadingListItems.URL, url);
+                    values.put(ReadingListItems.TITLE, message.optString("title"));
+                    values.put(ReadingListItems.LENGTH, message.optInt("length"));
+                    values.put(ReadingListItems.EXCERPT, message.optString("excerpt"));
+                    BrowserDB.addReadingListItem(cr, values);
+
+                    showToast(R.string.reading_list_added, Toast.LENGTH_SHORT);
+                }
             }
         });
 
         GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Reader:Added", url));
     }
 
     /**
      * Gecko (ReaderMode) requests the page favicon to append to the
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -354,16 +354,17 @@ size. -->
 <!-- Localization note (site_settings_*) : These strings are used in the "Site Settings"
      dialog that appears after selecting the "Edit Site Settings" context menu item. -->
 <!ENTITY site_settings_title3       "Site Settings">
 <!ENTITY site_settings_cancel       "Cancel">
 <!ENTITY site_settings_clear        "Clear">
 <!ENTITY site_settings_no_settings  "There are no settings to clear.">
 
 <!ENTITY reading_list_added "Page added to your Reading List">
+<!ENTITY reading_list_duplicate "Page already in your Reading List">
 
 <!-- Localization note (reading_list_time_minutes2) : This string is used in the "Reading List"
      panel on the home page to give the user an estimate of how many minutes it will take to
      read an article. The word "minute" should be abbreviated if possible. -->
 <!ENTITY reading_list_time_minutes2 "&formatD; min">
 <!ENTITY reading_list_time_over_an_hour "Over an hour">
 
 <!-- Localization note : These strings are used as alternate text for accessibility.
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -289,16 +289,17 @@
   <string name="edit_mode_cancel">&edit_mode_cancel;</string>
 
   <string name="site_settings_title">&site_settings_title3;</string>
   <string name="site_settings_cancel">&site_settings_cancel;</string>
   <string name="site_settings_clear">&site_settings_clear;</string>
   <string name="site_settings_no_settings">&site_settings_no_settings;</string>
 
   <string name="reading_list_added">&reading_list_added;</string>
+  <string name="reading_list_duplicate">&reading_list_duplicate;</string>
   <string name="reading_list_time_minutes">&reading_list_time_minutes2;</string>
   <string name="reading_list_time_over_an_hour">&reading_list_time_over_an_hour;</string>
 
   <string name="page_action_dropmarker_description">&page_action_dropmarker_description;</string>
 
   <string name="contextmenu_open_new_tab">&contextmenu_open_new_tab;</string>
   <string name="contextmenu_open_private_tab">&contextmenu_open_private_tab;</string>
   <string name="contextmenu_remove">&contextmenu_remove;</string>