зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 8d663f978a22 (bug 960746) for Android 4.0 robocop perma-fail. a=backout
This commit is contained in:
Родитель
37abdbb0e3
Коммит
b3912c5b41
|
@ -10,7 +10,6 @@ import java.util.Arrays;
|
||||||
import org.mozilla.gecko.R;
|
import org.mozilla.gecko.R;
|
||||||
import org.mozilla.gecko.Tab;
|
import org.mozilla.gecko.Tab;
|
||||||
import org.mozilla.gecko.Tabs;
|
import org.mozilla.gecko.Tabs;
|
||||||
import org.mozilla.gecko.Tabs.TabEvents;
|
|
||||||
import org.mozilla.gecko.animation.PropertyAnimator;
|
import org.mozilla.gecko.animation.PropertyAnimator;
|
||||||
import org.mozilla.gecko.animation.ViewHelper;
|
import org.mozilla.gecko.animation.ViewHelper;
|
||||||
|
|
||||||
|
@ -20,6 +19,7 @@ import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.AccelerateInterpolator;
|
import android.view.animation.AccelerateInterpolator;
|
||||||
import android.view.animation.Interpolator;
|
import android.view.animation.Interpolator;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
@ -37,12 +37,7 @@ abstract class BrowserToolbarTabletBase extends BrowserToolbar {
|
||||||
protected final LinearLayout actionItemBar;
|
protected final LinearLayout actionItemBar;
|
||||||
|
|
||||||
protected final BackButton backButton;
|
protected final BackButton backButton;
|
||||||
private final OnClickListener backButtonOnClickListener;
|
|
||||||
private final OnLongClickListener backButtonOnLongClickListener;
|
|
||||||
|
|
||||||
protected final ForwardButton forwardButton;
|
protected final ForwardButton forwardButton;
|
||||||
private final OnClickListener forwardButtonOnClickListener;
|
|
||||||
private final OnLongClickListener forwardButtonOnLongClickListener;
|
|
||||||
|
|
||||||
private final Interpolator buttonsInterpolator = new AccelerateInterpolator();
|
private final Interpolator buttonsInterpolator = new AccelerateInterpolator();
|
||||||
|
|
||||||
|
@ -57,57 +52,39 @@ abstract class BrowserToolbarTabletBase extends BrowserToolbar {
|
||||||
setButtonEnabled(backButton, false);
|
setButtonEnabled(backButton, false);
|
||||||
forwardButton = (ForwardButton) findViewById(R.id.forward);
|
forwardButton = (ForwardButton) findViewById(R.id.forward);
|
||||||
setButtonEnabled(forwardButton, false);
|
setButtonEnabled(forwardButton, false);
|
||||||
|
initButtonListeners();
|
||||||
backButtonOnClickListener = new BackButtonOnClickListener();
|
|
||||||
backButtonOnLongClickListener = new BackButtonOnLongClickListener();
|
|
||||||
forwardButtonOnClickListener = new ForwardButtonOnClickListener();
|
|
||||||
forwardButtonOnLongClickListener = new ForwardButtonOnLongClickListener();
|
|
||||||
setNavigationButtonListeners(true);
|
|
||||||
|
|
||||||
focusOrder.addAll(Arrays.asList(tabsButton, (View) backButton, (View) forwardButton, this));
|
focusOrder.addAll(Arrays.asList(tabsButton, (View) backButton, (View) forwardButton, this));
|
||||||
focusOrder.addAll(urlDisplayLayout.getFocusOrder());
|
focusOrder.addAll(urlDisplayLayout.getFocusOrder());
|
||||||
focusOrder.addAll(Arrays.asList(actionItemBar, menuButton));
|
focusOrder.addAll(Arrays.asList(actionItemBar, menuButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void initButtonListeners() {
|
||||||
* Enables or disables the click listeners on the back and forward buttons.
|
backButton.setOnClickListener(new Button.OnClickListener() {
|
||||||
*
|
|
||||||
* This method is useful to remove and later add the listeners when a navigation button is hit
|
|
||||||
* because calling `browser.go*()` twice in succession can cause the UI buttons to get out of
|
|
||||||
* sync with gecko's browser state (bug 960746).
|
|
||||||
*
|
|
||||||
* @param disabled True if the listeners should be removed, false for them to be added.
|
|
||||||
*/
|
|
||||||
private void setNavigationButtonListeners(final boolean enabled) {
|
|
||||||
if (enabled) {
|
|
||||||
backButton.setOnClickListener(backButtonOnClickListener);
|
|
||||||
backButton.setOnLongClickListener(backButtonOnLongClickListener);
|
|
||||||
|
|
||||||
forwardButton.setOnClickListener(forwardButtonOnClickListener);
|
|
||||||
forwardButton.setOnLongClickListener(forwardButtonOnLongClickListener);
|
|
||||||
} else {
|
|
||||||
backButton.setOnClickListener(null);
|
|
||||||
backButton.setOnLongClickListener(null);
|
|
||||||
|
|
||||||
forwardButton.setOnClickListener(null);
|
|
||||||
forwardButton.setOnLongClickListener(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabChanged(final Tab tab, final Tabs.TabEvents msg, final Object data) {
|
public void onClick(View view) {
|
||||||
// STOP appears to be the first page load event where async nav issues are prevented,
|
Tabs.getInstance().getSelectedTab().doBack();
|
||||||
// SELECTED is for switching tabs, and LOAD_ERROR is called when a JavaScript exception
|
|
||||||
// is thrown while loading a URI, which can prevent STOP from ever being called.
|
|
||||||
//
|
|
||||||
// See `setNavigationButtonListeners` javadoc for more information.
|
|
||||||
if (msg == TabEvents.STOP ||
|
|
||||||
msg == TabEvents.SELECTED ||
|
|
||||||
msg == TabEvents.LOAD_ERROR) {
|
|
||||||
setNavigationButtonListeners(true);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
backButton.setOnLongClickListener(new Button.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View view) {
|
||||||
|
return Tabs.getInstance().getSelectedTab().showBackHistory();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
super.onTabChanged(tab, msg, data);
|
forwardButton.setOnClickListener(new Button.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Tabs.getInstance().getSelectedTab().doForward();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
forwardButton.setOnLongClickListener(new Button.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View view) {
|
||||||
|
return Tabs.getInstance().getSelectedTab().showForwardHistory();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -187,36 +164,4 @@ abstract class BrowserToolbarTabletBase extends BrowserToolbar {
|
||||||
|
|
||||||
button.setEnabled(enabled);
|
button.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BackButtonOnClickListener implements OnClickListener {
|
|
||||||
@Override
|
|
||||||
public void onClick(final View view) {
|
|
||||||
setNavigationButtonListeners(false);
|
|
||||||
Tabs.getInstance().getSelectedTab().doBack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class BackButtonOnLongClickListener implements OnLongClickListener {
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(final View view) {
|
|
||||||
setNavigationButtonListeners(false);
|
|
||||||
return Tabs.getInstance().getSelectedTab().showBackHistory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ForwardButtonOnClickListener implements OnClickListener {
|
|
||||||
@Override
|
|
||||||
public void onClick(final View view) {
|
|
||||||
setNavigationButtonListeners(false);
|
|
||||||
Tabs.getInstance().getSelectedTab().doForward();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ForwardButtonOnLongClickListener implements OnLongClickListener {
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(final View view) {
|
|
||||||
setNavigationButtonListeners(false);
|
|
||||||
return Tabs.getInstance().getSelectedTab().showForwardHistory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче