mobile/android/base/ReaderModeUtils.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 package org.mozilla.gecko;
michael@0 6
michael@0 7 import org.mozilla.gecko.util.StringUtils;
michael@0 8
michael@0 9 import android.net.Uri;
michael@0 10
michael@0 11 public class ReaderModeUtils {
michael@0 12 private static final String LOGTAG = "ReaderModeUtils";
michael@0 13
michael@0 14 public static String getUrlFromAboutReader(String aboutReaderUrl) {
michael@0 15 return StringUtils.getQueryParameter(aboutReaderUrl, "url");
michael@0 16 }
michael@0 17
michael@0 18 public static boolean isEnteringReaderMode(String currentUrl, String newUrl) {
michael@0 19 if (currentUrl == null || newUrl == null) {
michael@0 20 return false;
michael@0 21 }
michael@0 22
michael@0 23 if (!AboutPages.isAboutReader(newUrl)) {
michael@0 24 return false;
michael@0 25 }
michael@0 26
michael@0 27 String urlFromAboutReader = getUrlFromAboutReader(newUrl);
michael@0 28 if (urlFromAboutReader == null) {
michael@0 29 return false;
michael@0 30 }
michael@0 31
michael@0 32 return urlFromAboutReader.equals(currentUrl);
michael@0 33 }
michael@0 34
michael@0 35 public static String getAboutReaderForUrl(String url) {
michael@0 36 return getAboutReaderForUrl(url, -1);
michael@0 37 }
michael@0 38
michael@0 39 public static String getAboutReaderForUrl(String url, int tabId) {
michael@0 40 String aboutReaderUrl = AboutPages.READER + "?url=" + Uri.encode(url);
michael@0 41
michael@0 42 if (tabId >= 0) {
michael@0 43 aboutReaderUrl += "&tabId=" + tabId;
michael@0 44 }
michael@0 45
michael@0 46 return aboutReaderUrl;
michael@0 47 }
michael@0 48 }

mercurial