Bug 778489 - Use ReaderModeUtils to create about:reader urls (r=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Tue, 11 Sep 2012 18:51:43 +0100
changeset 104807 ff9853a03d8e9f986ac6f10cde1704abe4ccdab5
parent 104806 3254e5b70c098e0275809797f6a62a35f4ed0f37
child 104808 110ae125057f953d45322181cd9e37073a2b7d6a
push id14693
push userlrocha@mozilla.com
push dateTue, 11 Sep 2012 17:52:18 +0000
treeherdermozilla-inbound@c11b2042ea31 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs778489
milestone18.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 778489 - Use ReaderModeUtils to create about:reader urls (r=mfinkle)
mobile/android/base/AwesomeBar.java
mobile/android/base/Makefile.in
mobile/android/base/ReaderModeUtils.java
mobile/android/base/Tab.java
mobile/android/base/awesomebar/BookmarksTab.java
--- a/mobile/android/base/AwesomeBar.java
+++ b/mobile/android/base/AwesomeBar.java
@@ -524,17 +524,17 @@ public class AwesomeBar extends GeckoAct
                 break;
             }
             case R.id.open_in_reader: {
                 if (url == null) {
                     Log.e(LOGTAG, "Can't open in reader mode because URL is null");
                     break;
                 }
 
-                openUrlAndFinish(getReaderForUrl(url));
+                openUrlAndFinish(ReaderModeUtils.getAboutReaderForUrl(url, true));
                 break;
             }
             case R.id.edit_bookmark: {
                 AlertDialog.Builder editPrompt = new AlertDialog.Builder(this);
                 View editView = getLayoutInflater().inflate(R.layout.bookmark_edit, null);
                 editPrompt.setTitle(R.string.bookmark_edit_title);
                 editPrompt.setView(editView);
 
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -99,16 +99,17 @@ FENNEC_JAVA_FILES = \
   PrivateDataPreference.java \
   PropertyAnimator.java \
   ProfileMigrator.java \
   PromptService.java \
   sqlite/ByteBufferInputStream.java \
   sqlite/MatrixBlobCursor.java \
   sqlite/SQLiteBridge.java \
   sqlite/SQLiteBridgeException.java \
+  ReaderModeUtils.java \
   RemoteTabs.java \
   RobocopAPI.java \
   SetupScreen.java \
   ShapedButton.java \
   SiteIdentityPopup.java \
   SuggestClient.java \
   SurfaceBits.java \
   Tab.java \
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/ReaderModeUtils.java
@@ -0,0 +1,25 @@
+/* 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/. */
+
+package org.mozilla.gecko;
+
+import android.net.Uri;
+
+public class ReaderModeUtils {
+    private static final String LOGTAG = "ReaderModeUtils";
+
+    public static String getAboutReaderForUrl(String url, boolean inReadingList) {
+        return getAboutReaderForUrl(url, -1, inReadingList);
+    }
+
+    public static String getAboutReaderForUrl(String url, int tabId, boolean inReadingList) {
+        String aboutReaderUrl = "about:reader?url=" + Uri.encode(url) +
+                                "&readingList=" + (inReadingList ? 1 : 0);
+
+        if (tabId >= 0)
+            aboutReaderUrl += "&tabId=" + tabId;
+
+        return aboutReaderUrl;
+    }
+}
--- a/mobile/android/base/Tab.java
+++ b/mobile/android/base/Tab.java
@@ -434,19 +434,17 @@ public final class Tab {
             }
         });
     }
 
     public void readerMode() {
         if (!mReaderEnabled)
             return;
 
-        GeckoApp.mAppContext.loadUrl("about:reader?tabId=" + mId +
-                                     "&url=" + Uri.encode(getURL()) +
-                                     "&readingList=" + (mReadingListItem ? 1 : 0));
+        GeckoApp.mAppContext.loadUrl(ReaderModeUtils.getAboutReaderForUrl(getURL(), mId, mReadingListItem));
     }
 
     public void doReload() {
         GeckoEvent e = GeckoEvent.createBroadcastEvent("Session:Reload", "");
         GeckoAppShell.sendEventToGecko(e);
     }
 
     // Our version of nsSHistory::GetCanGoBack
--- a/mobile/android/base/awesomebar/BookmarksTab.java
+++ b/mobile/android/base/awesomebar/BookmarksTab.java
@@ -198,17 +198,17 @@ public class BookmarksTab extends Awesom
         AwesomeBarTabs.OnUrlOpenListener listener = getUrlListener();
         if (listener == null) {
             return;
         }
 
         String url = cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.URL));
         long parentId = cursor.getLong(cursor.getColumnIndexOrThrow(Bookmarks.PARENT));
         if (parentId == Bookmarks.FIXED_READING_LIST_ID) {
-            url = AwesomeBar.getReaderForUrl(url);
+            url = ReaderModeUtils.getAboutReaderForUrl(url, true);
         }
         listener.onUrlOpen(url);
     }
 
     private class BookmarksListAdapter extends SimpleCursorAdapter {
         private static final int VIEW_TYPE_ITEM = 0;
         private static final int VIEW_TYPE_FOLDER = 1;
         private static final int VIEW_TYPE_COUNT = 2;