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>
|
||||
<!-- 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 accessibility service does. [CHAR LIMIT=35] -->
|
||||
<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] -->
|
||||
<string name="accessibility_screen_option">Options</string>
|
||||
<!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->
|
||||
|
@@ -32,11 +32,17 @@
|
||||
settings:allowDividerBelow="true"
|
||||
settings:searchable="false" />
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:key="color_inversion_footer"
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
android:title="@string/accessibility_display_inversion_preference_subtitle"
|
||||
settings:allowDividerAbove="true"
|
||||
settings:searchable="false" />
|
||||
<PreferenceCategory
|
||||
android:key="color_inversion_footer_category">
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:key="color_inversion_footer"
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
settings:allowDividerAbove="false"
|
||||
android:title="@string/accessibility_display_inversion_preference_subtitle"
|
||||
settings:searchable="false" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -26,31 +26,43 @@
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
android:title="@string/summary_placeholder"
|
||||
settings:allowDividerBelow="true"
|
||||
settings:searchable="false"/>
|
||||
|
||||
<com.android.settingslib.widget.RadioButtonPreference
|
||||
android:key="daltonizer_mode_deuteranomaly"
|
||||
android:persistent="false"
|
||||
android:summary="@string/daltonizer_mode_deuteranomaly_summary"
|
||||
android:title="@string/daltonizer_mode_deuteranomaly_title"
|
||||
settings:allowDividerAbove="true" />
|
||||
<PreferenceCategory
|
||||
android:title="@string/daltonizer_type"
|
||||
android:key="daltonizer_mode_category" >
|
||||
|
||||
<com.android.settingslib.widget.RadioButtonPreference
|
||||
android:key="daltonizer_mode_protanomaly"
|
||||
android:persistent="false"
|
||||
android:summary="@string/daltonizer_mode_protanomaly_summary"
|
||||
android:title="@string/daltonizer_mode_protanomaly_title" />
|
||||
<com.android.settingslib.widget.RadioButtonPreference
|
||||
android:key="daltonizer_mode_deuteranomaly"
|
||||
android:persistent="false"
|
||||
android:summary="@string/daltonizer_mode_deuteranomaly_summary"
|
||||
android:title="@string/daltonizer_mode_deuteranomaly_title" />
|
||||
|
||||
<com.android.settingslib.widget.RadioButtonPreference
|
||||
android:key="daltonizer_mode_tritanomaly"
|
||||
android:persistent="false"
|
||||
android:summary="@string/daltonizer_mode_tritanomaly_summary"
|
||||
android:title="@string/daltonizer_mode_tritanomaly_title" />
|
||||
<com.android.settingslib.widget.RadioButtonPreference
|
||||
android:key="daltonizer_mode_protanomaly"
|
||||
android:persistent="false"
|
||||
android:summary="@string/daltonizer_mode_protanomaly_summary"
|
||||
android:title="@string/daltonizer_mode_protanomaly_title" />
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:key="daltonizer_footer"
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
android:title="@string/accessibility_display_daltonizer_preference_subtitle"
|
||||
settings:searchable="false" />
|
||||
<com.android.settingslib.widget.RadioButtonPreference
|
||||
android:key="daltonizer_mode_tritanomaly"
|
||||
android:persistent="false"
|
||||
android:summary="@string/daltonizer_mode_tritanomaly_summary"
|
||||
android:title="@string/daltonizer_mode_tritanomaly_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="daltonizer_footer_category" >
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:key="daltonizer_footer"
|
||||
android:persistent="false"
|
||||
android:selectable="false"
|
||||
settings:allowDividerAbove="false"
|
||||
android:title="@string/accessibility_display_daltonizer_preference_subtitle"
|
||||
settings:searchable="false" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
@@ -41,6 +41,7 @@ import android.view.View;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
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 EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
||||
private ShortcutPreference mShortcutPreference;
|
||||
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
||||
// Used to restore the edit dialog status.
|
||||
private int mUserShortcutTypeCache = UserShortcutType.DEFAULT;
|
||||
@@ -116,13 +116,13 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, 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);
|
||||
}
|
||||
|
||||
@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() {
|
||||
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
mShortcutPreference = new ShortcutPreference(
|
||||
@@ -380,9 +389,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
|
||||
mShortcutPreference.setKey(getShortcutPreferenceKey());
|
||||
mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
|
||||
mShortcutPreference.setOnClickListener(this);
|
||||
// Put the shortcutPreference before settingsPreference.
|
||||
mShortcutPreference.setOrder(-1);
|
||||
preferenceScreen.addPreference(mShortcutPreference);
|
||||
}
|
||||
|
||||
private void updateShortcutPreference() {
|
||||
|
@@ -36,6 +36,7 @@ import android.widget.Switch;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
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 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 int DIALOG_ID_EDIT_SHORTCUT = 1;
|
||||
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
||||
private final Handler mHandler = new Handler();
|
||||
private ShortcutPreference mShortcutPreference;
|
||||
private SettingsContentObserver mSettingsContentObserver;
|
||||
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
||||
// Used to restore the edit dialog status.
|
||||
@@ -111,6 +112,13 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
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
|
||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||
Settings.Secure.putInt(getContentResolver(), ENABLED, isChecked ? State.ON : State.OFF);
|
||||
@@ -127,13 +135,6 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
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);
|
||||
enableServiceFeatureKeys.add(ENABLED);
|
||||
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
|
||||
@@ -147,6 +148,25 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
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
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putInt(EXTRA_SHORTCUT_TYPE, mUserShortcutTypeCache);
|
||||
@@ -318,9 +338,6 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
mShortcutPreference.setKey(getShortcutPreferenceKey());
|
||||
mShortcutPreference.setTitle(R.string.accessibility_shortcut_title);
|
||||
mShortcutPreference.setOnClickListener(this);
|
||||
// Put the shortcutPreference before previewPreference.
|
||||
mShortcutPreference.setOrder(previewPreference.getOrder() - 1);
|
||||
preferenceScreen.addPreference(mShortcutPreference);
|
||||
}
|
||||
|
||||
private void updateShortcutPreference() {
|
||||
|
@@ -37,6 +37,7 @@ import android.widget.Switch;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
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.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.widget.RadioButtonPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -61,13 +61,12 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
||||
SwitchBar.OnSwitchChangeListener, ShortcutPreference.OnClickListener {
|
||||
|
||||
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 KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
|
||||
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
|
||||
private final Handler mHandler = new Handler();
|
||||
private ShortcutPreference mShortcutPreference;
|
||||
private SettingsContentObserver mSettingsContentObserver;
|
||||
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
||||
// Used to restore the edit dialog status.
|
||||
@@ -100,13 +99,6 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
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);
|
||||
enableServiceFeatureKeys.add(ENABLED);
|
||||
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
|
||||
@@ -120,6 +112,25 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
||||
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
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
outState.putInt(EXTRA_SHORTCUT_TYPE, mUserShortcutTypeCache);
|
||||
@@ -330,6 +341,13 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
||||
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
|
||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||
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.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||
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() {
|
||||
|
@@ -29,6 +29,7 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -45,7 +46,8 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
|
||||
protected SwitchBar mSwitchBar;
|
||||
protected ToggleSwitch mToggleSwitch;
|
||||
|
||||
protected ShortcutPreference mShortcutPreference;
|
||||
protected Preference mSettingsPreference;
|
||||
protected String mPreferenceKey;
|
||||
|
||||
protected CharSequence mSettingsTitle;
|
||||
@@ -98,16 +100,6 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
updateSwitchBarText(mSwitchBar);
|
||||
|
||||
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) {
|
||||
final AnimatedImagePreference animatedImagePreference = new AnimatedImagePreference(
|
||||
preferenceScreen.getContext());
|
||||
@@ -116,27 +108,55 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
preferenceScreen.addPreference(animatedImagePreference);
|
||||
}
|
||||
|
||||
if (mStaticDescription != null) {
|
||||
final StaticTextPreference staticTextPreference = new StaticTextPreference(
|
||||
preferenceScreen.getContext());
|
||||
staticTextPreference.setSelectable(/* selectable= */ false);
|
||||
staticTextPreference.setSummary(mStaticDescription);
|
||||
preferenceScreen.addPreference(staticTextPreference);
|
||||
// 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 (mHtmlDescription != null) {
|
||||
// For accessibility service, avoid malicious links made by third party developer
|
||||
final List<String> unsupportedTagList = new ArrayList<>();
|
||||
unsupportedTagList.add(ANCHOR_TAG);
|
||||
if (mSettingsPreference != null || mShortcutPreference != null) {
|
||||
final PreferenceCategory category = new PreferenceCategory(getPrefContext());
|
||||
category.setTitle(R.string.accessibility_screen_option);
|
||||
preferenceScreen.addPreference(category);
|
||||
|
||||
final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(
|
||||
preferenceScreen.getContext());
|
||||
htmlTextPreference.setSelectable(/* selectable= */ false);
|
||||
htmlTextPreference.setSummary(mHtmlDescription);
|
||||
htmlTextPreference.setImageGetter(mImageGetter);
|
||||
htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
|
||||
htmlTextPreference.setDividerAllowedAbove(true);
|
||||
preferenceScreen.addPreference(htmlTextPreference);
|
||||
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) {
|
||||
final StaticTextPreference staticTextPreference = new StaticTextPreference(
|
||||
preferenceScreen.getContext());
|
||||
staticTextPreference.setSummary(mStaticDescription);
|
||||
staticTextPreference.setSelectable(/* selectable= */ false);
|
||||
footerCategory.addPreference(staticTextPreference);
|
||||
}
|
||||
|
||||
if (mHtmlDescription != null) {
|
||||
// For accessibility service, avoid malicious links made by third party developer.
|
||||
final List<String> unsupportedTagList = new ArrayList<>();
|
||||
unsupportedTagList.add(ANCHOR_TAG);
|
||||
|
||||
final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(
|
||||
preferenceScreen.getContext());
|
||||
htmlTextPreference.setSummary(mHtmlDescription);
|
||||
htmlTextPreference.setImageGetter(mImageGetter);
|
||||
htmlTextPreference.setUnsupportedTagList(unsupportedTagList);
|
||||
htmlTextPreference.setDividerAllowedAbove(true);
|
||||
htmlTextPreference.setSelectable(/* selectable= */ false);
|
||||
footerCategory.addPreference(htmlTextPreference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,16 +169,23 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
||||
removeActionBarToggleSwitch();
|
||||
}
|
||||
|
||||
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,
|
||||
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 void onInstallSwitchBarToggleSwitch() {
|
||||
|
@@ -33,9 +33,7 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||
import android.widget.CheckBox;
|
||||
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 EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
||||
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||
private ShortcutPreference mShortcutPreference;
|
||||
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
||||
// Used to restore the edit dialog status.
|
||||
private int mUserShortcutTypeCache = UserShortcutType.DEFAULT;
|
||||
@@ -84,6 +81,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
|
||||
protected Preference mConfigWarningPreference;
|
||||
protected VideoPreference mVideoPreference;
|
||||
|
||||
protected class VideoPreference extends Preference {
|
||||
private ImageView mVideoBackgroundView;
|
||||
private OnGlobalLayoutListener mLayoutListener;
|
||||
@@ -167,52 +165,35 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
|
||||
mVideoPreference = new VideoPreference(getPrefContext());
|
||||
mVideoPreference.setSelectable(false);
|
||||
mVideoPreference.setPersistent(false);
|
||||
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();
|
||||
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());
|
||||
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);
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
mConfigWarningPreference = new Preference(getPrefContext());
|
||||
mConfigWarningPreference.setSelectable(false);
|
||||
mConfigWarningPreference.setPersistent(false);
|
||||
mConfigWarningPreference.setVisible(false);
|
||||
mConfigWarningPreference.setIcon(R.drawable.ic_warning_24dp);
|
||||
preferenceScreen.addPreference(mConfigWarningPreference);
|
||||
}
|
||||
|
||||
final PreferenceScreen preferenceScreen = getPreferenceManager().getPreferenceScreen();
|
||||
preferenceScreen.setOrderingAsAdded(false);
|
||||
mVideoPreference.setOrder(0);
|
||||
optionCategory.setOrder(1);
|
||||
aboutCategory.setOrder(2);
|
||||
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
|
||||
protected void updateFooterTitle(PreferenceCategory category) {
|
||||
final String titleText = getString(R.string.accessibility_footer_title,
|
||||
getString(R.string.accessibility_screen_magnification_title));
|
||||
category.setTitle(titleText);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user