Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0132d90b authored by Rhed Jao's avatar Rhed Jao Committed by Android (Google) Code Review
Browse files

Merge "Support rich content for accessibility shortcut target"

parents 3bfbadb2 649b2fb0
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -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.
     */
+5 −2
Original line number Diff line number Diff line
@@ -4972,11 +4972,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)
+6 −0
Original line number Diff line number Diff line
@@ -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
+3 −0
Original line number Diff line number Diff line
@@ -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>
+2 −0
Original line number Diff line number Diff line
@@ -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
Loading