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

Commit fd5bbdab authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Fix 5772: Pattern screen lock shows incorrect attempts" into ics

parents 7d1ce115 ab6d6190
Loading
Loading
Loading
Loading
+33 −2
Original line number Diff line number Diff line
@@ -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();