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:
@@ -4067,12 +4067,22 @@
|
|||||||
<string name="accessibility_captioning_title">Captions</string>
|
<string name="accessibility_captioning_title">Captions</string>
|
||||||
<!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
|
<!-- Title for the accessibility preference screen to enable screen magnification. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_screen_magnification_title">Magnification</string>
|
<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] -->
|
<!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->
|
||||||
<string name="accessibility_preference_magnification_summary">Zoom in on screen</string>
|
<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 -->
|
<!-- 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>
|
<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>
|
<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 & 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 can’t 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 & hold the Accessibility button, then select magnification.</string>
|
||||||
<!-- Title for the preference to enable the global geture that turns on accessibility. [CHAR LIMIT=35] -->
|
<!-- 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>
|
<string name="accessibility_global_gesture_preference_title">Accessibility shortcut</string>
|
||||||
<!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->
|
<!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->
|
||||||
|
26
res/xml/accessibility_magnification_settings.xml
Normal file
26
res/xml/accessibility_magnification_settings.xml
Normal 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>
|
@@ -51,9 +51,9 @@
|
|||||||
android:title="@string/screen_zoom_title"/>
|
android:title="@string/screen_zoom_title"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:fragment="com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment"
|
android:fragment="com.android.settings.accessibility.MagnificationPreferenceFragment"
|
||||||
android:key="screen_magnification_preference_screen"
|
android:key="magnification_preference_screen"
|
||||||
android:title="@string/accessibility_screen_magnification_title" />
|
android:title="@string/accessibility_screen_magnification_title"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
|
android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
|
||||||
|
@@ -26,10 +26,10 @@
|
|||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:fragment=
|
android:fragment=
|
||||||
"com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragmentForSetupWizard"
|
"com.android.settings.accessibility.MagnificationPreferenceFragment"
|
||||||
android:key="screen_magnification_preference"
|
android:key="screen_magnification_preference"
|
||||||
android:title="@string/accessibility_screen_magnification_title"
|
android:title="@string/accessibility_screen_magnification_title"
|
||||||
android:summary="@string/accessibility_screen_magnification_short_summary" />
|
android:summary="@string/accessibility_preference_magnification_summary" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:fragment=
|
android:fragment=
|
||||||
|
@@ -121,6 +121,8 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
static final String EXTRA_SETTINGS_TITLE = "settings_title";
|
static final String EXTRA_SETTINGS_TITLE = "settings_title";
|
||||||
static final String EXTRA_COMPONENT_NAME = "component_name";
|
static final String EXTRA_COMPONENT_NAME = "component_name";
|
||||||
static final String EXTRA_SETTINGS_COMPONENT_NAME = "settings_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
|
// Timeout before we update the services if packages are added/removed
|
||||||
// since the AccessibilityManagerService has to do that processing first
|
// since the AccessibilityManagerService has to do that processing first
|
||||||
@@ -350,9 +352,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
} else if (mToggleMasterMonoPreference == preference) {
|
} else if (mToggleMasterMonoPreference == preference) {
|
||||||
handleToggleMasterMonoPreferenceClick();
|
handleToggleMasterMonoPreferenceClick();
|
||||||
return true;
|
return true;
|
||||||
} else if (mDisplayMagnificationPreferenceScreen == preference) {
|
|
||||||
handleDisplayMagnificationPreferenceScreenClick();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return super.onPreferenceTreeClick(preference);
|
return super.onPreferenceTreeClick(preference);
|
||||||
}
|
}
|
||||||
@@ -387,17 +386,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
mToggleMasterMonoPreference.isChecked() ? 1 : 0, UserHandle.USER_CURRENT);
|
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() {
|
private void initializeAllPreferences() {
|
||||||
for (int i = 0; i < CATEGORIES.length; i++) {
|
for (int i = 0; i < CATEGORIES.length; i++) {
|
||||||
PreferenceCategory prefCategory = (PreferenceCategory) findPreference(CATEGORIES[i]);
|
PreferenceCategory prefCategory = (PreferenceCategory) findPreference(CATEGORIES[i]);
|
||||||
@@ -656,8 +644,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
|
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED,
|
||||||
mCaptioningPreferenceScreen);
|
mCaptioningPreferenceScreen);
|
||||||
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
|
|
||||||
mDisplayMagnificationPreferenceScreen);
|
|
||||||
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
|
updateFeatureSummary(Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED,
|
||||||
mDisplayDaltonizerPreferenceScreen);
|
mDisplayDaltonizerPreferenceScreen);
|
||||||
|
|
||||||
|
@@ -96,13 +96,7 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
|||||||
public boolean onPreferenceTreeClick(Preference preference) {
|
public boolean onPreferenceTreeClick(Preference preference) {
|
||||||
if (mDisplayMagnificationPreference == preference) {
|
if (mDisplayMagnificationPreference == preference) {
|
||||||
Bundle extras = mDisplayMagnificationPreference.getExtras();
|
Bundle extras = mDisplayMagnificationPreference.getExtras();
|
||||||
extras.putString(AccessibilitySettings.EXTRA_TITLE,
|
extras.putBoolean(AccessibilitySettings.EXTRA_LAUNCHED_FROM_SUW, true);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onPreferenceTreeClick(preference);
|
return super.onPreferenceTreeClick(preference);
|
||||||
|
@@ -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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@@ -20,29 +20,28 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.provider.Settings;
|
|
||||||
|
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
import android.media.MediaPlayer.OnPreparedListener;
|
import android.media.MediaPlayer.OnPreparedListener;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.MediaController;
|
|
||||||
import android.widget.RelativeLayout.LayoutParams;
|
import android.widget.RelativeLayout.LayoutParams;
|
||||||
|
import android.widget.Switch;
|
||||||
import android.widget.VideoView;
|
import android.widget.VideoView;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.widget.ToggleSwitch;
|
import com.android.settings.widget.SwitchBar;
|
||||||
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
|
|
||||||
|
|
||||||
public class ToggleScreenMagnificationPreferenceFragment extends ToggleFeaturePreferenceFragment {
|
public class ToggleScreenMagnificationPreferenceFragment extends
|
||||||
|
ToggleFeaturePreferenceFragment implements SwitchBar.OnSwitchChangeListener {
|
||||||
|
|
||||||
protected class VideoPreference extends Preference {
|
protected class VideoPreference extends Preference {
|
||||||
private ImageView mVideoBackgroundView;
|
private ImageView mVideoBackgroundView;
|
||||||
@@ -77,10 +76,15 @@ public class ToggleScreenMagnificationPreferenceFragment extends ToggleFeaturePr
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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",
|
videoView.setVideoURI(Uri.parse(String.format("%s://%s/%s",
|
||||||
ContentResolver.SCHEME_ANDROID_RESOURCE,
|
ContentResolver.SCHEME_ANDROID_RESOURCE,
|
||||||
getPrefContext().getPackageName(),
|
getPrefContext().getPackageName(),
|
||||||
R.raw.accessibility_screen_magnification)));
|
args.getInt(AccessibilitySettings.EXTRA_VIDEO_RAW_RESOURCE_ID))));
|
||||||
|
}
|
||||||
// Make sure video controls (e.g. for pausing) are not displayed.
|
// Make sure video controls (e.g. for pausing) are not displayed.
|
||||||
videoView.setMediaController(null);
|
videoView.setMediaController(null);
|
||||||
|
|
||||||
@@ -112,6 +116,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends ToggleFeaturePr
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected VideoPreference mVideoPreference;
|
protected VideoPreference mVideoPreference;
|
||||||
|
protected Preference mConfigWarningPreference;
|
||||||
|
|
||||||
|
private boolean mLaunchFromSuw = false;
|
||||||
|
private boolean mInitialSetting = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -122,66 +130,100 @@ public class ToggleScreenMagnificationPreferenceFragment extends ToggleFeaturePr
|
|||||||
mVideoPreference.setPersistent(false);
|
mVideoPreference.setPersistent(false);
|
||||||
mVideoPreference.setLayoutResource(R.layout.magnification_video_preference);
|
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();
|
final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
|
||||||
preferenceScreen.setOrderingAsAdded(false);
|
preferenceScreen.setOrderingAsAdded(false);
|
||||||
mVideoPreference.setOrder(0);
|
mVideoPreference.setOrder(0);
|
||||||
mSummaryPreference.setOrder(1);
|
mSummaryPreference.setOrder(1);
|
||||||
|
mConfigWarningPreference.setOrder(2);
|
||||||
preferenceScreen.addPreference(mVideoPreference);
|
preferenceScreen.addPreference(mVideoPreference);
|
||||||
}
|
preferenceScreen.addPreference(mConfigWarningPreference);
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.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);
|
VideoView videoView = (VideoView) getView().findViewById(R.id.video);
|
||||||
if (videoView != null) {
|
if (videoView != null) {
|
||||||
videoView.start();
|
videoView.start();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
updateConfigurationWarningIfNeeded();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
|
// TODO: Distinguish between magnification modes
|
||||||
return MetricsEvent.ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION;
|
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) {
|
private static int getScreenWidth(Context context) {
|
||||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||||
Display display = wm.getDefaultDisplay();
|
Display display = wm.getDefaultDisplay();
|
||||||
|
@@ -24,14 +24,6 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
|||||||
public class ToggleScreenMagnificationPreferenceFragmentForSetupWizard
|
public class ToggleScreenMagnificationPreferenceFragmentForSetupWizard
|
||||||
extends ToggleScreenMagnificationPreferenceFragment {
|
extends ToggleScreenMagnificationPreferenceFragment {
|
||||||
|
|
||||||
private boolean mToggleSwitchWasInitiallyChecked;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onProcessArguments(Bundle arguments) {
|
|
||||||
super.onProcessArguments(arguments);
|
|
||||||
mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION;
|
return MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION;
|
||||||
@@ -40,12 +32,15 @@ public class ToggleScreenMagnificationPreferenceFragmentForSetupWizard
|
|||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
// Log the final choice in value if it's different from the previous value.
|
// Log the final choice in value if it's different from the previous value.
|
||||||
if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
|
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(),
|
mMetricsFeatureProvider.action(getContext(),
|
||||||
MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION,
|
MetricsEvent.SUW_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFICATION,
|
||||||
mToggleSwitch.isChecked());
|
mToggleSwitch.isChecked());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.ScreenPinningSettings;
|
import com.android.settings.ScreenPinningSettings;
|
||||||
import com.android.settings.SecuritySettings;
|
import com.android.settings.SecuritySettings;
|
||||||
import com.android.settings.accessibility.AccessibilitySettings;
|
import com.android.settings.accessibility.AccessibilitySettings;
|
||||||
|
import com.android.settings.accessibility.MagnificationPreferenceFragment;
|
||||||
import com.android.settings.accounts.UserAndAccountDashboardFragment;
|
import com.android.settings.accounts.UserAndAccountDashboardFragment;
|
||||||
import com.android.settings.applications.AdvancedAppSettings;
|
import com.android.settings.applications.AdvancedAppSettings;
|
||||||
import com.android.settings.applications.AppAndNotificationDashboardFragment;
|
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);
|
TtsEnginePreferenceFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
|
||||||
addIndex(LockscreenDashboardFragment.class, R.xml.security_lockscreen_settings,
|
addIndex(LockscreenDashboardFragment.class, R.xml.security_lockscreen_settings,
|
||||||
R.drawable.ic_settings_security);
|
R.drawable.ic_settings_security);
|
||||||
|
addIndex(MagnificationPreferenceFragment.class, NO_DATA_RES_ID,
|
||||||
|
R.drawable.ic_settings_accessibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SearchIndexableResources() {
|
private SearchIndexableResources() {
|
||||||
|
Reference in New Issue
Block a user