Tutorial improvement for Accessibility shortcut (1/n).
Because can't save the value into setting keys for the service before version R, and in order to let tutorial dialog can get the consistent value, using alternative that each fragment with shortcut to must implement the new abstract method. Bug: 148989018 Test: manual test Change-Id: Iba2a7daa70eb00f0bba37317c9355531fbb77628
This commit is contained in:
@@ -100,6 +100,12 @@ public class LaunchAccessibilityActivityPreferenceFragment extends
|
|||||||
showDialog(DialogEnums.EDIT_SHORTCUT);
|
showDialog(DialogEnums.EDIT_SHORTCUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getUserShortcutTypes() {
|
||||||
|
return AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),
|
||||||
|
mComponentName);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
// Do not call super. We don't want to see the "Help & feedback" option on this page so as
|
// Do not call super. We don't want to see the "Help & feedback" option on this page so as
|
||||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accessibility;
|
|||||||
|
|
||||||
import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
|
import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
|
||||||
|
|
||||||
|
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -48,6 +49,22 @@ public class LegacyAccessibilityServicePreferenceFragment extends
|
|||||||
setAllowedPreferredShortcutType(UserShortcutType.HARDWARE);
|
setAllowedPreferredShortcutType(UserShortcutType.HARDWARE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getUserShortcutTypes() {
|
||||||
|
int shortcutTypes = super.getUserShortcutTypes();
|
||||||
|
|
||||||
|
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
|
||||||
|
final boolean hasRequestAccessibilityButtonFlag =
|
||||||
|
(info.flags & AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON) != 0;
|
||||||
|
if (hasRequestAccessibilityButtonFlag) {
|
||||||
|
shortcutTypes |= UserShortcutType.SOFTWARE;
|
||||||
|
} else {
|
||||||
|
shortcutTypes &= (~UserShortcutType.SOFTWARE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return shortcutTypes;
|
||||||
|
}
|
||||||
|
|
||||||
private void setAllowedPreferredShortcutType(int type) {
|
private void setAllowedPreferredShortcutType(int type) {
|
||||||
final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(
|
final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(
|
||||||
mComponentName.flattenToString(), type);
|
mComponentName.flattenToString(), type);
|
||||||
|
@@ -106,7 +106,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
// capabilities. For
|
// capabilities. For
|
||||||
// example, before JellyBean MR2 the user was granting the explore by touch
|
// example, before JellyBean MR2 the user was granting the explore by touch
|
||||||
// one.
|
// one.
|
||||||
private AccessibilityServiceInfo getAccessibilityServiceInfo() {
|
AccessibilityServiceInfo getAccessibilityServiceInfo() {
|
||||||
final List<AccessibilityServiceInfo> infos = AccessibilityManager.getInstance(
|
final List<AccessibilityServiceInfo> infos = AccessibilityManager.getInstance(
|
||||||
getPrefContext()).getInstalledAccessibilityServiceList();
|
getPrefContext()).getInstalledAccessibilityServiceList();
|
||||||
|
|
||||||
@@ -197,6 +197,12 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getUserShortcutTypes() {
|
||||||
|
return AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),
|
||||||
|
mComponentName);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
|
protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
|
||||||
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
|
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
|
||||||
|
@@ -124,6 +124,12 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
|||||||
showDialog(DialogEnums.EDIT_SHORTCUT);
|
showDialog(DialogEnums.EDIT_SHORTCUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getUserShortcutTypes() {
|
||||||
|
return AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),
|
||||||
|
mComponentName);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateSwitchBarToggleSwitch() {
|
private void updateSwitchBarToggleSwitch() {
|
||||||
final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
|
final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
|
||||||
if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
|
if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
|
||||||
|
@@ -198,6 +198,12 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
showDialog(DialogEnums.EDIT_SHORTCUT);
|
showDialog(DialogEnums.EDIT_SHORTCUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getUserShortcutTypes() {
|
||||||
|
return AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),
|
||||||
|
mComponentName);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateSwitchBarToggleSwitch() {
|
private void updateSwitchBarToggleSwitch() {
|
||||||
final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
|
final boolean checked = Settings.Secure.getInt(getContentResolver(), ENABLED, OFF) == ON;
|
||||||
if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
|
if (mToggleServiceDividerSwitchPreference.isChecked() == checked) {
|
||||||
|
@@ -334,6 +334,11 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
removeActionBarToggleSwitch();
|
removeActionBarToggleSwitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shortcut type list which has been checked by user.
|
||||||
|
*/
|
||||||
|
abstract int getUserShortcutTypes();
|
||||||
|
|
||||||
protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
|
protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
|
||||||
switchPreference.setTitle(R.string.accessibility_service_master_switch_title);
|
switchPreference.setTitle(R.string.accessibility_service_master_switch_title);
|
||||||
}
|
}
|
||||||
|
@@ -412,6 +412,11 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getUserShortcutTypes() {
|
||||||
|
return getUserShortcutTypeFromSettings(getPrefContext());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||||
if (enabled && TextUtils.equals(
|
if (enabled && TextUtils.equals(
|
||||||
|
@@ -129,6 +129,11 @@ public class ToggleFeaturePreferenceFragmentTest {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getUserShortcutTypes() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferenceScreenResId() {
|
public int getPreferenceScreenResId() {
|
||||||
return R.xml.placeholder_prefs;
|
return R.xml.placeholder_prefs;
|
||||||
|
@@ -86,5 +86,10 @@ public class ToggleFeaturePreferenceFragmentTest {
|
|||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getUserShortcutTypes() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user