Loading core/java/com/android/internal/widget/LockPatternView.java +70 −17 Original line number Original line Diff line number Diff line Loading @@ -17,8 +17,6 @@ package com.android.internal.widget; package com.android.internal.widget; import com.android.internal.R; import android.content.Context; import android.content.Context; import android.content.res.Resources; import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.TypedArray; Loading @@ -39,6 +37,10 @@ import android.util.AttributeSet; import android.util.Log; import android.util.Log; import android.view.MotionEvent; import android.view.MotionEvent; import android.view.View; import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import com.android.internal.R; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; Loading Loading @@ -401,6 +403,34 @@ public class LockPatternView extends View { invalidate(); invalidate(); } } private void notifyCellAdded() { if (mOnPatternListener != null) { mOnPatternListener.onPatternCellAdded(mPattern); } sendAccessEvent(R.string.lockscreen_access_pattern_cell_added); } private void notifyPatternStarted() { if (mOnPatternListener != null) { mOnPatternListener.onPatternStart(); } sendAccessEvent(R.string.lockscreen_access_pattern_start); } private void notifyPatternDetected() { if (mOnPatternListener != null) { mOnPatternListener.onPatternDetected(mPattern); } sendAccessEvent(R.string.lockscreen_access_pattern_detected); } private void notifyPatternCleared() { if (mOnPatternListener != null) { mOnPatternListener.onPatternCleared(); } sendAccessEvent(R.string.lockscreen_access_pattern_cleared); } /** /** * Clear the pattern. * Clear the pattern. */ */ Loading Loading @@ -554,9 +584,7 @@ public class LockPatternView extends View { private void addCellToPattern(Cell newCell) { private void addCellToPattern(Cell newCell) { mPatternDrawLookup[newCell.getRow()][newCell.getColumn()] = true; mPatternDrawLookup[newCell.getRow()][newCell.getColumn()] = true; mPattern.add(newCell); mPattern.add(newCell); if (mOnPatternListener != null) { notifyCellAdded(); mOnPatternListener.onPatternCellAdded(mPattern); } } } // helper method to find which cell a point maps to // helper method to find which cell a point maps to Loading Loading @@ -618,6 +646,27 @@ public class LockPatternView extends View { return -1; return -1; } } @Override public boolean onHoverEvent(MotionEvent event) { if (AccessibilityManager.getInstance(mContext).isTouchExplorationEnabled()) { final int action = event.getAction(); switch (action) { case MotionEvent.ACTION_HOVER_ENTER: event.setAction(MotionEvent.ACTION_DOWN); break; case MotionEvent.ACTION_HOVER_MOVE: event.setAction(MotionEvent.ACTION_MOVE); break; case MotionEvent.ACTION_HOVER_EXIT: event.setAction(MotionEvent.ACTION_UP); break; } onTouchEvent(event); event.setAction(action); } return super.onHoverEvent(event); } @Override @Override public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) { if (!mInputEnabled || !isEnabled()) { if (!mInputEnabled || !isEnabled()) { Loading @@ -636,10 +685,8 @@ public class LockPatternView extends View { return true; return true; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL: resetPattern(); resetPattern(); if (mOnPatternListener != null) { mPatternInProgress = false; mPatternInProgress = false; mOnPatternListener.onPatternCleared(); notifyPatternCleared(); } if (PROFILE_DRAWING) { if (PROFILE_DRAWING) { if (mDrawingProfilingStarted) { if (mDrawingProfilingStarted) { Debug.stopMethodTracing(); Debug.stopMethodTracing(); Loading @@ -661,9 +708,9 @@ public class LockPatternView extends View { final int patternSizePreHitDetect = mPattern.size(); final int patternSizePreHitDetect = mPattern.size(); Cell hitCell = detectAndAddHit(x, y); Cell hitCell = detectAndAddHit(x, y); final int patternSize = mPattern.size(); final int patternSize = mPattern.size(); if (hitCell != null && (mOnPatternListener != null) && (patternSize == 1)) { if (hitCell != null && patternSize == 1) { mPatternInProgress = true; mPatternInProgress = true; mOnPatternListener.onPatternStart(); notifyPatternStarted(); } } // note current x and y for rubber banding of in progress patterns // note current x and y for rubber banding of in progress patterns final float dx = Math.abs(x - mInProgressX); final float dx = Math.abs(x - mInProgressX); Loading Loading @@ -778,11 +825,17 @@ public class LockPatternView extends View { } } } } private void sendAccessEvent(int resId) { setContentDescription(mContext.getString(resId)); sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); setContentDescription(null); } private void handleActionUp(MotionEvent event) { private void handleActionUp(MotionEvent event) { // report pattern detected // report pattern detected if (!mPattern.isEmpty() && mOnPatternListener != null) { if (!mPattern.isEmpty()) { mPatternInProgress = false; mPatternInProgress = false; mOnPatternListener.onPatternDetected(mPattern); notifyPatternDetected(); invalidate(); invalidate(); } } if (PROFILE_DRAWING) { if (PROFILE_DRAWING) { Loading @@ -798,13 +851,13 @@ public class LockPatternView extends View { final float x = event.getX(); final float x = event.getX(); final float y = event.getY(); final float y = event.getY(); final Cell hitCell = detectAndAddHit(x, y); final Cell hitCell = detectAndAddHit(x, y); if (hitCell != null && mOnPatternListener != null) { if (hitCell != null) { mPatternInProgress = true; mPatternInProgress = true; mPatternDisplayMode = DisplayMode.Correct; mPatternDisplayMode = DisplayMode.Correct; mOnPatternListener.onPatternStart(); notifyPatternStarted(); } else if (mOnPatternListener != null) { } else { mPatternInProgress = false; mPatternInProgress = false; mOnPatternListener.onPatternCleared(); notifyPatternCleared(); } } if (hitCell != null) { if (hitCell != null) { final float startX = getCenterXForColumn(hitCell.column); final float startX = getCenterXForColumn(hitCell.column); Loading core/res/res/values/strings.xml +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1958,6 +1958,15 @@ <!-- Displayed on lock screen's right tab - turn sound off --> <!-- Displayed on lock screen's right tab - turn sound off --> <string name="lockscreen_sound_off_label">Sound off</string> <string name="lockscreen_sound_off_label">Sound off</string> <!-- Accessibility description sent when user starts drawing a lock pattern. [CHAR LIMIT=NONE] --> <string name="lockscreen_access_pattern_start">Pattern started</string> <!-- Accessibility description sent when the pattern times out and is cleared. [CHAR LIMIT=NONE] --> <string name="lockscreen_access_pattern_cleared">Pattern cleared</string> <!-- Accessibility description sent when user adds a cell to the pattern. [CHAR LIMIT=NONE] --> <string name="lockscreen_access_pattern_cell_added">Cell added</string> <!-- Accessibility description sent when user completes drawing a pattern. [CHAR LIMIT=NONE] --> <string name="lockscreen_access_pattern_detected">Pattern completed</string> <!-- Password keyboard strings. Used by LockScreen and Settings --><skip /> <!-- Password keyboard strings. Used by LockScreen and Settings --><skip /> <!-- Label for "switch to symbols" key. Must be short to fit on key! --> <!-- Label for "switch to symbols" key. Must be short to fit on key! --> <string name="password_keyboard_label_symbol_key">\?123</string> <string name="password_keyboard_label_symbol_key">\?123</string> Loading Loading
core/java/com/android/internal/widget/LockPatternView.java +70 −17 Original line number Original line Diff line number Diff line Loading @@ -17,8 +17,6 @@ package com.android.internal.widget; package com.android.internal.widget; import com.android.internal.R; import android.content.Context; import android.content.Context; import android.content.res.Resources; import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.TypedArray; Loading @@ -39,6 +37,10 @@ import android.util.AttributeSet; import android.util.Log; import android.util.Log; import android.view.MotionEvent; import android.view.MotionEvent; import android.view.View; import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; import com.android.internal.R; import java.util.ArrayList; import java.util.ArrayList; import java.util.List; import java.util.List; Loading Loading @@ -401,6 +403,34 @@ public class LockPatternView extends View { invalidate(); invalidate(); } } private void notifyCellAdded() { if (mOnPatternListener != null) { mOnPatternListener.onPatternCellAdded(mPattern); } sendAccessEvent(R.string.lockscreen_access_pattern_cell_added); } private void notifyPatternStarted() { if (mOnPatternListener != null) { mOnPatternListener.onPatternStart(); } sendAccessEvent(R.string.lockscreen_access_pattern_start); } private void notifyPatternDetected() { if (mOnPatternListener != null) { mOnPatternListener.onPatternDetected(mPattern); } sendAccessEvent(R.string.lockscreen_access_pattern_detected); } private void notifyPatternCleared() { if (mOnPatternListener != null) { mOnPatternListener.onPatternCleared(); } sendAccessEvent(R.string.lockscreen_access_pattern_cleared); } /** /** * Clear the pattern. * Clear the pattern. */ */ Loading Loading @@ -554,9 +584,7 @@ public class LockPatternView extends View { private void addCellToPattern(Cell newCell) { private void addCellToPattern(Cell newCell) { mPatternDrawLookup[newCell.getRow()][newCell.getColumn()] = true; mPatternDrawLookup[newCell.getRow()][newCell.getColumn()] = true; mPattern.add(newCell); mPattern.add(newCell); if (mOnPatternListener != null) { notifyCellAdded(); mOnPatternListener.onPatternCellAdded(mPattern); } } } // helper method to find which cell a point maps to // helper method to find which cell a point maps to Loading Loading @@ -618,6 +646,27 @@ public class LockPatternView extends View { return -1; return -1; } } @Override public boolean onHoverEvent(MotionEvent event) { if (AccessibilityManager.getInstance(mContext).isTouchExplorationEnabled()) { final int action = event.getAction(); switch (action) { case MotionEvent.ACTION_HOVER_ENTER: event.setAction(MotionEvent.ACTION_DOWN); break; case MotionEvent.ACTION_HOVER_MOVE: event.setAction(MotionEvent.ACTION_MOVE); break; case MotionEvent.ACTION_HOVER_EXIT: event.setAction(MotionEvent.ACTION_UP); break; } onTouchEvent(event); event.setAction(action); } return super.onHoverEvent(event); } @Override @Override public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) { if (!mInputEnabled || !isEnabled()) { if (!mInputEnabled || !isEnabled()) { Loading @@ -636,10 +685,8 @@ public class LockPatternView extends View { return true; return true; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL: resetPattern(); resetPattern(); if (mOnPatternListener != null) { mPatternInProgress = false; mPatternInProgress = false; mOnPatternListener.onPatternCleared(); notifyPatternCleared(); } if (PROFILE_DRAWING) { if (PROFILE_DRAWING) { if (mDrawingProfilingStarted) { if (mDrawingProfilingStarted) { Debug.stopMethodTracing(); Debug.stopMethodTracing(); Loading @@ -661,9 +708,9 @@ public class LockPatternView extends View { final int patternSizePreHitDetect = mPattern.size(); final int patternSizePreHitDetect = mPattern.size(); Cell hitCell = detectAndAddHit(x, y); Cell hitCell = detectAndAddHit(x, y); final int patternSize = mPattern.size(); final int patternSize = mPattern.size(); if (hitCell != null && (mOnPatternListener != null) && (patternSize == 1)) { if (hitCell != null && patternSize == 1) { mPatternInProgress = true; mPatternInProgress = true; mOnPatternListener.onPatternStart(); notifyPatternStarted(); } } // note current x and y for rubber banding of in progress patterns // note current x and y for rubber banding of in progress patterns final float dx = Math.abs(x - mInProgressX); final float dx = Math.abs(x - mInProgressX); Loading Loading @@ -778,11 +825,17 @@ public class LockPatternView extends View { } } } } private void sendAccessEvent(int resId) { setContentDescription(mContext.getString(resId)); sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); setContentDescription(null); } private void handleActionUp(MotionEvent event) { private void handleActionUp(MotionEvent event) { // report pattern detected // report pattern detected if (!mPattern.isEmpty() && mOnPatternListener != null) { if (!mPattern.isEmpty()) { mPatternInProgress = false; mPatternInProgress = false; mOnPatternListener.onPatternDetected(mPattern); notifyPatternDetected(); invalidate(); invalidate(); } } if (PROFILE_DRAWING) { if (PROFILE_DRAWING) { Loading @@ -798,13 +851,13 @@ public class LockPatternView extends View { final float x = event.getX(); final float x = event.getX(); final float y = event.getY(); final float y = event.getY(); final Cell hitCell = detectAndAddHit(x, y); final Cell hitCell = detectAndAddHit(x, y); if (hitCell != null && mOnPatternListener != null) { if (hitCell != null) { mPatternInProgress = true; mPatternInProgress = true; mPatternDisplayMode = DisplayMode.Correct; mPatternDisplayMode = DisplayMode.Correct; mOnPatternListener.onPatternStart(); notifyPatternStarted(); } else if (mOnPatternListener != null) { } else { mPatternInProgress = false; mPatternInProgress = false; mOnPatternListener.onPatternCleared(); notifyPatternCleared(); } } if (hitCell != null) { if (hitCell != null) { final float startX = getCenterXForColumn(hitCell.column); final float startX = getCenterXForColumn(hitCell.column); Loading
core/res/res/values/strings.xml +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1958,6 +1958,15 @@ <!-- Displayed on lock screen's right tab - turn sound off --> <!-- Displayed on lock screen's right tab - turn sound off --> <string name="lockscreen_sound_off_label">Sound off</string> <string name="lockscreen_sound_off_label">Sound off</string> <!-- Accessibility description sent when user starts drawing a lock pattern. [CHAR LIMIT=NONE] --> <string name="lockscreen_access_pattern_start">Pattern started</string> <!-- Accessibility description sent when the pattern times out and is cleared. [CHAR LIMIT=NONE] --> <string name="lockscreen_access_pattern_cleared">Pattern cleared</string> <!-- Accessibility description sent when user adds a cell to the pattern. [CHAR LIMIT=NONE] --> <string name="lockscreen_access_pattern_cell_added">Cell added</string> <!-- Accessibility description sent when user completes drawing a pattern. [CHAR LIMIT=NONE] --> <string name="lockscreen_access_pattern_detected">Pattern completed</string> <!-- Password keyboard strings. Used by LockScreen and Settings --><skip /> <!-- Password keyboard strings. Used by LockScreen and Settings --><skip /> <!-- Label for "switch to symbols" key. Must be short to fit on key! --> <!-- Label for "switch to symbols" key. Must be short to fit on key! --> <string name="password_keyboard_label_symbol_key">\?123</string> <string name="password_keyboard_label_symbol_key">\?123</string> Loading