From e8c39274610dc0a92c00d6e01c31434e6afdebfb Mon Sep 17 00:00:00 2001 From: Vojtech Bocek Date: Sun, 15 Mar 2015 15:25:37 +0100 Subject: Fix GUIPatternPassword when the pattern crosses already visited dots Change-Id: I59b3f8c5604c036dbc74c020ee21aeeef28132d3 Signed-off-by: Vojtech Bocek --- gui/patternpassword.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/gui/patternpassword.cpp b/gui/patternpassword.cpp index 4fc781298..ed152851f 100644 --- a/gui/patternpassword.cpp +++ b/gui/patternpassword.cpp @@ -226,19 +226,24 @@ void GUIPatternPassword::ConnectIntermediateDots(int dot_idx) return; const int last_dot = mConnectedDots[mConnectedDotsLen-1]; + int mid = -1; // The line is vertical and has crossed a point in the middle - if(dot_idx%3 == last_dot%3 && abs(dot_idx - last_dot) > 3) - ConnectDot(3 + dot_idx%3); + if(dot_idx%3 == last_dot%3 && abs(dot_idx - last_dot) > 3) { + mid = 3 + dot_idx%3; // the line is horizontal and has crossed a point in the middle - else if(dot_idx/3 == last_dot/3 && abs(dot_idx - last_dot) > 1) - ConnectDot((dot_idx/3)*3 + 1); + } else if(dot_idx/3 == last_dot/3 && abs(dot_idx - last_dot) > 1) { + mid = (dot_idx/3)*3 + 1; // the line is diagonal and has crossed the middle point - else if((dot_idx == 0 && last_dot == 8) || (dot_idx == 8 && last_dot == 0) || - (dot_idx == 2 && last_dot == 6) || (dot_idx == 6 && last_dot == 2)) - { - ConnectDot(4); + } else if((dot_idx == 0 && last_dot == 8) || (dot_idx == 8 && last_dot == 0) || + (dot_idx == 2 && last_dot == 6) || (dot_idx == 6 && last_dot == 2)) { + mid = 4; + } else { + return; } + + if(!DotUsed(mid)) + ConnectDot(mid); } int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y) -- cgit v1.2.3