[Material Next] Support "Learn more" for help link
Allow CaptionManager, Magnification, Color correction, Color inversion, Time to take action, and Autoclick. Bug: 187671696 Test: make RunSettingsRoboTests -j52 ROBOTEST_FILTER=AccessibilityFooterPreferenceTest Change-Id: I9d753243d4f61b6b3d58b50425b7a75a812a481d
This commit is contained in:
@@ -5249,6 +5249,8 @@
|
||||
<string name="accessibility_shortcut_edit_dialog_summary_software_gesture_talkback">Swipe up from the bottom of the screen with 3 fingers.\n\nTo switch between features, swipe up with 3 fingers and hold.</string>
|
||||
<!-- Summary for software shortcut in accessibility edit shortcut dialog when user had enabled the accessibility floating button mode (Floating over other apps). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_shortcut_edit_dialog_summary_software_floating"><annotation id="link">Customize accessibility button</annotation></string>
|
||||
<!-- Summary for footer to show help link. [CHAR LIMIT=NONE] -->
|
||||
<string name="footer_learn_more"><annotation id="link">Learn more</annotation></string>
|
||||
<!-- Title for hardware shortcut in accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_shortcut_edit_dialog_title_hardware">Hold volume keys</string>
|
||||
<!-- Part of list to compose user's accessibility shortcut list. [CHAR LIMIT=NONE] -->
|
||||
|
@@ -34,4 +34,9 @@ public class AccessibilityControlTimeoutFooterPreferenceController extends
|
||||
protected String getLabelName() {
|
||||
return mContext.getString(R.string.accessibility_setting_item_control_timeout_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_url_timeout;
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,8 @@
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.AttributeSet;
|
||||
@@ -25,7 +27,9 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settingslib.R;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.utils.AnnotationSpan;
|
||||
import com.android.settingslib.HelpUtils;
|
||||
import com.android.settingslib.widget.FooterPreference;
|
||||
|
||||
/**
|
||||
@@ -106,4 +110,23 @@ public final class AccessibilityFooterPreference extends FooterPreference {
|
||||
public boolean isLinkEnabled() {
|
||||
return mLinkEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends {@link AnnotationSpan} with learn more link apart from the other text.
|
||||
*
|
||||
* @param helpLinkRes The Help Uri Resource key
|
||||
*/
|
||||
public void appendHelpLink(int helpLinkRes) {
|
||||
final SpannableStringBuilder sb = new SpannableStringBuilder();
|
||||
sb.append(getTitle()).append("\n\n").append(getLearnMoreLink(getContext(), helpLinkRes));
|
||||
setTitle(sb);
|
||||
}
|
||||
|
||||
private CharSequence getLearnMoreLink(Context context, int helpLinkRes) {
|
||||
final Intent helpIntent = HelpUtils.getHelpIntent(
|
||||
context, context.getString(helpLinkRes), context.getClass().getName());
|
||||
final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
|
||||
context, AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, helpIntent);
|
||||
return AnnotationSpan.linkify(context.getText(R.string.footer_learn_more), linkInfo);
|
||||
}
|
||||
}
|
||||
|
@@ -46,6 +46,14 @@ public abstract class AccessibilityFooterPreferenceController extends BasePrefer
|
||||
updateFooterPreferences(footerPreference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this if showing a help item in the footer bar, by returning the resource id.
|
||||
*
|
||||
* @return the resource id for the help url
|
||||
*/
|
||||
protected int getHelpResource() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Returns the accessibility feature name. */
|
||||
protected abstract String getLabelName();
|
||||
@@ -54,5 +62,10 @@ public abstract class AccessibilityFooterPreferenceController extends BasePrefer
|
||||
final String iconContentDescription = mContext.getString(
|
||||
R.string.accessibility_introduction_title, getLabelName());
|
||||
footerPreference.setIconContentDescription(iconContentDescription);
|
||||
|
||||
if (getHelpResource() != 0) {
|
||||
footerPreference.appendHelpLink(getHelpResource());
|
||||
footerPreference.setLinkEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -33,4 +33,9 @@ public class CaptionFooterPreferenceController extends AccessibilityFooterPrefer
|
||||
protected String getLabelName() {
|
||||
return mContext.getString(R.string.accessibility_captioning_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_url_caption;
|
||||
}
|
||||
}
|
||||
|
@@ -34,4 +34,9 @@ public class ToggleAutoclickFooterPreferenceController extends
|
||||
protected String getLabelName() {
|
||||
return mContext.getString(R.string.accessibility_autoclick_preference_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHelpResource() {
|
||||
return R.string.help_url_autoclick;
|
||||
}
|
||||
}
|
||||
|
@@ -303,6 +303,11 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
return SettingsEnums.ACCESSIBILITY_SERVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHelpResource() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
@@ -508,7 +513,13 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
new AccessibilityFooterPreference(screen.getContext());
|
||||
htmlFooterPreference.setKey(KEY_HTML_DESCRIPTION_PREFERENCE);
|
||||
htmlFooterPreference.setSummary(htmlDescription);
|
||||
// Only framework tools support help link
|
||||
if (getHelpResource() != 0) {
|
||||
htmlFooterPreference.appendHelpLink(getHelpResource());
|
||||
htmlFooterPreference.setLinkEnabled(true);
|
||||
} else {
|
||||
htmlFooterPreference.setLinkEnabled(false);
|
||||
}
|
||||
htmlFooterPreference.setIconContentDescription(iconContentDescription);
|
||||
screen.addPreference(htmlFooterPreference);
|
||||
}
|
||||
@@ -542,6 +553,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
||||
new AccessibilityFooterPreference(screen.getContext());
|
||||
footerPreference.setSummary(summary);
|
||||
footerPreference.setIconContentDescription(iconContentDescription);
|
||||
if (getHelpResource() != 0) {
|
||||
footerPreference.appendHelpLink(getHelpResource());
|
||||
footerPreference.setLinkEnabled(true);
|
||||
}
|
||||
screen.addPreference(footerPreference);
|
||||
}
|
||||
|
||||
|
@@ -296,6 +296,11 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
getShortcutTypeSummary(getPrefContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHelpResource() {
|
||||
return R.string.help_url_magnification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
// TODO: Distinguish between magnification modes
|
||||
|
@@ -25,8 +25,9 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settingslib.R;
|
||||
import com.android.settings.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -41,6 +42,7 @@ public final class AccessibilityFooterPreferenceTest {
|
||||
private static final String DEFAULT_SUMMARY = "default summary";
|
||||
private static final String DEFAULT_DESCRIPTION = "default description";
|
||||
|
||||
private Context mContext = ApplicationProvider.getApplicationContext();
|
||||
private AccessibilityFooterPreference mAccessibilityFooterPreference;
|
||||
private PreferenceViewHolder mPreferenceViewHolder;
|
||||
|
||||
@@ -83,4 +85,14 @@ public final class AccessibilityFooterPreferenceTest {
|
||||
assertThat(infoFrame.getContentDescription()).isEqualTo(DEFAULT_DESCRIPTION);
|
||||
assertThat(infoFrame.isFocusable()).isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void appendHelpLink_timeoutHelpUri_updateSummary() {
|
||||
mAccessibilityFooterPreference.setSummary(DEFAULT_SUMMARY);
|
||||
|
||||
mAccessibilityFooterPreference.appendHelpLink(R.string.help_url_timeout);
|
||||
|
||||
final String title = mAccessibilityFooterPreference.getTitle().toString();
|
||||
assertThat(title.contains(mContext.getString(R.string.footer_learn_more))).isTrue();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user