Support accessibility shortcut secondary action (9/n)
Reorder layout and add title for each category block. Bug: 142530063 Bug: 142531156 Test: make RunSettingsRoboTests2 Change-Id: I0f4067aaf9c42c3ce065eebd0e75ad4153f7e9dc
This commit is contained in:
@@ -4795,8 +4795,8 @@
|
|||||||
<string name="accessibility_screen_magnification_navbar_title">Magnify with shortcut</string>
|
<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] -->
|
<!-- 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>
|
<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] -->
|
<!-- Title for the footer text to explain what accessibility service does. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_screen_magnification_about">About Magnify</string>
|
<string name="accessibility_footer_title">About <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
|
||||||
<!-- Title for the footer text to explain what option accessibility service does. [CHAR LIMIT=35] -->
|
<!-- Title for the footer text to explain what option accessibility service does. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_screen_option">Options</string>
|
<string name="accessibility_screen_option">Options</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] -->
|
||||||
|
@@ -32,11 +32,17 @@
|
|||||||
settings:allowDividerBelow="true"
|
settings:allowDividerBelow="true"
|
||||||
settings:searchable="false" />
|
settings:searchable="false" />
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="color_inversion_footer_category">
|
||||||
|
|
||||||
<com.android.settingslib.widget.FooterPreference
|
<com.android.settingslib.widget.FooterPreference
|
||||||
android:key="color_inversion_footer"
|
android:key="color_inversion_footer"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
|
settings:allowDividerAbove="false"
|
||||||
android:title="@string/accessibility_display_inversion_preference_subtitle"
|
android:title="@string/accessibility_display_inversion_preference_subtitle"
|
||||||
settings:allowDividerAbove="true"
|
|
||||||
settings:searchable="false" />
|
settings:searchable="false" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -26,14 +26,18 @@
|
|||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
android:title="@string/summary_placeholder"
|
android:title="@string/summary_placeholder"
|
||||||
|
settings:allowDividerBelow="true"
|
||||||
settings:searchable="false"/>
|
settings:searchable="false"/>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:title="@string/daltonizer_type"
|
||||||
|
android:key="daltonizer_mode_category" >
|
||||||
|
|
||||||
<com.android.settingslib.widget.RadioButtonPreference
|
<com.android.settingslib.widget.RadioButtonPreference
|
||||||
android:key="daltonizer_mode_deuteranomaly"
|
android:key="daltonizer_mode_deuteranomaly"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:summary="@string/daltonizer_mode_deuteranomaly_summary"
|
android:summary="@string/daltonizer_mode_deuteranomaly_summary"
|
||||||
android:title="@string/daltonizer_mode_deuteranomaly_title"
|
android:title="@string/daltonizer_mode_deuteranomaly_title" />
|
||||||
settings:allowDividerAbove="true" />
|
|
||||||
|
|
||||||
<com.android.settingslib.widget.RadioButtonPreference
|
<com.android.settingslib.widget.RadioButtonPreference
|
||||||
android:key="daltonizer_mode_protanomaly"
|
android:key="daltonizer_mode_protanomaly"
|
||||||
@@ -47,10 +51,18 @@
|
|||||||
android:summary="@string/daltonizer_mode_tritanomaly_summary"
|
android:summary="@string/daltonizer_mode_tritanomaly_summary"
|
||||||
android:title="@string/daltonizer_mode_tritanomaly_title" />
|
android:title="@string/daltonizer_mode_tritanomaly_title" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="daltonizer_footer_category" >
|
||||||
|
|
||||||
<com.android.settingslib.widget.FooterPreference
|
<com.android.settingslib.widget.FooterPreference
|
||||||
android:key="daltonizer_footer"
|
android:key="daltonizer_footer"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
|
settings:allowDividerAbove="false"
|
||||||
android:title="@string/accessibility_display_daltonizer_preference_subtitle"
|
android:title="@string/accessibility_display_daltonizer_preference_subtitle"
|
||||||
settings:searchable="false" />
|
settings:searchable="false" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -41,6 +41,7 @@ import android.view.View;
|
|||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
@@ -66,7 +67,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
|
|
||||||
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||||
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
||||||
private ShortcutPreference mShortcutPreference;
|
|
||||||
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
||||||
// Used to restore the edit dialog status.
|
// Used to restore the edit dialog status.
|
||||||
private int mUserShortcutTypeCache = UserShortcutType.DEFAULT;
|
private int mUserShortcutTypeCache = UserShortcutType.DEFAULT;
|
||||||
@@ -116,13 +116,13 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
// Restore the user shortcut type.
|
// Restore the user shortcut type.
|
||||||
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
|
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
|
||||||
mUserShortcutTypeCache = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE,
|
mUserShortcutTypeCache = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE,
|
||||||
UserShortcutType.DEFAULT);
|
UserShortcutType.DEFAULT);
|
||||||
}
|
}
|
||||||
initShortcutPreference();
|
initShortcutPreference();
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -372,6 +372,15 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateFooterTitle(PreferenceCategory category) {
|
||||||
|
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
|
||||||
|
final String titleText = (info == null) ? "" :
|
||||||
|
getString(R.string.accessibility_footer_title,
|
||||||
|
info.getResolveInfo().loadLabel(getPackageManager()));
|
||||||
|
category.setTitle(titleText);
|
||||||
|
}
|
||||||
|
|
||||||
private void initShortcutPreference() {
|
private void initShortcutPreference() {
|
||||||
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
mShortcutPreference = new ShortcutPreference(
|
mShortcutPreference = new ShortcutPreference(
|
||||||
@@ -380,9 +389,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
|||||||
mShortcutPreference.setKey(getShortcutPreferenceKey());
|
mShortcutPreference.setKey(getShortcutPreferenceKey());
|
||||||
mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
|
mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
|
||||||
mShortcutPreference.setOnClickListener(this);
|
mShortcutPreference.setOnClickListener(this);
|
||||||
// Put the shortcutPreference before settingsPreference.
|
|
||||||
mShortcutPreference.setOrder(-1);
|
|
||||||
preferenceScreen.addPreference(mShortcutPreference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShortcutPreference() {
|
private void updateShortcutPreference() {
|
||||||
|
@@ -36,6 +36,7 @@ import android.widget.Switch;
|
|||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -58,11 +59,11 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
|||||||
|
|
||||||
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
|
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
|
||||||
private static final String PREVIEW_PREFERENCE_KEY = "color_inversion_preview";
|
private static final String PREVIEW_PREFERENCE_KEY = "color_inversion_preview";
|
||||||
|
private static final String CATEGORY_FOOTER_KEY = "color_inversion_footer_category";
|
||||||
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||||
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
|
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
|
||||||
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
||||||
private final Handler mHandler = new Handler();
|
private final Handler mHandler = new Handler();
|
||||||
private ShortcutPreference mShortcutPreference;
|
|
||||||
private SettingsContentObserver mSettingsContentObserver;
|
private SettingsContentObserver mSettingsContentObserver;
|
||||||
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
||||||
// Used to restore the edit dialog status.
|
// Used to restore the edit dialog status.
|
||||||
@@ -111,6 +112,13 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
|||||||
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateFooterTitle(PreferenceCategory category) {
|
||||||
|
final String titleText = getString(R.string.accessibility_footer_title,
|
||||||
|
getString(R.string.accessibility_display_inversion_preference_title));
|
||||||
|
category.setTitle(titleText);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||||
Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
|
Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
|
||||||
@@ -127,13 +135,6 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
// Restore the user shortcut type.
|
|
||||||
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
|
|
||||||
mUserShortcutTypeCache = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE,
|
|
||||||
UserShortcutType.DEFAULT);
|
|
||||||
}
|
|
||||||
initShortcutPreference();
|
|
||||||
|
|
||||||
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
||||||
enableServiceFeatureKeys.add(ENABLED);
|
enableServiceFeatureKeys.add(ENABLED);
|
||||||
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
|
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
|
||||||
@@ -147,6 +148,25 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
|||||||
return super.onCreateView(inflater, container, savedInstanceState);
|
return super.onCreateView(inflater, container, savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
// Restore the user shortcut type.
|
||||||
|
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
|
||||||
|
mUserShortcutTypeCache = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE,
|
||||||
|
UserShortcutType.DEFAULT);
|
||||||
|
}
|
||||||
|
initShortcutPreference();
|
||||||
|
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
|
preferenceScreen.setOrderingAsAdded(false);
|
||||||
|
final PreferenceCategory footerCategory = preferenceScreen.findPreference(
|
||||||
|
CATEGORY_FOOTER_KEY);
|
||||||
|
updateFooterTitle(footerCategory);
|
||||||
|
footerCategory.setOrder(Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
outState.putInt(EXTRA_SHORTCUT_TYPE, mUserShortcutTypeCache);
|
outState.putInt(EXTRA_SHORTCUT_TYPE, mUserShortcutTypeCache);
|
||||||
@@ -318,9 +338,6 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
|||||||
mShortcutPreference.setKey(getShortcutPreferenceKey());
|
mShortcutPreference.setKey(getShortcutPreferenceKey());
|
||||||
mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
|
mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
|
||||||
mShortcutPreference.setOnClickListener(this);
|
mShortcutPreference.setOnClickListener(this);
|
||||||
// Put the shortcutPreference before previewPreference.
|
|
||||||
mShortcutPreference.setOrder(previewPreference.getOrder() - 1);
|
|
||||||
preferenceScreen.addPreference(mShortcutPreference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShortcutPreference() {
|
private void updateShortcutPreference() {
|
||||||
|
@@ -37,6 +37,7 @@ import android.widget.Switch;
|
|||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -47,7 +48,6 @@ import com.android.settings.widget.SwitchBar;
|
|||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
import com.android.settingslib.widget.RadioButtonPreference;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -61,13 +61,12 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
SwitchBar.OnSwitchChangeListener, ShortcutPreference.OnClickListener {
|
SwitchBar.OnSwitchChangeListener, ShortcutPreference.OnClickListener {
|
||||||
|
|
||||||
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
|
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
|
||||||
private static final String PREFERENCE_KEY = "daltonizer_mode_deuteranomaly";
|
private static final String CATEGORY_FOOTER_KEY = "daltonizer_footer_category";
|
||||||
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
||||||
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||||
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
|
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
|
||||||
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
|
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
|
||||||
private final Handler mHandler = new Handler();
|
private final Handler mHandler = new Handler();
|
||||||
private ShortcutPreference mShortcutPreference;
|
|
||||||
private SettingsContentObserver mSettingsContentObserver;
|
private SettingsContentObserver mSettingsContentObserver;
|
||||||
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
||||||
// Used to restore the edit dialog status.
|
// Used to restore the edit dialog status.
|
||||||
@@ -100,13 +99,6 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
// Restore the user shortcut type.
|
|
||||||
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
|
|
||||||
mUserShortcutTypeCache = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE,
|
|
||||||
UserShortcutType.DEFAULT);
|
|
||||||
}
|
|
||||||
initShortcutPreference();
|
|
||||||
|
|
||||||
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
||||||
enableServiceFeatureKeys.add(ENABLED);
|
enableServiceFeatureKeys.add(ENABLED);
|
||||||
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
|
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
|
||||||
@@ -120,6 +112,25 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
return super.onCreateView(inflater, container, savedInstanceState);
|
return super.onCreateView(inflater, container, savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
// Restore the user shortcut type.
|
||||||
|
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
|
||||||
|
mUserShortcutTypeCache = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE,
|
||||||
|
UserShortcutType.DEFAULT);
|
||||||
|
}
|
||||||
|
initShortcutPreference();
|
||||||
|
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
|
||||||
|
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
|
preferenceScreen.setOrderingAsAdded(false);
|
||||||
|
final PreferenceCategory footerCategory = preferenceScreen.findPreference(
|
||||||
|
CATEGORY_FOOTER_KEY);
|
||||||
|
updateFooterTitle(footerCategory);
|
||||||
|
footerCategory.setOrder(Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
outState.putInt(EXTRA_SHORTCUT_TYPE, mUserShortcutTypeCache);
|
outState.putInt(EXTRA_SHORTCUT_TYPE, mUserShortcutTypeCache);
|
||||||
@@ -330,6 +341,13 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
switchBar.setSwitchBarText(switchBarText, switchBarText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateFooterTitle(PreferenceCategory category) {
|
||||||
|
final String titleText = getString(R.string.accessibility_footer_title,
|
||||||
|
getString(R.string.accessibility_display_daltonizer_preference_title));
|
||||||
|
category.setTitle(titleText);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||||
Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
|
Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
|
||||||
@@ -370,10 +388,6 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
|
mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
|
||||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||||
mShortcutPreference.setOnClickListener(this);
|
mShortcutPreference.setOnClickListener(this);
|
||||||
final RadioButtonPreference radioButtonPreference = findPreference(PREFERENCE_KEY);
|
|
||||||
// Put the shortcutPreference before radioButtonPreference.
|
|
||||||
mShortcutPreference.setOrder(radioButtonPreference.getOrder() - 1);
|
|
||||||
preferenceScreen.addPreference(mShortcutPreference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShortcutPreferenceData() {
|
private void updateShortcutPreferenceData() {
|
||||||
|
@@ -29,6 +29,7 @@ import android.view.View;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -45,7 +46,8 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
|
|
||||||
protected SwitchBar mSwitchBar;
|
protected SwitchBar mSwitchBar;
|
||||||
protected ToggleSwitch mToggleSwitch;
|
protected ToggleSwitch mToggleSwitch;
|
||||||
|
protected ShortcutPreference mShortcutPreference;
|
||||||
|
protected Preference mSettingsPreference;
|
||||||
protected String mPreferenceKey;
|
protected String mPreferenceKey;
|
||||||
|
|
||||||
protected CharSequence mSettingsTitle;
|
protected CharSequence mSettingsTitle;
|
||||||
@@ -98,16 +100,6 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
updateSwitchBarText(mSwitchBar);
|
updateSwitchBarText(mSwitchBar);
|
||||||
|
|
||||||
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||||
|
|
||||||
// Show the "Settings" menu as if it were a preference screen
|
|
||||||
if (mSettingsTitle != null && mSettingsIntent != null) {
|
|
||||||
Preference settingsPref = new Preference(preferenceScreen.getContext());
|
|
||||||
settingsPref.setTitle(mSettingsTitle);
|
|
||||||
settingsPref.setIconSpaceReserved(true);
|
|
||||||
settingsPref.setIntent(mSettingsIntent);
|
|
||||||
preferenceScreen.addPreference(settingsPref);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mImageUri != null) {
|
if (mImageUri != null) {
|
||||||
final AnimatedImagePreference animatedImagePreference = new AnimatedImagePreference(
|
final AnimatedImagePreference animatedImagePreference = new AnimatedImagePreference(
|
||||||
preferenceScreen.getContext());
|
preferenceScreen.getContext());
|
||||||
@@ -116,27 +108,55 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
preferenceScreen.addPreference(animatedImagePreference);
|
preferenceScreen.addPreference(animatedImagePreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show the "Settings" menu as if it were a preference screen.
|
||||||
|
if (mSettingsTitle != null && mSettingsIntent != null) {
|
||||||
|
mSettingsPreference = new Preference(preferenceScreen.getContext());
|
||||||
|
mSettingsPreference.setTitle(mSettingsTitle);
|
||||||
|
mSettingsPreference.setIconSpaceReserved(true);
|
||||||
|
mSettingsPreference.setIntent(mSettingsIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSettingsPreference != null || mShortcutPreference != null) {
|
||||||
|
final PreferenceCategory category = new PreferenceCategory(getPrefContext());
|
||||||
|
category.setTitle(R.string.accessibility_screen_option);
|
||||||
|
preferenceScreen.addPreference(category);
|
||||||
|
|
||||||
|
if (mShortcutPreference != null) {
|
||||||
|
category.addPreference(mShortcutPreference);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSettingsPreference != null) {
|
||||||
|
category.addPreference(mSettingsPreference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mStaticDescription != null || mHtmlDescription != null) {
|
||||||
|
final PreferenceCategory footerCategory = new PreferenceCategory(getPrefContext());
|
||||||
|
updateFooterTitle(footerCategory);
|
||||||
|
preferenceScreen.addPreference(footerCategory);
|
||||||
|
|
||||||
if (mStaticDescription != null) {
|
if (mStaticDescription != null) {
|
||||||
final StaticTextPreference staticTextPreference = new StaticTextPreference(
|
final StaticTextPreference staticTextPreference = new StaticTextPreference(
|
||||||
preferenceScreen.getContext());
|
preferenceScreen.getContext());
|
||||||
staticTextPreference.setSelectable(/* selectable= */ false);
|
|
||||||
staticTextPreference.setSummary(mStaticDescription);
|
staticTextPreference.setSummary(mStaticDescription);
|
||||||
preferenceScreen.addPreference(staticTextPreference);
|
staticTextPreference.setSelectable(/* selectable= */ false);
|
||||||
|
footerCategory.addPreference(staticTextPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHtmlDescription != null) {
|
if (mHtmlDescription != null) {
|
||||||
// For accessibility service, avoid malicious links made by third party developer
|
// For accessibility service, avoid malicious links made by third party developer.
|
||||||
final List<String> unsupportedTagList = new ArrayList<>();
|
final List<String> unsupportedTagList = new ArrayList<>();
|
||||||
unsupportedTagList.add(ANCHOR_TAG);
|
unsupportedTagList.add(ANCHOR_TAG);
|
||||||
|
|
||||||
final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(
|
final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(
|
||||||
preferenceScreen.getContext());
|
preferenceScreen.getContext());
|
||||||
htmlTextPreference.setSelectable(/* selectable= */ false);
|
|
||||||
htmlTextPreference.setSummary(mHtmlDescription);
|
htmlTextPreference.setSummary(mHtmlDescription);
|
||||||
htmlTextPreference.setImageGetter(mImageGetter);
|
htmlTextPreference.setImageGetter(mImageGetter);
|
||||||
htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
|
htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
|
||||||
htmlTextPreference.setDividerAllowedAbove(true);
|
htmlTextPreference.setDividerAllowedAbove(true);
|
||||||
preferenceScreen.addPreference(htmlTextPreference);
|
htmlTextPreference.setSelectable(/* selectable= */ false);
|
||||||
|
footerCategory.addPreference(htmlTextPreference);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,16 +169,23 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
|
||||||
removeActionBarToggleSwitch();
|
removeActionBarToggleSwitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateSwitchBarText(SwitchBar switchBar) {
|
protected void updateSwitchBarText(SwitchBar switchBar) {
|
||||||
// Implement this to provide meaningful text in switch bar
|
// Implement this to provide meaningful text in switch bar.
|
||||||
switchBar.setSwitchBarText(R.string.accessibility_service_master_switch_title,
|
switchBar.setSwitchBarText(R.string.accessibility_service_master_switch_title,
|
||||||
R.string.accessibility_service_master_switch_title);
|
R.string.accessibility_service_master_switch_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateFooterTitle(PreferenceCategory category) {
|
||||||
|
// Implement this to provide meaningful text in the footer.
|
||||||
|
if (category != null) {
|
||||||
|
category.setTitle(getString(R.string.accessibility_footer_title,
|
||||||
|
mComponentName.getPackageName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void onPreferenceToggled(String preferenceKey, boolean enabled);
|
protected abstract void onPreferenceToggled(String preferenceKey, boolean enabled);
|
||||||
|
|
||||||
protected void onInstallSwitchBarToggleSwitch() {
|
protected void onInstallSwitchBarToggleSwitch() {
|
||||||
|
@@ -33,9 +33,7 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@@ -67,7 +65,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
private static final String SETTINGS_KEY = "screen_magnification_settings";
|
private static final String SETTINGS_KEY = "screen_magnification_settings";
|
||||||
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
||||||
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||||
private ShortcutPreference mShortcutPreference;
|
|
||||||
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
||||||
// Used to restore the edit dialog status.
|
// Used to restore the edit dialog status.
|
||||||
private int mUserShortcutTypeCache = UserShortcutType.DEFAULT;
|
private int mUserShortcutTypeCache = UserShortcutType.DEFAULT;
|
||||||
@@ -84,6 +81,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
|
|
||||||
protected Preference mConfigWarningPreference;
|
protected Preference mConfigWarningPreference;
|
||||||
protected VideoPreference mVideoPreference;
|
protected VideoPreference mVideoPreference;
|
||||||
|
|
||||||
protected class VideoPreference extends Preference {
|
protected class VideoPreference extends Preference {
|
||||||
private ImageView mVideoBackgroundView;
|
private ImageView mVideoBackgroundView;
|
||||||
private OnGlobalLayoutListener mLayoutListener;
|
private OnGlobalLayoutListener mLayoutListener;
|
||||||
@@ -167,52 +165,35 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
Bundle savedInstanceState) {
|
final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
|
||||||
|
|
||||||
mVideoPreference = new VideoPreference(getPrefContext());
|
mVideoPreference = new VideoPreference(getPrefContext());
|
||||||
mVideoPreference.setSelectable(false);
|
mVideoPreference.setSelectable(false);
|
||||||
mVideoPreference.setPersistent(false);
|
mVideoPreference.setPersistent(false);
|
||||||
mVideoPreference.setLayoutResource(R.layout.magnification_video_preference);
|
mVideoPreference.setLayoutResource(R.layout.magnification_video_preference);
|
||||||
|
preferenceScreen.addPreference(mVideoPreference);
|
||||||
|
|
||||||
final PreferenceCategory optionCategory = new PreferenceCategory(getPrefContext());
|
|
||||||
optionCategory.setTitle(R.string.accessibility_screen_option);
|
|
||||||
|
|
||||||
// Restore the user shortcut type.
|
|
||||||
if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
|
|
||||||
mUserShortcutTypeCache = savedInstanceState.getInt(EXTRA_SHORTCUT_TYPE,
|
|
||||||
UserShortcutType.DEFAULT);
|
|
||||||
}
|
|
||||||
initShortcutPreference();
|
initShortcutPreference();
|
||||||
|
mSettingsPreference = new Preference(getPrefContext());
|
||||||
|
mSettingsPreference.setTitle(R.string.accessibility_magnification_service_settings_title);
|
||||||
|
mSettingsPreference.setKey(SETTINGS_KEY);
|
||||||
|
mSettingsPreference.setFragment(MagnificationSettingsFragment.class.getName());
|
||||||
|
mSettingsPreference.setPersistent(false);
|
||||||
|
|
||||||
final Preference settingsPreference = new Preference(getPrefContext());
|
super.onViewCreated(view, savedInstanceState);
|
||||||
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 = new Preference(getPrefContext());
|
||||||
mConfigWarningPreference.setSelectable(false);
|
mConfigWarningPreference.setSelectable(false);
|
||||||
mConfigWarningPreference.setPersistent(false);
|
mConfigWarningPreference.setPersistent(false);
|
||||||
mConfigWarningPreference.setVisible(false);
|
mConfigWarningPreference.setVisible(false);
|
||||||
mConfigWarningPreference.setIcon(R.drawable.ic_warning_24dp);
|
preferenceScreen.addPreference(mConfigWarningPreference);
|
||||||
|
}
|
||||||
|
|
||||||
final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
|
@Override
|
||||||
preferenceScreen.setOrderingAsAdded(false);
|
protected void updateFooterTitle(PreferenceCategory category) {
|
||||||
mVideoPreference.setOrder(0);
|
final String titleText = getString(R.string.accessibility_footer_title,
|
||||||
optionCategory.setOrder(1);
|
getString(R.string.accessibility_screen_magnification_title));
|
||||||
aboutCategory.setOrder(2);
|
category.setTitle(titleText);
|
||||||
preferenceScreen.addPreference(mVideoPreference);
|
|
||||||
preferenceScreen.addPreference(optionCategory);
|
|
||||||
optionCategory.addPreference(mShortcutPreference);
|
|
||||||
optionCategory.addPreference(settingsPreference);
|
|
||||||
preferenceScreen.addPreference(aboutCategory);
|
|
||||||
aboutCategory.addPreference(mConfigWarningPreference);
|
|
||||||
|
|
||||||
return super.onCreateView(inflater, container, savedInstanceState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user