зеркало из https://github.com/mozilla/gecko-dev.git
Backout d8018c23945a for NPE failures
This commit is contained in:
Родитель
95f08184ef
Коммит
b135ecaa10
|
@ -14,8 +14,6 @@ import java.util.Vector;
|
|||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.gecko.DynamicToolbar.PinReason;
|
||||
import org.mozilla.gecko.DynamicToolbar.VisibilityTransition;
|
||||
import org.mozilla.gecko.GeckoProfileDirectories.NoMozillaDirectoryException;
|
||||
import org.mozilla.gecko.animation.PropertyAnimator;
|
||||
import org.mozilla.gecko.animation.ViewHelper;
|
||||
|
@ -111,6 +109,8 @@ abstract public class BrowserApp extends GeckoApp
|
|||
ActionModeCompat.Presenter {
|
||||
private static final String LOGTAG = "GeckoBrowserApp";
|
||||
|
||||
private static final String PREF_CHROME_DYNAMICTOOLBAR = "browser.chrome.dynamictoolbar";
|
||||
|
||||
private static final int TABS_ANIMATION_DURATION = 450;
|
||||
|
||||
private static final int READER_ADD_SUCCESS = 0;
|
||||
|
@ -121,6 +121,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||
public static final String GUEST_BROWSING_ARG = "--guest";
|
||||
|
||||
private static final String STATE_ABOUT_HOME_TOP_PADDING = "abouthome_top_padding";
|
||||
private static final String STATE_DYNAMIC_TOOLBAR_ENABLED = "dynamic_toolbar";
|
||||
|
||||
private static final String BROWSER_SEARCH_TAG = "browser_search";
|
||||
private BrowserSearch mBrowserSearch;
|
||||
|
@ -170,9 +171,14 @@ abstract public class BrowserApp extends GeckoApp
|
|||
private FindInPageBar mFindInPageBar;
|
||||
private MediaCastingBar mMediaCastingBar;
|
||||
|
||||
private boolean mAccessibilityEnabled = false;
|
||||
|
||||
// We'll ask for feedback after the user launches the app this many times.
|
||||
private static final int FEEDBACK_LAUNCH_COUNT = 15;
|
||||
|
||||
// Whether the dynamic toolbar pref is enabled.
|
||||
private boolean mDynamicToolbarEnabled = false;
|
||||
|
||||
// Stored value of the toolbar height, so we know when it's changed.
|
||||
private int mToolbarHeight = 0;
|
||||
|
||||
|
@ -180,6 +186,8 @@ abstract public class BrowserApp extends GeckoApp
|
|||
// scrolling.
|
||||
private boolean mDynamicToolbarCanScroll = false;
|
||||
|
||||
private Integer mPrefObserverId;
|
||||
|
||||
private SharedPreferencesHelper mSharedPreferencesHelper;
|
||||
|
||||
private OrderedBroadcastHelper mOrderedBroadcastHelper;
|
||||
|
@ -195,8 +203,6 @@ abstract public class BrowserApp extends GeckoApp
|
|||
// race by determining if the web content should be hidden at the animation's end.
|
||||
private boolean mHideWebContentOnAnimationEnd = false;
|
||||
|
||||
private DynamicToolbar mDynamicToolbar = new DynamicToolbar();
|
||||
|
||||
@Override
|
||||
public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
|
||||
if (tab == null) {
|
||||
|
@ -237,8 +243,9 @@ abstract public class BrowserApp extends GeckoApp
|
|||
if (Tabs.getInstance().isSelectedTab(tab)) {
|
||||
invalidateOptionsMenu();
|
||||
|
||||
if (mDynamicToolbar.isEnabled()) {
|
||||
mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
|
||||
if (isDynamicToolbarEnabled()) {
|
||||
// Show the toolbar.
|
||||
mLayerView.getLayerMarginsAnimator().showMargins(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -280,9 +287,9 @@ abstract public class BrowserApp extends GeckoApp
|
|||
case KeyEvent.KEYCODE_BUTTON_Y:
|
||||
// Toggle/focus the address bar on gamepad-y button.
|
||||
if (mViewFlipper.getVisibility() == View.VISIBLE) {
|
||||
if (mDynamicToolbar.isEnabled() && !isHomePagerVisible()) {
|
||||
mDynamicToolbar.setVisible(false, VisibilityTransition.ANIMATE);
|
||||
if (isDynamicToolbarEnabled() && !isHomePagerVisible()) {
|
||||
if (mLayerView != null) {
|
||||
mLayerView.getLayerMarginsAnimator().hideMargins(false);
|
||||
mLayerView.requestFocus();
|
||||
}
|
||||
} else {
|
||||
|
@ -291,7 +298,9 @@ abstract public class BrowserApp extends GeckoApp
|
|||
mBrowserToolbar.requestFocusFromTouch();
|
||||
}
|
||||
} else {
|
||||
mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
|
||||
if (mLayerView != null) {
|
||||
mLayerView.getLayerMarginsAnimator().showMargins(false);
|
||||
}
|
||||
mBrowserToolbar.requestFocusFromTouch();
|
||||
}
|
||||
return true;
|
||||
|
@ -580,14 +589,36 @@ abstract public class BrowserApp extends GeckoApp
|
|||
}
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mDynamicToolbar.onRestoreInstanceState(savedInstanceState);
|
||||
mDynamicToolbarEnabled = savedInstanceState.getBoolean(STATE_DYNAMIC_TOOLBAR_ENABLED);
|
||||
mHomePagerContainer.setPadding(0, savedInstanceState.getInt(STATE_ABOUT_HOME_TOP_PADDING), 0, 0);
|
||||
}
|
||||
|
||||
mDynamicToolbar.setEnabledChangedListener(new DynamicToolbar.OnEnabledChangedListener() {
|
||||
// Listen to the dynamic toolbar pref
|
||||
mPrefObserverId = PrefsHelper.getPref(PREF_CHROME_DYNAMICTOOLBAR, new PrefsHelper.PrefHandlerBase() {
|
||||
@Override
|
||||
public void onEnabledChanged(boolean enabled) {
|
||||
setDynamicToolbarEnabled(enabled);
|
||||
public void prefValue(String pref, boolean value) {
|
||||
if (value == mDynamicToolbarEnabled) {
|
||||
return;
|
||||
}
|
||||
mDynamicToolbarEnabled = value;
|
||||
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// If accessibility is enabled, the dynamic toolbar is
|
||||
// forced to be off.
|
||||
if (!mAccessibilityEnabled) {
|
||||
setDynamicToolbarEnabled(mDynamicToolbarEnabled);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObserver() {
|
||||
// We want to be notified of changes to be able to switch mode
|
||||
// without restarting.
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -628,8 +659,6 @@ abstract public class BrowserApp extends GeckoApp
|
|||
}
|
||||
|
||||
private void setDynamicToolbarEnabled(boolean enabled) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
if (enabled) {
|
||||
if (mLayerView != null) {
|
||||
mLayerView.getLayerClient().setOnMetricsChangedListener(this);
|
||||
|
@ -651,6 +680,10 @@ abstract public class BrowserApp extends GeckoApp
|
|||
refreshToolbarHeight();
|
||||
}
|
||||
|
||||
private boolean isDynamicToolbarEnabled() {
|
||||
return mDynamicToolbarEnabled && !mAccessibilityEnabled;
|
||||
}
|
||||
|
||||
private static boolean isAboutHome(final Tab tab) {
|
||||
return AboutPages.isAboutHome(tab.getURL());
|
||||
}
|
||||
|
@ -726,13 +759,24 @@ abstract public class BrowserApp extends GeckoApp
|
|||
|
||||
@Override
|
||||
public void setAccessibilityEnabled(boolean enabled) {
|
||||
mDynamicToolbar.setAccessibilityEnabled(enabled);
|
||||
if (mAccessibilityEnabled == enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable the dynamic toolbar when accessibility features are enabled,
|
||||
// and re-read the preference when they're disabled.
|
||||
mAccessibilityEnabled = enabled;
|
||||
if (mDynamicToolbarEnabled) {
|
||||
setDynamicToolbarEnabled(!enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
mDynamicToolbar.destroy();
|
||||
|
||||
if (mPrefObserverId != null) {
|
||||
PrefsHelper.removeObserver(mPrefObserverId);
|
||||
mPrefObserverId = null;
|
||||
}
|
||||
if (mBrowserToolbar != null)
|
||||
mBrowserToolbar.onDestroy();
|
||||
|
||||
|
@ -794,8 +838,12 @@ abstract public class BrowserApp extends GeckoApp
|
|||
|
||||
mDoorHangerPopup.setAnchor(mBrowserToolbar.getDoorHangerAnchor());
|
||||
|
||||
mDynamicToolbar.setLayerView(mLayerView);
|
||||
setDynamicToolbarEnabled(mDynamicToolbar.isEnabled());
|
||||
// Listen to margin changes to position the toolbar correctly
|
||||
if (isDynamicToolbarEnabled()) {
|
||||
refreshToolbarHeight();
|
||||
mLayerView.getLayerMarginsAnimator().showMargins(true);
|
||||
mLayerView.getLayerClient().setOnMetricsChangedListener(this);
|
||||
}
|
||||
|
||||
// Intercept key events for gamepad shortcuts
|
||||
mLayerView.setOnKeyListener(this);
|
||||
|
@ -855,7 +903,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||
if (mViewFlipper.getVisibility() != View.VISIBLE) {
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
public void run() {
|
||||
mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
|
||||
mLayerView.getLayerMarginsAnimator().showMargins(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -882,7 +930,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||
|
||||
@Override
|
||||
public void onPanZoomStopped() {
|
||||
if (!mDynamicToolbar.isEnabled() || isHomePagerVisible()) {
|
||||
if (!isDynamicToolbarEnabled() || isHomePagerVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -892,25 +940,23 @@ abstract public class BrowserApp extends GeckoApp
|
|||
ImmutableViewportMetrics metrics = mLayerView.getViewportMetrics();
|
||||
if (metrics.getPageHeight() < metrics.getHeight()
|
||||
|| metrics.marginTop >= mToolbarHeight / 2) {
|
||||
mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
|
||||
mLayerView.getLayerMarginsAnimator().showMargins(false);
|
||||
} else {
|
||||
mDynamicToolbar.setVisible(false, VisibilityTransition.ANIMATE);
|
||||
mLayerView.getLayerMarginsAnimator().hideMargins(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshToolbarHeight() {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
int height = 0;
|
||||
if (mViewFlipper != null) {
|
||||
height = mViewFlipper.getHeight();
|
||||
}
|
||||
|
||||
if (!mDynamicToolbar.isEnabled() || isHomePagerVisible()) {
|
||||
if (!isDynamicToolbarEnabled() || isHomePagerVisible()) {
|
||||
// Use aVisibleHeight here so that when the dynamic toolbar is
|
||||
// enabled, the padding will animate with the toolbar becoming
|
||||
// visible.
|
||||
if (mDynamicToolbar.isEnabled()) {
|
||||
if (isDynamicToolbarEnabled()) {
|
||||
// When the dynamic toolbar is enabled, set the padding on the
|
||||
// about:home widget directly - this is to avoid resizing the
|
||||
// LayerView, which can cause visible artifacts.
|
||||
|
@ -926,7 +972,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||
if (mLayerView != null && height != mToolbarHeight) {
|
||||
mToolbarHeight = height;
|
||||
mLayerView.getLayerMarginsAnimator().setMaxMargins(0, height, 0, 0);
|
||||
mDynamicToolbar.setVisible(true, VisibilityTransition.IMMEDIATE);
|
||||
mLayerView.getLayerMarginsAnimator().showMargins(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1305,12 +1351,12 @@ abstract public class BrowserApp extends GeckoApp
|
|||
|
||||
// If the tabs layout is animating onto the screen, pin the dynamic
|
||||
// toolbar.
|
||||
if (mDynamicToolbar.isEnabled()) {
|
||||
if (mLayerView != null && isDynamicToolbarEnabled()) {
|
||||
if (width > 0 && height > 0) {
|
||||
mDynamicToolbar.setPinned(true, PinReason.RELAYOUT);
|
||||
mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
|
||||
mLayerView.getLayerMarginsAnimator().setMarginsPinned(true);
|
||||
mLayerView.getLayerMarginsAnimator().showMargins(false);
|
||||
} else {
|
||||
mDynamicToolbar.setPinned(false, PinReason.RELAYOUT);
|
||||
mLayerView.getLayerMarginsAnimator().setMarginsPinned(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1336,7 +1382,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mDynamicToolbar.onSaveInstanceState(outState);
|
||||
outState.putBoolean(STATE_DYNAMIC_TOOLBAR_ENABLED, mDynamicToolbarEnabled);
|
||||
outState.putInt(STATE_ABOUT_HOME_TOP_PADDING, mHomePagerContainer.getPaddingTop());
|
||||
}
|
||||
|
||||
|
@ -1598,8 +1644,9 @@ abstract public class BrowserApp extends GeckoApp
|
|||
final String pageId = AboutPages.getPageIdFromAboutHomeUrl(tab.getURL());
|
||||
showHomePager(pageId);
|
||||
|
||||
if (mDynamicToolbar.isEnabled()) {
|
||||
mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
|
||||
if (isDynamicToolbarEnabled()) {
|
||||
// Show the toolbar.
|
||||
mLayerView.getLayerMarginsAnimator().showMargins(false);
|
||||
}
|
||||
} else {
|
||||
hideHomePager();
|
||||
|
@ -1638,8 +1685,8 @@ abstract public class BrowserApp extends GeckoApp
|
|||
|
||||
// Show the toolbar before hiding about:home so the
|
||||
// onMetricsChanged callback still works.
|
||||
if (mDynamicToolbar.isEnabled()) {
|
||||
mDynamicToolbar.setVisible(true, VisibilityTransition.IMMEDIATE);
|
||||
if (isDynamicToolbarEnabled() && mLayerView != null) {
|
||||
mLayerView.getLayerMarginsAnimator().showMargins(true);
|
||||
}
|
||||
|
||||
if (mHomePager == null) {
|
||||
|
@ -2007,9 +2054,8 @@ abstract public class BrowserApp extends GeckoApp
|
|||
if (!mBrowserToolbar.openOptionsMenu())
|
||||
super.openOptionsMenu();
|
||||
|
||||
if (mDynamicToolbar.isEnabled()) {
|
||||
mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
|
||||
}
|
||||
if (isDynamicToolbarEnabled() && mLayerView != null)
|
||||
mLayerView.getLayerMarginsAnimator().showMargins(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2026,16 +2072,16 @@ abstract public class BrowserApp extends GeckoApp
|
|||
public void run() {
|
||||
if (fullscreen) {
|
||||
mViewFlipper.setVisibility(View.GONE);
|
||||
if (mDynamicToolbar.isEnabled()) {
|
||||
mDynamicToolbar.setVisible(false, VisibilityTransition.IMMEDIATE);
|
||||
if (isDynamicToolbarEnabled()) {
|
||||
mLayerView.getLayerMarginsAnimator().hideMargins(true);
|
||||
mLayerView.getLayerMarginsAnimator().setMaxMargins(0, 0, 0, 0);
|
||||
} else {
|
||||
setToolbarMargin(0);
|
||||
}
|
||||
} else {
|
||||
mViewFlipper.setVisibility(View.VISIBLE);
|
||||
if (mDynamicToolbar.isEnabled()) {
|
||||
mDynamicToolbar.setVisible(true, VisibilityTransition.IMMEDIATE);
|
||||
if (isDynamicToolbarEnabled()) {
|
||||
mLayerView.getLayerMarginsAnimator().showMargins(true);
|
||||
mLayerView.getLayerMarginsAnimator().setMaxMargins(0, mToolbarHeight, 0, 0);
|
||||
}
|
||||
}
|
||||
|
@ -2616,16 +2662,16 @@ abstract public class BrowserApp extends GeckoApp
|
|||
LayerMarginsAnimator margins = mLayerView.getLayerMarginsAnimator();
|
||||
|
||||
// If the toolbar is dynamic and not currently showing, just slide it in
|
||||
if (mDynamicToolbar.isEnabled() && !margins.areMarginsShown()) {
|
||||
if (isDynamicToolbarEnabled() && !margins.areMarginsShown()) {
|
||||
margins.setMaxMargins(0, mViewFlipper.getHeight(), 0, 0);
|
||||
mDynamicToolbar.setVisible(true, VisibilityTransition.ANIMATE);
|
||||
margins.showMargins(false);
|
||||
mShowActionModeEndAnimation = true;
|
||||
} else {
|
||||
// Otherwise, we animate the actionbar itself
|
||||
mActionBar.animateIn();
|
||||
}
|
||||
|
||||
mDynamicToolbar.setPinned(true, PinReason.ACTION_MODE);
|
||||
margins.setMarginsPinned(true);
|
||||
} else {
|
||||
// Otherwise, we're already showing an action mode. Just finish it and show the new one
|
||||
mActionMode.finish();
|
||||
|
@ -2646,14 +2692,15 @@ abstract public class BrowserApp extends GeckoApp
|
|||
|
||||
mActionMode.finish();
|
||||
mActionMode = null;
|
||||
mDynamicToolbar.setPinned(false, PinReason.ACTION_MODE);
|
||||
final LayerMarginsAnimator margins = mLayerView.getLayerMarginsAnimator();
|
||||
margins.setMarginsPinned(false);
|
||||
|
||||
mViewFlipper.showPrevious();
|
||||
|
||||
// Only slide the urlbar out if it was hidden when the action mode started
|
||||
// Don't animate hiding it so that there's no flash as we switch back to url mode
|
||||
if (mShowActionModeEndAnimation) {
|
||||
mDynamicToolbar.setVisible(false, VisibilityTransition.IMMEDIATE);
|
||||
margins.hideMargins(true);
|
||||
mShowActionModeEndAnimation = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,167 +0,0 @@
|
|||
package org.mozilla.gecko;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.mozilla.gecko.PrefsHelper.PrefHandlerBase;
|
||||
import org.mozilla.gecko.gfx.LayerView;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class DynamicToolbar {
|
||||
private static final String STATE_ENABLED = "dynamic_toolbar";
|
||||
private static final String CHROME_PREF = "browser.chrome.dynamictoolbar";
|
||||
|
||||
// DynamicToolbar is enabled iff prefEnabled is true *and* accessibilityEnabled is false,
|
||||
// so it is disabled by default on startup. We do not enable it until we explicitly get
|
||||
// the pref from Gecko telling us to turn it on.
|
||||
private volatile boolean prefEnabled;
|
||||
private boolean accessibilityEnabled;
|
||||
|
||||
private final int prefObserverId;
|
||||
private EnumSet<PinReason> pinFlags;
|
||||
private LayerView layerView;
|
||||
private OnEnabledChangedListener enabledChangedListener;
|
||||
|
||||
public enum PinReason {
|
||||
RELAYOUT,
|
||||
ACTION_MODE
|
||||
}
|
||||
|
||||
public enum VisibilityTransition {
|
||||
IMMEDIATE,
|
||||
ANIMATE
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for changes to the dynamic toolbar's enabled state.
|
||||
*/
|
||||
public interface OnEnabledChangedListener {
|
||||
/**
|
||||
* This callback is executed on the UI thread.
|
||||
*/
|
||||
public void onEnabledChanged(boolean enabled);
|
||||
}
|
||||
|
||||
public DynamicToolbar() {
|
||||
// Listen to the dynamic toolbar pref
|
||||
prefObserverId = PrefsHelper.getPref(CHROME_PREF, new PrefHandler());
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
PrefsHelper.removeObserver(prefObserverId);
|
||||
}
|
||||
|
||||
public void setLayerView(LayerView layerView) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
this.layerView = layerView;
|
||||
}
|
||||
|
||||
public void setEnabledChangedListener(OnEnabledChangedListener listener) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
enabledChangedListener = listener;
|
||||
}
|
||||
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
outState.putBoolean(STATE_ENABLED, prefEnabled);
|
||||
}
|
||||
|
||||
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
prefEnabled = savedInstanceState.getBoolean(STATE_ENABLED);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
return prefEnabled && !accessibilityEnabled;
|
||||
}
|
||||
|
||||
public void setAccessibilityEnabled(boolean enabled) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
if (accessibilityEnabled == enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable the dynamic toolbar when accessibility features are enabled,
|
||||
// and re-read the preference when they're disabled.
|
||||
accessibilityEnabled = enabled;
|
||||
if (prefEnabled) {
|
||||
triggerEnabledListener();
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible, VisibilityTransition transition) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
if (layerView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean immediate = transition.equals(VisibilityTransition.ANIMATE);
|
||||
if (visible) {
|
||||
layerView.getLayerMarginsAnimator().showMargins(immediate);
|
||||
} else {
|
||||
layerView.getLayerMarginsAnimator().hideMargins(immediate);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPinned(boolean pinned, PinReason reason) {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
|
||||
if (layerView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pinned) {
|
||||
pinFlags.add(reason);
|
||||
} else {
|
||||
pinFlags.remove(reason);
|
||||
}
|
||||
|
||||
layerView.getLayerMarginsAnimator().setMarginsPinned(!pinFlags.isEmpty());
|
||||
}
|
||||
|
||||
private void triggerEnabledListener() {
|
||||
if (enabledChangedListener != null) {
|
||||
enabledChangedListener.onEnabledChanged(isEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
private class PrefHandler extends PrefHandlerBase {
|
||||
@Override
|
||||
public void prefValue(String pref, boolean value) {
|
||||
if (value == prefEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
prefEnabled = value;
|
||||
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// If accessibility is enabled, the dynamic toolbar is
|
||||
// forced to be off.
|
||||
if (!accessibilityEnabled) {
|
||||
triggerEnabledListener();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isObserver() {
|
||||
// We want to be notified of changes to be able to switch mode
|
||||
// without restarting.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -131,7 +131,6 @@ gbjar.sources += [
|
|||
'db/TransactionalProvider.java',
|
||||
'Distribution.java',
|
||||
'DoorHangerPopup.java',
|
||||
'DynamicToolbar.java',
|
||||
'EditBookmarkDialog.java',
|
||||
'EventDispatcher.java',
|
||||
'favicons/cache/FaviconCache.java',
|
||||
|
|
Загрузка…
Ссылка в новой задаче