Settings: Forward port pattern visibility settings (2/2)
Change-Id: Ic627953c5df854c442671a98b5da539b994da18b
This commit is contained in:
committed by
Michael Bestas
parent
34a8deb417
commit
2739162b84
@@ -42,4 +42,9 @@
|
||||
<string name="lock_pattern_size_5" translatable="false">5 \u00d7 5</string>
|
||||
<string name="lock_pattern_size_6" translatable="false">6 \u00d7 6</string>
|
||||
<string name="lock_settings_picker_pattern_size_message">Choose a pattern size</string>
|
||||
|
||||
<!-- Whether a visible red line will be drawn after the user has drawn the unlock pattern incorrectly -->
|
||||
<string name="lockpattern_settings_enable_error_path_title">Show pattern error</string>
|
||||
<!-- Whether the dots will be drawn when using the lockscreen pattern -->
|
||||
<string name="lockpattern_settings_enable_dots_title">Show pattern dots</string>
|
||||
</resources>
|
||||
|
||||
@@ -27,6 +27,14 @@
|
||||
android:key="visiblepattern"
|
||||
android:title="@string/lockpattern_settings_enable_visible_pattern_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="visible_error_pattern"
|
||||
android:title="@string/lockpattern_settings_enable_error_path_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="visibledots"
|
||||
android:title="@string/lockpattern_settings_enable_dots_title" />
|
||||
|
||||
<!-- available in pin -->
|
||||
<SwitchPreferenceCompat
|
||||
android:key="auto_pin_confirm"
|
||||
@@ -37,8 +45,7 @@
|
||||
android:key="enhancedPinPrivacy"
|
||||
android:title="@string/lockpattern_settings_enhanced_pin_privacy_title"
|
||||
android:summary="@string/lockpattern_settings_enhanced_pin_privacy_summary" />
|
||||
|
||||
|
||||
|
||||
<!-- available in pin/pattern/password -->
|
||||
<com.android.settings.security.screenlock.ProtectedTimeoutListPreference
|
||||
android:key="lock_after_timeout"
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source 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.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;
|
||||
|
||||
public abstract class AbstractPatternSwitchPreferenceController
|
||||
extends AbstractPreferenceController
|
||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
private final String mKey;
|
||||
private final int mUserId;
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
|
||||
public AbstractPatternSwitchPreferenceController(Context context, String key,
|
||||
int userId, LockPatternUtils lockPatternUtils) {
|
||||
super(context);
|
||||
mKey = key;
|
||||
mUserId = userId;
|
||||
mLockPatternUtils = lockPatternUtils;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return isPatternLock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return mKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
((TwoStatePreference) preference).setChecked(isEnabled(mLockPatternUtils, mUserId));
|
||||
}
|
||||
|
||||
private boolean isPatternLock() {
|
||||
return mLockPatternUtils.getCredentialTypeForUser(mUserId)
|
||||
== LockPatternUtils.CREDENTIAL_TYPE_PATTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
setEnabled(mLockPatternUtils, mUserId, (Boolean) newValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract boolean isEnabled(LockPatternUtils utils, int userId);
|
||||
protected abstract void setEnabled(LockPatternUtils utils, int userId, boolean enabled);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source 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.content.Context;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
|
||||
public class PatternDotsVisiblePreferenceController
|
||||
extends AbstractPatternSwitchPreferenceController {
|
||||
private static final String PREF_KEY = "visibledots";
|
||||
|
||||
public PatternDotsVisiblePreferenceController(Context context, int userId,
|
||||
LockPatternUtils lockPatternUtils) {
|
||||
super(context, PREF_KEY, userId, lockPatternUtils);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(LockPatternUtils utils, int userId) {
|
||||
return utils.isVisibleDotsEnabled(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setEnabled(LockPatternUtils utils, int userId, boolean enabled) {
|
||||
utils.setVisibleDotsEnabled(enabled, userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source 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.content.Context;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
|
||||
public class PatternErrorVisiblePreferenceController
|
||||
extends AbstractPatternSwitchPreferenceController {
|
||||
private static final String PREF_KEY = "visible_error_pattern";
|
||||
|
||||
public PatternErrorVisiblePreferenceController(Context context, int userId,
|
||||
LockPatternUtils lockPatternUtils) {
|
||||
super(context, PREF_KEY, userId, lockPatternUtils);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled(LockPatternUtils utils, int userId) {
|
||||
return utils.isShowErrorPath(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setEnabled(LockPatternUtils utils, int userId, boolean enabled) {
|
||||
utils.setShowErrorPath(enabled, userId);
|
||||
}
|
||||
}
|
||||
@@ -18,52 +18,23 @@ package com.android.settings.security.screenlock;
|
||||
|
||||
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;
|
||||
|
||||
public class PatternVisiblePreferenceController extends AbstractPreferenceController
|
||||
implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
public class PatternVisiblePreferenceController extends AbstractPatternSwitchPreferenceController {
|
||||
private static final String PREF_KEY = "visiblepattern";
|
||||
|
||||
private final int mUserId;
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
|
||||
public PatternVisiblePreferenceController(Context context, int userId,
|
||||
LockPatternUtils lockPatternUtils) {
|
||||
super(context);
|
||||
mUserId = userId;
|
||||
mLockPatternUtils = lockPatternUtils;
|
||||
super(context, PREF_KEY, userId, lockPatternUtils);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return isPatternLock();
|
||||
protected boolean isEnabled(LockPatternUtils utils, int userId) {
|
||||
return utils.isVisiblePatternEnabled(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return PREF_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
((TwoStatePreference) preference).setChecked(
|
||||
mLockPatternUtils.isVisiblePatternEnabled(mUserId));
|
||||
}
|
||||
|
||||
private boolean isPatternLock() {
|
||||
return mLockPatternUtils.getCredentialTypeForUser(mUserId)
|
||||
== LockPatternUtils.CREDENTIAL_TYPE_PATTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mLockPatternUtils.setVisiblePatternEnabled((Boolean) newValue, mUserId);
|
||||
return true;
|
||||
protected void setEnabled(LockPatternUtils utils, int userId, boolean enabled) {
|
||||
utils.setVisiblePatternEnabled(enabled, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,10 @@ public class ScreenLockSettings extends DashboardFragment
|
||||
context, MY_USER_ID, lockPatternUtils));
|
||||
controllers.add(new PinPrivacyPreferenceController(
|
||||
context, MY_USER_ID, lockPatternUtils));
|
||||
controllers.add(new PatternErrorVisiblePreferenceController(
|
||||
context, MY_USER_ID, lockPatternUtils));
|
||||
controllers.add(new PatternDotsVisiblePreferenceController(
|
||||
context, MY_USER_ID, lockPatternUtils));
|
||||
controllers.add(new PowerButtonInstantLockPreferenceController(
|
||||
context, MY_USER_ID, lockPatternUtils));
|
||||
controllers.add(new LockAfterTimeoutPreferenceController(
|
||||
|
||||
Reference in New Issue
Block a user