Settings: Forward port lock pattern grid size (2/2)
Co-authored-by: Alberto97 <albertop2197@gmail.com> Co-authored-by: d34d <clark@cyngn.com> Co-authored-by: Dhina17 <dhinalogu@gmail.com> Co-authored-by: LuK1337 <priv.luk@gmail.com> Co-authored-by: Roman Birg <roman@cyngn.com> Change-Id: I7078d703c218cd096d9b77c003a94b52fbce6322
This commit is contained in:
committed by
Michael Bestas
parent
7625635bb8
commit
34a8deb417
@@ -3123,6 +3123,10 @@
|
||||
android:enableOnBackInvokedCallback="false"
|
||||
android:excludeFromRecents="true" />
|
||||
|
||||
<activity android:name=".password.ChooseLockPatternSize"
|
||||
android:exported="false"
|
||||
android:theme="@style/GlifTheme.Light" />
|
||||
|
||||
<activity android:name=".password.SetupChooseLockPattern"
|
||||
android:exported="false"
|
||||
android:enableOnBackInvokedCallback="false"
|
||||
|
||||
26
res/drawable/ic_security_pattern_3x3.xml
Normal file
26
res/drawable/ic_security_pattern_3x3.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<!--
|
||||
Copyright (C) 2016 The CyanogenMod 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M4,17.268C3.402,17.613 3,18.26 3,19C3,20.105 3.895,21 5,21C5.74,21 6.387,20.598 6.732,20L9.268,20C9.613,20.598 10.26,21 11,21C12.105,21 13,20.105 13,19C13,17.895 12.105,17 11,17C10.26,17 9.613,17.402 9.268,18L6.732,18C6.557,17.696 6.304,17.443 6,17.268L6,14.732C6.598,14.387 7,13.74 7,13C7,11.895 6.105,11 5,11C3.895,11 3,11.895 3,13C3,13.74 3.402,14.387 4,14.732L4,17.268ZM21,11L21,9.5C21,8.67 20.33,8 19.5,8C20.33,8 21,7.33 21,6.5L21,5C21,3.89 20.1,3 19,3L15,3L15,5L19,5L19,7L17,7L17,9L19,9L19,11L15,11L15,13L19,13C20.1,13 21,12.11 21,11ZM5,9C6.105,9 7,8.105 7,7C7,5.895 6.105,5 5,5C3.895,5 3,5.895 3,7C3,8.105 3.895,9 5,9ZM11,9C12.105,9 13,8.105 13,7C13,5.895 12.105,5 11,5C9.895,5 9,5.895 9,7C9,8.105 9.895,9 11,9ZM11,15C12.105,15 13,14.105 13,13C13,11.895 12.105,11 11,11C9.895,11 9,11.895 9,13C9,14.105 9.895,15 11,15ZM17,21C18.105,21 19,20.105 19,19C19,17.895 18.105,17 17,17C15.895,17 15,17.895 15,19C15,20.105 15.895,21 17,21Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillColor="#777777"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
26
res/drawable/ic_security_pattern_4x4.xml
Normal file
26
res/drawable/ic_security_pattern_4x4.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<!--
|
||||
Copyright (C) 2016 The CyanogenMod 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M4,17.268C3.402,17.613 3,18.26 3,19C3,20.105 3.895,21 5,21C5.74,21 6.387,20.598 6.732,20L9.268,20C9.613,20.598 10.26,21 11,21C12.105,21 13,20.105 13,19C13,17.895 12.105,17 11,17C10.26,17 9.613,17.402 9.268,18L6.732,18C6.557,17.696 6.304,17.443 6,17.268L6,14.732C6.598,14.387 7,13.74 7,13C7,11.895 6.105,11 5,11C3.895,11 3,11.895 3,13C3,13.74 3.402,14.387 4,14.732L4,17.268ZM21,13L21,3L19,3L19,7L17,7L17,3L15,3L15,9L19,9L19,13L21,13ZM5,9C6.105,9 7,8.105 7,7C7,5.895 6.105,5 5,5C3.895,5 3,5.895 3,7C3,8.105 3.895,9 5,9ZM11,9C12.105,9 13,8.105 13,7C13,5.895 12.105,5 11,5C9.895,5 9,5.895 9,7C9,8.105 9.895,9 11,9ZM11,15C12.105,15 13,14.105 13,13C13,11.895 12.105,11 11,11C9.895,11 9,11.895 9,13C9,14.105 9.895,15 11,15ZM17,21C18.105,21 19,20.105 19,19C19,17.895 18.105,17 17,17C15.895,17 15,17.895 15,19C15,20.105 15.895,21 17,21Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillColor="#777777"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
26
res/drawable/ic_security_pattern_5x5.xml
Normal file
26
res/drawable/ic_security_pattern_5x5.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<!--
|
||||
Copyright (C) 2016 The CyanogenMod 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M4,17.268C3.402,17.613 3,18.26 3,19C3,20.105 3.895,21 5,21C5.74,21 6.387,20.598 6.732,20L9.268,20C9.613,20.598 10.26,21 11,21C12.105,21 13,20.105 13,19C13,17.895 12.105,17 11,17C10.26,17 9.613,17.402 9.268,18L6.732,18C6.557,17.696 6.304,17.443 6,17.268L6,14.732C6.598,14.387 7,13.74 7,13C7,11.895 6.105,11 5,11C3.895,11 3,11.895 3,13C3,13.74 3.402,14.387 4,14.732L4,17.268ZM21,11L21,9C21,7.89 20.1,7 19,7L17,7L17,5L21,5L21,3L15,3L15,9L19,9L19,11L15,11L15,13L19,13C20.1,13 21,12.11 21,11ZM5,9C6.105,9 7,8.105 7,7C7,5.895 6.105,5 5,5C3.895,5 3,5.895 3,7C3,8.105 3.895,9 5,9ZM11,9C12.105,9 13,8.105 13,7C13,5.895 12.105,5 11,5C9.895,5 9,5.895 9,7C9,8.105 9.895,9 11,9ZM11,15C12.105,15 13,14.105 13,13C13,11.895 12.105,11 11,11C9.895,11 9,11.895 9,13C9,14.105 9.895,15 11,15ZM17,21C18.105,21 19,20.105 19,19C19,17.895 18.105,17 17,17C15.895,17 15,17.895 15,19C15,20.105 15.895,21 17,21Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillColor="#777777"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
26
res/drawable/ic_security_pattern_6x6.xml
Normal file
26
res/drawable/ic_security_pattern_6x6.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<!--
|
||||
Copyright (C) 2016 The CyanogenMod 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M17,13L19,13C20.1,13 21,12.11 21,11L21,9C21,7.89 20.1,7 19,7L17,7L17,5L21,5L21,3L17,3C15.9,3 15,3.89 15,5L15,11C15,12.11 15.9,13 17,13L17,13ZM4,17.268C3.402,17.613 3,18.26 3,19C3,20.105 3.895,21 5,21C5.74,21 6.387,20.598 6.732,20L9.268,20C9.613,20.598 10.26,21 11,21C12.105,21 13,20.105 13,19C13,17.895 12.105,17 11,17C10.26,17 9.613,17.402 9.268,18L6.732,18C6.557,17.696 6.304,17.443 6,17.268L6,14.732C6.598,14.387 7,13.74 7,13C7,11.895 6.105,11 5,11C3.895,11 3,11.895 3,13C3,13.74 3.402,14.387 4,14.732L4,17.268ZM17,9L19,9L19,11L17,11L17,9ZM5,9C6.105,9 7,8.105 7,7C7,5.895 6.105,5 5,5C3.895,5 3,5.895 3,7C3,8.105 3.895,9 5,9ZM11,9C12.105,9 13,8.105 13,7C13,5.895 12.105,5 11,5C9.895,5 9,5.895 9,7C9,8.105 9.895,9 11,9ZM11,15C12.105,15 13,14.105 13,13C13,11.895 12.105,11 11,11C9.895,11 9,11.895 9,13C9,14.105 9.895,15 11,15ZM17,21C18.105,21 19,20.105 19,19C19,17.895 18.105,17 17,17C15.895,17 15,17.895 15,19C15,20.105 15.895,21 17,21Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillColor="#777777"
|
||||
android:strokeWidth="1"/>
|
||||
</vector>
|
||||
@@ -35,4 +35,11 @@
|
||||
<string name="show_dev_on_cm">You have enabled development settings!</string>
|
||||
<!-- [CHAR LIMIT=NONE] Device Info screen. Okay we get it, stop pressing, you already have it on -->
|
||||
<string name="show_dev_already_cm">No need, you have already enabled development settings.</string>
|
||||
|
||||
<!-- Lock screen pattern size -->
|
||||
<string name="lock_pattern_size_3" translatable="false">3 \u00d7 3</string>
|
||||
<string name="lock_pattern_size_4" translatable="false">4 \u00d7 4</string>
|
||||
<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>
|
||||
</resources>
|
||||
|
||||
23
res/values/lineage_styles.xml
Normal file
23
res/values/lineage_styles.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<resources>
|
||||
<style name="LockPatternSizeHeaderStyle" parent="android:style/TextAppearance.Material.Subhead">
|
||||
<item name="android:paddingTop">16dp</item>
|
||||
<item name="android:textColor">@color/primary_dark_material_light</item>
|
||||
<item name="android:lineSpacingMultiplier">1.2</item>
|
||||
</style>
|
||||
</resources>
|
||||
44
res/xml/security_settings_pattern_size.xml
Normal file
44
res/xml/security_settings_pattern_size.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2012-2013 The CyanogenMod 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.
|
||||
-->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_security_pattern_3x3"
|
||||
android:key="lock_pattern_size_3"
|
||||
android:title="@string/lock_pattern_size_3"
|
||||
android:persistent="false"/>
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_security_pattern_4x4"
|
||||
android:key="lock_pattern_size_4"
|
||||
android:title="@string/lock_pattern_size_4"
|
||||
android:persistent="false"/>
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_security_pattern_5x5"
|
||||
android:key="lock_pattern_size_5"
|
||||
android:title="@string/lock_pattern_size_5"
|
||||
android:persistent="false"/>
|
||||
|
||||
<Preference
|
||||
android:icon="@drawable/ic_security_pattern_6x6"
|
||||
android:key="lock_pattern_size_6"
|
||||
android:title="@string/lock_pattern_size_6"
|
||||
android:persistent="false"/>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -1109,7 +1109,8 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
mUserId);
|
||||
|
||||
mSaveAndFinishWorker.start(mLockPatternUtils,
|
||||
mChosenPassword, mCurrentCredential, mUserId);
|
||||
mChosenPassword, mCurrentCredential, mUserId,
|
||||
mLockPatternUtils.getLockPatternSize(mUserId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -102,7 +102,8 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
private final Intent mIntent;
|
||||
|
||||
public IntentBuilder(Context context) {
|
||||
mIntent = new Intent(context, ChooseLockPattern.class);
|
||||
mIntent = new Intent(context, ChooseLockPatternSize.class);
|
||||
mIntent.putExtra("className", ChooseLockPattern.class.getName());
|
||||
mIntent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, false);
|
||||
}
|
||||
|
||||
@@ -219,19 +220,14 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
protected FooterButton mSkipOrClearButton;
|
||||
protected FooterButton mNextButton;
|
||||
@VisibleForTesting protected LockscreenCredential mChosenPattern;
|
||||
private byte mPatternSize = LockPatternUtils.PATTERN_SIZE_DEFAULT;
|
||||
private ColorStateList mDefaultHeaderColorList;
|
||||
private View mSudContent;
|
||||
|
||||
/**
|
||||
* The patten used during the help screen to show how to draw a pattern.
|
||||
*/
|
||||
private final List<LockPatternView.Cell> mAnimatePattern =
|
||||
Collections.unmodifiableList(Lists.newArrayList(
|
||||
LockPatternView.Cell.of(0, 0),
|
||||
LockPatternView.Cell.of(0, 1),
|
||||
LockPatternView.Cell.of(1, 1),
|
||||
LockPatternView.Cell.of(2, 1)
|
||||
));
|
||||
private List<LockPatternView.Cell> mAnimatePattern;
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode,
|
||||
@@ -276,12 +272,13 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
mLockPatternView.removeCallbacks(mClearPatternRunnable);
|
||||
}
|
||||
|
||||
public void onPatternDetected(List<LockPatternView.Cell> pattern) {
|
||||
public void onPatternDetected(List<LockPatternView.Cell> pattern,
|
||||
byte patternSize) {
|
||||
if (mUiStage == Stage.NeedToConfirm || mUiStage == Stage.ConfirmWrong) {
|
||||
if (mChosenPattern == null) throw new IllegalStateException(
|
||||
"null chosen pattern in stage 'need to confirm");
|
||||
try (LockscreenCredential confirmPattern =
|
||||
LockscreenCredential.createPattern(pattern)) {
|
||||
LockscreenCredential.createPattern(pattern, patternSize)) {
|
||||
if (mChosenPattern.equals(confirmPattern)) {
|
||||
updateStage(Stage.ChoiceConfirmed);
|
||||
} else {
|
||||
@@ -292,7 +289,8 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
if (pattern.size() < LockPatternUtils.MIN_LOCK_PATTERN_SIZE) {
|
||||
updateStage(Stage.ChoiceTooShort);
|
||||
} else {
|
||||
mChosenPattern = LockscreenCredential.createPattern(pattern);
|
||||
mChosenPattern = LockscreenCredential.createPattern(
|
||||
pattern, patternSize);
|
||||
updateStage(Stage.FirstChoiceValid);
|
||||
}
|
||||
} else {
|
||||
@@ -550,6 +548,16 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
mSudContent.setPadding(mSudContent.getPaddingLeft(), 0, mSudContent.getPaddingRight(),
|
||||
0);
|
||||
|
||||
mPatternSize = getActivity().getIntent().getByteExtra("pattern_size",
|
||||
LockPatternUtils.PATTERN_SIZE_DEFAULT);
|
||||
LockPatternView.Cell.updateSize(mPatternSize);
|
||||
mAnimatePattern = Collections.unmodifiableList(Lists.newArrayList(
|
||||
LockPatternView.Cell.of(0, 0, mPatternSize),
|
||||
LockPatternView.Cell.of(0, 1, mPatternSize),
|
||||
LockPatternView.Cell.of(1, 1, mPatternSize),
|
||||
LockPatternView.Cell.of(2, 1, mPatternSize)
|
||||
));
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -564,6 +572,8 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener);
|
||||
mLockPatternView.setFadePattern(false);
|
||||
mLockPatternView.setClickable(false);
|
||||
mLockPatternView.setLockPatternUtils(mLockPatternUtils);
|
||||
mLockPatternView.setLockPatternSize(mPatternSize);
|
||||
|
||||
mFooterText = (TextView) view.findViewById(R.id.footerText);
|
||||
|
||||
@@ -610,6 +620,9 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
// restore from previous state
|
||||
mChosenPattern = savedInstanceState.getParcelable(KEY_PATTERN_CHOICE);
|
||||
mCurrentCredential = savedInstanceState.getParcelable(KEY_CURRENT_PATTERN);
|
||||
mLockPatternView.setPattern(DisplayMode.Correct,
|
||||
LockPatternUtils.byteArrayToPattern(
|
||||
mChosenPattern.getCredential(), mPatternSize));
|
||||
|
||||
updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
|
||||
|
||||
@@ -867,7 +880,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
}
|
||||
}
|
||||
mSaveAndFinishWorker.start(mLockPatternUtils,
|
||||
mChosenPattern, mCurrentCredential, mUserId);
|
||||
mChosenPattern, mCurrentCredential, mUserId, mPatternSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
149
src/com/android/settings/password/ChooseLockPatternSize.java
Normal file
149
src/com/android/settings/password/ChooseLockPatternSize.java
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2013 The CyanogenMod 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.password;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources.Theme;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.internal.widget.LockscreenCredential;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SetupWizardUtils;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.utils.SettingsDividerItemDecoration;
|
||||
|
||||
import com.google.android.setupdesign.GlifPreferenceLayout;
|
||||
import com.google.android.setupdesign.util.ThemeHelper;
|
||||
|
||||
import org.lineageos.internal.logging.LineageMetricsLogger;
|
||||
|
||||
public class ChooseLockPatternSize extends SettingsActivity {
|
||||
|
||||
@Override
|
||||
public Intent getIntent() {
|
||||
Intent modIntent = new Intent(super.getIntent());
|
||||
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockPatternSizeFragment.class.getName());
|
||||
return modIntent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidFragment(String fragmentName) {
|
||||
if (ChooseLockPatternSizeFragment.class.getName().equals(fragmentName)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isToolbarEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
|
||||
ThemeHelper.trySetDynamicColor(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
findViewById(R.id.content_parent).setFitsSystemWindows(false);
|
||||
}
|
||||
|
||||
public static class ChooseLockPatternSizeFragment extends SettingsPreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (!(getActivity() instanceof ChooseLockPatternSize)) {
|
||||
throw new SecurityException("Fragment contained in wrong activity");
|
||||
}
|
||||
addPreferencesFromResource(R.xml.security_settings_pattern_size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceTreeClick(Preference preference) {
|
||||
final String key = preference.getKey();
|
||||
|
||||
byte patternSize;
|
||||
if ("lock_pattern_size_4".equals(key)) {
|
||||
patternSize = 4;
|
||||
} else if ("lock_pattern_size_5".equals(key)) {
|
||||
patternSize = 5;
|
||||
} else if ("lock_pattern_size_6".equals(key)) {
|
||||
patternSize = 6;
|
||||
} else {
|
||||
patternSize = 3;
|
||||
}
|
||||
|
||||
Bundle extras = getActivity().getIntent().getExtras();
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName(getActivity(), extras.getString("className"));
|
||||
intent.putExtras(extras);
|
||||
intent.putExtra("pattern_size", patternSize);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||
startActivity(intent);
|
||||
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
|
||||
layout.setDividerItemDecoration(new SettingsDividerItemDecoration(getContext()));
|
||||
|
||||
layout.setIcon(getContext().getDrawable(R.drawable.ic_lock));
|
||||
|
||||
if (getActivity() != null) {
|
||||
getActivity().setTitle(R.string.lock_settings_picker_pattern_size_message);
|
||||
}
|
||||
|
||||
layout.setHeaderText(R.string.lock_settings_picker_pattern_size_message);
|
||||
|
||||
// Remove the padding on the start of the header text.
|
||||
if (ThemeHelper.shouldApplyMaterialYouStyle(getContext())) {
|
||||
final LinearLayout headerLayout = layout.findManagedViewById(
|
||||
com.google.android.setupdesign.R.id.sud_layout_header);
|
||||
if (headerLayout != null) {
|
||||
headerLayout.setPadding(0, layout.getPaddingTop(), 0,
|
||||
layout.getPaddingBottom());
|
||||
}
|
||||
}
|
||||
|
||||
// Use the dividers in SetupWizardRecyclerLayout. Suppress the dividers in
|
||||
// PreferenceFragment.
|
||||
setDivider(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
|
||||
Bundle savedInstanceState) {
|
||||
GlifPreferenceLayout layout = (GlifPreferenceLayout) parent;
|
||||
return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return LineageMetricsLogger.CHOOSE_LOCK_PATTERN_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -475,6 +475,9 @@ public final class ChooseLockSettingsHelper {
|
||||
intent.setClassName(SETTINGS_PACKAGE_NAME, activityClass.getName());
|
||||
intent.putExtra(SettingsBaseActivity.EXTRA_PAGE_TRANSITION_TYPE,
|
||||
SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE);
|
||||
if (userId == LockPatternUtils.USER_FRP) {
|
||||
intent.putExtra("className", ConfirmLockPattern.class.getName());
|
||||
}
|
||||
|
||||
Intent inIntent = mFragment != null ? mFragment.getActivity().getIntent() :
|
||||
mActivity.getIntent();
|
||||
@@ -555,7 +558,9 @@ public final class ChooseLockSettingsHelper {
|
||||
? ConfirmLockPassword.InternalActivity.class
|
||||
: ConfirmLockPassword.class);
|
||||
case KeyguardManager.PATTERN:
|
||||
return Optional.of(returnCredentials || forceVerifyPath
|
||||
return Optional.of(userId == LockPatternUtils.USER_FRP
|
||||
? ChooseLockPatternSize.class
|
||||
: returnCredentials || forceVerifyPath
|
||||
? ConfirmLockPattern.InternalActivity.class
|
||||
: ConfirmLockPattern.class);
|
||||
}
|
||||
|
||||
@@ -653,7 +653,8 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
||||
mLockPatternUtils,
|
||||
mRemoteLockscreenValidationFragment.getLockscreenCredential(),
|
||||
/* currentCredential= */ null,
|
||||
mEffectiveUserId);
|
||||
mEffectiveUserId,
|
||||
mLockPatternUtils.getLockPatternSize(mEffectiveUserId));
|
||||
} else {
|
||||
mCredentialCheckResultTracker.setResult(/* matched= */ true, new Intent(),
|
||||
/* timeoutMs= */ 0, mEffectiveUserId);
|
||||
|
||||
@@ -118,6 +118,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
private DisappearAnimationUtils mDisappearAnimationUtils;
|
||||
|
||||
private boolean mIsManagedProfile;
|
||||
private byte mPatternSize;
|
||||
|
||||
// required constructor for fragments
|
||||
public ConfirmLockPatternFragment() {
|
||||
@@ -144,6 +145,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
mSudContent.setPadding(mSudContent.getPaddingLeft(), 0, mSudContent.getPaddingRight(),
|
||||
0);
|
||||
mIsManagedProfile = UserManager.get(getActivity()).isManagedProfile(mEffectiveUserId);
|
||||
mPatternSize = mLockPatternUtils.getLockPatternSize(mEffectiveUserId);
|
||||
|
||||
// make it so unhandled touch events within the unlock screen go to the
|
||||
// lock pattern view.
|
||||
@@ -158,6 +160,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
mDetailsText = intent.getCharSequenceExtra(
|
||||
ConfirmDeviceCredentialBaseFragment.DETAILS_TEXT);
|
||||
mCheckBoxLabel = intent.getCharSequenceExtra(KeyguardManager.EXTRA_CHECKBOX_LABEL);
|
||||
mPatternSize = intent.getByteExtra("pattern_size", mPatternSize);
|
||||
}
|
||||
if (TextUtils.isEmpty(mHeaderText) && mIsManagedProfile) {
|
||||
mHeaderText = mDevicePolicyManager.getOrganizationNameForUser(mUserId);
|
||||
@@ -165,6 +168,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
|
||||
mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled(
|
||||
mEffectiveUserId));
|
||||
mLockPatternView.setLockPatternSize(mPatternSize);
|
||||
mLockPatternView.setOnPatternListener(mConfirmExistingLockPatternListener);
|
||||
mLockPatternView.setOnTouchListener((v, event) -> {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
@@ -506,14 +510,15 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
|
||||
}
|
||||
|
||||
public void onPatternDetected(List<LockPatternView.Cell> pattern) {
|
||||
public void onPatternDetected(List<LockPatternView.Cell> pattern, byte patternSize) {
|
||||
if (mPendingLockCheck != null || mDisappearing) {
|
||||
return;
|
||||
}
|
||||
|
||||
mLockPatternView.setEnabled(false);
|
||||
|
||||
final LockscreenCredential credential = LockscreenCredential.createPattern(pattern);
|
||||
final LockscreenCredential credential = LockscreenCredential.createPattern(pattern,
|
||||
patternSize);
|
||||
|
||||
if (mRemoteValidation) {
|
||||
validateGuess(credential);
|
||||
@@ -652,7 +657,8 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
||||
mLockPatternUtils,
|
||||
mRemoteLockscreenValidationFragment.getLockscreenCredential(),
|
||||
/* currentCredential= */ null,
|
||||
mEffectiveUserId);
|
||||
mEffectiveUserId,
|
||||
mLockPatternUtils.getLockPatternSize(mEffectiveUserId));
|
||||
} else {
|
||||
mCredentialCheckResultTracker.setResult(/* matched= */ true, new Intent(),
|
||||
/* timeoutMs= */ 0, mEffectiveUserId);
|
||||
|
||||
@@ -53,6 +53,7 @@ public class SaveAndFinishWorker extends Fragment {
|
||||
private LockscreenCredential mUnificationProfileCredential;
|
||||
private LockscreenCredential mChosenCredential;
|
||||
private LockscreenCredential mCurrentCredential;
|
||||
private byte mPatternSize;
|
||||
|
||||
private boolean mBlocking;
|
||||
|
||||
@@ -76,9 +77,10 @@ public class SaveAndFinishWorker extends Fragment {
|
||||
|
||||
@VisibleForTesting
|
||||
void prepare(LockPatternUtils utils, LockscreenCredential chosenCredential,
|
||||
LockscreenCredential currentCredential, int userId) {
|
||||
LockscreenCredential currentCredential, int userId, byte patternSize) {
|
||||
mUtils = utils;
|
||||
mUserId = userId;
|
||||
mPatternSize = patternSize;
|
||||
// This will be a no-op for non managed profiles.
|
||||
mWasSecureBefore = mUtils.isSecure(mUserId);
|
||||
mFinished = false;
|
||||
@@ -90,8 +92,8 @@ public class SaveAndFinishWorker extends Fragment {
|
||||
}
|
||||
|
||||
public void start(LockPatternUtils utils, LockscreenCredential chosenCredential,
|
||||
LockscreenCredential currentCredential, int userId) {
|
||||
prepare(utils, chosenCredential, currentCredential, userId);
|
||||
LockscreenCredential currentCredential, int userId, byte patternSize) {
|
||||
prepare(utils, chosenCredential, currentCredential, userId, patternSize);
|
||||
if (mBlocking) {
|
||||
finish(saveAndVerifyInBackground().second);
|
||||
} else {
|
||||
@@ -107,6 +109,7 @@ public class SaveAndFinishWorker extends Fragment {
|
||||
@VisibleForTesting
|
||||
Pair<Boolean, Intent> saveAndVerifyInBackground() {
|
||||
final int userId = mUserId;
|
||||
mUtils.setLockPatternSize(mPatternSize, userId);
|
||||
try {
|
||||
if (!mUtils.setLockCredential(mChosenCredential, mCurrentCredential, userId)) {
|
||||
return Pair.create(false, null);
|
||||
|
||||
@@ -45,7 +45,8 @@ import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
public class SetupChooseLockPattern extends ChooseLockPattern {
|
||||
|
||||
public static Intent modifyIntentForSetup(Context context, Intent chooseLockPatternIntent) {
|
||||
chooseLockPatternIntent.setClass(context, SetupChooseLockPattern.class);
|
||||
chooseLockPatternIntent.setClass(context, ChooseLockPatternSize.class);
|
||||
chooseLockPatternIntent.putExtra("className", SetupChooseLockPattern.class.getName());
|
||||
return chooseLockPatternIntent;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user