Bug 1280539 - don't open topsites into reader view if stored as offline reader-view page r?sebastian
By default, i.e. for most lists in the homepanels, we want to open the offline reader-view version
of a page if the page is stored as an offline reader-view bookmark (TwoLinePageRow shows the bookmark
and offline status for pages, not only in bookmarks, but also in the list of top sites, awesomescreen
results, and history). The only exception is the topsites grid, where we don't offer any indication
of the bookmark or offline status of a page. For now the expectation is that topsites open the
normal version of a page, so we need to bypass the usual flow for that case.
(It's possible the UI around this would change in future, but with the current UI this is probably
the most obvious / least frustrating behaviour.)
MozReview-Commit-ID: BMpGG4KQ62w
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -3841,17 +3841,26 @@ public class BrowserApp extends GeckoApp
// HomePager.OnUrlOpenListener
@Override
public void onUrlOpen(String url, EnumSet<OnUrlOpenListener.Flags> flags) {
if (flags.contains(OnUrlOpenListener.Flags.OPEN_WITH_INTENT)) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
} else {
- final String pageURL = SavedReaderViewHelper.getReaderURLIfCached(getContext(), url);
+ // By default this listener is used for lists where the offline reader-view icon
+ // is shown - hence we need to redirect to the reader-view page by default.
+ // However there are some cases where we might not want to use this, e.g.
+ // for topsites where we do not indicate that a page is an offline reader-view bookmark too.
+ final String pageURL;
+ if (!flags.contains(OnUrlOpenListener.Flags.NO_READER_VIEW)) {
+ pageURL = SavedReaderViewHelper.getReaderURLIfCached(getContext(), url);
+ } else {
+ pageURL = url;
+ }
if (!maybeSwitchToTab(pageURL, flags)) {
openUrlAndStopEditing(pageURL);
clearSelectedTabApplicationId();
}
}
}
--- a/mobile/android/base/java/org/mozilla/gecko/home/HomePager.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/HomePager.java
@@ -73,17 +73,22 @@ public class HomePager extends ViewPager
public static final String LIST_TAG_TOP_SITES = "top_sites";
public static final String LIST_TAG_RECENT_TABS = "recent_tabs";
public static final String LIST_TAG_BROWSER_SEARCH = "browser_search";
public static final String LIST_TAG_REMOTE_TABS = "remote_tabs";
public interface OnUrlOpenListener {
public enum Flags {
ALLOW_SWITCH_TO_TAB,
- OPEN_WITH_INTENT
+ OPEN_WITH_INTENT,
+ /**
+ * Ensure that the raw URL is opened. If not set, then the reader view version of the page
+ * might be opened if the URL is stored as an offline reader-view bookmark.
+ */
+ NO_READER_VIEW
}
public void onUrlOpen(String url, EnumSet<Flags> flags);
}
/**
* Interface for requesting a new tab be opened in the background.
* <p>
--- a/mobile/android/base/java/org/mozilla/gecko/home/TopSitesPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/TopSitesPanel.java
@@ -217,17 +217,17 @@ public class TopSitesPanel extends HomeF
String extra = Integer.toString(position);
if (type == TopSites.TYPE_PINNED) {
extra += "-pinned";
}
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, method, extra);
- mUrlOpenListener.onUrlOpen(url, EnumSet.noneOf(OnUrlOpenListener.Flags.class));
+ mUrlOpenListener.onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.NO_READER_VIEW));
}
} else {
if (mEditPinnedSiteListener != null) {
mEditPinnedSiteListener.onEditPinnedSite(position, "");
}
}
}
});