2 * Copyright (C) 2012-2013 The CyanogenMod Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.settings;
19 import android.content.Intent;
20 import android.os.Bundle;
21 import android.preference.PreferenceActivity;
22 import android.support.v7.preference.Preference;
23 import android.support.v7.preference.PreferenceScreen;
25 import com.android.internal.widget.LockPatternUtils;
27 import org.cyanogenmod.internal.logging.CMMetricsLogger;
29 public class ChooseLockPatternSize extends PreferenceActivity {
32 public Intent getIntent() {
33 Intent modIntent = new Intent(super.getIntent());
34 modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockPatternSizeFragment.class.getName());
35 modIntent.putExtra(EXTRA_NO_HEADERS, true);
40 protected boolean isValidFragment(String fragmentName) {
41 if (ChooseLockPatternSizeFragment.class.getName().equals(fragmentName)) return true;
45 public static class ChooseLockPatternSizeFragment extends SettingsPreferenceFragment {
46 private ChooseLockSettingsHelper mChooseLockSettingsHelper;
49 public void onCreate(Bundle savedInstanceState) {
50 super.onCreate(savedInstanceState);
51 mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this.getActivity());
52 if (!(getActivity() instanceof ChooseLockPatternSize)) {
53 throw new SecurityException("Fragment contained in wrong activity");
55 addPreferencesFromResource(R.xml.security_settings_pattern_size);
59 public boolean onPreferenceTreeClick(Preference preference) {
60 final String key = preference.getKey();
63 if ("lock_pattern_size_4".equals(key)) {
65 } else if ("lock_pattern_size_5".equals(key)) {
67 } else if ("lock_pattern_size_6".equals(key)) {
73 final boolean isFallback = getActivity().getIntent()
74 .getBooleanExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false);
76 Intent intent = new Intent(getActivity(), ChooseLockPattern.class);
77 intent.putExtra("pattern_size", patternSize);
78 intent.putExtra("key_lock_method", "pattern");
79 intent.putExtra("confirm_credentials", false);
80 intent.putExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK,
83 Intent originatingIntent = getActivity().getIntent();
84 // Forward the challenge extras if available in originating intent.
85 if (originatingIntent.hasExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE)) {
86 intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE,
87 originatingIntent.getBooleanExtra(
88 ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false));
90 intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE,
91 originatingIntent.getLongExtra(
92 ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0));
94 // Forward the Encryption interstitial required password selection
95 if (originatingIntent.hasExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD)) {
96 intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, originatingIntent
97 .getBooleanExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true));
99 intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
100 startActivity(intent);
107 protected int getMetricsCategory() {
108 return CMMetricsLogger.CHOOSE_LOCK_PATTERN_SIZE;