Refactoring One-Handed feature flag and others
Purify some conditions for reducing redundancy codes.
Test: manual
Change-Id: I2f39207424f9db3fb6b12bc08bee525f3dfab0aa
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
index 7168875..fe152a0 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
@@ -98,6 +98,7 @@
private float mAssistantVisibility;
private boolean mIsOneHandedModeEnabled;
private boolean mIsSwipeToNotificationEnabled;
+ private final boolean mIsOneHandedModeSupported;
private boolean mIsUserUnlocked;
private final ArrayList<Runnable> mUserUnlockedActions = new ArrayList<>();
@@ -123,6 +124,7 @@
mSysUiNavMode = SysUINavigationMode.INSTANCE.get(context);
mDefaultDisplay = DefaultDisplay.INSTANCE.get(context);
mDisplayId = mDefaultDisplay.getInfo().id;
+ mIsOneHandedModeSupported = SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false);
runOnDestroy(() -> mDefaultDisplay.removeChangeListener(this));
mRotationTouchHelper = new RotationTouchHelper(context);
runOnDestroy(mRotationTouchHelper::destroy);
@@ -167,7 +169,7 @@
}
}
- if (SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) {
+ if (mIsOneHandedModeSupported) {
SecureSettingsObserver oneHandedEnabledObserver =
SecureSettingsObserver.newOneHandedSettingsObserver(
mContext, enabled -> mIsOneHandedModeEnabled = enabled);
@@ -522,19 +524,18 @@
* @return whether the given motion event can trigger the one handed mode.
*/
public boolean canTriggerOneHandedAction(MotionEvent ev) {
- if (!SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) {
+ if (!mIsOneHandedModeSupported) {
return false;
}
- if (!mIsOneHandedModeEnabled && !mIsSwipeToNotificationEnabled) {
- return false;
+ if (mIsOneHandedModeEnabled || mIsSwipeToNotificationEnabled) {
+ final DefaultDisplay.Info displayInfo = mDefaultDisplay.getInfo();
+ return (mRotationTouchHelper.touchInOneHandedModeRegion(ev)
+ && displayInfo.rotation != Surface.ROTATION_90
+ && displayInfo.rotation != Surface.ROTATION_270
+ && displayInfo.metrics.densityDpi < DisplayMetrics.DENSITY_600);
}
-
- final DefaultDisplay.Info displayInfo = mDefaultDisplay.getInfo();
- return (mRotationTouchHelper.touchInOneHandedModeRegion(ev)
- && displayInfo.rotation != Surface.ROTATION_90
- && displayInfo.rotation != Surface.ROTATION_270
- && displayInfo.metrics.densityDpi < DisplayMetrics.DENSITY_600);
+ return false;
}
public boolean isOneHandedModeEnabled() {