summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2012-07-27 01:42:45 +0200
committerJorge Ruesga <jorge@ruesga.com>2012-07-27 01:42:45 +0200
commitab6d6190174a163dbd688eb28e3074eabff4afb1 (patch)
tree502ae309fce0c04813731fa6d6b348aac184ccfc
parentec2df26d40daef188108422f24c19a72c03e6d48 (diff)
downloadframeworks_base-ab6d6190174a163dbd688eb28e3074eabff4afb1.zip
frameworks_base-ab6d6190174a163dbd688eb28e3074eabff4afb1.tar.gz
frameworks_base-ab6d6190174a163dbd688eb28e3074eabff4afb1.tar.bz2
Fix 5772: Pattern screen lock shows incorrect attempts
Hide incorrect draw paths. If the pattern is incorrect a message is displayed instead of incorrect pattern. Change-Id: I6183bfda22c266e6d5ecd100efd23f1b802b8fc2
-rw-r--r--core/java/com/android/internal/widget/LockPatternView.java35
1 files changed, 33 insertions, 2 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternView.java b/core/java/com/android/internal/widget/LockPatternView.java
index 0d9cf9a..5f756db 100644
--- a/core/java/com/android/internal/widget/LockPatternView.java
+++ b/core/java/com/android/internal/widget/LockPatternView.java
@@ -64,6 +64,7 @@ public class LockPatternView extends View {
private Paint mPaint = new Paint();
private Paint mPathPaint = new Paint();
+ private Paint mMsgPaint = new Paint();
// TODO: make this common with PhoneWindow
static final int STATUS_BAR_HEIGHT = 25;
@@ -115,6 +116,8 @@ public class LockPatternView extends View {
private Bitmap mBitmapCircleGreen;
private Bitmap mBitmapCircleRed;
+ private String mIncorrectPatternMsg;
+
private Bitmap mBitmapArrowGreenUp;
private Bitmap mBitmapArrowRedUp;
@@ -267,6 +270,12 @@ public class LockPatternView extends View {
mPathPaint.setStrokeJoin(Paint.Join.ROUND);
mPathPaint.setStrokeCap(Paint.Cap.ROUND);
+ mMsgPaint.setAntiAlias(true);
+ mMsgPaint.setDither(true);
+ mMsgPaint.setColor(Color.RED); // TODO this should be from the style
+ mMsgPaint.setTextAlign(Paint.Align.CENTER);
+
+
// lot's of bitmaps!
mBitmapBtnDefault = getBitmapFor(R.drawable.btn_code_lock_default_holo);
mBitmapBtnTouched = getBitmapFor(R.drawable.btn_code_lock_touched_holo);
@@ -286,6 +295,8 @@ public class LockPatternView extends View {
mBitmapHeight = Math.max(mBitmapHeight, bitmap.getHeight());
}
+ // incorrect pattern message
+ mIncorrectPatternMsg = context.getResources().getString(R.string.lockscreen_pattern_wrong);
}
private Bitmap getBitmapFor(int resId) {
@@ -452,6 +463,9 @@ public class LockPatternView extends View {
final int height = h - mPaddingTop - mPaddingBottom;
mSquareHeight = height / 3.0f;
+
+ // Try to set a message size relative to square size
+ mMsgPaint.setTextSize(mSquareHeight / 6);
}
private int resolveMeasured(int measureSpec, int desired)
@@ -930,11 +944,17 @@ public class LockPatternView extends View {
}
}
+ // If lock pattern is in stealth mode and the pattern was wrong
+ // show a text advising of the pattern failure
+ float msgLeftX = paddingLeft + squareWidth + (squareWidth / 2);
+ float msgTopY = paddingTop + (squareHeight * 2);
+ drawMsg(canvas, (int) msgLeftX, (int) msgTopY);
+
// TODO: the path should be created and cached every time we hit-detect a cell
// only the last segment of the path should be computed here
// draw the path of the pattern (unless the user is in progress, and
// we are in stealth mode)
- final boolean drawPath = (!mInStealthMode || mPatternDisplayMode == DisplayMode.Wrong);
+ final boolean drawPath = !mInStealthMode;
// draw the arrows associated with the path (unless the user is in progress, and
// we are in stealth mode)
@@ -1038,7 +1058,7 @@ public class LockPatternView extends View {
Bitmap outerCircle;
Bitmap innerCircle;
- if (!partOfPattern || (mInStealthMode && mPatternDisplayMode != DisplayMode.Wrong)) {
+ if (!partOfPattern || (mInStealthMode)) {
// unselected circle
outerCircle = mBitmapCircleDefault;
innerCircle = mBitmapBtnDefault;
@@ -1081,6 +1101,17 @@ public class LockPatternView extends View {
canvas.drawBitmap(innerCircle, mCircleMatrix, mPaint);
}
+ /**
+ * @param canvas
+ * @param leftX
+ * @param topY
+ */
+ private void drawMsg(Canvas canvas, int leftX, int topY) {
+ if (mInStealthMode && mPatternDisplayMode == DisplayMode.Wrong) {
+ canvas.drawText(mIncorrectPatternMsg, leftX, topY, mMsgPaint);
+ }
+ }
+
@Override
protected Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();