Merge "Fix hold volume keys don't trigger the one handed mode in One-handed mode settings page" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f761f2e15f
@@ -93,7 +93,8 @@ public class OneHandedActionPullDownPrefController extends BasePreferenceControl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)
|
if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)
|
||||||
|| uri.equals(OneHandedSettingsUtils.SHORTCUT_ENABLED_URI)) {
|
|| uri.equals(OneHandedSettingsUtils.SOFTWARE_SHORTCUT_ENABLED_URI)
|
||||||
|
|| uri.equals(OneHandedSettingsUtils.HARDWARE_SHORTCUT_ENABLED_URI)) {
|
||||||
mPreference.setEnabled(OneHandedSettingsUtils.canEnableController(mContext));
|
mPreference.setEnabled(OneHandedSettingsUtils.canEnableController(mContext));
|
||||||
} else if (uri.equals(OneHandedSettingsUtils.SHOW_NOTIFICATION_ENABLED_URI)) {
|
} else if (uri.equals(OneHandedSettingsUtils.SHOW_NOTIFICATION_ENABLED_URI)) {
|
||||||
updateState(mPreference);
|
updateState(mPreference);
|
||||||
|
@@ -93,7 +93,8 @@ public class OneHandedActionShowNotificationPrefController extends BasePreferenc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)
|
if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)
|
||||||
|| uri.equals(OneHandedSettingsUtils.SHORTCUT_ENABLED_URI)) {
|
|| uri.equals(OneHandedSettingsUtils.SOFTWARE_SHORTCUT_ENABLED_URI)
|
||||||
|
|| uri.equals(OneHandedSettingsUtils.HARDWARE_SHORTCUT_ENABLED_URI)) {
|
||||||
mPreference.setEnabled(OneHandedSettingsUtils.canEnableController(mContext));
|
mPreference.setEnabled(OneHandedSettingsUtils.canEnableController(mContext));
|
||||||
} else if (uri.equals(OneHandedSettingsUtils.SHOW_NOTIFICATION_ENABLED_URI)) {
|
} else if (uri.equals(OneHandedSettingsUtils.SHOW_NOTIFICATION_ENABLED_URI)) {
|
||||||
updateState(mPreference);
|
updateState(mPreference);
|
||||||
|
@@ -27,6 +27,7 @@ import android.os.Looper;
|
|||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
@@ -45,8 +46,10 @@ public class OneHandedSettingsUtils {
|
|||||||
Settings.Secure.getUriFor(Settings.Secure.ONE_HANDED_MODE_ENABLED);
|
Settings.Secure.getUriFor(Settings.Secure.ONE_HANDED_MODE_ENABLED);
|
||||||
static final Uri SHOW_NOTIFICATION_ENABLED_URI =
|
static final Uri SHOW_NOTIFICATION_ENABLED_URI =
|
||||||
Settings.Secure.getUriFor(Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED);
|
Settings.Secure.getUriFor(Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED);
|
||||||
static final Uri SHORTCUT_ENABLED_URI =
|
static final Uri SOFTWARE_SHORTCUT_ENABLED_URI =
|
||||||
Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
|
Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
|
||||||
|
static final Uri HARDWARE_SHORTCUT_ENABLED_URI =
|
||||||
|
Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
|
||||||
|
|
||||||
public enum OneHandedTimeout {
|
public enum OneHandedTimeout {
|
||||||
NEVER(0), SHORT(4), MEDIUM(8), LONG(12);
|
NEVER(0), SHORT(4), MEDIUM(8), LONG(12);
|
||||||
@@ -238,9 +241,20 @@ public class OneHandedSettingsUtils {
|
|||||||
* @return true if user enabled one-handed shortcut in settings, false otherwise.
|
* @return true if user enabled one-handed shortcut in settings, false otherwise.
|
||||||
*/
|
*/
|
||||||
public static boolean getShortcutEnabled(Context context) {
|
public static boolean getShortcutEnabled(Context context) {
|
||||||
final String targets = Settings.Secure.getStringForUser(context.getContentResolver(),
|
// Checks SOFTWARE_SHORTCUT_KEY
|
||||||
|
final String targetsSW = Settings.Secure.getStringForUser(context.getContentResolver(),
|
||||||
Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, sCurrentUserId);
|
Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS, sCurrentUserId);
|
||||||
return targets != null ? targets.contains(ONE_HANDED_MODE_TARGET_NAME) : false;
|
if (!TextUtils.isEmpty(targetsSW) && targetsSW.contains(ONE_HANDED_MODE_TARGET_NAME)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks HARDWARE_SHORTCUT_KEY
|
||||||
|
final String targetsHW = Settings.Secure.getStringForUser(context.getContentResolver(),
|
||||||
|
Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE, sCurrentUserId);
|
||||||
|
if (!TextUtils.isEmpty(targetsHW) && targetsHW.contains(ONE_HANDED_MODE_TARGET_NAME)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -285,7 +299,8 @@ public class OneHandedSettingsUtils {
|
|||||||
final ContentResolver resolver = mContext.getContentResolver();
|
final ContentResolver resolver = mContext.getContentResolver();
|
||||||
resolver.registerContentObserver(ONE_HANDED_MODE_ENABLED_URI, true, this);
|
resolver.registerContentObserver(ONE_HANDED_MODE_ENABLED_URI, true, this);
|
||||||
resolver.registerContentObserver(SHOW_NOTIFICATION_ENABLED_URI, true, this);
|
resolver.registerContentObserver(SHOW_NOTIFICATION_ENABLED_URI, true, this);
|
||||||
resolver.registerContentObserver(SHORTCUT_ENABLED_URI, true, this);
|
resolver.registerContentObserver(SOFTWARE_SHORTCUT_ENABLED_URI, true, this);
|
||||||
|
resolver.registerContentObserver(HARDWARE_SHORTCUT_ENABLED_URI, true, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user