Updates to Magnification Settings

Restructures accessibility settings to support multiple
magnification modes.

Removes "preview" behavior within magnification settings

Test: Manual
Bug: 30960346
Bug: 36136580
Change-Id: I9f95b8ef2460f5178336e8cb44b10a2553d28ea9
This commit is contained in:
Casey Burkhardt
2017-03-22 18:19:19 -07:00
parent b11abb9c3a
commit 9c7143c3e4
10 changed files with 320 additions and 91 deletions

View File

@@ -4067,12 +4067,22 @@
<string name="accessibility_captioning_title">Captions</string>
<!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
<string name="accessibility_screen_magnification_title">Magnification</string>
<!-- Title for the accessibility preference screen to enable triple-tap gesture screen magnification. [CHAR LIMIT=35] -->
<string name="accessibility_screen_magnification_gestures_title">Magnify with triple-tap</string>
<!-- Title for the accessibility preference screen to enable navigation bar screen magnification. [CHAR LIMIT=35] -->
<string name="accessibility_screen_magnification_navbar_title">Magnify with button</string>
<!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->
<string name="accessibility_preference_magnification_summary">Zoom in on screen</string>
<!-- Short summary for Magnification gesture. Tells the user that this feature allows the user to magnify the screen by tapping 3 times. Appears in accessibility portion of setup wizard -->
<string name="accessibility_screen_magnification_short_summary">Tap 3 times to zoom</string>
<!-- Summary for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=none] -->
<!-- Short summary for nav bar Magnification. Tells the user that this feature allows the user to magnify the screen using a button in the nav bar -->
<string name="accessibility_screen_magnification_navbar_short_summary">Tap a button to zoom</string>
<!-- Summary for the accessibility preference screen to enable screen magnification gestures. [CHAR LIMIT=none] -->
<string name="accessibility_screen_magnification_summary"><b>To zoom</b>, quickly tap the screen 3 times with one finger.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers together or apart to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, quickly tap the screen 3 times and hold down your finger on the third tap.\n<ul><li>Drag your finger to move around the screen</li>\n<li>Lift your finger to zoom out</li></ul>\n\nYou can\'t zoom in on the keyboard and navigation bar.</string>
<!-- Summary for the accessibility preference screen to enable screen magnification via the nav bar. [CHAR LIMIT=none] -->
<string name="accessibility_screen_magnification_navbar_summary">When magnification is turned on, use the Accessibility button at the bottom of the screen to quickly magnify.\n\n<b>To zoom</b>, tap the Accessibility button, then tap anywhere on the screen.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, tap the Accessibility button, then touch &amp; hold anywhere on the screen.\n<ul><li>Drag to move around the screen</li>\n<li>Lift finger to zoom out</li></ul>\n\nYou cant zoom in on the keyboard or navigation bar.</string>
<!-- Summary text appearing on the accessibility preference screen to enable screen magnification from the nav bar when the feature is enabled, but the accessibility button is not configured correctly for the feature to be used [CHAR LIMIT=none] -->
<string name="accessibility_screen_magnification_navbar_configuration_warning">The Accessibility button is set to <xliff:g id="service" example="Select to Speak">%1$s</xliff:g>. To use magnification, touch &amp; hold the Accessibility button, then select magnification.</string>
<!-- Title for the preference to enable the global geture that turns on accessibility. [CHAR LIMIT=35] -->
<string name="accessibility_global_gesture_preference_title">Accessibility shortcut</string>
<!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/accessibility_screen_magnification_title">
<Preference
android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
android:key="screen_magnification_gestures_preference_screen"
android:title="@string/accessibility_screen_magnification_gestures_title"/>
<Preference
android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
android:key="screen_magnification_navbar_preference_screen"
android:title="@string/accessibility_screen_magnification_navbar_title"/>
</PreferenceScreen>

View File

@@ -51,9 +51,9 @@
android:title="@string/screen_zoom_title"/>
<Preference
android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
android:key="screen_magnification_preference_screen"
android:title="@string/accessibility_screen_magnification_title" />
android:fragment="com.android.settings.accessibility.MagnificationPreferenceFragment"
android:key="magnification_preference_screen"
android:title="@string/accessibility_screen_magnification_title"/>
<Preference
android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"

View File

@@ -26,10 +26,10 @@
<Preference
android:fragment=
"com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragmentForSetupWizard"
"com.android.settings.accessibility.MagnificationPreferenceFragment"
android:key="screen_magnification_preference"
android:title="@string/accessibility_screen_magnification_title"
android:summary="@string/accessibility_screen_magnification_short_summary" />
android:summary="@string/accessibility_preference_magnification_summary" />
<Preference
android:fragment=

View File

@@ -121,6 +121,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
static final String EXTRA_SETTINGS_TITLE = "settings_title";
static final String EXTRA_COMPONENT_NAME = "component_name";
static final String EXTRA_SETTINGS_COMPONENT_NAME = "settings_component_name";
static final String EXTRA_VIDEO_RAW_RESOURCE_ID = "video_resource";
static final String EXTRA_LAUNCHED_FROM_SUW = "from_suw";
// Timeout before we update the services if packages are added/removed
// since the AccessibilityManagerService has to do that processing first
@@ -350,9 +352,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
} else if (mToggleMasterMonoPreference == preference) {
handleToggleMasterMonoPreferenceClick();
return true;
} else if (mDisplayMagnificationPreferenceScreen == preference) {
handleDisplayMagnificationPreferenceScreenClick();
return true;
}
return super.onPreferenceTreeClick(preference);
}
@@ -387,17 +386,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
mToggleMasterMonoPreference.isChecked() ? 1 : 0, UserHandle.USER_CURRENT);
}
private void handleDisplayMagnificationPreferenceScreenClick() {
Bundle extras = mDisplayMagnificationPreferenceScreen.getExtras();
extras.putString(EXTRA_TITLE, getString(
R.string.accessibility_screen_magnification_title));
extras.putCharSequence(EXTRA_SUMMARY, getActivity().getResources().getText(
R.string.accessibility_screen_magnification_summary));
extras.putBoolean(EXTRA_CHECKED, Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1);
super.onPreferenceTreeClick(mDisplayMagnificationPreferenceScreen);
}
private void initializeAllPreferences() {
for (int i = 0; i < CATEGORIES.length; i++) {
PreferenceCategory prefCategory = (PreferenceCategory) findPreference(CATEGORIES[i]);
@@ -656,8 +644,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
mCaptioningPreferenceScreen);
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
mDisplayMagnificationPreferenceScreen);
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
mDisplayDaltonizerPreferenceScreen);

View File

@@ -96,13 +96,7 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
public boolean onPreferenceTreeClick(Preference preference) {
if (mDisplayMagnificationPreference == preference) {
Bundle extras = mDisplayMagnificationPreference.getExtras();
extras.putString(AccessibilitySettings.EXTRA_TITLE,
getString(R.string.accessibility_screen_magnification_title));
extras.putCharSequence(AccessibilitySettings.EXTRA_SUMMARY,
getText(R.string.accessibility_screen_magnification_summary));
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1);
extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, true);
}
return super.onPreferenceTreeClick(preference);

View File

@@ -0,0 +1,173 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.accessibility;
import android.content.ContentResolver;
import android.content.Context;
import android.os.Bundle;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.view.View;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import java.util.Arrays;
import java.util.List;
public final class MagnificationPreferenceFragment extends SettingsPreferenceFragment implements
Indexable {
// Settings App preference keys
private static final String MAGNIFICATION_GESTURES_PREFERENCE_SCREEN_KEY =
"screen_magnification_gestures_preference_screen";
private static final String MAGNIFICATION_NAVBAR_PREFERENCE_SCREEN_KEY =
"screen_magnification_navbar_preference_screen";
private Preference mMagnificationGesturesPreference;
private Preference mMagnificationNavbarPreference;
private boolean mLaunchedFromSuw = false;
@Override
public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.accessibility_magnification_settings);
mMagnificationGesturesPreference = findPreference(
MAGNIFICATION_GESTURES_PREFERENCE_SCREEN_KEY);
mMagnificationNavbarPreference = findPreference(MAGNIFICATION_NAVBAR_PREFERENCE_SCREEN_KEY);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final Bundle args = getArguments();
if ((args != null) && args.containsKey(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW)) {
mLaunchedFromSuw = args.getBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW);
}
}
@Override
public void onResume() {
super.onResume();
getActivity().setTitle(R.string.accessibility_screen_magnification_title);
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
mMagnificationGesturesPreference);
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
mMagnificationNavbarPreference);
}
@Override
public int getMetricsCategory() {
return MetricsEvent.ACCESSIBILITY_SCREEN_MAGNIFICATION_SETTINGS;
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (mLaunchedFromSuw) {
// If invoked from SUW, redirect to fragment instrumented for Vision Settings metrics
preference.setFragment(
ToggleScreenMagnificationPreferenceFragmentForSetupWizard.class.getName());
}
if (mMagnificationGesturesPreference == preference) {
handleMagnificationGesturesPreferenceScreenClick();
super.onPreferenceTreeClick(mMagnificationGesturesPreference);
return true;
} else if (mMagnificationNavbarPreference == preference) {
handleMagnificationNavbarPreferenceScreenClick();
super.onPreferenceTreeClick(mMagnificationNavbarPreference);
return true;
}
return super.onPreferenceTreeClick(preference);
}
private void updateFeatureSummary(String prefKey, Preference pref) {
if (!mLaunchedFromSuw) {
final boolean enabled = Settings.Secure.getInt(getContentResolver(), prefKey, 0) == 1;
pref.setSummary(enabled ? R.string.accessibility_feature_state_on
: R.string.accessibility_feature_state_off);
} else {
if (Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED.equals(prefKey)) {
pref.setSummary(R.string.accessibility_screen_magnification_short_summary);
} else if (Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED.equals(
prefKey)) {
pref.setSummary(R.string.accessibility_screen_magnification_navbar_short_summary);
}
}
}
private void handleMagnificationGesturesPreferenceScreenClick() {
Bundle extras = mMagnificationGesturesPreference.getExtras();
extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY,
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED);
extras.putString(AccessibilitySettings.EXTRA_TITLE, getString(
R.string.accessibility_screen_magnification_gestures_title));
extras.putCharSequence(AccessibilitySettings.EXTRA_SUMMARY,
getActivity().getResources().getText(
R.string.accessibility_screen_magnification_summary));
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1);
extras.putInt(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID,
R.raw.accessibility_screen_magnification);
extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mLaunchedFromSuw);
}
private void handleMagnificationNavbarPreferenceScreenClick() {
Bundle extras = mMagnificationNavbarPreference.getExtras();
extras.putString(AccessibilitySettings.EXTRA_PREFERENCE_KEY,
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED);
extras.putString(AccessibilitySettings.EXTRA_TITLE, getString(
R.string.accessibility_screen_magnification_navbar_title));
extras.putCharSequence(AccessibilitySettings.EXTRA_SUMMARY,
getActivity().getResources().getText(
R.string.accessibility_screen_magnification_navbar_summary));
extras.putBoolean(AccessibilitySettings.EXTRA_CHECKED,
Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0)
== 1);
extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, mLaunchedFromSuw);
}
static int getConfigurationWarningStringResourceForSecureSettingsKey(String key,
ContentResolver resolver) {
if (Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED.equals(key)) {
if (Settings.Secure.getInt(resolver,
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 1) {
// TODO(b/34720082): Only report a config warning when nav-bar is not mapped to mag
return R.string.accessibility_screen_magnification_navbar_configuration_warning;
}
}
return -1;
}
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
boolean enabled) {
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.accessibility_magnification_settings;
return Arrays.asList(sir);
}
};
}

View File

@@ -20,29 +20,28 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
import android.os.Bundle;
import android.provider.Settings;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.preference.PreferenceViewHolder;
import android.view.Display;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.Switch;
import android.widget.VideoView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.widget.ToggleSwitch;
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
import com.android.settings.widget.SwitchBar;
public class ToggleScreenMagnificationPreferenceFragment extends ToggleFeaturePreferenceFragment {
public class ToggleScreenMagnificationPreferenceFragment extends
ToggleFeaturePreferenceFragment implements SwitchBar.OnSwitchChangeListener {
protected class VideoPreference extends Preference {
private ImageView mVideoBackgroundView;
@@ -77,10 +76,15 @@ public class ToggleScreenMagnificationPreferenceFragment extends ToggleFeaturePr
}
});
videoView.setVideoURI(Uri.parse(String.format("%s://%s/%s",
ContentResolver.SCHEME_ANDROID_RESOURCE,
getPrefContext().getPackageName(),
R.raw.accessibility_screen_magnification)));
// Resolve and set the video content
Bundle args = getArguments();
if ((args != null) && args.containsKey(
AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID)) {
videoView.setVideoURI(Uri.parse(String.format("%s://%s/%s",
ContentResolver.SCHEME_ANDROID_RESOURCE,
getPrefContext().getPackageName(),
args.getInt(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID))));
}
// Make sure video controls (e.g. for pausing) are not displayed.
videoView.setMediaController(null);
@@ -112,6 +116,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends ToggleFeaturePr
}
protected VideoPreference mVideoPreference;
protected Preference mConfigWarningPreference;
private boolean mLaunchFromSuw = false;
private boolean mInitialSetting = false;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -122,66 +130,100 @@ public class ToggleScreenMagnificationPreferenceFragment extends ToggleFeaturePr
mVideoPreference.setPersistent(false);
mVideoPreference.setLayoutResource(R.layout.magnification_video_preference);
mConfigWarningPreference = new Preference(getPrefContext());
mConfigWarningPreference.setSelectable(false);
mConfigWarningPreference.setPersistent(false);
mConfigWarningPreference.setVisible(false);
mConfigWarningPreference.setIcon(R.drawable.ic_warning_24dp);
final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
preferenceScreen.setOrderingAsAdded(false);
mVideoPreference.setOrder(0);
mSummaryPreference.setOrder(1);
mConfigWarningPreference.setOrder(2);
preferenceScreen.addPreference(mVideoPreference);
}
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
// Do nothing.
}
@Override
protected void onInstallSwitchBarToggleSwitch() {
super.onInstallSwitchBarToggleSwitch();
mToggleSwitch.setOnBeforeCheckedChangeListener(new OnBeforeCheckedChangeListener() {
@Override
public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked) {
mSwitchBar.setCheckedInternal(checked);
getArguments().putBoolean(AccessibilitySettings.EXTRA_CHECKED, checked);
onPreferenceToggled(mPreferenceKey, checked);
return false;
}
});
preferenceScreen.addPreference(mConfigWarningPreference);
}
@Override
public void onResume() {
super.onResume();
// Temporarily enable Magnification on this screen if it's disabled.
if (Settings.Secure.getInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 0) {
setMagnificationEnabled(1);
}
VideoView videoView = (VideoView) getView().findViewById(R.id.video);
if (videoView != null) {
videoView.start();
}
}
@Override
public void onPause() {
super.onPause();
if (!mToggleSwitch.isChecked()) {
setMagnificationEnabled(0);
}
}
private void setMagnificationEnabled(int enabled) {
Settings.Secure.putInt(getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, enabled);
updateConfigurationWarningIfNeeded();
}
@Override
public int getMetricsCategory() {
// TODO: Distinguish between magnification modes
return MetricsEvent.ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION;
}
@Override
public void onSwitchChanged(Switch switchView, boolean isChecked) {
onPreferenceToggled(mPreferenceKey, isChecked);
}
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
Settings.Secure.putInt(getContentResolver(), preferenceKey, enabled ? 1 : 0);
updateConfigurationWarningIfNeeded();
}
@Override
protected void onInstallSwitchBarToggleSwitch() {
super.onInstallSwitchBarToggleSwitch();
mSwitchBar.setCheckedInternal(
Settings.Secure.getInt(getContentResolver(), mPreferenceKey, 0) == 1);
mSwitchBar.addOnSwitchChangeListener(this);
}
@Override
protected void onRemoveSwitchBarToggleSwitch() {
super.onRemoveSwitchBarToggleSwitch();
mSwitchBar.removeOnSwitchChangeListener(this);
}
@Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
if (arguments == null) {
return;
}
if (arguments.containsKey(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID)) {
mVideoPreference.setVisible(true);
final int resId = arguments.getInt(
AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID);
} else {
mVideoPreference.setVisible(false);
}
if (arguments.containsKey(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW)) {
mLaunchFromSuw = arguments.getBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW);
}
if (arguments.containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
mInitialSetting = arguments.getBoolean(AccessibilitySettings.EXTRA_CHECKED);
}
}
private void updateConfigurationWarningIfNeeded() {
final int warningRes =
MagnificationPreferenceFragment
.getConfigurationWarningStringResourceForSecureSettingsKey(
mPreferenceKey, getContentResolver());
if (warningRes != -1) {
mConfigWarningPreference.setSummary(warningRes);
}
mConfigWarningPreference.setVisible(warningRes != -1);
}
private static int getScreenWidth(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();

View File

@@ -24,14 +24,6 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
public class ToggleScreenMagnificationPreferenceFragmentForSetupWizard
extends ToggleScreenMagnificationPreferenceFragment {
private boolean mToggleSwitchWasInitiallyChecked;
@Override
protected void onProcessArguments(Bundle arguments) {
super.onProcessArguments(arguments);
mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
}
@Override
public int getMetricsCategory() {
return MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION;
@@ -40,12 +32,15 @@ public class ToggleScreenMagnificationPreferenceFragmentForSetupWizard
@Override
public void onStop() {
// Log the final choice in value if it's different from the previous value.
if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
mMetricsFeatureProvider.action(getContext(),
MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION,
mToggleSwitch.isChecked());
Bundle args = getArguments();
if ((args != null) && args.containsKey(AccessibilitySettings.EXTRA_CHECKED)) {
if (mToggleSwitch.isChecked() != args.getBoolean(AccessibilitySettings.EXTRA_CHECKED)) {
// TODO: Distinguish between magnification modes
mMetricsFeatureProvider.action(getContext(),
MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION,
mToggleSwitch.isChecked());
}
}
super.onStop();
}
}

View File

@@ -30,6 +30,7 @@ import com.android.settings.R;
import com.android.settings.ScreenPinningSettings;
import com.android.settings.SecuritySettings;
import com.android.settings.accessibility.AccessibilitySettings;
import com.android.settings.accessibility.MagnificationPreferenceFragment;
import com.android.settings.accounts.UserAndAccountDashboardFragment;
import com.android.settings.applications.AdvancedAppSettings;
import com.android.settings.applications.AppAndNotificationDashboardFragment;
@@ -173,6 +174,8 @@ public final class SearchIndexableResources {
TtsEnginePreferenceFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
addIndex(LockscreenDashboardFragment.class, R.xml.security_lockscreen_settings,
R.drawable.ic_settings_security);
addIndex(MagnificationPreferenceFragment.class, NO_DATA_RES_ID,
R.drawable.ic_settings_accessibility);
}
private SearchIndexableResources() {