diff options
| author | 2018-10-08 20:08:23 +0000 | |
|---|---|---|
| committer | 2018-10-08 20:08:23 +0000 | |
| commit | 91c222ce4156dadac3febb52c2ef835dd55f8017 (patch) | |
| tree | 2813d43afa89d92bdd5aa97a3956b17c923e6733 | |
| parent | 6725df0b344fbce665c05b74d8c87fd8029c3393 (diff) | |
| parent | b687c8a30502e4082493c3de87c3be084865b5e8 (diff) | |
Merge "Update swipe back gesture experiment settings"
3 files changed, 34 insertions, 22 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java index 9c579daa38c6..0b5871ed5e3f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java @@ -195,7 +195,7 @@ public class NavigationBarFragment extends Fragment implements Callbacks { @Override public void onBackButtonAlphaChanged(float alpha, boolean animate) { final ButtonDispatcher backButton = mNavigationBarView.getBackButton(); - if (QuickStepController.shouldhideBackButton()) { + if (QuickStepController.shouldhideBackButton(getContext())) { // If property was changed to hide/show back button, going home will trigger // launcher to to change the back button alpha to reflect property change backButton.setVisibility(View.GONE); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 16b2987558d3..c4efa9431317 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -594,7 +594,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav // Always disable recents when alternate car mode UI is active. boolean disableRecent = mUseCarModeUi || !isOverviewEnabled(); - boolean disableBack = QuickStepController.shouldhideBackButton() + boolean disableBack = QuickStepController.shouldhideBackButton(getContext()) || (((mDisabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0) && !useAltBack); // When screen pinning, don't hide back and home when connected service or back and diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java index bce52a294e85..fd5403fd8301 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickStepController.java @@ -42,7 +42,7 @@ import android.hardware.input.InputManager; import android.os.Handler; import android.os.RemoteException; import android.os.SystemClock; -import android.os.SystemProperties; +import android.provider.Settings; import android.util.FloatProperty; import android.util.Log; import android.util.Slog; @@ -77,10 +77,11 @@ public class QuickStepController implements GestureHelper { private static final float GRADIENT_WIDTH = .75f; /** Experiment to swipe home button left to execute a back key press */ - private static final String PULL_HOME_GO_BACK_PROP = "persist.quickstepcontroller.homegoesback"; - private static final String HIDE_BACK_BUTTON_PROP = "persist.quickstepcontroller.hideback"; + private static final String PULL_HOME_GO_BACK_PROP = "quickstepcontroller_homegoesback"; + private static final String HIDE_BACK_BUTTON_PROP = "quickstepcontroller_hideback"; private static final String BACK_AFTER_END_PROP - = "persist.quickstepcontroller.homegoesbackwhenend"; + = "quickstepcontroller_homegoesbackwhenend"; + private static final String NAVBAR_EXPERIMENTS_DISABLED = "navbarexperiments_disabled"; private static final long BACK_BUTTON_FADE_OUT_ALPHA = 60; private static final long BACK_BUTTON_FADE_IN_ALPHA = 150; private static final long BACK_GESTURE_POLL_TIMEOUT = 1000; @@ -124,14 +125,6 @@ public class QuickStepController implements GestureHelper { private final Matrix mTransformLocalMatrix = new Matrix(); private final Paint mTrackPaint = new Paint(); - public static boolean swipeHomeGoBackGestureEnabled() { - return SystemProperties.getBoolean(PULL_HOME_GO_BACK_PROP, false); - } - public static boolean shouldhideBackButton() { - return swipeHomeGoBackGestureEnabled() - && SystemProperties.getBoolean(HIDE_BACK_BUTTON_PROP, false); - } - private final FloatProperty<QuickStepController> mTrackAlphaProperty = new FloatProperty<QuickStepController>("TrackAlpha") { @Override @@ -211,7 +204,7 @@ public class QuickStepController implements GestureHelper { public void setComponents(NavigationBarView navigationBarView) { mNavigationBarView = navigationBarView; - mNavigationBarView.getBackButton().setVisibility(shouldhideBackButton() + mNavigationBarView.getBackButton().setVisibility(shouldhideBackButton(mContext) ? View.GONE : View.VISIBLE); } @@ -344,7 +337,7 @@ public class QuickStepController implements GestureHelper { // Passing the drag slop then touch slop will start quick step if (allowDrag) { startQuickScrub(); - } else if (swipeHomeGoBackGestureEnabled() + } else if (swipeHomeGoBackGestureEnabled(mContext) && mNavigationBarView.getDownHitTarget() == HIT_TARGET_HOME && mDragPositive ? pos < touchDown : pos > touchDown) { startBackGesture(); @@ -607,10 +600,9 @@ public class QuickStepController implements GestureHelper { if (!mBackGestureActive) { mBackGestureActive = true; mNavigationBarView.getHomeButton().abortCurrentGesture(); - final boolean runBackMidGesture - = !SystemProperties.getBoolean(BACK_AFTER_END_PROP, false); + final boolean runBackMidGesture = !shouldExecuteBackOnUp(mContext); if (mCanPerformBack) { - if (!shouldhideBackButton()) { + if (!shouldhideBackButton(mContext)) { mNavigationBarView.getBackButton().setAlpha(0 /* alpha */, true /* animate */, BACK_BUTTON_FADE_OUT_ALPHA); } @@ -638,11 +630,11 @@ public class QuickStepController implements GestureHelper { mHomeAnimator.translationX(0); } mHomeAnimator.start(); - if (!shouldhideBackButton()) { + if (!shouldhideBackButton(mContext)) { mNavigationBarView.getBackButton().setAlpha( mOverviewEventSender.getBackButtonAlpha(), true /* animate */); } - if (SystemProperties.getBoolean(BACK_AFTER_END_PROP, false)) { + if (shouldExecuteBackOnUp(mContext)) { performBack(); } } @@ -709,7 +701,8 @@ public class QuickStepController implements GestureHelper { } private boolean canPerformHomeBackGesture() { - return swipeHomeGoBackGestureEnabled() && mOverviewEventSender.getBackButtonAlpha() > 0; + return swipeHomeGoBackGestureEnabled(mContext) + && mOverviewEventSender.getBackButtonAlpha() > 0; } private void performBack() { @@ -746,4 +739,23 @@ public class QuickStepController implements GestureHelper { } return false; } + + private static boolean getBoolGlobalSetting(Context context, String key) { + return Settings.Global.getInt(context.getContentResolver(), key, 0) != 0; + } + + public static boolean swipeHomeGoBackGestureEnabled(Context context) { + return !getBoolGlobalSetting(context, NAVBAR_EXPERIMENTS_DISABLED) + && getBoolGlobalSetting(context, PULL_HOME_GO_BACK_PROP); + } + + public static boolean shouldhideBackButton(Context context) { + return swipeHomeGoBackGestureEnabled(context) + && getBoolGlobalSetting(context, HIDE_BACK_BUTTON_PROP); + } + + public static boolean shouldExecuteBackOnUp(Context context) { + return !getBoolGlobalSetting(context, NAVBAR_EXPERIMENTS_DISABLED) + && getBoolGlobalSetting(context, BACK_AFTER_END_PROP); + } } |