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.

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

mercurial