2727
2828import android .widget .FrameLayout ;
2929
30+ import com .android .internal .R ;
31+
3032public class KeyguardWidgetPager extends PagedView {
3133 ZInterpolator mZInterpolator = new ZInterpolator (0.5f );
3234 private static float CAMERA_DISTANCE = 10000 ;
@@ -47,6 +49,9 @@ public KeyguardWidgetPager(Context context) {
4749
4850 public KeyguardWidgetPager (Context context , AttributeSet attrs , int defStyle ) {
4951 super (context , attrs , defStyle );
52+ if (getImportantForAccessibility () == View .IMPORTANT_FOR_ACCESSIBILITY_AUTO ) {
53+ setImportantForAccessibility (View .IMPORTANT_FOR_ACCESSIBILITY_YES );
54+ }
5055 }
5156
5257 /*
@@ -60,6 +65,7 @@ public void addWidget(AppWidgetHostView widget) {
6065 // The framework adds a default padding to AppWidgetHostView. We don't need this padding
6166 // for the Keyguard, so we override it to be 0.
6267 widget .setPadding (0 , 0 , 0 , 0 );
68+ widget .setContentDescription (widget .getAppWidgetInfo ().label );
6369 frame .addView (widget , lp );
6470 addView (frame );
6571 }
@@ -89,6 +95,21 @@ public float getInterpolation(float input) {
8995 }
9096 }
9197
98+ @ Override
99+ public String getCurrentPageDescription () {
100+ final int nextPageIndex = getNextPage ();
101+ if (nextPageIndex >= 0 && nextPageIndex < getChildCount ()) {
102+ KeyguardWidgetFrame frame = (KeyguardWidgetFrame ) getChildAt (nextPageIndex );
103+ CharSequence title = frame .getChildAt (0 ).getContentDescription ();
104+ if (title == null ) {
105+ title = "" ;
106+ }
107+ return mContext .getString (R .string .keyguard_accessibility_widget_changed ,
108+ title , nextPageIndex + 1 , getChildCount ());
109+ }
110+ return super .getCurrentPageDescription ();
111+ }
112+
92113 @ Override
93114 protected void overScroll (float amount ) {
94115 acceleratedOverScroll (amount );
0 commit comments