[Material Next] Update accessibility tool footer style
1. Implement API extends Material Next FooterBarPreference and support Accessibility API for icons 2. Apply solutions to accessibility tools and framework tools in accessibility settings page. 3. Apply DashboardFragment for Caption preference for xml parser Bug: 185973304 Test: make RunSettingsRoboTests -j52 Change-Id: I6b80bc80190d6666e3fbcd462442a9f2c0e60bba
This commit is contained in:
@@ -54,7 +54,6 @@ import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
|
||||
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
import com.android.settingslib.widget.OnMainSwitchChangeListener;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -87,7 +86,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
private static final String DRAWABLE_FOLDER = "drawable";
|
||||
protected static final String KEY_USE_SERVICE_PREFERENCE = "use_service";
|
||||
protected static final String KEY_GENERAL_CATEGORY = "general_categories";
|
||||
protected static final String KEY_INTRODUCTION_CATEGORY = "introduction_categories";
|
||||
protected static final String KEY_HTML_DESCRIPTION_PREFERENCE = "html_description";
|
||||
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||
protected static final String KEY_SAVED_USER_SHORTCUT_TYPE = "shortcut_type";
|
||||
protected static final String KEY_ANIMATED_IMAGE = "animated_image";
|
||||
@@ -383,7 +382,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
lists.add(KEY_USE_SERVICE_PREFERENCE);
|
||||
lists.add(KEY_ANIMATED_IMAGE);
|
||||
lists.add(KEY_GENERAL_CATEGORY);
|
||||
lists.add(KEY_INTRODUCTION_CATEGORY);
|
||||
lists.add(KEY_HTML_DESCRIPTION_PREFERENCE);
|
||||
return lists;
|
||||
}
|
||||
|
||||
@@ -495,44 +494,57 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
generalCategory.addPreference(mSettingsPreference);
|
||||
}
|
||||
|
||||
private void initIntroductionCategory() {
|
||||
final PreferenceCategory introductionCategory = new PreferenceCategory(getPrefContext());
|
||||
final CharSequence title =
|
||||
getString(R.string.accessibility_introduction_title, mPackageName);
|
||||
introductionCategory.setKey(KEY_INTRODUCTION_CATEGORY);
|
||||
introductionCategory.setTitle(title);
|
||||
|
||||
getPreferenceScreen().addPreference(introductionCategory);
|
||||
}
|
||||
|
||||
private void initHtmlTextPreference() {
|
||||
if (TextUtils.isEmpty(mHtmlDescription)) {
|
||||
return;
|
||||
}
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
final CharSequence htmlDescription = Html.fromHtml(mHtmlDescription.toString(),
|
||||
Html.FROM_HTML_MODE_COMPACT, mImageGetter, /* tagHandler= */ null);
|
||||
final String iconContentDescription =
|
||||
getString(R.string.accessibility_introduction_title, mPackageName);
|
||||
|
||||
initIntroductionCategory();
|
||||
|
||||
final HtmlTextPreference htmlTextPreference = new HtmlTextPreference(getPrefContext());
|
||||
htmlTextPreference.setSummary(mHtmlDescription);
|
||||
htmlTextPreference.setImageGetter(mImageGetter);
|
||||
htmlTextPreference.setSelectable(false);
|
||||
|
||||
final PreferenceCategory introductionCategory = findPreference(KEY_INTRODUCTION_CATEGORY);
|
||||
introductionCategory.addPreference(htmlTextPreference);
|
||||
final AccessibilityFooterPreference htmlFooterPreference =
|
||||
new AccessibilityFooterPreference(screen.getContext());
|
||||
htmlFooterPreference.setKey(KEY_HTML_DESCRIPTION_PREFERENCE);
|
||||
htmlFooterPreference.setSummary(htmlDescription);
|
||||
htmlFooterPreference.setLinkEnabled(false);
|
||||
htmlFooterPreference.setIconContentDescription(iconContentDescription);
|
||||
screen.addPreference(htmlFooterPreference);
|
||||
}
|
||||
|
||||
private void initFooterPreference() {
|
||||
if (!TextUtils.isEmpty(mDescription)) {
|
||||
createFooterPreference(mDescription);
|
||||
createFooterPreference(getPreferenceScreen(), mDescription,
|
||||
getString(R.string.accessibility_introduction_title, mPackageName));
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(mHtmlDescription) && TextUtils.isEmpty(mDescription)) {
|
||||
final CharSequence defaultDescription =
|
||||
getText(R.string.accessibility_service_default_description);
|
||||
createFooterPreference(defaultDescription);
|
||||
createFooterPreference(getPreferenceScreen(), defaultDescription,
|
||||
getString(R.string.accessibility_introduction_title, mPackageName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates {@link AccessibilityFooterPreference} and append into {@link PreferenceScreen}
|
||||
*
|
||||
* @param screen The preference screen to add the footer preference
|
||||
* @param summary The summary of the preference summary.
|
||||
* @param iconContentDescription The content description of icon in the footer.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
void createFooterPreference(PreferenceScreen screen, CharSequence summary,
|
||||
String iconContentDescription) {
|
||||
final AccessibilityFooterPreference footerPreference =
|
||||
new AccessibilityFooterPreference(screen.getContext());
|
||||
footerPreference.setSummary(summary);
|
||||
footerPreference.setIconContentDescription(iconContentDescription);
|
||||
screen.addPreference(footerPreference);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void setupEditShortcutDialog(Dialog dialog) {
|
||||
final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
|
||||
@@ -707,12 +719,6 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
showDialog(DialogEnums.EDIT_SHORTCUT);
|
||||
}
|
||||
|
||||
private void createFooterPreference(CharSequence title) {
|
||||
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
preferenceScreen.addPreference(new FooterPreference.Builder(getActivity()).setTitle(
|
||||
title).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Setups a configurable default if the setting has never been set.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user