Skip to content

Commit c7375af

Browse files
committed
Fix keypad accessibility.
Add lift-to-type to the PIN keypad. Speak entered PIN digits. Add content descriptions to PIN keypad buttons. Bug: 7436382 Change-Id: I7cb3977cc769598c5f783221e1257b13e5e108c7
1 parent 3e31a0d commit c7375af

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

core/res/res/layout/keyguard_pin_view.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
android:paddingLeft="24dp"
6060
android:paddingRight="24dp"
6161
android:background="?android:attr/selectableItemBackground"
62+
android:contentDescription="@string/keyboardview_keycode_delete"
6263
/>
6364
</LinearLayout>
6465
<View
@@ -196,6 +197,7 @@
196197
android:layout_height="match_parent"
197198
android:layout_weight="1"
198199
android:src="@drawable/sym_keyboard_return_holo"
200+
android:contentDescription="@string/keyboardview_keycode_enter"
199201
/>
200202
</LinearLayout>
201203

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ protected void onFinishInflate() {
9797
mPasswordEntry.setOnEditorActionListener(this);
9898
mPasswordEntry.addTextChangedListener(this);
9999

100+
// Set selected property on so the view can send accessibility events.
101+
mPasswordEntry.setSelected(true);
102+
100103
// Poke the wakelock any time the text is selected or modified
101104
mPasswordEntry.setOnClickListener(new OnClickListener() {
102105
public void onClick(View v) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public void onClick(View v) {
5959
verifyPasswordAndUnlock();
6060
}
6161
});
62+
ok.setOnHoverListener(new NumPadKey.LiftToActivateListener(getContext()));
6263
}
6364

6465
// The delete button is of the PIN keyboard itself in some (e.g. tablet) layouts,

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import android.text.style.TextAppearanceSpan;
2323
import android.util.AttributeSet;
2424
import android.view.HapticFeedbackConstants;
25+
import android.view.MotionEvent;
2526
import android.view.View;
27+
import android.view.accessibility.AccessibilityManager;
2628
import android.widget.Button;
2729
import android.widget.TextView;
2830

@@ -72,6 +74,7 @@ public NumPadKey(Context context, AttributeSet attrs, int defStyle) {
7274
setTextViewResId(a.getResourceId(R.styleable.NumPadKey_textView, 0));
7375

7476
setOnClickListener(mListener);
77+
setOnHoverListener(new LiftToActivateListener(context));
7578

7679
mEnableHaptics = new LockPatternUtils(context).isTactileFeedbackEnabled();
7780

@@ -113,4 +116,45 @@ public void doHapticKeyClick() {
113116
| HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
114117
}
115118
}
119+
120+
/**
121+
* Hover listener that implements lift-to-activate interaction for
122+
* accessibility. May be added to multiple views.
123+
*/
124+
static class LiftToActivateListener implements View.OnHoverListener {
125+
/** Manager used to query accessibility enabled state. */
126+
private final AccessibilityManager mAccessibilityManager;
127+
128+
public LiftToActivateListener(Context context) {
129+
mAccessibilityManager = (AccessibilityManager) context.getSystemService(
130+
Context.ACCESSIBILITY_SERVICE);
131+
}
132+
133+
@Override
134+
public boolean onHover(View v, MotionEvent event) {
135+
// When touch exploration is turned on, lifting a finger while
136+
// inside the view bounds should perform a click action.
137+
if (mAccessibilityManager.isEnabled()
138+
&& mAccessibilityManager.isTouchExplorationEnabled()) {
139+
switch (event.getActionMasked()) {
140+
case MotionEvent.ACTION_HOVER_ENTER:
141+
// Lift-to-type temporarily disables double-tap
142+
// activation.
143+
v.setClickable(false);
144+
break;
145+
case MotionEvent.ACTION_HOVER_EXIT:
146+
final int x = (int) event.getX();
147+
final int y = (int) event.getY();
148+
if ((x > v.getPaddingLeft()) && (y > v.getPaddingTop())
149+
&& (x < v.getWidth() - v.getPaddingRight())
150+
&& (y < v.getHeight() - v.getPaddingBottom())) {
151+
v.performClick();
152+
}
153+
v.setClickable(true);
154+
break;
155+
}
156+
}
157+
return false;
158+
}
159+
}
116160
}

0 commit comments

Comments
 (0)