Bug 798942 - Fix "Open in New Tab" for bookmarks in reading list folder (r=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Wed, 17 Oct 2012 11:12:25 +0100
changeset 110654 b23d650f31fea9b7ee6aed12a8a0166e8e3fac85
parent 110653 b5964726ad30b6d45de56d96d26478501009d681
child 110655 506a35df1d672d0110111ceb29bfd83ccc8aab34
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersmfinkle
bugs798942
milestone19.0a1
Bug 798942 - Fix "Open in New Tab" for bookmarks in reading list folder (r=mfinkle)
mobile/android/base/AwesomeBar.java
mobile/android/base/awesomebar/BookmarksTab.java
--- a/mobile/android/base/AwesomeBar.java
+++ b/mobile/android/base/AwesomeBar.java
@@ -506,25 +506,30 @@ public class AwesomeBar extends GeckoAct
         if (mContextMenuSubject == null)
             return false;
 
         final int id = mContextMenuSubject.id;
         final String url = mContextMenuSubject.url;
         final byte[] b = mContextMenuSubject.favicon;
         final String title = mContextMenuSubject.title;
         final String keyword = mContextMenuSubject.keyword;
+        final int display = mContextMenuSubject.display;
 
         switch (item.getItemId()) {
             case R.id.open_new_tab: {
                 if (url == null) {
                     Log.e(LOGTAG, "Can't open in new tab because URL is null");
                     break;
                 }
 
-                Tabs.getInstance().loadUrl(url, Tabs.LOADURL_NEW_TAB);
+                String newTabUrl = url;
+                if (display == Combined.DISPLAY_READER)
+                    newTabUrl = ReaderModeUtils.getAboutReaderForUrl(url, true);
+
+                Tabs.getInstance().loadUrl(newTabUrl, Tabs.LOADURL_NEW_TAB);
                 Toast.makeText(this, R.string.new_tab_opened, Toast.LENGTH_SHORT).show();
                 break;
             }
             case R.id.open_in_reader: {
                 if (url == null) {
                     Log.e(LOGTAG, "Can't open in reader mode because URL is null");
                     break;
                 }
--- a/mobile/android/base/awesomebar/BookmarksTab.java
+++ b/mobile/android/base/awesomebar/BookmarksTab.java
@@ -2,16 +2,17 @@
  * 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 org.mozilla.gecko.AwesomeBar.ContextMenuSubject;
 import org.mozilla.gecko.db.BrowserContract.Bookmarks;
+import org.mozilla.gecko.db.BrowserContract.Combined;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.BrowserDB.URLColumns;
 
 import android.app.Activity;
 import android.content.Context;
 import android.database.Cursor;
 import android.os.AsyncTask;
 import android.util.Log;
@@ -431,17 +432,18 @@ public class BookmarksTab extends Awesom
                 keyword = cursor.getString(keywordCol);
 
             int id = cursor.getInt(cursor.getColumnIndexOrThrow(Bookmarks._ID));
 
             subject = new ContextMenuSubject(id,
                                             cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.URL)),
                                             cursor.getBlob(cursor.getColumnIndexOrThrow(URLColumns.FAVICON)),
                                             cursor.getString(cursor.getColumnIndexOrThrow(URLColumns.TITLE)),
-                                            keyword);
+                                            keyword,
+                                            isInReadingList() ? Combined.DISPLAY_READER : Combined.DISPLAY_NORMAL);
         }
 
         if (subject == null)
             return subject;
 
         MenuInflater inflater = new MenuInflater(mContext);
         inflater.inflate(R.menu.awesomebar_contextmenu, menu);