Settings: Add option to scramble pin layout when unlocking (1/2).
Change-Id: I3e2c200a0a31d3c765831bc30280029a50c88051
This commit is contained in:
@@ -60,6 +60,10 @@
|
|||||||
<string name="show_navbar_hint_title">Navigation hint</string>
|
<string name="show_navbar_hint_title">Navigation hint</string>
|
||||||
<string name="show_navbar_hint_summary">Show navigation hint bar at the bottom of the screen</string>
|
<string name="show_navbar_hint_summary">Show navigation hint bar at the bottom of the screen</string>
|
||||||
|
|
||||||
|
<!-- PIN scramble -->
|
||||||
|
<string name="unlock_scramble_pin_layout_title">Scramble layout</string>
|
||||||
|
<string name="unlock_scramble_pin_layout_summary">Scramble PIN layout when unlocking device</string>
|
||||||
|
|
||||||
<!-- Touchscreen gesture settings -->
|
<!-- Touchscreen gesture settings -->
|
||||||
<string name="touchscreen_gesture_settings_title">Touchscreen gestures</string>
|
<string name="touchscreen_gesture_settings_title">Touchscreen gestures</string>
|
||||||
<string name="touchscreen_gesture_settings_summary">Perform various touchscreen gestures for quick actions</string>
|
<string name="touchscreen_gesture_settings_summary">Perform various touchscreen gestures for quick actions</string>
|
||||||
|
|||||||
@@ -59,4 +59,10 @@
|
|||||||
android:key="power_button_instantly_locks"
|
android:key="power_button_instantly_locks"
|
||||||
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks" />
|
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks" />
|
||||||
|
|
||||||
|
<!-- Lineage additions, available in pin -->
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:key="lockscreen_scramble_pin_layout"
|
||||||
|
android:title="@string/unlock_scramble_pin_layout_title"
|
||||||
|
android:summary="@string/unlock_scramble_pin_layout_summary" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The LineageOS Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.security.screenlock;
|
||||||
|
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.TwoStatePreference;
|
||||||
|
|
||||||
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
|
|
||||||
|
import lineageos.providers.LineageSettings;
|
||||||
|
|
||||||
|
public class PinScramblePreferenceController extends AbstractPreferenceController
|
||||||
|
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
|
static final String KEY_LOCKSCREEN_SCRAMBLE_PIN_LAYOUT = "lockscreen_scramble_pin_layout";
|
||||||
|
|
||||||
|
private final int mUserId;
|
||||||
|
private final LockPatternUtils mLockPatternUtils;
|
||||||
|
|
||||||
|
public PinScramblePreferenceController(Context context, int userId,
|
||||||
|
LockPatternUtils lockPatternUtils) {
|
||||||
|
super(context);
|
||||||
|
mUserId = userId;
|
||||||
|
mLockPatternUtils = lockPatternUtils;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAvailable() {
|
||||||
|
return isPinLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPreferenceKey() {
|
||||||
|
return KEY_LOCKSCREEN_SCRAMBLE_PIN_LAYOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateState(Preference preference) {
|
||||||
|
((TwoStatePreference) preference).setChecked(LineageSettings.System.getInt(
|
||||||
|
mContext.getContentResolver(),
|
||||||
|
LineageSettings.System.LOCKSCREEN_PIN_SCRAMBLE_LAYOUT,
|
||||||
|
0) == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPinLock() {
|
||||||
|
int quality = mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId);
|
||||||
|
boolean hasPin = quality == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC ||
|
||||||
|
quality == DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX;
|
||||||
|
return mLockPatternUtils.isSecure(mUserId) && hasPin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
LineageSettings.System.putInt(
|
||||||
|
mContext.getContentResolver(),
|
||||||
|
LineageSettings.System.LOCKSCREEN_PIN_SCRAMBLE_LAYOUT,
|
||||||
|
(Boolean) newValue ? 1 : 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -92,6 +92,8 @@ public class ScreenLockSettings extends DashboardFragment
|
|||||||
context, MY_USER_ID, lockPatternUtils));
|
context, MY_USER_ID, lockPatternUtils));
|
||||||
controllers.add(new AutoPinConfirmPreferenceController(
|
controllers.add(new AutoPinConfirmPreferenceController(
|
||||||
context, MY_USER_ID, lockPatternUtils, parent));
|
context, MY_USER_ID, lockPatternUtils, parent));
|
||||||
|
controllers.add(new PinScramblePreferenceController(
|
||||||
|
context, MY_USER_ID, lockPatternUtils));
|
||||||
controllers.add(new OwnerInfoPreferenceController(context, parent));
|
controllers.add(new OwnerInfoPreferenceController(context, parent));
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user