mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
5be418ce39
--HG-- extra : rebase_source : 7ff1fa41da1fe32e63f57141040cf172486996b7
49 lines
1.4 KiB
Java
49 lines
1.4 KiB
Java
/* 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.util.StringUtils;
|
|
|
|
import android.net.Uri;
|
|
|
|
public class ReaderModeUtils {
|
|
private static final String LOGTAG = "ReaderModeUtils";
|
|
|
|
public static String getUrlFromAboutReader(String aboutReaderUrl) {
|
|
return StringUtils.getQueryParameter(aboutReaderUrl, "url");
|
|
}
|
|
|
|
public static boolean isEnteringReaderMode(String currentUrl, String newUrl) {
|
|
if (currentUrl == null || newUrl == null) {
|
|
return false;
|
|
}
|
|
|
|
if (!AboutPages.isAboutReader(newUrl)) {
|
|
return false;
|
|
}
|
|
|
|
String urlFromAboutReader = getUrlFromAboutReader(newUrl);
|
|
if (urlFromAboutReader == null) {
|
|
return false;
|
|
}
|
|
|
|
return urlFromAboutReader.equals(currentUrl);
|
|
}
|
|
|
|
public static String getAboutReaderForUrl(String url) {
|
|
return getAboutReaderForUrl(url, -1);
|
|
}
|
|
|
|
public static String getAboutReaderForUrl(String url, int tabId) {
|
|
String aboutReaderUrl = AboutPages.READER + "?url=" + Uri.encode(url);
|
|
|
|
if (tabId >= 0) {
|
|
aboutReaderUrl += "&tabId=" + tabId;
|
|
}
|
|
|
|
return aboutReaderUrl;
|
|
}
|
|
}
|