summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/accessibilityservice/AccessibilityShortcutInfo.java37
-rw-r--r--core/java/android/content/Intent.java7
-rw-r--r--core/res/res/values/attrs.xml6
-rw-r--r--core/tests/coretests/res/values/strings.xml3
-rw-r--r--core/tests/coretests/res/xml/accessibility_shortcut_test_activity.xml2
-rw-r--r--core/tests/coretests/src/android/accessibilityservice/AccessibilityShortcutInfoTest.java16
6 files changed, 69 insertions, 2 deletions
diff --git a/core/java/android/accessibilityservice/AccessibilityShortcutInfo.java b/core/java/android/accessibilityservice/AccessibilityShortcutInfo.java
index d79740b49b3d..9912d2b1cc8b 100644
--- a/core/java/android/accessibilityservice/AccessibilityShortcutInfo.java
+++ b/core/java/android/accessibilityservice/AccessibilityShortcutInfo.java
@@ -76,6 +76,16 @@ public final class AccessibilityShortcutInfo {
private final int mDescriptionResId;
/**
+ * Resource id of the animated image of the accessibility shortcut target.
+ */
+ private final int mAnimatedImageRes;
+
+ /**
+ * Resource id of the html description of the accessibility shortcut target.
+ */
+ private final int mHtmlDescriptionRes;
+
+ /**
* Creates a new instance.
*
* @param context Context for accessing resources.
@@ -119,6 +129,14 @@ public final class AccessibilityShortcutInfo {
// Gets summary
mSummaryResId = asAttributes.getResourceId(
com.android.internal.R.styleable.AccessibilityShortcutTarget_summary, 0);
+ // Gets animated image
+ mAnimatedImageRes = asAttributes.getResourceId(
+ com.android.internal.R.styleable
+ .AccessibilityShortcutTarget_animatedImageDrawable, 0);
+ // Gets html description
+ mHtmlDescriptionRes = asAttributes.getResourceId(
+ com.android.internal.R.styleable.AccessibilityShortcutTarget_htmlDescription,
+ 0);
asAttributes.recycle();
if (mDescriptionResId == 0 || mSummaryResId == 0) {
@@ -172,6 +190,25 @@ public final class AccessibilityShortcutInfo {
}
/**
+ * The animated image resource id of the accessibility shortcut target.
+ *
+ * @return The animated image resource id.
+ */
+ public int getAnimatedImageRes() {
+ return mAnimatedImageRes;
+ }
+
+ /**
+ * The localized html description of the accessibility shortcut target.
+ *
+ * @return The localized html description.
+ */
+ @Nullable
+ public String loadHtmlDescription(@NonNull PackageManager packageManager) {
+ return loadResourceString(packageManager, mActivityInfo, mHtmlDescriptionRes);
+ }
+
+ /**
* Gets string resource by the given activity and resource id.
*/
@Nullable
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index acffec98b2fc..7091a278640b 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -4962,11 +4962,14 @@ public class Intent implements Parcelable, Cloneable {
* <pre>
* &lt;accessibility-shortcut-target
* android:description="@string/shortcut_target_description"
- * android:summary="@string/shortcut_target_summary" /&gt;
+ * android:summary="@string/shortcut_target_summary"
+ * android:animatedImageDrawable="@drawable/shortcut_target_animated_image"
+ * android:htmlDescription="@string/shortcut_target_html_description" /&gt;
* </pre>
* <p>
* Both description and summary are necessary. The system will ignore the accessibility
- * shortcut target if they are missing.
+ * shortcut target if they are missing. The animated image and html description are supported
+ * to help users understand how to use the shortcut target.
* </p>
*/
@SdkConstant(SdkConstantType.INTENT_CATEGORY)
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 20901e04e6c5..7d8b8db9d4a0 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3790,6 +3790,12 @@
<attr name="description" />
<!-- Brief summary of the target of accessibility shortcut purpose or behavior. -->
<attr name="summary" />
+ <!-- Animated image of the target of accessibility shortcut purpose or behavior, to help
+ users understand how the target of accessibility shortcut can help them.-->
+ <attr name="animatedImageDrawable" format="reference"/>
+ <!-- Html description of the target of accessibility shortcut purpose or behavior, to help
+ users understand how the target of accessibility shortcut can help them. -->
+ <attr name="htmlDescription" format="string"/>
</declare-styleable>
<!-- Use <code>print-service</code> as the root tag of the XML resource that
diff --git a/core/tests/coretests/res/values/strings.xml b/core/tests/coretests/res/values/strings.xml
index f630188e54dc..21613a82deef 100644
--- a/core/tests/coretests/res/values/strings.xml
+++ b/core/tests/coretests/res/values/strings.xml
@@ -148,4 +148,7 @@
<!-- Summary of the accessibility shortcut [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_summary">Accessibility shortcut summary</string>
+
+ <!-- Html description of the accessibility shortcut [CHAR LIMIT=NONE] -->
+ <string name="accessibility_shortcut_html_description">Accessibility shortcut html description</string>
</resources>
diff --git a/core/tests/coretests/res/xml/accessibility_shortcut_test_activity.xml b/core/tests/coretests/res/xml/accessibility_shortcut_test_activity.xml
index 60e29989ef0d..a597b7190fd7 100644
--- a/core/tests/coretests/res/xml/accessibility_shortcut_test_activity.xml
+++ b/core/tests/coretests/res/xml/accessibility_shortcut_test_activity.xml
@@ -19,4 +19,6 @@
<accessibility-shortcut-target xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/accessibility_shortcut_description"
android:summary="@string/accessibility_shortcut_summary"
+ android:animatedImageDrawable="@drawable/bitmap_drawable"
+ android:htmlDescription="@string/accessibility_shortcut_html_description"
/> \ No newline at end of file
diff --git a/core/tests/coretests/src/android/accessibilityservice/AccessibilityShortcutInfoTest.java b/core/tests/coretests/src/android/accessibilityservice/AccessibilityShortcutInfoTest.java
index ae6d8df26feb..82a7b2c9217e 100644
--- a/core/tests/coretests/src/android/accessibilityservice/AccessibilityShortcutInfoTest.java
+++ b/core/tests/coretests/src/android/accessibilityservice/AccessibilityShortcutInfoTest.java
@@ -84,6 +84,22 @@ public class AccessibilityShortcutInfoTest {
}
@Test
+ public void testAnimatedImageRes() {
+ assertThat("Animated image resource id is not correct",
+ mShortcutInfo.getAnimatedImageRes(), is(R.drawable.bitmap_drawable));
+ }
+
+ @Test
+ public void testHtmlDescription() {
+ final String htmlDescription = mTargetContext.getResources()
+ .getString(R.string.accessibility_shortcut_html_description);
+
+ assertNotNull("Can't find html description string", htmlDescription);
+ assertThat("Html description is not correct",
+ mShortcutInfo.loadHtmlDescription(mPackageManager), is(htmlDescription));
+ }
+
+ @Test
public void testEquals() {
assertTrue(mShortcutInfo.equals(mShortcutInfo));
assertFalse(mShortcutInfo.equals(null));