diff options
author | Adrian Roos <roosa@google.com> | 2015-07-27 13:49:53 -0700 |
---|---|---|
committer | Adrian Roos <roosa@google.com> | 2015-07-29 14:13:53 -0700 |
commit | d2def946390505077766e34b6df4a529b25fdc23 (patch) | |
tree | ed77c0f0dc9257477c7a72100acc221b2696e4f2 /core/java/com | |
parent | 661794307a792690d7608dc81b4e1299937a8f67 (diff) | |
download | frameworks_base-d2def946390505077766e34b6df4a529b25fdc23.zip frameworks_base-d2def946390505077766e34b6df4a529b25fdc23.tar.gz frameworks_base-d2def946390505077766e34b6df4a529b25fdc23.tar.bz2 |
Fix pattern lock for accessibility
- remove the content description in Keyguard
- only show virtual views when pattern is in progress
- add a content description when the pattern is not in progress
Bug: 22646748
Change-Id: Id32a37c4c74c82b547cee8861b2856fa0a08c41c
Diffstat (limited to 'core/java/com')
-rw-r--r-- | core/java/com/android/internal/widget/LockPatternView.java | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternView.java b/core/java/com/android/internal/widget/LockPatternView.java index a709bb8..9211eaa 100644 --- a/core/java/com/android/internal/widget/LockPatternView.java +++ b/core/java/com/android/internal/widget/LockPatternView.java @@ -94,7 +94,7 @@ public class LockPatternView extends View { */ private static final float DRAG_THRESHHOLD = 0.0f; public static final int VIRTUAL_BASE_VIEW_ID = 1; - public static final boolean DEBUG_A11Y = true; + public static final boolean DEBUG_A11Y = false; private static final String TAG = "LockPatternView"; private OnPatternListener mOnPatternListener; @@ -568,9 +568,11 @@ public class LockPatternView extends View { @Override protected boolean dispatchHoverEvent(MotionEvent event) { - // Give TouchHelper first right of refusal - boolean handled = mExploreByTouchHelper.dispatchHoverEvent(event); - return super.dispatchHoverEvent(event) || handled; + // Dispatch to onHoverEvent first so mPatternInProgress is up to date when the + // helper gets the event. + boolean handled = super.dispatchHoverEvent(event); + handled |= mExploreByTouchHelper.dispatchHoverEvent(event); + return handled; } /** @@ -877,7 +879,7 @@ public class LockPatternView extends View { return true; case MotionEvent.ACTION_CANCEL: if (mPatternInProgress) { - mPatternInProgress = false; + setPatternInProgress(false); resetPattern(); notifyPatternCleared(); } @@ -892,6 +894,11 @@ public class LockPatternView extends View { return false; } + private void setPatternInProgress(boolean progress) { + mPatternInProgress = progress; + mExploreByTouchHelper.invalidateRoot(); + } + private void handleActionMove(MotionEvent event) { // Handle all recent motion events so we don't skip any cells even when the device // is busy... @@ -905,7 +912,7 @@ public class LockPatternView extends View { Cell hitCell = detectAndAddHit(x, y); final int patternSize = mPattern.size(); if (hitCell != null && patternSize == 1) { - mPatternInProgress = true; + setPatternInProgress(true); notifyPatternStarted(); } // note current x and y for rubber banding of in progress patterns @@ -963,7 +970,7 @@ public class LockPatternView extends View { private void handleActionUp() { // report pattern detected if (!mPattern.isEmpty()) { - mPatternInProgress = false; + setPatternInProgress(false); cancelLineAnimations(); notifyPatternDetected(); invalidate(); @@ -994,11 +1001,11 @@ public class LockPatternView extends View { final float y = event.getY(); final Cell hitCell = detectAndAddHit(x, y); if (hitCell != null) { - mPatternInProgress = true; + setPatternInProgress(true); mPatternDisplayMode = DisplayMode.Correct; notifyPatternStarted(); } else if (mPatternInProgress) { - mPatternInProgress = false; + setPatternInProgress(false); notifyPatternCleared(); } if (hitCell != null) { @@ -1315,6 +1322,9 @@ public class LockPatternView extends View { @Override protected void getVisibleVirtualViews(IntArray virtualViewIds) { if (DEBUG_A11Y) Log.v(TAG, "getVisibleVirtualViews(len=" + virtualViewIds.size() + ")"); + if (!mPatternInProgress) { + return; + } for (int i = VIRTUAL_BASE_VIEW_ID; i < VIRTUAL_BASE_VIEW_ID + 9; i++) { if (!mItems.containsKey(i)) { VirtualViewContainer item = new VirtualViewContainer(getTextForVirtualView(i)); @@ -1337,6 +1347,16 @@ public class LockPatternView extends View { } @Override + public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) { + super.onPopulateAccessibilityEvent(host, event); + if (!mPatternInProgress) { + CharSequence contentDescription = getContext().getText( + com.android.internal.R.string.lockscreen_access_pattern_area); + event.setContentDescription(contentDescription); + } + } + + @Override protected void onPopulateNodeForVirtualView(int virtualViewId, AccessibilityNodeInfo node) { if (DEBUG_A11Y) Log.v(TAG, "onPopulateNodeForVirtualView(view=" + virtualViewId + ")"); @@ -1345,10 +1365,14 @@ public class LockPatternView extends View { node.setText(getTextForVirtualView(virtualViewId)); node.setContentDescription(getTextForVirtualView(virtualViewId)); - if (isClickable(virtualViewId)) { - // Mark this node of interest by making it clickable. - node.addAction(AccessibilityAction.ACTION_CLICK); - node.setClickable(isClickable(virtualViewId)); + if (mPatternInProgress) { + node.setFocusable(true); + + if (isClickable(virtualViewId)) { + // Mark this node of interest by making it clickable. + node.addAction(AccessibilityAction.ACTION_CLICK); + node.setClickable(isClickable(virtualViewId)); + } } // Compute bounds for this object |