Merge "Fix keypad accessibility." into jb-mr1-lockscreen-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
cdb80888b7
@@ -59,6 +59,7 @@
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingRight="24dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:contentDescription="@string/keyboardview_keycode_delete"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<View
|
||||
@@ -196,6 +197,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/sym_keyboard_return_holo"
|
||||
android:contentDescription="@string/keyboardview_keycode_enter"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -98,6 +98,9 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
||||
mPasswordEntry.setOnEditorActionListener(this);
|
||||
mPasswordEntry.addTextChangedListener(this);
|
||||
|
||||
// Set selected property on so the view can send accessibility events.
|
||||
mPasswordEntry.setSelected(true);
|
||||
|
||||
// Poke the wakelock any time the text is selected or modified
|
||||
mPasswordEntry.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
|
||||
@@ -64,6 +64,7 @@ public class KeyguardPINView extends KeyguardAbsKeyInputView
|
||||
verifyPasswordAndUnlock();
|
||||
}
|
||||
});
|
||||
ok.setOnHoverListener(new NumPadKey.LiftToActivateListener(getContext()));
|
||||
}
|
||||
|
||||
// The delete button is of the PIN keyboard itself in some (e.g. tablet) layouts,
|
||||
|
||||
@@ -22,7 +22,9 @@ import android.text.SpannableStringBuilder;
|
||||
import android.text.style.TextAppearanceSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -72,6 +74,7 @@ public class NumPadKey extends Button {
|
||||
setTextViewResId(a.getResourceId(R.styleable.NumPadKey_textView, 0));
|
||||
|
||||
setOnClickListener(mListener);
|
||||
setOnHoverListener(new LiftToActivateListener(context));
|
||||
|
||||
mEnableHaptics = new LockPatternUtils(context).isTactileFeedbackEnabled();
|
||||
|
||||
@@ -113,4 +116,45 @@ public class NumPadKey extends Button {
|
||||
| HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hover listener that implements lift-to-activate interaction for
|
||||
* accessibility. May be added to multiple views.
|
||||
*/
|
||||
static class LiftToActivateListener implements View.OnHoverListener {
|
||||
/** Manager used to query accessibility enabled state. */
|
||||
private final AccessibilityManager mAccessibilityManager;
|
||||
|
||||
public LiftToActivateListener(Context context) {
|
||||
mAccessibilityManager = (AccessibilityManager) context.getSystemService(
|
||||
Context.ACCESSIBILITY_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHover(View v, MotionEvent event) {
|
||||
// When touch exploration is turned on, lifting a finger while
|
||||
// inside the view bounds should perform a click action.
|
||||
if (mAccessibilityManager.isEnabled()
|
||||
&& mAccessibilityManager.isTouchExplorationEnabled()) {
|
||||
switch (event.getActionMasked()) {
|
||||
case MotionEvent.ACTION_HOVER_ENTER:
|
||||
// Lift-to-type temporarily disables double-tap
|
||||
// activation.
|
||||
v.setClickable(false);
|
||||
break;
|
||||
case MotionEvent.ACTION_HOVER_EXIT:
|
||||
final int x = (int) event.getX();
|
||||
final int y = (int) event.getY();
|
||||
if ((x > v.getPaddingLeft()) && (y > v.getPaddingTop())
|
||||
&& (x < v.getWidth() - v.getPaddingRight())
|
||||
&& (y < v.getHeight() - v.getPaddingBottom())) {
|
||||
v.performClick();
|
||||
}
|
||||
v.setClickable(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user