Skip to content

Commit 5cf72e1

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Accessibility support for the widgets switcher of the lock screen." into jb-mr1-dev
2 parents 75c4800 + 6526fdd commit 5cf72e1

File tree

6 files changed

+40
-3
lines changed

6 files changed

+40
-3
lines changed

core/res/res/layout/keyguard_multi_user_selector.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
android:orientation="horizontal"
2222
android:layout_width="match_parent"
2323
android:layout_height="match_parent"
24-
android:layout_gravity="center">
24+
android:layout_gravity="center"
25+
android:contentDescription="@string/keyguard_accessibility_user_selector">
2526

2627
<com.android.internal.policy.impl.keyguard.KeyguardSubdivisionLayout
2728
android:id="@+id/keyguard_users_grid"

core/res/res/layout/keyguard_status_view.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
android:orientation="vertical"
3030
android:layout_width="match_parent"
3131
android:layout_height="match_parent"
32-
android:gravity="center_horizontal">
32+
android:gravity="center_horizontal"
33+
android:contentDescription="@string/keyguard_accessibility_status">
3334

3435
<com.android.internal.policy.impl.keyguard.ClockView
3536
android:id="@+id/clock_view"

core/res/res/layout/keyguard_transport_control_view.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
<FrameLayout
2727
android:layout_width="match_parent"
2828
android:layout_height="match_parent"
29-
android:foreground="@drawable/ic_lockscreen_player_background">
29+
android:foreground="@drawable/ic_lockscreen_player_background"
30+
android:contentDescription="@string/keygaurd_accessibility_media_controls">
3031
<!-- Use ImageView for its cropping features; otherwise could be android:background -->
3132
<ImageView
3233
android:id="@+id/albumart"

core/res/res/values/strings.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,6 +2272,15 @@
22722272
<!-- Accessibility description sent when user completes drawing a pattern. [CHAR LIMIT=NONE] -->
22732273
<string name="lockscreen_access_pattern_detected">Pattern completed</string>
22742274

2275+
<!-- Accessibility description sent when user changes the current lock screen widget. [CHAR_LIMIT=none] -->
2276+
<string name="keyguard_accessibility_widget_changed">%1$s. Widget %2$d of %3$d.</string>
2277+
<!-- Accessibility description of the lock screen user selector widget. [CHAR_LIMIT=none] -->
2278+
<string name="keyguard_accessibility_user_selector">User selector</string>
2279+
<!-- Accessibility description of the lock screen status widget. [CHAR_LIMIT=none] -->
2280+
<string name="keyguard_accessibility_status">Status</string>
2281+
<!-- Accessibility description of the lock media control widget. [CHAR_LIMIT=none] -->
2282+
<string name="keygaurd_accessibility_media_controls">Media controls</string>
2283+
22752284
<!-- Password keyboard strings. Used by LockScreen and Settings --><skip />
22762285
<!-- Label for "switch to symbols" key. Must be short to fit on key! -->
22772286
<string name="password_keyboard_label_symbol_key">\?123</string>

core/res/res/values/symbols.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,10 @@
549549
<java-symbol type="string" name="keyboardview_keycode_enter" />
550550
<java-symbol type="string" name="keyboardview_keycode_mode_change" />
551551
<java-symbol type="string" name="keyboardview_keycode_shift" />
552+
<java-symbol type="string" name="keygaurd_accessibility_media_controls" />
553+
<java-symbol type="string" name="keyguard_accessibility_status" />
554+
<java-symbol type="string" name="keyguard_accessibility_user_selector" />
555+
<java-symbol type="string" name="keyguard_accessibility_widget_changed" />
552556
<java-symbol type="string" name="kilobyteShort" />
553557
<java-symbol type="string" name="last_month" />
554558
<java-symbol type="string" name="launchBrowserDefault" />

policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
import android.widget.FrameLayout;
2929

30+
import com.android.internal.R;
31+
3032
public 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

Comments
 (0)