diff --git a/core/java/com/android/internal/widget/LockPatternView.java b/core/java/com/android/internal/widget/LockPatternView.java index a709bb8e1b075..9211eaaf45926 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)); @@ -1336,6 +1346,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 diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index a45a0faff24e5..d9fa287361c00 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1919,6 +1919,8 @@ Cell %1$s added Pattern completed + + Pattern area. %1$s. Widget %2$d of %3$d. diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index d8131f9d604d3..dae5db0216bcb 100755 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2310,6 +2310,8 @@ + + diff --git a/packages/Keyguard/res/layout/keyguard_pattern_view.xml b/packages/Keyguard/res/layout/keyguard_pattern_view.xml index 09c01de8d477e..ccb9af9ff7318 100644 --- a/packages/Keyguard/res/layout/keyguard_pattern_view.xml +++ b/packages/Keyguard/res/layout/keyguard_pattern_view.xml @@ -63,9 +63,6 @@ android:layout_marginStart="8dip" android:layout_gravity="center_horizontal" android:gravity="center" - android:contentDescription="@string/keyguard_accessibility_pattern_area" - android:focusable="true" - android:focusableInTouchMode="true" android:clipChildren="false" android:clipToPadding="false" /> diff --git a/packages/Keyguard/res/values/strings.xml b/packages/Keyguard/res/values/strings.xml index 14c8a2cec89b1..41b1059222fa1 100644 --- a/packages/Keyguard/res/values/strings.xml +++ b/packages/Keyguard/res/values/strings.xml @@ -109,7 +109,7 @@ Password unlock. - Pattern area. + Pattern area. Slide area.