mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 949181 - Get rid of the Page enum in HomePager. r=wesj
This commit is contained in:
parent
d4e33a3678
commit
805f5eb154
@ -1607,7 +1607,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||
}
|
||||
|
||||
if (isAboutHome(tab)) {
|
||||
showHomePager(tab.getAboutHomePage());
|
||||
showHomePager(tab.getAboutHomePageId());
|
||||
|
||||
if (isDynamicToolbarEnabled()) {
|
||||
// Show the toolbar.
|
||||
@ -1632,8 +1632,8 @@ abstract public class BrowserApp extends GeckoApp
|
||||
}
|
||||
}
|
||||
|
||||
private void showHomePager(HomePager.Page page) {
|
||||
showHomePagerWithAnimator(page, null);
|
||||
private void showHomePager(String pageId) {
|
||||
showHomePagerWithAnimator(pageId, null);
|
||||
}
|
||||
|
||||
private void showHomePagerWithAnimator(PropertyAnimator animator) {
|
||||
@ -1642,7 +1642,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||
showHomePagerWithAnimator(null, animator);
|
||||
}
|
||||
|
||||
private void showHomePagerWithAnimator(HomePager.Page page, PropertyAnimator animator) {
|
||||
private void showHomePagerWithAnimator(String pageId, PropertyAnimator animator) {
|
||||
if (isHomePagerVisible()) {
|
||||
return;
|
||||
}
|
||||
@ -1663,7 +1663,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||
|
||||
mHomePager.show(getSupportLoaderManager(),
|
||||
getSupportFragmentManager(),
|
||||
page, animator);
|
||||
pageId, animator);
|
||||
|
||||
// Hide the web content so it cannot be focused by screen readers.
|
||||
hideWebContentOnPropertyAnimationEnd(animator);
|
||||
|
@ -8,7 +8,6 @@ package org.mozilla.gecko;
|
||||
import org.mozilla.gecko.SiteIdentity.SecurityMode;
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.gfx.Layer;
|
||||
import org.mozilla.gecko.home.HomePager;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -52,7 +51,7 @@ public class Tab {
|
||||
private int mHistoryIndex;
|
||||
private int mHistorySize;
|
||||
private int mParentId;
|
||||
private HomePager.Page mAboutHomePage;
|
||||
private String mAboutHomePageId;
|
||||
private boolean mExternal;
|
||||
private boolean mBookmark;
|
||||
private boolean mReadingListItem;
|
||||
@ -95,7 +94,7 @@ public class Tab {
|
||||
mUserSearch = "";
|
||||
mExternal = external;
|
||||
mParentId = parentId;
|
||||
mAboutHomePage = null;
|
||||
mAboutHomePageId = null;
|
||||
mTitle = title == null ? "" : title;
|
||||
mFavicon = null;
|
||||
mFaviconUrl = null;
|
||||
@ -147,12 +146,12 @@ public class Tab {
|
||||
return mParentId;
|
||||
}
|
||||
|
||||
public HomePager.Page getAboutHomePage() {
|
||||
return mAboutHomePage;
|
||||
public String getAboutHomePageId() {
|
||||
return mAboutHomePageId;
|
||||
}
|
||||
|
||||
private void setAboutHomePage(HomePager.Page page) {
|
||||
mAboutHomePage = page;
|
||||
private void setAboutHomePageId(String pageId) {
|
||||
mAboutHomePageId = pageId;
|
||||
}
|
||||
|
||||
// may be null if user-entered query hasn't yet been resolved to a URI
|
||||
@ -656,11 +655,11 @@ public class Tab {
|
||||
setBackgroundColor(DEFAULT_BACKGROUND_COLOR);
|
||||
setErrorType(ErrorType.NONE);
|
||||
|
||||
final String homePage = message.getString("aboutHomePage");
|
||||
if (!TextUtils.isEmpty(homePage)) {
|
||||
setAboutHomePage(HomePager.Page.valueOf(homePage));
|
||||
final String homePageId = message.getString("aboutHomePage");
|
||||
if (!TextUtils.isEmpty(homePageId)) {
|
||||
setAboutHomePageId(homePageId);
|
||||
} else {
|
||||
setAboutHomePage(null);
|
||||
setAboutHomePageId(null);
|
||||
}
|
||||
|
||||
Tabs.getInstance().notifyListeners(this, Tabs.TabEvents.LOCATION_CHANGE, oldUrl);
|
||||
|
@ -7,7 +7,6 @@ package org.mozilla.gecko;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserDB;
|
||||
import org.mozilla.gecko.favicons.Favicons;
|
||||
import org.mozilla.gecko.home.HomePager;
|
||||
import org.mozilla.gecko.mozglue.JNITarget;
|
||||
import org.mozilla.gecko.mozglue.RobocopTarget;
|
||||
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
||||
@ -724,7 +723,8 @@ public class Tabs implements GeckoEventListener {
|
||||
args.put("delayLoad", delayLoad);
|
||||
args.put("desktopMode", desktopMode);
|
||||
args.put("selected", !background);
|
||||
args.put("aboutHomePage", (flags & LOADURL_READING_LIST) != 0 ? HomePager.Page.READING_LIST : "");
|
||||
// XXX: Dirty hack to pass reading list page id - let's get rid of this code path in bug 949178.
|
||||
args.put("aboutHomePage", (flags & LOADURL_READING_LIST) != 0 ? "reading_list-reading_list" : "");
|
||||
|
||||
if ((flags & LOADURL_NEW_TAB) != 0) {
|
||||
int tabId = getNextTabId();
|
||||
|
@ -8,7 +8,6 @@ package org.mozilla.gecko.home;
|
||||
import org.mozilla.gecko.home.HomeConfig.PageEntry;
|
||||
import org.mozilla.gecko.home.HomeConfig.PageType;
|
||||
import org.mozilla.gecko.home.HomePager;
|
||||
import org.mozilla.gecko.home.HomePager.Page;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
@ -84,10 +83,10 @@ class HomeAdapter extends FragmentStatePagerAdapter {
|
||||
mAddPageListener = listener;
|
||||
}
|
||||
|
||||
public int getItemPosition(Page page) {
|
||||
public int getItemPosition(String pageId) {
|
||||
for (int i = 0; i < mPageInfos.size(); i++) {
|
||||
final Page infoPage = mPageInfos.get(i).toPage();
|
||||
if (infoPage == page) {
|
||||
final String id = mPageInfos.get(i).getId();
|
||||
if (id.equals(pageId)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@ -95,15 +94,14 @@ class HomeAdapter extends FragmentStatePagerAdapter {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public Page getPageAtPosition(int position) {
|
||||
public String getPageIdAtPosition(int position) {
|
||||
// getPageAtPosition() might be called before HomeAdapter
|
||||
// has got its initial list of PageEntries. Just bail.
|
||||
if (mPageInfos.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PageInfo info = mPageInfos.get(position);
|
||||
return info.toPage();
|
||||
return mPageInfos.get(position).getId();
|
||||
}
|
||||
|
||||
private void addPage(PageInfo info) {
|
||||
@ -178,14 +176,5 @@ class HomeAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
public Page toPage() {
|
||||
final PageType type = mPageEntry.getType();
|
||||
if (type == PageType.LIST) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Page.valueOf(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
package org.mozilla.gecko.home;
|
||||
|
||||
import org.mozilla.gecko.home.HomePager.Page;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@ -31,25 +29,6 @@ final class HomeConfig {
|
||||
mPageClass = pageClass;
|
||||
}
|
||||
|
||||
public static PageType valueOf(Page page) {
|
||||
switch(page) {
|
||||
case TOP_SITES:
|
||||
return PageType.TOP_SITES;
|
||||
|
||||
case BOOKMARKS:
|
||||
return PageType.BOOKMARKS;
|
||||
|
||||
case HISTORY:
|
||||
return PageType.HISTORY;
|
||||
|
||||
case READING_LIST:
|
||||
return PageType.READING_LIST;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Could not convert unrecognized Page");
|
||||
}
|
||||
}
|
||||
|
||||
public static PageType fromId(String id) {
|
||||
if (id == null) {
|
||||
throw new IllegalArgumentException("Could not convert null String to PageType");
|
||||
|
@ -11,7 +11,6 @@ import org.mozilla.gecko.animation.ViewHelper;
|
||||
import org.mozilla.gecko.home.HomeAdapter.OnAddPageListener;
|
||||
import org.mozilla.gecko.home.HomeConfig.PageEntry;
|
||||
import org.mozilla.gecko.home.HomeConfig.PageType;
|
||||
import org.mozilla.gecko.mozglue.RobocopTarget;
|
||||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
|
||||
import android.content.Context;
|
||||
@ -46,35 +45,7 @@ public class HomePager extends ViewPager {
|
||||
private final HomeConfig mConfig;
|
||||
private ConfigLoaderCallbacks mConfigLoaderCallbacks;
|
||||
|
||||
private Page mInitialPage;
|
||||
|
||||
// List of pages in order.
|
||||
@RobocopTarget
|
||||
public enum Page {
|
||||
HISTORY,
|
||||
TOP_SITES,
|
||||
BOOKMARKS,
|
||||
READING_LIST;
|
||||
|
||||
static Page valueOf(PageType page) {
|
||||
switch(page) {
|
||||
case TOP_SITES:
|
||||
return Page.TOP_SITES;
|
||||
|
||||
case BOOKMARKS:
|
||||
return Page.BOOKMARKS;
|
||||
|
||||
case HISTORY:
|
||||
return Page.HISTORY;
|
||||
|
||||
case READING_LIST:
|
||||
return Page.READING_LIST;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Could not convert unrecognized PageType");
|
||||
}
|
||||
}
|
||||
}
|
||||
private String mInitialPageId;
|
||||
|
||||
// This is mostly used by UI tests to easily fetch
|
||||
// specific list views at runtime.
|
||||
@ -186,17 +157,17 @@ public class HomePager extends ViewPager {
|
||||
public void redisplay(LoaderManager lm, FragmentManager fm) {
|
||||
final HomeAdapter adapter = (HomeAdapter) getAdapter();
|
||||
|
||||
// If mInitialPage is non-null, this means the HomePager hasn't
|
||||
// If mInitialPageId is non-null, this means the HomePager hasn't
|
||||
// finished loading its config yet. Simply re-show() with the
|
||||
// current target page.
|
||||
final Page currentPage;
|
||||
if (mInitialPage != null) {
|
||||
currentPage = mInitialPage;
|
||||
final String currentPageId;
|
||||
if (mInitialPageId != null) {
|
||||
currentPageId = mInitialPageId;
|
||||
} else {
|
||||
currentPage = adapter.getPageAtPosition(getCurrentItem());
|
||||
currentPageId = adapter.getPageIdAtPosition(getCurrentItem());
|
||||
}
|
||||
|
||||
show(lm, fm, currentPage, null);
|
||||
show(lm, fm, currentPageId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,9 +175,9 @@ public class HomePager extends ViewPager {
|
||||
*
|
||||
* @param fm FragmentManager for the adapter
|
||||
*/
|
||||
public void show(LoaderManager lm, FragmentManager fm, Page page, PropertyAnimator animator) {
|
||||
public void show(LoaderManager lm, FragmentManager fm, String pageId, PropertyAnimator animator) {
|
||||
mLoaded = true;
|
||||
mInitialPage = page;
|
||||
mInitialPageId = pageId;
|
||||
|
||||
// Only animate on post-HC devices, when a non-null animator is given
|
||||
final boolean shouldAnimate = (animator != null && Build.VERSION.SDK_INT >= 11);
|
||||
@ -314,9 +285,9 @@ public class HomePager extends ViewPager {
|
||||
|
||||
// Use the default page as defined in the HomePager's configuration
|
||||
// if the initial page wasn't explicitly set by the show() caller.
|
||||
if (mInitialPage != null) {
|
||||
setCurrentItem(adapter.getItemPosition(mInitialPage), false);
|
||||
mInitialPage = null;
|
||||
if (mInitialPageId != null) {
|
||||
setCurrentItem(adapter.getItemPosition(mInitialPageId), false);
|
||||
mInitialPageId = null;
|
||||
} else {
|
||||
for (int i = 0; i < count; i++) {
|
||||
final PageEntry pageEntry = pageEntries.get(i);
|
||||
|
Loading…
Reference in New Issue
Block a user