Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e2cd8419 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge "Fix pattern lock for accessibility" into mnc-dev

parents 93184eef d2def946
Loading
Loading
Loading
Loading
+37 −13
Original line number Diff line number Diff line
@@ -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,11 +1365,15 @@ public class LockPatternView extends View {
            node.setText(getTextForVirtualView(virtualViewId));
            node.setContentDescription(getTextForVirtualView(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
            final Rect bounds = getBoundsForVirtualView(virtualViewId);
+2 −0
Original line number Diff line number Diff line
@@ -1919,6 +1919,8 @@
            Cell <xliff:g id="cell_index" example="3">%1$s</xliff:g> added</string>
    <!-- Accessibility description sent when user completes drawing a pattern. [CHAR LIMIT=NONE] -->
    <string name="lockscreen_access_pattern_detected">Pattern completed</string>
    <!-- Accessibility description of the unlock pattern area. [CHAR_LIMIT=none] -->
    <string name="lockscreen_access_pattern_area" msgid="">Pattern area.</string>

    <!-- Accessibility description sent when user changes the current lock screen widget. [CHAR_LIMIT=none] -->
    <string name="keyguard_accessibility_widget_changed">%1$s. Widget %2$d of %3$d.</string>
+2 −0
Original line number Diff line number Diff line
@@ -2310,6 +2310,8 @@
  <java-symbol type="plurals" name="selected_count" />
  <java-symbol type="drawable" name="ic_dialog_alert_material" />

  <java-symbol type="string" name="lockscreen_access_pattern_area" />

  <java-symbol type="bool" name="allow_stacked_button_bar" />
  <java-symbol type="bool" name="config_eap_sim_based_auth_supported" />

+0 −3
Original line number Diff line number Diff line
@@ -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" />

+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@
    <!-- Accessibility description of the password lock. [CHAR_LIMIT=none] -->
    <string name="keyguard_accessibility_password_unlock">Password unlock.</string>
    <!-- Accessibility description of the unlock pattern area. [CHAR_LIMIT=none] -->
    <string name="keyguard_accessibility_pattern_area">Pattern area.</string>
    <string name="keyguard_accessibility_pattern_area" msgid="7679891324509597904">Pattern area.</string>
    <!-- Accessibility description of the unlock slide area. [CHAR_LIMIT=none] -->
    <string name="keyguard_accessibility_slide_area">Slide area.</string>
    <!-- Accessibility description of the PIN password view. [CHAR_LIMIT=none] -->