Merge "Revising the function name related to user shortcut type." into rvc-dev am: eb04ef4f75 am: 4c7a690479 am: be6265865c am: 53bf408b10 am: 4ef910ce6c

Change-Id: I87157d34786e5ff5fe5d1442ddfb9ac284ffa931
This commit is contained in:
PETER LIANG
2020-04-15 23:55:30 +00:00
committed by Automerger Merge Worker
4 changed files with 51 additions and 51 deletions

View File

@@ -35,7 +35,7 @@ public final class SharedPreferenceUtils {
}
/** Returns a set of user shortcuts list to determine user preferred service shortcut. */
public static Set<String> getUserShortcutType(Context context) {
public static Set<String> getUserShortcutTypes(Context context) {
return getSharedPreferences(context, ACCESSIBILITY_PERF)
.getStringSet(USER_SHORTCUT_TYPE, ImmutableSet.of());
}

View File

@@ -295,7 +295,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
@Override
public void onToggleClicked(ShortcutPreference preference) {
final int shortcutTypes = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
final int shortcutTypes = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE);
if (preference.isChecked()) {
if (!mToggleServiceDividerSwitchPreference.isChecked()) {
preference.setChecked(false);
@@ -413,7 +413,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
private void onAllowButtonFromShortcutToggleClicked() {
mShortcutPreference.setChecked(true);
final int shortcutTypes = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
final int shortcutTypes = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE);
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), shortcutTypes, mComponentName);
mDialog.dismiss();

View File

@@ -85,7 +85,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
protected Uri mImageUri;
protected CharSequence mHtmlDescription;
// Used to restore the edit dialog status.
protected int mUserShortcutTypeCache = UserShortcutType.EMPTY;
protected int mUserShortcutTypesCache = UserShortcutType.EMPTY;
private static final String DRAWABLE_FOLDER = "drawable";
protected static final String KEY_USE_SERVICE_PREFERENCE = "use_service";
protected static final String KEY_GENERAL_CATEGORY = "general_categories";
@@ -93,7 +93,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
private int mUserShortcutType = UserShortcutType.EMPTY;
private int mUserShortcutTypes = UserShortcutType.EMPTY;
private CheckBox mSoftwareTypeCheckBox;
private CheckBox mHardwareTypeCheckBox;
@@ -233,7 +233,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putInt(EXTRA_SHORTCUT_TYPE, mUserShortcutTypeCache);
outState.putInt(EXTRA_SHORTCUT_TYPE, mUserShortcutTypesCache);
super.onSaveInstanceState(outState);
}
@@ -474,31 +474,31 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
}
private void updateAlertDialogCheckState() {
if (mUserShortcutTypeCache != UserShortcutType.EMPTY) {
if (mUserShortcutTypesCache != UserShortcutType.EMPTY) {
updateCheckStatus(mSoftwareTypeCheckBox, UserShortcutType.SOFTWARE);
updateCheckStatus(mHardwareTypeCheckBox, UserShortcutType.HARDWARE);
}
}
private void updateCheckStatus(CheckBox checkBox, @UserShortcutType int type) {
checkBox.setChecked((mUserShortcutTypeCache & type) == type);
checkBox.setChecked((mUserShortcutTypesCache & type) == type);
}
private void updateUserShortcutType(boolean saveChanges) {
mUserShortcutTypeCache = UserShortcutType.EMPTY;
mUserShortcutTypesCache = UserShortcutType.EMPTY;
if (mSoftwareTypeCheckBox.isChecked()) {
mUserShortcutTypeCache |= UserShortcutType.SOFTWARE;
mUserShortcutTypesCache |= UserShortcutType.SOFTWARE;
}
if (mHardwareTypeCheckBox.isChecked()) {
mUserShortcutTypeCache |= UserShortcutType.HARDWARE;
mUserShortcutTypesCache |= UserShortcutType.HARDWARE;
}
if (saveChanges) {
final boolean isChanged = (mUserShortcutTypeCache != UserShortcutType.EMPTY);
final boolean isChanged = (mUserShortcutTypesCache != UserShortcutType.EMPTY);
if (isChanged) {
setUserShortcutType(getPrefContext(), mUserShortcutTypeCache);
setUserShortcutType(getPrefContext(), mUserShortcutTypesCache);
}
mUserShortcutType = mUserShortcutTypeCache;
mUserShortcutTypes = mUserShortcutTypesCache;
}
}
@@ -507,7 +507,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
return;
}
Set<String> info = SharedPreferenceUtils.getUserShortcutType(context);
Set<String> info = SharedPreferenceUtils.getUserShortcutTypes(context);
final String componentName = mComponentName.flattenToString();
if (info.isEmpty()) {
info = new HashSet<>();
@@ -532,7 +532,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
return context.getText(R.string.switch_off_text);
}
final int shortcutType = getUserShortcutType(context, UserShortcutType.SOFTWARE);
final int shortcutTypes = getUserShortcutTypes(context, UserShortcutType.SOFTWARE);
int resId = R.string.accessibility_shortcut_edit_summary_software;
if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
resId = AccessibilityUtil.isTouchExploreEnabled(context)
@@ -542,10 +542,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
final CharSequence softwareTitle = context.getText(resId);
List<CharSequence> list = new ArrayList<>();
if ((shortcutType & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
list.add(softwareTitle);
}
if ((shortcutType & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE) {
if ((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE) {
final CharSequence hardwareTitle = context.getText(
R.string.accessibility_shortcut_edit_dialog_title_hardware);
list.add(hardwareTitle);
@@ -559,12 +559,12 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
return AccessibilityUtil.capitalize(joinStrings);
}
protected int getUserShortcutType(Context context, @UserShortcutType int defaultValue) {
protected int getUserShortcutTypes(Context context, @UserShortcutType int defaultValue) {
if (mComponentName == null) {
return defaultValue;
}
final Set<String> info = SharedPreferenceUtils.getUserShortcutType(context);
final Set<String> info = SharedPreferenceUtils.getUserShortcutTypes(context);
final String componentName = mComponentName.flattenToString();
final Set<String> filtered = info.stream()
.filter(str -> str.contains(componentName))
@@ -584,11 +584,11 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
}
updateUserShortcutType(/* saveChanges= */ true);
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), mUserShortcutType,
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), mUserShortcutTypes,
mComponentName);
AccessibilityUtil.optOutAllValuesFromSettings(getPrefContext(), ~mUserShortcutType,
AccessibilityUtil.optOutAllValuesFromSettings(getPrefContext(), ~mUserShortcutTypes,
mComponentName);
mShortcutPreference.setChecked(mUserShortcutType != UserShortcutType.EMPTY);
mShortcutPreference.setChecked(mUserShortcutTypes != UserShortcutType.EMPTY);
mShortcutPreference.setSummary(
getShortcutTypeSummary(getPrefContext()));
}
@@ -599,20 +599,20 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
}
// Get the user shortcut type from settings provider.
mUserShortcutType = AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),
mUserShortcutTypes = AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),
mComponentName);
if (mUserShortcutType != UserShortcutType.EMPTY) {
setUserShortcutType(getPrefContext(), mUserShortcutType);
if (mUserShortcutTypes != UserShortcutType.EMPTY) {
setUserShortcutType(getPrefContext(), mUserShortcutTypes);
} else {
// Get the user shortcut type from shared_prefs if cannot get from settings provider.
mUserShortcutType = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
mUserShortcutTypes = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE);
}
}
private void initShortcutPreference(Bundle savedInstanceState) {
// Restore the user shortcut type.
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
mUserShortcutTypeCache = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE,
mUserShortcutTypesCache = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE,
UserShortcutType.EMPTY);
}
@@ -631,7 +631,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
return;
}
final int shortcutTypes = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
final int shortcutTypes = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE);
mShortcutPreference.setChecked(
AccessibilityUtil.hasValuesInSettings(getPrefContext(), shortcutTypes,
mComponentName));
@@ -648,7 +648,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
return;
}
final int shortcutTypes = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
final int shortcutTypes = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE);
if (preference.isChecked()) {
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), shortcutTypes,
mComponentName);
@@ -662,8 +662,8 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
@Override
public void onSettingsClicked(ShortcutPreference preference) {
// Do not restore shortcut in shortcut chooser dialog when shortcutPreference is turned off.
mUserShortcutTypeCache = mShortcutPreference.isChecked()
? getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE)
mUserShortcutTypesCache = mShortcutPreference.isChecked()
? getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE)
: UserShortcutType.EMPTY;
}

View File

@@ -197,7 +197,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putInt(EXTRA_SHORTCUT_TYPE, mUserShortcutTypeCache);
outState.putInt(EXTRA_SHORTCUT_TYPE, mUserShortcutTypesCache);
super.onSaveInstanceState(outState);
}
@@ -286,7 +286,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
private void updateAlertDialogCheckState() {
if (mUserShortcutTypeCache != UserShortcutType.EMPTY) {
if (mUserShortcutTypesCache != UserShortcutType.EMPTY) {
updateCheckStatus(mSoftwareTypeCheckBox, UserShortcutType.SOFTWARE);
updateCheckStatus(mHardwareTypeCheckBox, UserShortcutType.HARDWARE);
updateCheckStatus(mTripleTapTypeCheckBox, UserShortcutType.TRIPLETAP);
@@ -294,32 +294,32 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
private void updateCheckStatus(CheckBox checkBox, @UserShortcutType int type) {
checkBox.setChecked((mUserShortcutTypeCache & type) == type);
checkBox.setChecked((mUserShortcutTypesCache & type) == type);
}
private void updateUserShortcutType(boolean saveChanges) {
mUserShortcutTypeCache = UserShortcutType.EMPTY;
mUserShortcutTypesCache = UserShortcutType.EMPTY;
if (mSoftwareTypeCheckBox.isChecked()) {
mUserShortcutTypeCache |= UserShortcutType.SOFTWARE;
mUserShortcutTypesCache |= UserShortcutType.SOFTWARE;
}
if (mHardwareTypeCheckBox.isChecked()) {
mUserShortcutTypeCache |= UserShortcutType.HARDWARE;
mUserShortcutTypesCache |= UserShortcutType.HARDWARE;
}
if (mTripleTapTypeCheckBox.isChecked()) {
mUserShortcutTypeCache |= UserShortcutType.TRIPLETAP;
mUserShortcutTypesCache |= UserShortcutType.TRIPLETAP;
}
if (saveChanges) {
final boolean isChanged = (mUserShortcutTypeCache != UserShortcutType.EMPTY);
final boolean isChanged = (mUserShortcutTypesCache != UserShortcutType.EMPTY);
if (isChanged) {
setUserShortcutType(getPrefContext(), mUserShortcutTypeCache);
setUserShortcutType(getPrefContext(), mUserShortcutTypesCache);
}
mUserShortcutType = mUserShortcutTypeCache;
mUserShortcutType = mUserShortcutTypesCache;
}
}
private void setUserShortcutType(Context context, int type) {
Set<String> info = SharedPreferenceUtils.getUserShortcutType(context);
Set<String> info = SharedPreferenceUtils.getUserShortcutTypes(context);
if (info.isEmpty()) {
info = new HashSet<>();
} else {
@@ -340,7 +340,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
return context.getText(R.string.switch_off_text);
}
final int shortcutType = getUserShortcutType(context, UserShortcutType.EMPTY);
final int shortcutType = getUserShortcutTypes(context, UserShortcutType.EMPTY);
int resId = R.string.accessibility_shortcut_edit_summary_software;
if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
resId = AccessibilityUtil.isTouchExploreEnabled(context)
@@ -374,8 +374,8 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
@Override
protected int getUserShortcutType(Context context, @UserShortcutType int defaultValue) {
final Set<String> info = SharedPreferenceUtils.getUserShortcutType(context);
protected int getUserShortcutTypes(Context context, @UserShortcutType int defaultValue) {
final Set<String> info = SharedPreferenceUtils.getUserShortcutTypes(context);
final Set<String> filtered = info.stream().filter(
str -> str.contains(MAGNIFICATION_CONTROLLER_NAME)).collect(
Collectors.toSet());
@@ -451,7 +451,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@Override
public void onToggleClicked(ShortcutPreference preference) {
final int shortcutTypes = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
final int shortcutTypes = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE);
if (preference.isChecked()) {
optInAllMagnificationValuesToSettings(getPrefContext(), shortcutTypes);
} else {
@@ -463,8 +463,8 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@Override
public void onSettingsClicked(ShortcutPreference preference) {
// Do not restore shortcut in shortcut chooser dialog when shortcutPreference is turned off.
mUserShortcutTypeCache = mShortcutPreference.isChecked()
? getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE)
mUserShortcutTypesCache = mShortcutPreference.isChecked()
? getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE)
: UserShortcutType.EMPTY;
showDialog(DialogEnums.MAGNIFICATION_EDIT_SHORTCUT);
}
@@ -476,7 +476,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
setUserShortcutType(getPrefContext(), mUserShortcutType);
} else {
// Get the user shortcut type from shared_prefs if cannot get from settings provider.
mUserShortcutType = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
mUserShortcutType = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE);
}
}
@@ -492,7 +492,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
private void updateShortcutPreference() {
final int shortcutTypes = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
final int shortcutTypes = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE);
mShortcutPreference.setChecked(
hasMagnificationValuesInSettings(getPrefContext(), shortcutTypes));
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));