Fix refresh in Gestures, not reflecting the changes after

toggling on/off one-handed mode

1) Remove disabling on swipe down notification.
2) Update to align asset with One-Handed mode temporarily.
3) Change some states when toggle on/off and align with
One-Handed mode.
4) Set temporary asset style to "centerInside" to avoid image
corrupted problem when device rotate.
5) Add new string on Swipe down notification toggle switch.

Bug: 177679988
Bug: 181970213

Test: manual verified on Settings > System > Gesture page
Test: make RunSettingsRoboTests ROBOTEST_FILTER=
      "com.android.settings.gestures.OneHandedSettingsTest"
Test: make RunSettingsRoboTests ROBOTEST_FILTER=
      "com.android.settings.gestures
      .OneHandedAppTapsExitPreferenceControllerTest"
Test: make RunSettingsRoboTests ROBOTEST_FILTER=
      "com.android.settings.gestures
      .OneHandedEnablePreferenceControllerTest"
Test: make RunSettingsRoboTests ROBOTEST_FILTER=
      "com.android.settings.gestures
      .OneHandedTimeoutPreferenceControllerTest"
Test: make RunSettingsRoboTests ROBOTEST_FILTER=
      "com.android.settings.gestures.OneHandedSettingsUtilsTest"
Test: make RunSettingsRoboTests ROBOTEST_FILTER=
      "com.android.settings.gestures.SwipeBottomToNotificationPreferenceControllerTest"
Test: make RunSettingsRoboTests ROBOTEST_FILTER=
      "com.android.settings.gestures.SwipeBottomToNotificationSettingsTest"

Change-Id: Ifd2346a7694323d21eb424891987c8317847e7c5
This commit is contained in:
Jason Chang
2021-03-12 17:26:42 +08:00
parent 59aa4f9cb1
commit 858bda81f1
12 changed files with 85 additions and 84 deletions

View File

@@ -17,7 +17,6 @@
package com.android.settings.gestures;
import android.content.Context;
import android.os.SystemProperties;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
@@ -28,15 +27,13 @@ import com.android.settings.core.TogglePreferenceController;
**/
public class OneHandedEnablePreferenceController extends TogglePreferenceController {
static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode";
public OneHandedEnablePreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
return SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)
return OneHandedSettingsUtils.isSupportOneHandedMode()
? BasePreferenceController.AVAILABLE
: BasePreferenceController.UNSUPPORTED_ON_DEVICE;
}
@@ -45,6 +42,7 @@ public class OneHandedEnablePreferenceController extends TogglePreferenceControl
public boolean setChecked(boolean isChecked) {
OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext,
isChecked);
OneHandedSettingsUtils.setSwipeDownNotificationEnabled(mContext, !isChecked);
return true;
}

View File

@@ -18,7 +18,6 @@ package com.android.settings.gestures;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.SystemProperties;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -52,8 +51,7 @@ public class OneHandedSettings extends DashboardFragment {
new BaseSearchIndexProvider(R.xml.one_handed_settings) {
@Override
protected boolean isPageSearchEnabled(Context context) {
return SystemProperties.getBoolean(
OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, false);
return OneHandedSettingsUtils.isSupportOneHandedMode();
}
};
}

View File

@@ -22,6 +22,7 @@ import android.database.ContentObserver;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemProperties;
import android.provider.Settings;
/**
@@ -29,6 +30,8 @@ import android.provider.Settings;
*/
public class OneHandedSettingsUtils {
static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode";
public enum OneHandedTimeout {
NEVER(0), SHORT(4), MEDIUM(8), LONG(12);
@@ -51,6 +54,13 @@ public class OneHandedSettingsUtils {
mSettingsObserver = new SettingsObserver(new Handler(Looper.getMainLooper()));
}
/**
* Get One-Handed mode support flag.
*/
public static boolean isSupportOneHandedMode() {
return SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false);
}
/**
* Get one-handed mode enable or disable flag from Settings provider.
*
@@ -118,6 +128,28 @@ public class OneHandedSettingsUtils {
Settings.Secure.ONE_HANDED_MODE_TIMEOUT, timeout);
}
/**
* Get Swipe-down-notification enable or disable flag from Settings provider.
*
* @param context App context
* @return enable or disable Swipe-down-notification flag.
*/
public static boolean isSwipeDownNotificationEnabled(Context context) {
return Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 0) == 1;
}
/**
* Set Swipe-down-notification enable or disable flag to Settings provider.
*
* @param context App context
* @param enable enable or disable Swipe-down-notification.
*/
public static void setSwipeDownNotificationEnabled(Context context, boolean enable) {
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, enable ? 1 : 0);
}
/**
* Register callback for observing Settings.Secure.ONE_HANDED_MODE_ENABLED state.
* @param callback for state changes

View File

@@ -16,14 +16,8 @@
package com.android.settings.gestures;
import static android.provider.Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED;
import static com.android.settings.gestures.OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE;
import android.content.Context;
import android.os.SystemProperties;
import android.provider.Settings;
import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
@@ -33,32 +27,20 @@ import com.android.settings.core.TogglePreferenceController;
**/
public class SwipeBottomToNotificationPreferenceController extends TogglePreferenceController {
private static final int ON = 1;
private static final int OFF = 0;
private static final String PREF_KEY = "gesture_swipe_bottom_to_notification";
public SwipeBottomToNotificationPreferenceController(Context context, String key) {
super(context, key);
}
/** Indicates whether the gesture is available or not. */
public static boolean isGestureAvailable(Context context) {
// Disable the gesture once One-Handed mode gesture enabled.
if (SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) {
return !OneHandedSettingsUtils.isOneHandedModeEnabled(context);
}
return true;
}
@Override
public int getAvailabilityStatus() {
return isGestureAvailable(mContext) ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
return OneHandedSettingsUtils.isSupportOneHandedMode() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
public boolean isSliceable() {
return TextUtils.equals(getPreferenceKey(), PREF_KEY);
return true;
}
@Override
@@ -68,15 +50,16 @@ public class SwipeBottomToNotificationPreferenceController extends TogglePrefere
@Override
public boolean setChecked(boolean isChecked) {
Settings.Secure.putInt(mContext.getContentResolver(),
SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, isChecked ? ON : OFF);
if (isChecked) {
OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, false);
}
OneHandedSettingsUtils.setSwipeDownNotificationEnabled(mContext, isChecked);
return true;
}
@Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(),
SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, OFF) == ON;
return OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext);
}
@Override

View File

@@ -50,8 +50,10 @@ public class SwipeBottomToNotificationSettings extends DashboardFragment {
@Override
protected boolean isPageSearchEnabled(Context context) {
return SwipeBottomToNotificationPreferenceController
.isGestureAvailable(context);
if (!OneHandedSettingsUtils.isSupportOneHandedMode()) {
return false;
}
return !OneHandedSettingsUtils.isOneHandedModeEnabled(context);
}
};
}