diff options
| author | Kenny Guy <kennyguy@google.com> | 2016-05-23 19:26:13 +0100 |
|---|---|---|
| committer | Kenny Guy <kennyguy@google.com> | 2016-05-23 19:35:59 +0100 |
| commit | af6ef8f6f97e28e6f0bbb6947f70f4366116b09a (patch) | |
| tree | 30252c4ba7dab9bd2593e60466a6fe56cb4f97db /core/java/android/appwidget/AppWidgetHostView.java | |
| parent | d86ac8116bfc64c61d8124ff8d3e92be5e55cd3e (diff) | |
Set accessibility string for suspended widgets.
Update the content description to mention the
widget is suspended.
Mark the remote views as not significant for
accessibility.
Bug: 28909714
Change-Id: I8804d41e520e2b4af7ade0fa8820ee7b2488bde5
Diffstat (limited to 'core/java/android/appwidget/AppWidgetHostView.java')
| -rw-r--r-- | core/java/android/appwidget/AppWidgetHostView.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java index cd8f1260b590..bb5f7a1d606e 100644 --- a/core/java/android/appwidget/AppWidgetHostView.java +++ b/core/java/android/appwidget/AppWidgetHostView.java @@ -19,6 +19,7 @@ package android.appwidget; import android.content.ComponentName; import android.content.Context; import android.content.pm.ApplicationInfo; +import android.content.pm.LauncherApps; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; @@ -150,7 +151,7 @@ public class AppWidgetHostView extends FrameLayout { // We add padding to the AppWidgetHostView if necessary Rect padding = getDefaultPaddingForWidget(mContext, info.provider, null); setPadding(padding.left, padding.top, padding.right, padding.bottom); - setContentDescription(info.label); + updateContentDescription(info); } } @@ -459,6 +460,7 @@ public class AppWidgetHostView extends FrameLayout { } applyContent(content, recycled, exception); + updateContentDescription(mInfo); } private void applyContent(View content, boolean recycled, Exception exception) { @@ -493,6 +495,22 @@ public class AppWidgetHostView extends FrameLayout { } } + private void updateContentDescription(AppWidgetProviderInfo info) { + if (info != null) { + LauncherApps launcherApps = getContext().getSystemService(LauncherApps.class); + ApplicationInfo appInfo = launcherApps.getApplicationInfo( + info.provider.getPackageName(), 0, info.getProfile()); + if (appInfo != null && + (appInfo.flags & ApplicationInfo.FLAG_SUSPENDED) != 0) { + setContentDescription( + Resources.getSystem().getString( + com.android.internal.R.string.suspended_widget_accessibility, info.label)); + } else { + setContentDescription(info.label); + } + } + } + private void inflateAsync(RemoteViews remoteViews) { // Prepare a local reference to the remote Context so we're ready to // inflate any requested LayoutParams. |
