Bug 959184 - Use enum instead of boolean to track BrowserToolbar's mode (r=mcomella)

This commit is contained in:
Lucas Rocha 2014-01-21 16:44:38 +00:00
parent d4d8ec5721
commit 5fb54f9d63

View File

@ -109,6 +109,11 @@ public class BrowserToolbar extends GeckoRelativeLayout
public void onStopEditing();
}
private enum UIMode {
EDIT,
DISPLAY
}
enum ForwardButtonAnimation {
SHOW,
HIDE
@ -141,7 +146,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
final private BrowserApp mActivity;
private boolean mHasSoftMenuButton;
private boolean mIsEditing;
private UIMode mUIMode;
private boolean mAnimatingEntry;
private int mUrlBarViewOffset;
@ -220,7 +225,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
mFocusOrder.addAll(Arrays.asList(mTabs, mMenu));
}
setIsEditing(false);
setUIMode(UIMode.DISPLAY);
}
@Override
@ -537,7 +542,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
}
private void updateProgressVisibility(Tab selectedTab, int progress) {
if (!mIsEditing && selectedTab.getState() == Tab.STATE_LOADING) {
if (!isEditing() && selectedTab.getState() == Tab.STATE_LOADING) {
mProgressBar.setProgress(progress);
mProgressBar.setVisibility(View.VISIBLE);
} else {
@ -568,11 +573,11 @@ public class BrowserToolbar extends GeckoRelativeLayout
}
private boolean canDoBack(Tab tab) {
return (tab.canDoBack() && !mIsEditing);
return (tab.canDoBack() && !isEditing());
}
private boolean canDoForward(Tab tab) {
return (tab.canDoForward() && !mIsEditing);
return (tab.canDoForward() && !isEditing());
}
private void addTab() {
@ -848,7 +853,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
}
// Disable toolbar elemens while in editing mode
final boolean enabled = !mIsEditing;
final boolean enabled = !isEditing();
// This alpha value has to be in sync with the one used
// in setButtonEnabled().
@ -874,16 +879,16 @@ public class BrowserToolbar extends GeckoRelativeLayout
// forward button slides away if necessary. This is because we might
// have only disabled it (without hiding it) when the toolbar entered
// editing mode.
if (!mIsEditing) {
if (!isEditing()) {
animateForwardButton(canDoForward(tab) ?
ForwardButtonAnimation.SHOW : ForwardButtonAnimation.HIDE);
}
}
}
private void setIsEditing(boolean isEditing) {
mIsEditing = isEditing;
mUrlEditLayout.setEnabled(isEditing);
private void setUIMode(final UIMode uiMode) {
mUIMode = uiMode;
mUrlEditLayout.setEnabled(uiMode == UIMode.EDIT);
}
/**
@ -891,7 +896,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
* tab button). Note that selection state is independent of editing mode.
*/
public boolean isEditing() {
return mIsEditing;
return (mUIMode == UIMode.EDIT);
}
public void startEditing(String url, PropertyAnimator animator) {
@ -901,7 +906,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
mUrlEditLayout.setText(url != null ? url : "");
setIsEditing(true);
setUIMode(UIMode.EDIT);
updateChildrenForEditing();
updateProgressVisibility();
@ -1018,7 +1023,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
if (!isEditing()) {
return url;
}
setIsEditing(false);
setUIMode(UIMode.DISPLAY);
updateChildrenForEditing();