Merge "Support settings activity for accessibility shortcut target" into rvc-dev am: 6820d68e25 am: 218fb98760
Change-Id: I3f9e6e5d2ebb9284fd105bbb1f24600ee575bc7d
This commit is contained in:
@@ -90,6 +90,12 @@ public final class AccessibilityShortcutInfo {
|
||||
*/
|
||||
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.
|
||||
*
|
||||
@@ -142,6 +148,9 @@ public final class AccessibilityShortcutInfo {
|
||||
mHtmlDescriptionRes = asAttributes.getResourceId(
|
||||
com.android.internal.R.styleable.AccessibilityShortcutTarget_htmlDescription,
|
||||
0);
|
||||
// Get settings activity name
|
||||
mSettingsActivityName = asAttributes.getString(
|
||||
com.android.internal.R.styleable.AccessibilityShortcutTarget_settingsActivity);
|
||||
asAttributes.recycle();
|
||||
|
||||
if (mDescriptionResId == 0 || mSummaryResId == 0) {
|
||||
@@ -237,6 +246,16 @@ public final class AccessibilityShortcutInfo {
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -4940,12 +4940,15 @@ public class Intent implements Parcelable, Cloneable {
|
||||
* android:description="@string/shortcut_target_description"
|
||||
* android:summary="@string/shortcut_target_summary"
|
||||
* 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>
|
||||
* <p>
|
||||
* 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
|
||||
* 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>
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.INTENT_CATEGORY)
|
||||
|
||||
@@ -3796,6 +3796,9 @@
|
||||
<!-- 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="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>
|
||||
|
||||
<!-- Use <code>print-service</code> as the root tag of the XML resource that
|
||||
|
||||
@@ -21,4 +21,5 @@
|
||||
android:summary="@string/accessibility_shortcut_summary"
|
||||
android:animatedImageDrawable="@drawable/bitmap_drawable"
|
||||
android:htmlDescription="@string/accessibility_shortcut_html_description"
|
||||
android:settingsActivity="com.example.shortcut.target.SettingsActivity"
|
||||
/>
|
||||
@@ -48,6 +48,9 @@ import java.util.List;
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class AccessibilityShortcutInfoTest {
|
||||
private static final String SETTINGS_ACTIVITY_NAME =
|
||||
"com.example.shortcut.target.SettingsActivity";
|
||||
|
||||
private Context mTargetContext;
|
||||
private PackageManager mPackageManager;
|
||||
private ComponentName mComponentName;
|
||||
@@ -105,6 +108,12 @@ public class AccessibilityShortcutInfoTest {
|
||||
mShortcutInfo.loadHtmlDescription(mPackageManager), is(htmlDescription));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSettingsActivity() {
|
||||
assertThat("Settings Activity is not correct",
|
||||
mShortcutInfo.getSettingsActivityName(), is(SETTINGS_ACTIVITY_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
assertTrue(mShortcutInfo.equals(mShortcutInfo));
|
||||
|
||||
Reference in New Issue
Block a user