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

Commit c9b0de8a authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Gerrit Code Review
Browse files

Merge "LockscreenPattern : Toggle dots/error pattern visibility (1/2)" into cm-10.1

parents b5845790 949758a0
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -900,6 +900,8 @@ public final class Settings {
            MOVED_TO_SECURE.add(Secure.LOCK_BIOMETRIC_WEAK_FLAGS);
            MOVED_TO_SECURE.add(Secure.LOCK_BIOMETRIC_WEAK_FLAGS);
            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_ENABLED);
            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_ENABLED);
            MOVED_TO_SECURE.add(Secure.LOCK_PATTERN_VISIBLE);
            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.LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED);
            MOVED_TO_SECURE.add(Secure.LOGGING_ID);
            MOVED_TO_SECURE.add(Secure.LOGGING_ID);
            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_ENABLED);
            MOVED_TO_SECURE.add(Secure.PARENTAL_CONTROL_ENABLED);
@@ -3367,6 +3369,8 @@ public final class Settings {
            MOVED_TO_LOCK_SETTINGS = new HashSet<String>(3);
            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_ENABLED);
            MOVED_TO_LOCK_SETTINGS.add(Secure.LOCK_PATTERN_VISIBLE);
            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_PATTERN_TACTILE_FEEDBACK_ENABLED);


            MOVED_TO_GLOBAL = new HashSet<String>();
            MOVED_TO_GLOBAL = new HashSet<String>();
@@ -4003,6 +4007,16 @@ public final class Settings {
        public static final String
        public static final String
                LOCK_PATTERN_TACTILE_FEEDBACK_ENABLED = "lock_pattern_tactile_feedback_enabled";
                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,
         * This preference allows the device to be locked given time after screen goes off,
         * subject to current DeviceAdmin policy limits.
         * subject to current DeviceAdmin policy limits.
+16 −0
Original line number Original line Diff line number Diff line
@@ -986,6 +986,22 @@ public class LockPatternUtils {
        setLong(Settings.Secure.LOCK_PATTERN_SIZE, size);
        setLong(Settings.Secure.LOCK_PATTERN_SIZE, size);
    }
    }


    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
     * Set and store the lockout deadline, meaning the user can't attempt his/her unlock
     * pattern until the deadline has passed.
     * pattern until the deadline has passed.
+45 −5
Original line number Original line Diff line number Diff line
@@ -101,6 +101,8 @@ public class LockPatternView extends View {
    private boolean mInStealthMode = false;
    private boolean mInStealthMode = false;
    private boolean mEnableHapticFeedback = true;
    private boolean mEnableHapticFeedback = true;
    private boolean mPatternInProgress = false;
    private boolean mPatternInProgress = false;
    private boolean mVisibleDots = true;
    private boolean mShowErrorPath = true;


    private float mDiameterFactor = 0.10f; // TODO: move to attrs
    private float mDiameterFactor = 0.10f; // TODO: move to attrs
    private final int mStrokeAlpha = 128;
    private final int mStrokeAlpha = 128;
@@ -329,6 +331,22 @@ public class LockPatternView extends View {
        mInStealthMode = inStealthMode;
        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
     * Set whether the view will use tactile feedback.  If true, there will be
     * tactile feedback as the user enters the pattern.
     * tactile feedback as the user enters the pattern.
@@ -964,7 +982,8 @@ public class LockPatternView extends View {
        // only the last segment of the path should be computed here
        // only the last segment of the path should be computed here
        // draw the path of the pattern (unless the user is in progress, and
        // draw the path of the pattern (unless the user is in progress, and
        // we are in stealth mode)
        // we are in stealth mode)
        final boolean drawPath = (!mInStealthMode || mPatternDisplayMode == DisplayMode.Wrong);
        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
        // draw the arrows associated with the path (unless the user is in progress, and
        // we are in stealth mode)
        // we are in stealth mode)
@@ -1067,8 +1086,11 @@ public class LockPatternView extends View {
    private void drawCircle(Canvas canvas, int leftX, int topY, boolean partOfPattern) {
    private void drawCircle(Canvas canvas, int leftX, int topY, boolean partOfPattern) {
        Bitmap outerCircle;
        Bitmap outerCircle;
        Bitmap innerCircle;
        Bitmap innerCircle;

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


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


    /**
    /**
@@ -1145,13 +1169,15 @@ public class LockPatternView extends View {
        private final boolean mInputEnabled;
        private final boolean mInputEnabled;
        private final boolean mInStealthMode;
        private final boolean mInStealthMode;
        private final boolean mTactileFeedbackEnabled;
        private final boolean mTactileFeedbackEnabled;
        private final boolean mVisibleDots;
        private final boolean mShowErrorPath;


        /**
        /**
         * Constructor called from {@link LockPatternView#onSaveInstanceState()}
         * Constructor called from {@link LockPatternView#onSaveInstanceState()}
         */
         */
        private SavedState(Parcelable superState, String serializedPattern, int displayMode,
        private SavedState(Parcelable superState, String serializedPattern, int displayMode,
                byte patternSize, boolean inputEnabled, boolean inStealthMode,
                byte patternSize, boolean inputEnabled, boolean inStealthMode,
                boolean tactileFeedbackEnabled) {
                boolean tactileFeedbackEnabled, boolean visibleDots, boolean showErrorPath) {
            super(superState);
            super(superState);
            mSerializedPattern = serializedPattern;
            mSerializedPattern = serializedPattern;
            mDisplayMode = displayMode;
            mDisplayMode = displayMode;
@@ -1159,6 +1185,8 @@ public class LockPatternView extends View {
            mInputEnabled = inputEnabled;
            mInputEnabled = inputEnabled;
            mInStealthMode = inStealthMode;
            mInStealthMode = inStealthMode;
            mTactileFeedbackEnabled = tactileFeedbackEnabled;
            mTactileFeedbackEnabled = tactileFeedbackEnabled;
            mVisibleDots = visibleDots;
            mShowErrorPath = showErrorPath;
        }
        }


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


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


        public boolean isVisibleDots() {
            return mVisibleDots;
        }

        public boolean isShowErrorPath() {
            return mShowErrorPath;
        }

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


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