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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user