Bug 719479 - Don't animate tab counter during session restore. r=mfinkle

This commit is contained in:
Brian Nicholson 2012-02-01 14:25:50 -08:00
parent b206de36b1
commit a2f48f5d4a
4 changed files with 62 additions and 26 deletions

View File

@ -151,7 +151,7 @@ public class BrowserToolbar extends LinearLayout {
addTab();
}
});
mTabs.setImageLevel(1);
mTabs.setImageLevel(0);
mCounterColor = 0xFFC7D1DB;
@ -224,8 +224,8 @@ public class BrowserToolbar extends LinearLayout {
public int getHighlightColor() {
return mColor;
}
public void updateTabs(int count) {
public void updateTabCountAndAnimate(int count) {
if (mCount > count) {
mTabsCount.setInAnimation(mSlideDownIn);
mTabsCount.setOutAnimation(mSlideDownOut);
@ -267,6 +267,12 @@ public class BrowserToolbar extends LinearLayout {
}, 2 * mDuration);
}
public void updateTabCount(int count) {
mTabsCount.setCurrentText(String.valueOf(count));
mTabs.setImageLevel(count);
mTabsCount.setVisibility(count > 1 ? View.VISIBLE : View.INVISIBLE);
}
public void setProgressVisibility(boolean visible) {
if (visible) {
mFavicon.setImageDrawable(mProgressSpinner);
@ -326,7 +332,7 @@ public class BrowserToolbar extends LinearLayout {
setSecurityMode(tab.getSecurityMode());
setProgressVisibility(tab.isLoading());
setShadowVisibility(!(tab.getURL().startsWith("about:")));
updateTabs(Tabs.getInstance().getCount());
updateTabCountAndAnimate(Tabs.getInstance().getCount());
}
}
}

View File

@ -1659,6 +1659,20 @@ abstract public class GeckoApp
checkAndLaunchUpdate();
}
super.onCreate(savedInstanceState);
setContentView(R.layout.gecko_app);
mOrientation = getResources().getConfiguration().orientation;
if (Build.VERSION.SDK_INT >= 11) {
refreshActionBar();
} else {
mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar);
}
mBrowserToolbar.setTitle(mLastTitle);
String passedUri = null;
String uri = getURIFromIntent(intent);
if (uri != null && uri.length() > 0)
@ -1672,8 +1686,12 @@ abstract public class GeckoApp
if (profileDir != null)
sessionExists = new File(profileDir, "sessionstore.bak").exists();
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - finish check sessionstore.bak exists");
if (!sessionExists)
if (!sessionExists) {
mBrowserToolbar.updateTabCount(1);
showAboutHome();
}
} else {
mBrowserToolbar.updateTabCount(1);
}
if (sGREDir == null)
@ -1698,20 +1716,6 @@ abstract public class GeckoApp
checkAndSetLaunchState(LaunchState.Launching, LaunchState.Launched))
sGeckoThread.start();
super.onCreate(savedInstanceState);
setContentView(R.layout.gecko_app);
mOrientation = getResources().getConfiguration().orientation;
if (Build.VERSION.SDK_INT >= 11) {
refreshActionBar();
} else {
mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar);
}
mBrowserToolbar.setTitle(mLastTitle);
mFavicons = new Favicons(this);
// setup gecko layout
@ -1727,7 +1731,7 @@ abstract public class GeckoApp
mBrowserToolbar.setTitle(tab.getDisplayTitle());
mBrowserToolbar.setFavicon(tab.getFavicon());
mBrowserToolbar.setProgressVisibility(tab.isLoading());
mBrowserToolbar.updateTabs(Tabs.getInstance().getCount());
mBrowserToolbar.updateTabCountAndAnimate(Tabs.getInstance().getCount());
}
tabs.setContentResolver(getContentResolver());

View File

@ -55,6 +55,7 @@ public class Tabs implements GeckoEventListener {
private HashMap<Integer, Tab> tabs;
private ArrayList<Tab> order;
private ContentResolver resolver;
private boolean mRestoringSession = false;
private Tabs() {
tabs = new HashMap<Integer, Tab>();
@ -68,6 +69,8 @@ public class Tabs implements GeckoEventListener {
GeckoAppShell.registerGeckoEventListener("Tab:Close", this);
GeckoAppShell.registerGeckoEventListener("Tab:Select", this);
GeckoAppShell.registerGeckoEventListener("Tab:ScreenshotData", this);
GeckoAppShell.registerGeckoEventListener("Session:RestoreBegin", this);
GeckoAppShell.registerGeckoEventListener("Session:RestoreEnd", this);
}
public int getCount() {
@ -88,11 +91,13 @@ public class Tabs implements GeckoEventListener {
tabs.put(id, tab);
order.add(tab);
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {
GeckoApp.mBrowserToolbar.updateTabs(getCount());
}
});
if (!mRestoringSession) {
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {
GeckoApp.mBrowserToolbar.updateTabCountAndAnimate(getCount());
}
});
}
Log.i(LOGTAG, "Added a tab with id: " + id + ", url: " + url);
return tab;
@ -197,7 +202,7 @@ public class Tabs implements GeckoEventListener {
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {
GeckoApp.mAppContext.onTabsChanged(closedTab);
GeckoApp.mBrowserToolbar.updateTabs(Tabs.getInstance().getCount());
GeckoApp.mBrowserToolbar.updateTabCountAndAnimate(Tabs.getInstance().getCount());
GeckoApp.mDoorHangerPopup.updatePopup();
GeckoApp.mAppContext.hidePlugins(closedTab, true);
}
@ -290,6 +295,15 @@ public class Tabs implements GeckoEventListener {
return;
byte[] compressed = GeckoAppShell.decodeBase64(data.substring(22));
GeckoApp.mAppContext.processThumbnail(tab, null, compressed);
} else if (event.equals("Session:RestoreBegin")) {
mRestoringSession = true;
} else if (event.equals("Session:RestoreEnd")) {
mRestoringSession = false;
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {
GeckoApp.mBrowserToolbar.updateTabCount(getCount());
}
});
}
} catch (Exception e) {
Log.i(LOGTAG, "handleMessage throws " + e + " for message: " + event);

View File

@ -292,6 +292,12 @@ var BrowserApp = {
// A restored tab should not be active if we are loading a URL
let restoreToFront = false;
sendMessageToJava({
gecko: {
type: "Session:RestoreBegin"
}
});
// Open any commandline URLs, except the homepage
if (url && url != "about:home") {
this.addTab(url);
@ -308,6 +314,12 @@ var BrowserApp = {
let params = { selected: restoreToFront };
BrowserApp.addTab("about:home", { showProgress: false });
}
sendMessageToJava({
gecko: {
type: "Session:RestoreEnd"
}
});
}
};
Services.obs.addObserver(restoreCleanup, "sessionstore-windows-restored", false);