diff options
-rw-r--r-- | res/layout/weak_biometric_fallback_header.xml | 24 | ||||
-rw-r--r-- | res/xml/security_settings_picker.xml | 25 | ||||
-rw-r--r-- | src/com/android/settings/ChooseLockGeneric.java | 42 |
3 files changed, 54 insertions, 37 deletions
diff --git a/res/layout/weak_biometric_fallback_header.xml b/res/layout/weak_biometric_fallback_header.xml new file mode 100644 index 0000000..adbb613 --- /dev/null +++ b/res/layout/weak_biometric_fallback_header.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 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. +--> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="8dip" + android:gravity="center" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="?android:attr/textColorSecondary" + android:text="@string/unlock_backup_info_summary" +/>
\ No newline at end of file diff --git a/res/xml/security_settings_picker.xml b/res/xml/security_settings_picker.xml index 2d0760c..87e69e0 100644 --- a/res/xml/security_settings_picker.xml +++ b/res/xml/security_settings_picker.xml @@ -16,53 +16,40 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - <PreferenceCategory - android:key="security_picker_category" - android:title="@string/lock_settings_picker_title"> - -<!-- TODO: find a better way to display this backup info --> - <PreferenceScreen - android:key="unlock_backup_info" - android:summary="@string/unlock_backup_info_summary" - android:selectable="false" - android:persistent="false"/> - - <PreferenceScreen + <PreferenceScreen android:key="unlock_set_off" android:title="@string/unlock_set_unlock_off_title" android:summary="@string/unlock_set_unlock_off_summary" android:persistent="false"/> - <PreferenceScreen + <PreferenceScreen android:key="unlock_set_none" android:title="@string/unlock_set_unlock_none_title" android:summary="@string/unlock_set_unlock_none_summary" android:persistent="false"/> - <PreferenceScreen + <PreferenceScreen android:key="unlock_set_biometric_weak" android:title="@string/unlock_set_unlock_biometric_weak_title" android:summary="@string/unlock_set_unlock_biometric_weak_summary" android:persistent="false"/> - <PreferenceScreen + <PreferenceScreen android:key="unlock_set_pattern" android:title="@string/unlock_set_unlock_pattern_title" android:summary="@string/unlock_set_unlock_pattern_summary" android:persistent="false"/> - <PreferenceScreen + <PreferenceScreen android:key="unlock_set_pin" android:title="@string/unlock_set_unlock_pin_title" android:summary="@string/unlock_set_unlock_pin_summary" android:persistent="false"/> - <PreferenceScreen + <PreferenceScreen android:key="unlock_set_password" android:title="@string/unlock_set_unlock_password_title" android:summary="@string/unlock_set_unlock_password_summary" android:persistent="false"/> - </PreferenceCategory> - </PreferenceScreen> diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java index ac66a97..d246263 100644 --- a/src/com/android/settings/ChooseLockGeneric.java +++ b/src/com/android/settings/ChooseLockGeneric.java @@ -25,9 +25,12 @@ import android.os.Bundle; import android.os.SystemProperties; import android.preference.Preference; import android.preference.PreferenceActivity; -import android.preference.PreferenceCategory; import android.preference.PreferenceScreen; import android.security.KeyStore; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ListView; import com.android.internal.widget.LockPatternUtils; @@ -119,6 +122,21 @@ public class ChooseLockGeneric extends PreferenceActivity { } @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View v = super.onCreateView(inflater, container, savedInstanceState); + final boolean onlyShowFallback = getActivity().getIntent() + .getBooleanExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false); + if (onlyShowFallback) { + View header = v.inflate(getActivity(), + R.layout.weak_biometric_fallback_header, null); + ((ListView) v.findViewById(android.R.id.list)).addHeaderView(header, null, false); + } + + return v; + } + + @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == Activity.RESULT_OK) { @@ -205,30 +223,18 @@ public class ChooseLockGeneric extends PreferenceActivity { * @param quality the requested quality. */ private void disableUnusablePreferences(final int quality) { - final Preference picker = - getPreferenceScreen().findPreference("security_picker_category"); - final PreferenceCategory cat = (PreferenceCategory) picker; - final int preferenceCount = cat.getPreferenceCount(); + final PreferenceScreen entries = getPreferenceScreen(); final boolean onlyShowFallback = getActivity().getIntent() .getBooleanExtra(LockPatternUtils.LOCKSCREEN_BIOMETRIC_WEAK_FALLBACK, false); final boolean weakBiometricAvailable = isBiometricSensorAvailable( DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK); - // TODO: This code can be removed once the second header is gone - if (onlyShowFallback) { - picker.setTitle(R.string.backup_lock_settings_picker_title); - } else { - picker.setTitle(R.string.lock_settings_picker_title); - } - for (int i = preferenceCount-1; i >= 0; --i) { - Preference pref = cat.getPreference(i); + for (int i = entries.getPreferenceCount() - 1; i >= 0; --i) { + Preference pref = entries.getPreference(i); if (pref instanceof PreferenceScreen) { final String key = ((PreferenceScreen) pref).getKey(); boolean enabled = true; boolean visible = true; - if (KEY_UNLOCK_BACKUP_INFO.equals(key)) { - enabled = true; - visible = onlyShowFallback; - } else if (KEY_UNLOCK_SET_OFF.equals(key)) { + if (KEY_UNLOCK_SET_OFF.equals(key)) { enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; } else if (KEY_UNLOCK_SET_NONE.equals(key)) { enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED; @@ -243,7 +249,7 @@ public class ChooseLockGeneric extends PreferenceActivity { enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_COMPLEX; } if (!visible || (onlyShowFallback && !allowedForFallback(key))) { - cat.removePreference(pref); + entries.removePreference(pref); } else if (!enabled) { pref.setSummary(R.string.unlock_set_unlock_disabled_summary); pref.setEnabled(false); |