Maginfy Improvement
Implements the magnify new accessbility settings UI, including the setupwizard and a11y settings Bug: 146019459 Test: make RunSettingsRoboTests2 Change-Id: If11849a539c7841e2db495b63132e6d02b7285c0
This commit is contained in:
@@ -4765,7 +4765,7 @@
|
||||
<!-- Title for the accessibility preference screen to enable video captioning. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_captioning_title">Caption preferences</string>
|
||||
<!-- 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">Magnify</string>
|
||||
<!-- Title for the accessibility preference screen to edit magnification area. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_magnification_mode_title">Magnification area</string>
|
||||
<!-- Message for the accessibility preference screen to edit magnification area dialog. [CHAR LIMIT=none] -->
|
||||
@@ -4785,13 +4785,17 @@
|
||||
<!-- Summary for the accessibility preference screen to show move controller. [CHAR LIMIT=none] -->
|
||||
<string name="accessibility_magnification_window_control_switch_summary">Show a joystick-like controller to move the magnification area</string>
|
||||
<!-- Title for the accessibility preference screen to enable screen magnification settings. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_magnification_service_settings_title">Magnify settings</string>
|
||||
<string name="accessibility_magnification_service_settings_title">Magnification settings</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 shortcut</string>
|
||||
<!-- Summary for the accessibility magnification setting indicating both "Magnify with button" and "Magnify with triple-tap" are enabled [CHAR LIMIT=50] -->
|
||||
<string name="accessibility_screen_magnification_state_navbar_gesture">Magnify with shortcut & triple-tap</string>
|
||||
<!-- Title for the footer text to explain what Magnify does. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_screen_magnification_about">About Magnify</string>
|
||||
<!-- Title for the footer text to explain what option accessibility service does. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_screen_option">Options</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 -->
|
||||
|
@@ -15,47 +15,45 @@
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/vision_settings_title"
|
||||
android:persistent="true" >
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:persistent="true"
|
||||
android:title="@string/vision_settings_title">
|
||||
|
||||
<com.android.settings.accessibility.DividerAllowedBelowPreference
|
||||
android:key="vision_settings_summary"
|
||||
android:title="@string/vision_settings_description"
|
||||
android:layout="@layout/preference_multiline_title"
|
||||
android:selectable="false" />
|
||||
android:selectable="false"
|
||||
android:title="@string/vision_settings_description" />
|
||||
|
||||
<Preference
|
||||
android:fragment=
|
||||
"com.android.settings.accessibility.MagnificationPreferenceFragment"
|
||||
settings:controller="com.android.settings.accessibility.MagnificationPreferenceController"
|
||||
android:fragment="com.android.settings.accessibility.MagnificationPreferenceFragment"
|
||||
android:key="screen_magnification_preference"
|
||||
android:title="@string/accessibility_screen_magnification_title"
|
||||
android:summary="@string/accessibility_preference_magnification_summary" />
|
||||
android:summary="@string/accessibility_preference_magnification_summary"
|
||||
android:title="@string/accessibility_screen_magnification_title" />
|
||||
|
||||
<Preference
|
||||
android:fragment=
|
||||
"com.android.settings.display.FontSizePreferenceFragmentForSetupWizard"
|
||||
android:fragment="com.android.settings.display.FontSizePreferenceFragmentForSetupWizard"
|
||||
android:key="font_size_preference"
|
||||
android:title="@string/title_font_size"
|
||||
android:summary="@string/short_summary_font_size" />
|
||||
android:summary="@string/short_summary_font_size"
|
||||
android:title="@string/title_font_size" />
|
||||
|
||||
<com.android.settings.display.ScreenZoomPreference
|
||||
android:fragment="com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard"
|
||||
android:key="force_density_preference"
|
||||
android:title="@string/screen_zoom_title"
|
||||
android:summary="@string/screen_zoom_short_summary" />
|
||||
android:summary="@string/screen_zoom_short_summary"
|
||||
android:title="@string/screen_zoom_title" />
|
||||
|
||||
<Preference
|
||||
android:fragment=
|
||||
"com.android.settings.accessibility.ToggleSelectToSpeakPreferenceFragmentForSetupWizard"
|
||||
android:fragment="com.android.settings.accessibility.ToggleSelectToSpeakPreferenceFragmentForSetupWizard"
|
||||
android:key="select_to_speak_preference"
|
||||
android:summary="@string/select_to_speak_summary"
|
||||
android:persistent="true" />
|
||||
android:persistent="true"
|
||||
android:summary="@string/select_to_speak_summary" />
|
||||
|
||||
<Preference
|
||||
android:fragment=
|
||||
"com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard"
|
||||
android:fragment="com.android.settings.accessibility.ToggleScreenReaderPreferenceFragmentForSetupWizard"
|
||||
android:key="screen_reader_preference"
|
||||
android:summary="@string/talkback_summary"
|
||||
android:persistent="true" />
|
||||
android:persistent="true"
|
||||
android:summary="@string/talkback_summary" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -49,7 +49,6 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
"screen_magnification_preference";
|
||||
private static final String SCREEN_READER_PREFERENCE = "screen_reader_preference";
|
||||
private static final String SELECT_TO_SPEAK_PREFERENCE = "select_to_speak_preference";
|
||||
private static final String FONT_SIZE_PREFERENCE = "font_size_preference";
|
||||
|
||||
// Package names and service names used to identify screen reader and SelectToSpeak services.
|
||||
private static final String SCREEN_READER_PACKAGE_NAME = "com.google.android.marvin.talkback";
|
||||
@@ -175,16 +174,11 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
||||
}
|
||||
|
||||
private static void configureMagnificationPreferenceIfNeeded(Preference preference) {
|
||||
// Some devices support only a single magnification mode. In these cases, we redirect to
|
||||
// the magnification mode's UI directly, rather than showing a PreferenceScreen with a
|
||||
// single list item.
|
||||
final Context context = preference.getContext();
|
||||
if (!MagnificationPreferenceFragment.isApplicable(context.getResources())) {
|
||||
preference.setFragment(
|
||||
ToggleScreenMagnificationPreferenceFragmentForSetupWizard.class.getName());
|
||||
final Bundle extras = preference.getExtras();
|
||||
MagnificationGesturesPreferenceController
|
||||
.populateMagnificationGesturesPreferenceExtras(extras, context);
|
||||
}
|
||||
preference.setFragment(
|
||||
ToggleScreenMagnificationPreferenceFragmentForSetupWizard.class.getName());
|
||||
final Bundle extras = preference.getExtras();
|
||||
MagnificationGesturesPreferenceController
|
||||
.populateMagnificationGesturesPreferenceExtras(extras, context);
|
||||
}
|
||||
}
|
||||
|
@@ -67,14 +67,9 @@ public class MagnificationPreferenceController extends BasePreferenceController
|
||||
}
|
||||
|
||||
private void configureMagnificationPreferenceIfNeeded() {
|
||||
// Some devices support only a single magnification mode. In these cases, we redirect to
|
||||
// the magnification mode's UI directly, rather than showing a PreferenceScreen with a
|
||||
// single list item.
|
||||
if (!MagnificationPreferenceFragment.isApplicable(mContext.getResources())) {
|
||||
mPreference.setFragment(ToggleScreenMagnificationPreferenceFragment.class.getName());
|
||||
final Bundle extras = mPreference.getExtras();
|
||||
MagnificationGesturesPreferenceController
|
||||
.populateMagnificationGesturesPreferenceExtras(extras, mContext);
|
||||
}
|
||||
mPreference.setFragment(ToggleScreenMagnificationPreferenceFragment.class.getName());
|
||||
final Bundle extras = mPreference.getExtras();
|
||||
MagnificationGesturesPreferenceController
|
||||
.populateMagnificationGesturesPreferenceExtras(extras, mContext);
|
||||
}
|
||||
}
|
||||
|
@@ -38,17 +38,16 @@ import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout.LayoutParams;
|
||||
import android.widget.Switch;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.PreferredShortcutType;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -57,8 +56,7 @@ import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
ToggleFeaturePreferenceFragment implements SwitchBar.OnSwitchChangeListener,
|
||||
ShortcutPreference.OnClickListener {
|
||||
ToggleFeaturePreferenceFragment implements ShortcutPreference.OnClickListener {
|
||||
|
||||
private static final String SETTINGS_KEY = "screen_magnification_settings";
|
||||
private static final String EXTRA_SHORTCUT_TYPE = "shortcutType";
|
||||
@@ -78,6 +76,8 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
private static final TextUtils.SimpleStringSplitter sStringColonSplitter =
|
||||
new TextUtils.SimpleStringSplitter(COMPONENT_NAME_SEPARATOR);
|
||||
|
||||
protected Preference mConfigWarningPreference;
|
||||
protected VideoPreference mVideoPreference;
|
||||
protected class VideoPreference extends Preference {
|
||||
private ImageView mVideoBackgroundView;
|
||||
private OnGlobalLayoutListener mLayoutListener;
|
||||
@@ -154,25 +154,35 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
}
|
||||
}
|
||||
|
||||
protected VideoPreference mVideoPreference;
|
||||
protected Preference mConfigWarningPreference;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getActivity().setTitle(R.string.accessibility_screen_magnification_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
mVideoPreference = new VideoPreference(getPrefContext());
|
||||
mVideoPreference.setSelectable(false);
|
||||
mVideoPreference.setPersistent(false);
|
||||
mVideoPreference.setLayoutResource(R.layout.magnification_video_preference);
|
||||
|
||||
final PreferenceCategory optionCategory = new PreferenceCategory(getPrefContext());
|
||||
optionCategory.setTitle(R.string.accessibility_screen_option);
|
||||
|
||||
initShortcutPreference(savedInstanceState);
|
||||
|
||||
final Preference settingsPreference = new Preference(getPrefContext());
|
||||
final String SettingsText = getString(R.string.settings_button);
|
||||
settingsPreference.setTitle(SettingsText);
|
||||
settingsPreference.setTitle(R.string.accessibility_magnification_service_settings_title);
|
||||
settingsPreference.setKey(SETTINGS_KEY);
|
||||
settingsPreference.setFragment(MagnificationSettingsFragment.class.getName());
|
||||
settingsPreference.setPersistent(false);
|
||||
|
||||
final PreferenceCategory aboutCategory = new PreferenceCategory(getPrefContext());
|
||||
aboutCategory.setTitle(R.string.accessibility_screen_magnification_about);
|
||||
|
||||
mConfigWarningPreference = new Preference(getPrefContext());
|
||||
mConfigWarningPreference.setSelectable(false);
|
||||
mConfigWarningPreference.setPersistent(false);
|
||||
@@ -182,17 +192,15 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
|
||||
preferenceScreen.setOrderingAsAdded(false);
|
||||
mVideoPreference.setOrder(0);
|
||||
settingsPreference.setOrder(1);
|
||||
mConfigWarningPreference.setOrder(2);
|
||||
optionCategory.setOrder(1);
|
||||
aboutCategory.setOrder(2);
|
||||
preferenceScreen.addPreference(mVideoPreference);
|
||||
preferenceScreen.addPreference(settingsPreference);
|
||||
preferenceScreen.addPreference(mConfigWarningPreference);
|
||||
}
|
||||
preferenceScreen.addPreference(optionCategory);
|
||||
optionCategory.addPreference(mShortcutPreference);
|
||||
optionCategory.addPreference(settingsPreference);
|
||||
preferenceScreen.addPreference(aboutCategory);
|
||||
aboutCategory.addPreference(mConfigWarningPreference);
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
initShortcutPreference(savedInstanceState);
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@@ -377,11 +385,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||
onPreferenceToggled(mPreferenceKey, isChecked);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
|
||||
if (enabled && TextUtils.equals(
|
||||
@@ -399,22 +402,8 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
protected void onInstallSwitchBarToggleSwitch() {
|
||||
super.onInstallSwitchBarToggleSwitch();
|
||||
|
||||
mSwitchBar.setCheckedInternal(
|
||||
MagnificationPreferenceFragment.isChecked(getContentResolver(), mPreferenceKey));
|
||||
mSwitchBar.addOnSwitchChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRemoveSwitchBarToggleSwitch() {
|
||||
super.onRemoveSwitchBarToggleSwitch();
|
||||
mSwitchBar.removeOnSwitchChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateSwitchBarText(SwitchBar switchBar) {
|
||||
final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
|
||||
getString(R.string.accessibility_screen_magnification_title));
|
||||
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
||||
// Magnify is temporary-use app which uses shortcut to magnify screen, not by toggle.
|
||||
mSwitchBar.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -429,13 +418,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
} else {
|
||||
mVideoPreference.setVisible(false);
|
||||
}
|
||||
|
||||
if (arguments.containsKey(AccessibilitySettings.EXTRA_TITLE_RES)) {
|
||||
final int titleRes = arguments.getInt(AccessibilitySettings.EXTRA_TITLE_RES);
|
||||
if (titleRes > 0) {
|
||||
getActivity().setTitle(titleRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -443,15 +425,35 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
if (preference.getChecked()) {
|
||||
// TODO(b/142531156): Replace PreferredShortcutType.SOFTWARE value with dialog shortcut
|
||||
// preferred key.
|
||||
optInMagnificationValueToSettings(getContext(), PreferredShortcutType.SOFTWARE);
|
||||
|
||||
// TODO(b/142531156): ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED need to be treated
|
||||
// as special case in this file.
|
||||
optInMagnificationValueToSettings(getContext(), PreferredShortcutType.SOFTWARE);
|
||||
if ((mPreferredShortcutType & PreferredShortcutType.SOFTWARE)
|
||||
== PreferredShortcutType.SOFTWARE) {
|
||||
MagnificationPreferenceFragment.setChecked(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
|
||||
/* isChecked= */ true);
|
||||
}
|
||||
if ((mPreferredShortcutType & PreferredShortcutType.TRIPLETAP)
|
||||
== PreferredShortcutType.TRIPLETAP) {
|
||||
MagnificationPreferenceFragment.setChecked(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
|
||||
/* isChecked= */ true);
|
||||
}
|
||||
} else {
|
||||
// TODO(b/142531156): Replace PreferredShortcutType.SOFTWARE value with dialog shortcut
|
||||
// preferred key.
|
||||
optOutMagnificationValueFromSettings(getContext(), PreferredShortcutType.SOFTWARE);
|
||||
|
||||
// TODO(b/142531156): ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED need to be treated
|
||||
// as special case in this file.
|
||||
optOutMagnificationValueFromSettings(getContext(), PreferredShortcutType.SOFTWARE);
|
||||
MagnificationPreferenceFragment.setChecked(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
|
||||
/* isChecked= */ false);
|
||||
MagnificationPreferenceFragment.setChecked(getContentResolver(),
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
|
||||
/* isChecked= */ false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,10 +482,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
mShortcutPreference.setTitle(R.string.accessibility_magnification_shortcut_title);
|
||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||
mShortcutPreference.setOnClickListener(this);
|
||||
// Put the shortcutPreference before videoPreference.
|
||||
mShortcutPreference.setOrder(mVideoPreference.getOrder() - 1);
|
||||
// TODO(b/142530063): Check the new setting key to decide which summary should be shown.
|
||||
preferenceScreen.addPreference(mShortcutPreference);
|
||||
}
|
||||
|
||||
private void updateShortcutPreference() {
|
||||
|
Reference in New Issue
Block a user