зеркало из https://github.com/mozilla/gecko-dev.git
Bug 997049 - Fixed "Switch to tab" functionality for Reading List entries. r=margaret
This commit is contained in:
Родитель
4b5af3ebb0
Коммит
fe6578ff75
|
@ -1511,7 +1511,14 @@ abstract public class BrowserApp extends GeckoApp
|
|||
}
|
||||
|
||||
final Tabs tabs = Tabs.getInstance();
|
||||
final Tab tab = tabs.getFirstTabForUrl(url, tabs.getSelectedTab().isPrivate());
|
||||
final Tab tab;
|
||||
|
||||
if (AboutPages.isAboutReader(url)) {
|
||||
tab = tabs.getFirstReaderTabForUrl(url, tabs.getSelectedTab().isPrivate());
|
||||
} else {
|
||||
tab = tabs.getFirstTabForUrl(url, tabs.getSelectedTab().isPrivate());
|
||||
}
|
||||
|
||||
if (tab == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -668,12 +668,46 @@ public class Tabs implements GeckoEventListener {
|
|||
if (isPrivate != null && isPrivate != tab.isPrivate()) {
|
||||
continue;
|
||||
}
|
||||
if (url.equals(tab.getURL())) {
|
||||
return tab;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for a reader mode enabled open tab with the given URL and private
|
||||
* state.
|
||||
*
|
||||
* @param url
|
||||
* The URL of the tab we're looking for. The url parameter can be
|
||||
* the actual article URL or the reader mode article URL.
|
||||
* @param isPrivate
|
||||
* If true, only look for tabs that are private. If false, only
|
||||
* look for tabs that are not private.
|
||||
*
|
||||
* @return The first Tab with the given URL, or null if there is no such
|
||||
* tab.
|
||||
*/
|
||||
public Tab getFirstReaderTabForUrl(String url, boolean isPrivate) {
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (AboutPages.isAboutReader(url)) {
|
||||
url = ReaderModeUtils.getUrlFromAboutReader(url);
|
||||
}
|
||||
for (Tab tab : mOrder) {
|
||||
if (isPrivate != tab.isPrivate()) {
|
||||
continue;
|
||||
}
|
||||
String tabUrl = tab.getURL();
|
||||
if (AboutPages.isAboutReader(tabUrl)) {
|
||||
tabUrl = ReaderModeUtils.getUrlFromAboutReader(tabUrl);
|
||||
}
|
||||
if (url.equals(tabUrl)) {
|
||||
return tab;
|
||||
if (url.equals(tabUrl)) {
|
||||
return tab;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.mozilla.gecko.home;
|
|||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.Tab;
|
||||
import org.mozilla.gecko.Tabs;
|
||||
import org.mozilla.gecko.AboutPages;
|
||||
import org.mozilla.gecko.home.TwoLinePageRow;
|
||||
|
||||
import android.content.Context;
|
||||
|
@ -29,9 +28,9 @@ public class ReadingListRow extends TwoLinePageRow {
|
|||
String pageUrl = getUrl();
|
||||
|
||||
boolean isPrivate = Tabs.getInstance().getSelectedTab().isPrivate();
|
||||
Tab tab = Tabs.getInstance().getFirstTabForUrl(pageUrl, isPrivate);
|
||||
Tab tab = Tabs.getInstance().getFirstReaderTabForUrl(pageUrl, isPrivate);
|
||||
|
||||
if (tab != null && AboutPages.isAboutReader(tab.getURL())) {
|
||||
if (tab != null) {
|
||||
setUrl(R.string.switch_to_tab);
|
||||
setSwitchToTabIcon(R.drawable.ic_url_bar_tab);
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче