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

Commit 5230b524 authored by Danesh M's avatar Danesh M Committed by Gerrit Code Review
Browse files

LockscreenPattern : Toggle dots/error pattern visibility (1/2)

Give user ability to hide error pattern / dots.

Part 2 : http://review.cyanogenmod.com/#/c/21543/

Patchset 2 : Minor formatting

Change-Id: Idda9539b213eb78391b725fcd89ff5d93c8090ce
parent 8570b2d2
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -802,6 +802,8 @@ public final class Settings {
            MOVED_TO_SECURE.add(Secure.LOCK_BIOMETRIC_WEAK_FLAGS);
            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_ENABLED);
            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_VISIBLE);
            MOVED_TO_SECURE.add(Secure.LOCK_SHOW_ERROR_PATH);
            MOVED_TO_SECURE.add(Secure.LOCK_DOTS_VISIBLE);
            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
            MOVED_TO_SECURE.add(Secure.LOGGING_ID);
            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_ENABLED);
@@ -3114,6 +3116,8 @@ public final class Settings {
            MOVED_TO_LOCK_SETTINGS = new HashSet<String>(3);
            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_ENABLED);
            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_VISIBLE);
            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_SHOW_ERROR_PATH);
            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_DOTS_VISIBLE);
            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_BEFORE_UNLOCK);
        }
@@ -3587,6 +3591,16 @@ public final class Settings {
        public static final String LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED =
            "lock_pattern_tactile_feedback_enabled";

        /**
         * Whether lock pattern will show dots (0 = false, 1 = true)
         */
        public static final String LOCK_DOTS_VISIBLE = "lock_pattern_dotsvisible";

        /**
         * Whether lockscreen error pattern is visible (0 = false, 1 = true)
         */
        public static final String LOCK_SHOW_ERROR_PATH = "lock_pattern_show_error_path";

        /**
         * This preference allows the device to be locked given time after screen goes off,
         * subject to current DeviceAdmin policy limits.
+16 −0
Original line number Diff line number Diff line
@@ -918,6 +918,22 @@ public class LockPatternUtils {
        setBoolean(Settings.Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED, enabled);
    }

    public void setVisibleDotsEnabled(boolean enabled) {
        setBoolean(Settings.Secure.LOCK_DOTS_VISIBLE, enabled);
    }

    public boolean isVisibleDotsEnabled() {
        return getBoolean(Settings.Secure.LOCK_DOTS_VISIBLE, true);
    }

    public void setShowErrorPath(boolean enabled) {
        setBoolean(Settings.Secure.LOCK_SHOW_ERROR_PATH, enabled);
    }

    public boolean isShowErrorPath() {
        return getBoolean(Settings.Secure.LOCK_SHOW_ERROR_PATH, true);
    }

    /**
     * Set and store the lockout deadline, meaning the user can't attempt his/her unlock
     * pattern until the deadline has passed.
+46 −5
Original line number Diff line number Diff line
@@ -103,6 +103,9 @@ public class LockPatternView extends View {
    private boolean mEnableHapticFeedback = true;
    private boolean mPatternInProgress = false;

    private boolean mVisibleDots = true;
    private boolean mShowErrorPath = true;

    private float mDiameterFactor = 0.10f; // TODO: move to attrs
    private final int mStrokeAlpha = 128;
    private float mHitFactor = 0.6f;
@@ -327,6 +330,22 @@ public class LockPatternView extends View {
        mInStealthMode = inStealthMode;
    }

    public void setVisibleDots(boolean visibleDots) {
        mVisibleDots = visibleDots;
    }

    public boolean isVisibleDots() {
        return mVisibleDots;
    }

    public void setShowErrorPath(boolean showErrorPath) {
        mShowErrorPath = showErrorPath;
    }

    public boolean isShowErrorPath() {
        return mShowErrorPath;
    }

    /**
     * Set whether the view will use tactile feedback.  If true, there will be
     * tactile feedback as the user enters the pattern.
@@ -944,6 +963,7 @@ 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);
@@ -954,7 +974,8 @@ public class LockPatternView extends View {
        // 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;
        final boolean drawPath = ((!mInStealthMode && mPatternDisplayMode != DisplayMode.Wrong)
                || (mPatternDisplayMode == DisplayMode.Wrong && mShowErrorPath));

        // draw the arrows associated with the path (unless the user is in progress, and
        // we are in stealth mode)
@@ -1057,8 +1078,10 @@ public class LockPatternView extends View {
    private void drawCircle(Canvas canvas, int leftX, int topY, boolean partOfPattern) {
        Bitmap outerCircle;
        Bitmap innerCircle;

        if (!partOfPattern || (mInStealthMode)) {
        if (!partOfPattern || mInStealthMode || (!mShowErrorPath && mPatternDisplayMode == DisplayMode.Wrong)) {
            if (!mVisibleDots) {
                return;
            }
            // unselected circle
            outerCircle = mBitmapCircleDefault;
            innerCircle = mBitmapBtnDefault;
@@ -1118,7 +1141,7 @@ public class LockPatternView extends View {
        return new SavedState(superState,
                LockPatternUtils.patternToString(mPattern),
                mPatternDisplayMode.ordinal(),
                mInputEnabled, mInStealthMode, mEnableHapticFeedback);
                mInputEnabled, mInStealthMode, mEnableHapticFeedback, mVisibleDots, mShowErrorPath);
    }

    @Override
@@ -1132,6 +1155,8 @@ public class LockPatternView extends View {
        mInputEnabled = ss.isInputEnabled();
        mInStealthMode = ss.isInStealthMode();
        mEnableHapticFeedback = ss.isTactileFeedbackEnabled();
        mVisibleDots = ss.isVisibleDots();
        mShowErrorPath = ss.isShowErrorPath();
    }

    /**
@@ -1144,18 +1169,22 @@ public class LockPatternView extends View {
        private final boolean mInputEnabled;
        private final boolean mInStealthMode;
        private final boolean mTactileFeedbackEnabled;
        private final boolean mVisibleDots;
        private final boolean mShowErrorPath;

        /**
         * Constructor called from {@link LockPatternView#onSaveInstanceState()}
         */
        private SavedState(Parcelable superState, String serializedPattern, int displayMode,
                boolean inputEnabled, boolean inStealthMode, boolean tactileFeedbackEnabled) {
                boolean inputEnabled, boolean inStealthMode, boolean tactileFeedbackEnabled, boolean visibleDots, boolean showErrorPath) {
            super(superState);
            mSerializedPattern = serializedPattern;
            mDisplayMode = displayMode;
            mInputEnabled = inputEnabled;
            mInStealthMode = inStealthMode;
            mTactileFeedbackEnabled = tactileFeedbackEnabled;
            mVisibleDots = visibleDots;
            mShowErrorPath = showErrorPath;
        }

        /**
@@ -1168,6 +1197,8 @@ public class LockPatternView extends View {
            mInputEnabled = (Boolean) in.readValue(null);
            mInStealthMode = (Boolean) in.readValue(null);
            mTactileFeedbackEnabled = (Boolean) in.readValue(null);
            mVisibleDots = (Boolean) in.readValue(null);
            mShowErrorPath = (Boolean) in.readValue(null);
        }

        public String getSerializedPattern() {
@@ -1190,6 +1221,14 @@ public class LockPatternView extends View {
            return mTactileFeedbackEnabled;
        }

        public boolean isVisibleDots() {
            return mVisibleDots;
        }

        public boolean isShowErrorPath() {
            return mShowErrorPath;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            super.writeToParcel(dest, flags);
@@ -1198,6 +1237,8 @@ public class LockPatternView extends View {
            dest.writeValue(mInputEnabled);
            dest.writeValue(mInStealthMode);
            dest.writeValue(mTactileFeedbackEnabled);
            dest.writeValue(mVisibleDots);
            dest.writeValue(mShowErrorPath);
        }

        public static final Parcelable.Creator<SavedState> CREATOR =
+2 −0
Original line number Diff line number Diff line
@@ -383,6 +383,8 @@ public class LockSettingsService extends ILockSettings.Stub {
        Secure.LOCK_PATTERN_ENABLED,
        Secure.LOCK_BIOMETRIC_WEAK_FLAGS,
        Secure.LOCK_PATTERN_VISIBLE,
        Secure.LOCK_SHOW_ERROR_PATH,
        Secure.LOCK_DOTS_VISIBLE,
        Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED,
        Secure.LOCK_BEFORE_UNLOCK
        };
+2 −0
Original line number Diff line number Diff line
@@ -628,6 +628,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
           String[] settingsToMove = {
                   Secure.LOCK_PATTERN_ENABLED,
                   Secure.LOCK_PATTERN_VISIBLE,
                   Secure.LOCK_SHOW_ERROR_PATH,
                   Secure.LOCK_DOTS_VISIBLE,
                   Secure.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED,
                   "lockscreen.password_type",
                   "lockscreen.lockoutattemptdeadline",
Loading