mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 874036 - Tab counter displays incorrectly in some circumstances, r=lucasr
This commit is contained in:
parent
2d8ba8d27a
commit
cd6bce37d6
@ -464,10 +464,8 @@ public class BrowserToolbar implements Tabs.OnTabsChangedListener,
|
||||
updateTitle();
|
||||
}
|
||||
break;
|
||||
case RESTORED:
|
||||
updateTabCount(Tabs.getInstance().getDisplayCount());
|
||||
break;
|
||||
case SELECTED:
|
||||
updateTabCount(Tabs.getInstance().getDisplayCount());
|
||||
mSwitchingTabs = true;
|
||||
// fall through
|
||||
case LOCATION_CHANGE:
|
||||
@ -479,7 +477,7 @@ public class BrowserToolbar implements Tabs.OnTabsChangedListener,
|
||||
break;
|
||||
case CLOSED:
|
||||
case ADDED:
|
||||
updateTabCountAndAnimate(Tabs.getInstance().getDisplayCount());
|
||||
updateTabCount(Tabs.getInstance().getDisplayCount());
|
||||
if (Tabs.getInstance().isSelectedTab(tab)) {
|
||||
updateBackButton(tab.canDoBack());
|
||||
updateForwardButton(tab.canDoForward());
|
||||
@ -647,7 +645,7 @@ public class BrowserToolbar implements Tabs.OnTabsChangedListener,
|
||||
|
||||
// Trigger animation to update the tabs counter once the
|
||||
// tabs button is back on screen.
|
||||
updateTabCountAndAnimate(Tabs.getInstance().getDisplayCount());
|
||||
updateTabCount(Tabs.getInstance().getDisplayCount());
|
||||
}
|
||||
});
|
||||
|
||||
@ -748,26 +746,6 @@ public class BrowserToolbar implements Tabs.OnTabsChangedListener,
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTabCountAndAnimate(int count) {
|
||||
// Don't animate if the toolbar is hidden.
|
||||
if (!isVisible()) {
|
||||
updateTabCount(count);
|
||||
return;
|
||||
}
|
||||
|
||||
// If toolbar is selected, this means the entry is expanded and the
|
||||
// tabs button is translated offscreen. Don't trigger tabs counter
|
||||
// updates until the tabs button is back on screen.
|
||||
// See fromAwesomeBarSearch()
|
||||
if (!mLayout.isSelected()) {
|
||||
mTabsCounter.setCount(count);
|
||||
|
||||
mTabs.setContentDescription((count > 1) ?
|
||||
mActivity.getString(R.string.num_tabs, count) :
|
||||
mActivity.getString(R.string.one_tab));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTabCount(int count) {
|
||||
// If toolbar is selected, this means the entry is expanded and the
|
||||
// tabs button is translated offscreen. Don't trigger tabs counter
|
||||
@ -777,7 +755,14 @@ public class BrowserToolbar implements Tabs.OnTabsChangedListener,
|
||||
return;
|
||||
}
|
||||
|
||||
mTabsCounter.setCurrentText(String.valueOf(count));
|
||||
// Set TabCounter based on visibility
|
||||
if (isVisible() && ViewHelper.getAlpha(mTabsCounter) != 0) {
|
||||
mTabsCounter.setCountWithAnimation(count);
|
||||
} else {
|
||||
mTabsCounter.setCount(count);
|
||||
}
|
||||
|
||||
// Update A11y information
|
||||
mTabs.setContentDescription((count > 1) ?
|
||||
mActivity.getString(R.string.num_tabs, count) :
|
||||
mActivity.getString(R.string.one_tab));
|
||||
|
@ -50,7 +50,6 @@ public class TabCounter extends GeckoTextSwitcher
|
||||
|
||||
removeAllViews();
|
||||
setFactory(this);
|
||||
setCount(0);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
// This adds the TextSwitcher to the a11y node tree, where we in turn
|
||||
@ -66,21 +65,30 @@ public class TabCounter extends GeckoTextSwitcher
|
||||
}
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
if (mCount > count) {
|
||||
setInAnimation(mFlipInBackward);
|
||||
setOutAnimation(mFlipOutForward);
|
||||
} else if (mCount < count) {
|
||||
setInAnimation(mFlipInForward);
|
||||
setOutAnimation(mFlipOutBackward);
|
||||
} else {
|
||||
public void setCountWithAnimation(int count) {
|
||||
if (mCount == count)
|
||||
return;
|
||||
|
||||
// Don't animate from initial state
|
||||
if (mCount != 0) {
|
||||
if (count < mCount) {
|
||||
setInAnimation(mFlipInBackward);
|
||||
setOutAnimation(mFlipOutForward);
|
||||
} else if (count > mCount) {
|
||||
setInAnimation(mFlipInForward);
|
||||
setOutAnimation(mFlipOutBackward);
|
||||
}
|
||||
}
|
||||
|
||||
setText(String.valueOf(count));
|
||||
mCount = count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
setCurrentText(String.valueOf(count));
|
||||
mCount = count;
|
||||
}
|
||||
|
||||
private AnimationSet createAnimation(float startAngle, float endAngle,
|
||||
FadeMode fadeMode,
|
||||
float zEnd, boolean reverse) {
|
||||
|
Loading…
Reference in New Issue
Block a user