[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:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* Preference controller for accessibility button footer.
|
||||
*/
|
||||
public class AccessibilityButtonFooterPreferenceController extends
|
||||
AccessibilityFooterPreferenceController {
|
||||
|
||||
public AccessibilityButtonFooterPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLabelName() {
|
||||
return mContext.getString(R.string.accessibility_button_title);
|
||||
}
|
||||
}
|
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
@@ -35,11 +34,6 @@ public class AccessibilityButtonFragment extends DashboardFragment {
|
||||
return R.xml.accessibility_button_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* Preference controller for accessibility control timeout footer.
|
||||
*/
|
||||
public class AccessibilityControlTimeoutFooterPreferenceController extends
|
||||
AccessibilityFooterPreferenceController {
|
||||
|
||||
public AccessibilityControlTimeoutFooterPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLabelName() {
|
||||
return mContext.getString(R.string.accessibility_setting_item_control_timeout_title);
|
||||
}
|
||||
}
|
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settingslib.R;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
/**
|
||||
* A custom preference acting as footer of a page. It has a field for icon and text. It is added
|
||||
* to screen as the last preference and groups of icon and text content in accessibility-focusable
|
||||
* {@link android.view.accessibility.AccessibilityNodeInfo} for TalkBack to use.
|
||||
*/
|
||||
public final class AccessibilityFooterPreference extends FooterPreference {
|
||||
|
||||
private CharSequence mIconContentDescription;
|
||||
private boolean mLinkEnabled;
|
||||
|
||||
public AccessibilityFooterPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public AccessibilityFooterPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
|
||||
final TextView title = holder.itemView.findViewById(android.R.id.title);
|
||||
if (mLinkEnabled) {
|
||||
// When a TextView has a movement method, it will set the view to clickable. This makes
|
||||
// View.onTouchEvent always return true and consumes the touch event, essentially
|
||||
// nullifying any return values of MovementMethod.onTouchEvent.
|
||||
// To still allow propagating touch events to the parent when this view doesn't have
|
||||
// links, we only set the movement method here if the text contains links.
|
||||
title.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
} else {
|
||||
title.setMovementMethod(/* movement= */ null);
|
||||
}
|
||||
|
||||
final LinearLayout infoFrame = holder.itemView.findViewById(R.id.icon_frame);
|
||||
if (!TextUtils.isEmpty(mIconContentDescription)) {
|
||||
// Groups related content.
|
||||
infoFrame.setContentDescription(mIconContentDescription);
|
||||
title.setFocusable(false);
|
||||
} else {
|
||||
infoFrame.setContentDescription(null);
|
||||
title.setFocusable(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content description of the icon.
|
||||
*/
|
||||
public void setIconContentDescription(CharSequence iconContentDescription) {
|
||||
if (!TextUtils.equals(iconContentDescription, mIconContentDescription)) {
|
||||
mIconContentDescription = iconContentDescription;
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content description of the icon.
|
||||
*/
|
||||
public CharSequence getIconContentDescription() {
|
||||
return mIconContentDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the title field supports movement method.
|
||||
*/
|
||||
public void setLinkEnabled(boolean enabled) {
|
||||
if (mLinkEnabled != enabled) {
|
||||
mLinkEnabled = enabled;
|
||||
notifyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the title field supports movement method.
|
||||
*/
|
||||
public boolean isLinkEnabled() {
|
||||
return mLinkEnabled;
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
/**
|
||||
* Base class for accessibility preference footer.
|
||||
*/
|
||||
public abstract class AccessibilityFooterPreferenceController extends BasePreferenceController {
|
||||
|
||||
public AccessibilityFooterPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
|
||||
final AccessibilityFooterPreference footerPreference =
|
||||
screen.findPreference(getPreferenceKey());
|
||||
updateFooterPreferences(footerPreference);
|
||||
}
|
||||
|
||||
|
||||
/** Returns the accessibility feature name. */
|
||||
protected abstract String getLabelName();
|
||||
|
||||
private void updateFooterPreferences(AccessibilityFooterPreference footerPreference) {
|
||||
final String iconContentDescription = mContext.getString(
|
||||
R.string.accessibility_introduction_title, getLabelName());
|
||||
footerPreference.setIconContentDescription(iconContentDescription);
|
||||
}
|
||||
}
|
@@ -33,8 +33,8 @@ import androidx.preference.PreferenceCategory;
|
||||
|
||||
import com.android.internal.widget.SubtitleView;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.accessibility.ListDialogPreference.OnValueChangedListener;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
@@ -46,8 +46,10 @@ import java.util.Locale;
|
||||
|
||||
/** Settings fragment containing font style of captioning properties. */
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class CaptionAppearanceFragment extends SettingsPreferenceFragment
|
||||
public class CaptionAppearanceFragment extends DashboardFragment
|
||||
implements OnPreferenceChangeListener, OnValueChangedListener {
|
||||
|
||||
private static final String TAG = "CaptionAppearanceFragment";
|
||||
private static final String PREF_CAPTION_PREVIEW = "caption_preview";
|
||||
private static final String PREF_BACKGROUND_COLOR = "captioning_background_color";
|
||||
private static final String PREF_BACKGROUND_OPACITY = "captioning_background_opacity";
|
||||
@@ -107,12 +109,11 @@ public class CaptionAppearanceFragment extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
||||
|
||||
mCaptioningManager = (CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE);
|
||||
|
||||
addPreferencesFromResource(R.xml.captioning_appearance);
|
||||
initializeAllPreferences();
|
||||
updateAllPreferences();
|
||||
refreshShowingCustom();
|
||||
@@ -120,6 +121,16 @@ public class CaptionAppearanceFragment extends SettingsPreferenceFragment
|
||||
refreshPreviewText();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.captioning_appearance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
private void refreshPreviewText() {
|
||||
final Context context = getActivity();
|
||||
if (context == null) {
|
||||
|
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* Preference controller for caption footer.
|
||||
*/
|
||||
public class CaptionFooterPreferenceController extends AccessibilityFooterPreferenceController {
|
||||
|
||||
public CaptionFooterPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLabelName() {
|
||||
return mContext.getString(R.string.accessibility_captioning_title);
|
||||
}
|
||||
}
|
@@ -26,18 +26,19 @@ import android.view.accessibility.CaptioningManager;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
/** Settings fragment containing more options of captioning properties. */
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class CaptionMoreOptionsFragment extends SettingsPreferenceFragment
|
||||
public class CaptionMoreOptionsFragment extends DashboardFragment
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String TAG = "CaptionMoreOptionsFragment";
|
||||
private static final String PREF_LOCALE = "captioning_locale";
|
||||
|
||||
private CaptioningManager mCaptioningManager;
|
||||
|
||||
private LocalePreference mLocale;
|
||||
|
||||
@Override
|
||||
@@ -46,17 +47,26 @@ public class CaptionMoreOptionsFragment extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
||||
|
||||
mCaptioningManager = (CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE);
|
||||
|
||||
addPreferencesFromResource(R.xml.captioning_more_options);
|
||||
initializeAllPreferences();
|
||||
updateAllPreferences();
|
||||
installUpdateListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.captioning_more_options;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
private void initializeAllPreferences() {
|
||||
mLocale = (LocalePreference) findPreference(PREF_LOCALE);
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
@@ -41,8 +41,10 @@ import java.util.List;
|
||||
|
||||
/** Settings fragment containing captioning properties. */
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class CaptionPropertiesFragment extends SettingsPreferenceFragment
|
||||
public class CaptionPropertiesFragment extends DashboardFragment
|
||||
implements OnPreferenceChangeListener, OnMainSwitchChangeListener {
|
||||
|
||||
private static final String TAG = "CaptionPropertiesFragment";
|
||||
private static final String PREF_SWITCH = "captioning_preference_switch";
|
||||
private static final String PREF_TEXT = "captioning_caption_appearance";
|
||||
private static final String PREF_MORE = "captioning_more_options";
|
||||
@@ -62,12 +64,11 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
||||
|
||||
mCaptioningManager = (CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE);
|
||||
|
||||
addPreferencesFromResource(R.xml.captioning_settings);
|
||||
initializeAllPreferences();
|
||||
installUpdateListeners();
|
||||
initFontSizeValuesArray();
|
||||
@@ -79,6 +80,16 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
|
||||
updateAllPreferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.captioning_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
private void initializeAllPreferences() {
|
||||
mSwitch = (SettingsMainSwitchPreference) findPreference(PREF_SWITCH);
|
||||
mTextAppearance = (Preference) findPreference(PREF_TEXT);
|
||||
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* Preference controller for accessibility autoclick footer.
|
||||
*/
|
||||
public class ToggleAutoclickFooterPreferenceController extends
|
||||
AccessibilityFooterPreferenceController {
|
||||
|
||||
public ToggleAutoclickFooterPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLabelName() {
|
||||
return mContext.getString(R.string.accessibility_autoclick_preference_title);
|
||||
}
|
||||
}
|
@@ -107,7 +107,7 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
||||
lists.add(KEY_PREVIEW);
|
||||
lists.add(KEY_CATEGORY_MODE);
|
||||
lists.add(KEY_GENERAL_CATEGORY);
|
||||
lists.add(KEY_INTRODUCTION_CATEGORY);
|
||||
lists.add(KEY_HTML_DESCRIPTION_PREFERENCE);
|
||||
return lists;
|
||||
}
|
||||
|
||||
|
@@ -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