Merge "Support rich content for accessibility shortcut target"
This commit is contained in:
@@ -75,6 +75,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.
|
||||
*
|
||||
@@ -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) {
|
||||
@@ -171,6 +189,25 @@ public final class AccessibilityShortcutInfo {
|
||||
return loadResourceString(packageManager, mActivityInfo, mDescriptionResId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
@@ -4972,11 +4972,14 @@ public class Intent implements Parcelable, Cloneable {
|
||||
* <pre>
|
||||
* <accessibility-shortcut-target
|
||||
* 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:htmlDescription="@string/shortcut_target_html_description" />
|
||||
* </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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
@@ -83,6 +83,22 @@ public class AccessibilityShortcutInfoTest {
|
||||
mShortcutInfo.loadSummary(mPackageManager), is(summary));
|
||||
}
|
||||
|
||||
@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));
|
||||
|
||||
Reference in New Issue
Block a user