Loading core/java/android/accessibilityservice/AccessibilityShortcutInfo.java +19 −0 Original line number Original line Diff line number Diff line Loading @@ -90,6 +90,12 @@ public final class AccessibilityShortcutInfo { */ */ private final int mHtmlDescriptionRes; private final int mHtmlDescriptionRes; /** * The accessibility shortcut target setting activity's name, used by the system * settings to launch the setting activity of this accessibility shortcut target. */ private String mSettingsActivityName; /** /** * Creates a new instance. * Creates a new instance. * * Loading Loading @@ -142,6 +148,9 @@ public final class AccessibilityShortcutInfo { mHtmlDescriptionRes = asAttributes.getResourceId( mHtmlDescriptionRes = asAttributes.getResourceId( com.android.internal.R.styleable.AccessibilityShortcutTarget_htmlDescription, com.android.internal.R.styleable.AccessibilityShortcutTarget_htmlDescription, 0); 0); // Get settings activity name mSettingsActivityName = asAttributes.getString( com.android.internal.R.styleable.AccessibilityShortcutTarget_settingsActivity); asAttributes.recycle(); asAttributes.recycle(); if (mDescriptionResId == 0 || mSummaryResId == 0) { if (mDescriptionResId == 0 || mSummaryResId == 0) { Loading Loading @@ -237,6 +246,16 @@ public final class AccessibilityShortcutInfo { return TextUtils.isEmpty(htmlDescription) ? null : getFilteredHtmlText(htmlDescription); return TextUtils.isEmpty(htmlDescription) ? null : getFilteredHtmlText(htmlDescription); } } /** * The settings activity name. * * @return The settings activity name. */ @Nullable public String getSettingsActivityName() { return mSettingsActivityName; } /** /** * Gets string resource by the given activity and resource id. * Gets string resource by the given activity and resource id. */ */ Loading core/java/android/content/Intent.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -4940,12 +4940,15 @@ public class Intent implements Parcelable, Cloneable { * android:description="@string/shortcut_target_description" * android:description="@string/shortcut_target_description" * android:summary="@string/shortcut_target_summary" * android:summary="@string/shortcut_target_summary" * android:animatedImageDrawable="@drawable/shortcut_target_animated_image" * android:animatedImageDrawable="@drawable/shortcut_target_animated_image" * android:htmlDescription="@string/shortcut_target_html_description" /> * android:htmlDescription="@string/shortcut_target_html_description" * android:settingsActivity="com.example.android.shortcut.target.SettingsActivity" /> * </pre> * </pre> * <p> * <p> * Both description and summary are necessary. The system will ignore the accessibility * Both description and summary are necessary. The system will ignore the accessibility * shortcut target if they are missing. The animated image and html description are supported * shortcut target if they are missing. The animated image and html description are supported * to help users understand how to use the shortcut target. * to help users understand how to use the shortcut target. The settings activity is a * component name that allows the user to modify the settings for this accessibility shortcut * target. * </p> * </p> */ */ @SdkConstant(SdkConstantType.INTENT_CATEGORY) @SdkConstant(SdkConstantType.INTENT_CATEGORY) Loading core/res/res/values/attrs.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -3796,6 +3796,9 @@ <!-- Html description of the target of accessibility shortcut purpose or behavior, to help <!-- Html description of the target of accessibility shortcut purpose or behavior, to help users understand how the target of accessibility shortcut can help them. --> users understand how the target of accessibility shortcut can help them. --> <attr name="htmlDescription" format="reference"/> <attr name="htmlDescription" format="reference"/> <!-- Component name of an activity that allows the user to modify the settings for this target of accessibility shortcut. --> <attr name="settingsActivity" /> </declare-styleable> </declare-styleable> <!-- Use <code>print-service</code> as the root tag of the XML resource that <!-- Use <code>print-service</code> as the root tag of the XML resource that Loading core/tests/coretests/res/xml/accessibility_shortcut_test_activity.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -21,4 +21,5 @@ android:summary="@string/accessibility_shortcut_summary" android:summary="@string/accessibility_shortcut_summary" android:animatedImageDrawable="@drawable/bitmap_drawable" android:animatedImageDrawable="@drawable/bitmap_drawable" android:htmlDescription="@string/accessibility_shortcut_html_description" android:htmlDescription="@string/accessibility_shortcut_html_description" android:settingsActivity="com.example.shortcut.target.SettingsActivity" /> /> No newline at end of file core/tests/coretests/src/android/accessibilityservice/AccessibilityShortcutInfoTest.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,9 @@ import java.util.List; @SmallTest @SmallTest @RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class) public class AccessibilityShortcutInfoTest { public class AccessibilityShortcutInfoTest { private static final String SETTINGS_ACTIVITY_NAME = "com.example.shortcut.target.SettingsActivity"; private Context mTargetContext; private Context mTargetContext; private PackageManager mPackageManager; private PackageManager mPackageManager; private ComponentName mComponentName; private ComponentName mComponentName; Loading Loading @@ -105,6 +108,12 @@ public class AccessibilityShortcutInfoTest { mShortcutInfo.loadHtmlDescription(mPackageManager), is(htmlDescription)); mShortcutInfo.loadHtmlDescription(mPackageManager), is(htmlDescription)); } } @Test public void testSettingsActivity() { assertThat("Settings Activity is not correct", mShortcutInfo.getSettingsActivityName(), is(SETTINGS_ACTIVITY_NAME)); } @Test @Test public void testEquals() { public void testEquals() { assertTrue(mShortcutInfo.equals(mShortcutInfo)); assertTrue(mShortcutInfo.equals(mShortcutInfo)); Loading Loading
core/java/android/accessibilityservice/AccessibilityShortcutInfo.java +19 −0 Original line number Original line Diff line number Diff line Loading @@ -90,6 +90,12 @@ public final class AccessibilityShortcutInfo { */ */ private final int mHtmlDescriptionRes; private final int mHtmlDescriptionRes; /** * The accessibility shortcut target setting activity's name, used by the system * settings to launch the setting activity of this accessibility shortcut target. */ private String mSettingsActivityName; /** /** * Creates a new instance. * Creates a new instance. * * Loading Loading @@ -142,6 +148,9 @@ public final class AccessibilityShortcutInfo { mHtmlDescriptionRes = asAttributes.getResourceId( mHtmlDescriptionRes = asAttributes.getResourceId( com.android.internal.R.styleable.AccessibilityShortcutTarget_htmlDescription, com.android.internal.R.styleable.AccessibilityShortcutTarget_htmlDescription, 0); 0); // Get settings activity name mSettingsActivityName = asAttributes.getString( com.android.internal.R.styleable.AccessibilityShortcutTarget_settingsActivity); asAttributes.recycle(); asAttributes.recycle(); if (mDescriptionResId == 0 || mSummaryResId == 0) { if (mDescriptionResId == 0 || mSummaryResId == 0) { Loading Loading @@ -237,6 +246,16 @@ public final class AccessibilityShortcutInfo { return TextUtils.isEmpty(htmlDescription) ? null : getFilteredHtmlText(htmlDescription); return TextUtils.isEmpty(htmlDescription) ? null : getFilteredHtmlText(htmlDescription); } } /** * The settings activity name. * * @return The settings activity name. */ @Nullable public String getSettingsActivityName() { return mSettingsActivityName; } /** /** * Gets string resource by the given activity and resource id. * Gets string resource by the given activity and resource id. */ */ Loading
core/java/android/content/Intent.java +5 −2 Original line number Original line Diff line number Diff line Loading @@ -4940,12 +4940,15 @@ public class Intent implements Parcelable, Cloneable { * android:description="@string/shortcut_target_description" * android:description="@string/shortcut_target_description" * android:summary="@string/shortcut_target_summary" * android:summary="@string/shortcut_target_summary" * android:animatedImageDrawable="@drawable/shortcut_target_animated_image" * android:animatedImageDrawable="@drawable/shortcut_target_animated_image" * android:htmlDescription="@string/shortcut_target_html_description" /> * android:htmlDescription="@string/shortcut_target_html_description" * android:settingsActivity="com.example.android.shortcut.target.SettingsActivity" /> * </pre> * </pre> * <p> * <p> * Both description and summary are necessary. The system will ignore the accessibility * Both description and summary are necessary. The system will ignore the accessibility * shortcut target if they are missing. The animated image and html description are supported * shortcut target if they are missing. The animated image and html description are supported * to help users understand how to use the shortcut target. * to help users understand how to use the shortcut target. The settings activity is a * component name that allows the user to modify the settings for this accessibility shortcut * target. * </p> * </p> */ */ @SdkConstant(SdkConstantType.INTENT_CATEGORY) @SdkConstant(SdkConstantType.INTENT_CATEGORY) Loading
core/res/res/values/attrs.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -3796,6 +3796,9 @@ <!-- Html description of the target of accessibility shortcut purpose or behavior, to help <!-- Html description of the target of accessibility shortcut purpose or behavior, to help users understand how the target of accessibility shortcut can help them. --> users understand how the target of accessibility shortcut can help them. --> <attr name="htmlDescription" format="reference"/> <attr name="htmlDescription" format="reference"/> <!-- Component name of an activity that allows the user to modify the settings for this target of accessibility shortcut. --> <attr name="settingsActivity" /> </declare-styleable> </declare-styleable> <!-- Use <code>print-service</code> as the root tag of the XML resource that <!-- Use <code>print-service</code> as the root tag of the XML resource that Loading
core/tests/coretests/res/xml/accessibility_shortcut_test_activity.xml +1 −0 Original line number Original line Diff line number Diff line Loading @@ -21,4 +21,5 @@ android:summary="@string/accessibility_shortcut_summary" android:summary="@string/accessibility_shortcut_summary" android:animatedImageDrawable="@drawable/bitmap_drawable" android:animatedImageDrawable="@drawable/bitmap_drawable" android:htmlDescription="@string/accessibility_shortcut_html_description" android:htmlDescription="@string/accessibility_shortcut_html_description" android:settingsActivity="com.example.shortcut.target.SettingsActivity" /> /> No newline at end of file
core/tests/coretests/src/android/accessibilityservice/AccessibilityShortcutInfoTest.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,9 @@ import java.util.List; @SmallTest @SmallTest @RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class) public class AccessibilityShortcutInfoTest { public class AccessibilityShortcutInfoTest { private static final String SETTINGS_ACTIVITY_NAME = "com.example.shortcut.target.SettingsActivity"; private Context mTargetContext; private Context mTargetContext; private PackageManager mPackageManager; private PackageManager mPackageManager; private ComponentName mComponentName; private ComponentName mComponentName; Loading Loading @@ -105,6 +108,12 @@ public class AccessibilityShortcutInfoTest { mShortcutInfo.loadHtmlDescription(mPackageManager), is(htmlDescription)); mShortcutInfo.loadHtmlDescription(mPackageManager), is(htmlDescription)); } } @Test public void testSettingsActivity() { assertThat("Settings Activity is not correct", mShortcutInfo.getSettingsActivityName(), is(SETTINGS_ACTIVITY_NAME)); } @Test @Test public void testEquals() { public void testEquals() { assertTrue(mShortcutInfo.equals(mShortcutInfo)); assertTrue(mShortcutInfo.equals(mShortcutInfo)); Loading