Bug 1130461 - Part 2: correct value setting in AddToReadingList. r=margaret, a=readinglist
authorRichard Newman <rnewman@mozilla.com>
Mon, 23 Feb 2015 10:35:11 -0800
changeset 280728 dfe8f55e047a8bfc89b604881f355e930732c778
parent 280727 2a568085f0429a3a33f5587ffdbf64e4e16f6fb6
child 280729 bfe706982340a3b069f0b249edfa81e1609e450f
push id113
push userryanvm@gmail.com
push dateThu, 05 Nov 2015 16:09:15 +0000
reviewersmargaret, readinglist
bugs1130461
milestone38.0a2
Bug 1130461 - Part 2: correct value setting in AddToReadingList. r=margaret, a=readinglist It turns out we were using bookmark columns here, which was wrong. We also need to specify ADDED_ON etc.
mobile/android/base/overlays/service/sharemethods/AddToReadingList.java
--- a/mobile/android/base/overlays/service/sharemethods/AddToReadingList.java
+++ b/mobile/android/base/overlays/service/sharemethods/AddToReadingList.java
@@ -5,41 +5,40 @@
 package org.mozilla.gecko.overlays.service.sharemethods;
 
 import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.content.Context;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.db.LocalBrowserDB;
+import org.mozilla.gecko.db.ReadingListProvider;
 import org.mozilla.gecko.overlays.service.ShareData;
 
-import static org.mozilla.gecko.db.BrowserContract.Bookmarks;
+import static org.mozilla.gecko.db.BrowserContract.ReadingListItems;
 
 /**
  * ShareMethod to add a page to the reading list.
  *
  * Inserts the given URL/title pair into the reading list database.
- * TODO: In the event the page turns out not to be reader-mode-compatible, freezes sometimes occur
- * when we subsequently load the page in reader mode. (Bug 1044781)
  */
 public class AddToReadingList extends ShareMethod {
     private static final String LOGTAG = "GeckoAddToReadingList";
 
     @Override
     public Result handle(ShareData shareData) {
-        ContentResolver resolver = context.getContentResolver();
-
-        LocalBrowserDB browserDB = new LocalBrowserDB(GeckoProfile.DEFAULT_PROFILE);
+        final ContentResolver resolver = context.getContentResolver();
 
-        ContentValues values = new ContentValues();
-        values.put(Bookmarks.TITLE, shareData.title);
-        values.put(Bookmarks.URL, shareData.url);
+        final ContentValues values = new ContentValues();
+        values.put(ReadingListItems.TITLE, shareData.title);
+        values.put(ReadingListItems.URL, shareData.url);
+        values.put(ReadingListItems.ADDED_ON, System.currentTimeMillis());
+        values.put(ReadingListItems.ADDED_BY, ReadingListProvider.PLACEHOLDER_THIS_DEVICE);
 
-        browserDB.getReadingListAccessor().addReadingListItem(resolver, values);
+        new LocalBrowserDB(GeckoProfile.DEFAULT_PROFILE).getReadingListAccessor().addReadingListItem(resolver, values);
 
         return Result.SUCCESS;
     }
 
     @Override
     public String getSuccessMessage() {
         return context.getResources().getString(R.string.reading_list_added);
     }