Fix "Cannot get activity context when service off".
1. Unify getPrefContext() usage in Accessibility Settings 2. Correct the dialog emuns order Test: local test Change-Id: Idc51f7b15b5813bbae7b32e1ae3c7f00c71cea50
This commit is contained in:
@@ -19,7 +19,6 @@ package com.android.settings.accessibility;
|
|||||||
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
|
||||||
|
|
||||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -60,10 +59,17 @@ public class AccessibilityServiceWarning {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Dialog createCapabilitiesDialog(Activity parentActivity,
|
/**
|
||||||
|
* Gets a content View for a dialog to confirm that they want to enable a service.
|
||||||
|
*
|
||||||
|
* @param context A valid context
|
||||||
|
* @param info The info about a service
|
||||||
|
* @return A content view suitable for viewing
|
||||||
|
*/
|
||||||
|
public static Dialog createCapabilitiesDialog(Context context,
|
||||||
AccessibilityServiceInfo info, View.OnClickListener listener) {
|
AccessibilityServiceInfo info, View.OnClickListener listener) {
|
||||||
final AlertDialog ad = new AlertDialog.Builder(parentActivity)
|
final AlertDialog ad = new AlertDialog.Builder(context)
|
||||||
.setView(createEnableDialogContentView(parentActivity, info, listener))
|
.setView(createEnableDialogContentView(context, info, listener))
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
Window window = ad.getWindow();
|
Window window = ad.getWindow();
|
||||||
@@ -77,7 +83,7 @@ public class AccessibilityServiceWarning {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the device is encrypted with legacy full disk encryption. Newer devices
|
* Returns whether the device is encrypted with legacy full disk encryption. Newer devices
|
||||||
* should be using File Based Encryption.
|
* should be using File Based Encryption.
|
||||||
*
|
*
|
||||||
* @return true if device is encrypted
|
* @return true if device is encrypted
|
||||||
@@ -86,13 +92,6 @@ public class AccessibilityServiceWarning {
|
|||||||
return StorageManager.isNonDefaultBlockEncrypted();
|
return StorageManager.isNonDefaultBlockEncrypted();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a content View for a dialog to confirm that they want to enable a service.
|
|
||||||
*
|
|
||||||
* @param context A valid context
|
|
||||||
* @param info The info about a service
|
|
||||||
* @return A content view suitable for viewing
|
|
||||||
*/
|
|
||||||
private static View createEnableDialogContentView(Context context,
|
private static View createEnableDialogContentView(Context context,
|
||||||
AccessibilityServiceInfo info, View.OnClickListener listener) {
|
AccessibilityServiceInfo info, View.OnClickListener listener) {
|
||||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(
|
||||||
|
@@ -23,7 +23,6 @@ import android.app.admin.DevicePolicyManager;
|
|||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
@@ -98,7 +97,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
@Override
|
@Override
|
||||||
public void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
public void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||||
ComponentName toggledService = ComponentName.unflattenFromString(preferenceKey);
|
ComponentName toggledService = ComponentName.unflattenFromString(preferenceKey);
|
||||||
AccessibilityUtils.setAccessibilityServiceState(getActivity(), toggledService, enabled);
|
AccessibilityUtils.setAccessibilityServiceState(getPrefContext(), toggledService, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IMPORTANT: Refresh the info since there are dynamically changing
|
// IMPORTANT: Refresh the info since there are dynamically changing
|
||||||
@@ -129,7 +128,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
mDialog = AccessibilityServiceWarning
|
mDialog = AccessibilityServiceWarning
|
||||||
.createCapabilitiesDialog(getActivity(), info,
|
.createCapabilitiesDialog(getPrefContext(), info,
|
||||||
this::onDialogButtonFromToggleClicked);
|
this::onDialogButtonFromToggleClicked);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -139,17 +138,17 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
mDialog = AccessibilityServiceWarning
|
mDialog = AccessibilityServiceWarning
|
||||||
.createCapabilitiesDialog(getActivity(), info,
|
.createCapabilitiesDialog(getPrefContext(), info,
|
||||||
this::onDialogButtonFromShortcutClicked);
|
this::onDialogButtonFromShortcutClicked);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL: {
|
case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL: {
|
||||||
if (AccessibilityUtil.isGestureNavigateEnabled(getContext())) {
|
if (AccessibilityUtil.isGestureNavigateEnabled(getPrefContext())) {
|
||||||
mDialog = AccessibilityGestureNavigationTutorial
|
mDialog = AccessibilityGestureNavigationTutorial
|
||||||
.showGestureNavigationTutorialDialog(getActivity());
|
.showGestureNavigationTutorialDialog(getPrefContext());
|
||||||
} else {
|
} else {
|
||||||
mDialog = AccessibilityGestureNavigationTutorial
|
mDialog = AccessibilityGestureNavigationTutorial
|
||||||
.showAccessibilityButtonTutorialDialog(getActivity());
|
.showAccessibilityButtonTutorialDialog(getPrefContext());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -185,7 +184,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateSwitchBarToggleSwitch() {
|
private void updateSwitchBarToggleSwitch() {
|
||||||
final boolean checked = AccessibilityUtils.getEnabledServicesFromSettings(getActivity())
|
final boolean checked = AccessibilityUtils.getEnabledServicesFromSettings(getPrefContext())
|
||||||
.contains(mComponentName);
|
.contains(mComponentName);
|
||||||
mSwitchBar.setCheckedInternal(checked);
|
mSwitchBar.setCheckedInternal(checked);
|
||||||
}
|
}
|
||||||
@@ -220,8 +219,8 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isServiceSupportAccessibilityButton() {
|
private boolean isServiceSupportAccessibilityButton() {
|
||||||
final AccessibilityManager ams = (AccessibilityManager) getContext().getSystemService(
|
final AccessibilityManager ams = getPrefContext().getSystemService(
|
||||||
Context.ACCESSIBILITY_SERVICE);
|
AccessibilityManager.class);
|
||||||
final List<AccessibilityServiceInfo> services = ams.getInstalledAccessibilityServiceList();
|
final List<AccessibilityServiceInfo> services = ams.getInstalledAccessibilityServiceList();
|
||||||
|
|
||||||
for (AccessibilityServiceInfo info : services) {
|
for (AccessibilityServiceInfo info : services) {
|
||||||
@@ -268,17 +267,17 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckboxClicked(ShortcutPreference preference) {
|
public void onCheckboxClicked(ShortcutPreference preference) {
|
||||||
final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
|
final int shortcutTypes = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
|
||||||
if (preference.getChecked()) {
|
if (preference.getChecked()) {
|
||||||
if (!getArguments().getBoolean(AccessibilitySettings.EXTRA_CHECKED)) {
|
if (!getArguments().getBoolean(AccessibilitySettings.EXTRA_CHECKED)) {
|
||||||
preference.setChecked(false);
|
preference.setChecked(false);
|
||||||
showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_SHORTCUT);
|
showPopupDialog(DialogEnums.ENABLE_WARNING_FROM_SHORTCUT);
|
||||||
} else {
|
} else {
|
||||||
AccessibilityUtil.optInAllValuesToSettings(getContext(), shortcutTypes,
|
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), shortcutTypes,
|
||||||
mComponentName);
|
mComponentName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
AccessibilityUtil.optOutAllValuesFromSettings(getContext(), shortcutTypes,
|
AccessibilityUtil.optOutAllValuesFromSettings(getPrefContext(), shortcutTypes,
|
||||||
mComponentName);
|
mComponentName);
|
||||||
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, false);
|
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, false);
|
||||||
}
|
}
|
||||||
@@ -370,8 +369,8 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
private void onAllowButtonFromShortcutClicked() {
|
private void onAllowButtonFromShortcutClicked() {
|
||||||
mShortcutPreference.setChecked(true);
|
mShortcutPreference.setChecked(true);
|
||||||
|
|
||||||
final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
|
final int shortcutTypes = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
|
||||||
AccessibilityUtil.optInAllValuesToSettings(getContext(), shortcutTypes, mComponentName);
|
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), shortcutTypes, mComponentName);
|
||||||
|
|
||||||
mDialog.dismiss();
|
mDialog.dismiss();
|
||||||
}
|
}
|
||||||
|
@@ -114,7 +114,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
final int resId = getPreferenceScreenResId();
|
final int resId = getPreferenceScreenResId();
|
||||||
if (resId <= 0) {
|
if (resId <= 0) {
|
||||||
PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(
|
PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(
|
||||||
getActivity());
|
getPrefContext());
|
||||||
setPreferenceScreen(preferenceScreen);
|
setPreferenceScreen(preferenceScreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
if (mImageUri != null) {
|
if (mImageUri != null) {
|
||||||
final AnimatedImagePreference animatedImagePreference = new AnimatedImagePreference(
|
final AnimatedImagePreference animatedImagePreference = new AnimatedImagePreference(
|
||||||
preferenceScreen.getContext());
|
getPrefContext());
|
||||||
animatedImagePreference.setImageUri(mImageUri);
|
animatedImagePreference.setImageUri(mImageUri);
|
||||||
animatedImagePreference.setDividerAllowedAbove(true);
|
animatedImagePreference.setDividerAllowedAbove(true);
|
||||||
preferenceScreen.addPreference(animatedImagePreference);
|
preferenceScreen.addPreference(animatedImagePreference);
|
||||||
@@ -158,7 +158,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
|
|
||||||
// Show the "Settings" menu as if it were a preference screen.
|
// Show the "Settings" menu as if it were a preference screen.
|
||||||
if (mSettingsTitle != null && mSettingsIntent != null) {
|
if (mSettingsTitle != null && mSettingsIntent != null) {
|
||||||
mSettingsPreference = new Preference(preferenceScreen.getContext());
|
mSettingsPreference = new Preference(getPrefContext());
|
||||||
mSettingsPreference.setTitle(mSettingsTitle);
|
mSettingsPreference.setTitle(mSettingsTitle);
|
||||||
mSettingsPreference.setIconSpaceReserved(true);
|
mSettingsPreference.setIconSpaceReserved(true);
|
||||||
mSettingsPreference.setIntent(mSettingsIntent);
|
mSettingsPreference.setIntent(mSettingsIntent);
|
||||||
@@ -177,7 +177,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
|
|
||||||
if (mStaticDescription != null) {
|
if (mStaticDescription != null) {
|
||||||
final StaticTextPreference staticTextPreference = new StaticTextPreference(
|
final StaticTextPreference staticTextPreference = new StaticTextPreference(
|
||||||
preferenceScreen.getContext());
|
getPrefContext());
|
||||||
staticTextPreference.setSummary(mStaticDescription);
|
staticTextPreference.setSummary(mStaticDescription);
|
||||||
staticTextPreference.setSelectable(/* selectable= */ false);
|
staticTextPreference.setSelectable(/* selectable= */ false);
|
||||||
footerCategory.addPreference(staticTextPreference);
|
footerCategory.addPreference(staticTextPreference);
|
||||||
@@ -189,7 +189,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
unsupportedTagList.add(ANCHOR_TAG);
|
unsupportedTagList.add(ANCHOR_TAG);
|
||||||
|
|
||||||
final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(
|
final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(
|
||||||
preferenceScreen.getContext());
|
getPrefContext());
|
||||||
htmlTextPreference.setSummary(mHtmlDescription);
|
htmlTextPreference.setSummary(mHtmlDescription);
|
||||||
htmlTextPreference.setImageGetter(mImageGetter);
|
htmlTextPreference.setImageGetter(mImageGetter);
|
||||||
htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
|
htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
|
||||||
@@ -234,10 +234,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
public Dialog onCreateDialog(int dialogId) {
|
public Dialog onCreateDialog(int dialogId) {
|
||||||
switch (dialogId) {
|
switch (dialogId) {
|
||||||
case DialogEnums.EDIT_SHORTCUT:
|
case DialogEnums.EDIT_SHORTCUT:
|
||||||
final CharSequence dialogTitle = getActivity().getString(
|
final CharSequence dialogTitle = getPrefContext().getString(
|
||||||
R.string.accessibility_shortcut_edit_dialog_title, mPackageName);
|
R.string.accessibility_shortcut_edit_dialog_title, mPackageName);
|
||||||
Dialog dialog = AccessibilityEditDialogUtils.showEditShortcutDialog(getActivity(),
|
Dialog dialog = AccessibilityEditDialogUtils.showEditShortcutDialog(
|
||||||
dialogTitle, this::callOnAlertDialogCheckboxClicked);
|
getPrefContext(), dialogTitle, this::callOnAlertDialogCheckboxClicked);
|
||||||
initializeDialogCheckBox(dialog);
|
initializeDialogCheckBox(dialog);
|
||||||
return dialog;
|
return dialog;
|
||||||
default:
|
default:
|
||||||
@@ -258,37 +258,35 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
/** Denotes the dialog emuns for show dialog */
|
/** Denotes the dialog emuns for show dialog */
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
protected @interface DialogEnums {
|
protected @interface DialogEnums {
|
||||||
int UNKNOWN = 0;
|
|
||||||
|
|
||||||
/** OPEN: Settings > Accessibility > Any toggle service > Shortcut > Settings. */
|
/** OPEN: Settings > Accessibility > Any toggle service > Shortcut > Settings. */
|
||||||
int EDIT_SHORTCUT = 1;
|
int EDIT_SHORTCUT = 1;
|
||||||
|
|
||||||
/** OPEN: Settings > Accessibility > Magnification > Shortcut > Settings. */
|
/** OPEN: Settings > Accessibility > Magnification > Shortcut > Settings. */
|
||||||
int MAGNIFICATION_EDIT_SHORTCUT = 2;
|
int MAGNIFICATION_EDIT_SHORTCUT = 1001;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OPEN: Settings > Accessibility > Magnification > Toggle user service in gesture
|
* OPEN: Settings > Accessibility > Magnification > Toggle user service in gesture
|
||||||
* navigation.
|
* navigation.
|
||||||
*/
|
*/
|
||||||
int GESTURE_NAVIGATION_TUTORIAL = 1001;
|
int GESTURE_NAVIGATION_TUTORIAL = 1002;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OPEN: Settings > Accessibility > Magnification > Toggle user service in button
|
* OPEN: Settings > Accessibility > Magnification > Toggle user service in button
|
||||||
* navigation.
|
* navigation.
|
||||||
*/
|
*/
|
||||||
int ACCESSIBILITY_BUTTON_TUTORIAL = 1002;
|
int ACCESSIBILITY_BUTTON_TUTORIAL = 1003;
|
||||||
|
|
||||||
/** OPEN: Settings > Accessibility > Downloaded toggle service > Toggle user service. */
|
/** OPEN: Settings > Accessibility > Downloaded toggle service > Toggle user service. */
|
||||||
int ENABLE_WARNING_FROM_TOGGLE = 1003;
|
int ENABLE_WARNING_FROM_TOGGLE = 1004;
|
||||||
|
|
||||||
/** OPEN: Settings > Accessibility > Downloaded toggle service > Shortcut checkbox. */
|
/** OPEN: Settings > Accessibility > Downloaded toggle service > Shortcut checkbox. */
|
||||||
int ENABLE_WARNING_FROM_SHORTCUT = 1004;
|
int ENABLE_WARNING_FROM_SHORTCUT = 1005;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OPEN: Settings > Accessibility > Downloaded toggle service > Toggle user service > Show
|
* OPEN: Settings > Accessibility > Downloaded toggle service > Toggle user service > Show
|
||||||
* launch tutorial.
|
* launch tutorial.
|
||||||
*/
|
*/
|
||||||
int LAUNCH_ACCESSIBILITY_TUTORIAL = 1005;
|
int LAUNCH_ACCESSIBILITY_TUTORIAL = 1006;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -364,7 +362,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
|
|
||||||
private Drawable getDrawableFromUri(Uri imageUri) {
|
private Drawable getDrawableFromUri(Uri imageUri) {
|
||||||
if (mImageGetterCacheView == null) {
|
if (mImageGetterCacheView == null) {
|
||||||
mImageGetterCacheView = new ImageView(getContext());
|
mImageGetterCacheView = new ImageView(getPrefContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
mImageGetterCacheView.setAdjustViewBounds(true);
|
mImageGetterCacheView.setAdjustViewBounds(true);
|
||||||
|
@@ -241,16 +241,17 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
switch (dialogId) {
|
switch (dialogId) {
|
||||||
case DialogEnums.GESTURE_NAVIGATION_TUTORIAL:
|
case DialogEnums.GESTURE_NAVIGATION_TUTORIAL:
|
||||||
return AccessibilityGestureNavigationTutorial
|
return AccessibilityGestureNavigationTutorial
|
||||||
.showGestureNavigationTutorialDialog(getActivity());
|
.showGestureNavigationTutorialDialog(getPrefContext());
|
||||||
case DialogEnums.ACCESSIBILITY_BUTTON_TUTORIAL:
|
case DialogEnums.ACCESSIBILITY_BUTTON_TUTORIAL:
|
||||||
return AccessibilityGestureNavigationTutorial
|
return AccessibilityGestureNavigationTutorial
|
||||||
.showAccessibilityButtonTutorialDialog(getActivity());
|
.showAccessibilityButtonTutorialDialog(getPrefContext());
|
||||||
case DialogEnums.MAGNIFICATION_EDIT_SHORTCUT:
|
case DialogEnums.MAGNIFICATION_EDIT_SHORTCUT:
|
||||||
final CharSequence dialogTitle = getActivity().getText(
|
final CharSequence dialogTitle = getPrefContext().getText(
|
||||||
R.string.accessibility_shortcut_edit_dialog_title_magnification);
|
R.string.accessibility_shortcut_edit_dialog_title_magnification);
|
||||||
final AlertDialog dialog =
|
final AlertDialog dialog =
|
||||||
AccessibilityEditDialogUtils.showMagnificationEditShortcutDialog(
|
AccessibilityEditDialogUtils.showMagnificationEditShortcutDialog(
|
||||||
getActivity(), dialogTitle, this::callOnAlertDialogCheckboxClicked);
|
getPrefContext(), dialogTitle,
|
||||||
|
this::callOnAlertDialogCheckboxClicked);
|
||||||
initializeDialogCheckBox(dialog);
|
initializeDialogCheckBox(dialog);
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
@@ -425,7 +426,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
if (enabled && TextUtils.equals(
|
if (enabled && TextUtils.equals(
|
||||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
|
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
|
||||||
preferenceKey)) {
|
preferenceKey)) {
|
||||||
showDialog(AccessibilityUtil.isGestureNavigateEnabled(getContext())
|
showDialog(AccessibilityUtil.isGestureNavigateEnabled(getPrefContext())
|
||||||
? DialogEnums.GESTURE_NAVIGATION_TUTORIAL
|
? DialogEnums.GESTURE_NAVIGATION_TUTORIAL
|
||||||
: DialogEnums.ACCESSIBILITY_BUTTON_TUTORIAL);
|
: DialogEnums.ACCESSIBILITY_BUTTON_TUTORIAL);
|
||||||
}
|
}
|
||||||
@@ -457,11 +458,11 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckboxClicked(ShortcutPreference preference) {
|
public void onCheckboxClicked(ShortcutPreference preference) {
|
||||||
final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
|
final int shortcutTypes = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
|
||||||
if (preference.getChecked()) {
|
if (preference.getChecked()) {
|
||||||
optInAllMagnificationValuesToSettings(getContext(), shortcutTypes);
|
optInAllMagnificationValuesToSettings(getPrefContext(), shortcutTypes);
|
||||||
} else {
|
} else {
|
||||||
optOutAllMagnificationValuesFromSettings(getContext(), shortcutTypes);
|
optOutAllMagnificationValuesFromSettings(getPrefContext(), shortcutTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,31 +484,19 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initShortcutPreference() {
|
private void initShortcutPreference() {
|
||||||
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
mShortcutPreference = new ShortcutPreference(getPrefContext(), null);
|
||||||
mShortcutPreference = new ShortcutPreference(
|
|
||||||
preferenceScreen.getContext(), null);
|
|
||||||
mShortcutPreference.setPersistent(false);
|
mShortcutPreference.setPersistent(false);
|
||||||
mShortcutPreference.setKey(getShortcutPreferenceKey());
|
mShortcutPreference.setKey(KEY_SHORTCUT_PREFERENCE);
|
||||||
mShortcutPreference.setTitle(R.string.accessibility_magnification_shortcut_title);
|
mShortcutPreference.setTitle(R.string.accessibility_magnification_shortcut_title);
|
||||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||||
mShortcutPreference.setOnClickListener(this);
|
mShortcutPreference.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShortcutPreference() {
|
private void updateShortcutPreference() {
|
||||||
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
final int shortcutTypes = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
|
||||||
final ShortcutPreference shortcutPreference = preferenceScreen.findPreference(
|
mShortcutPreference.setChecked(
|
||||||
getShortcutPreferenceKey());
|
hasMagnificationValuesInSettings(getPrefContext(), shortcutTypes));
|
||||||
|
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||||
if (shortcutPreference != null) {
|
|
||||||
final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
|
|
||||||
shortcutPreference.setChecked(
|
|
||||||
hasMagnificationValuesInSettings(getContext(), shortcutTypes));
|
|
||||||
shortcutPreference.setSummary(getShortcutTypeSummary(getContext()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getShortcutPreferenceKey() {
|
|
||||||
return KEY_SHORTCUT_PREFERENCE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateConfigurationWarningIfNeeded() {
|
private void updateConfigurationWarningIfNeeded() {
|
||||||
|
Reference in New Issue
Block a user