Remove "Screen lock" category header as the title is sufficient.

Bug: 5203189

Insert a descriptive text as a header view when in weak biometric
fallback case.

Change-Id: Ic10cc7d276975b13c188bd15016fea2200ec0e5b
This commit is contained in:
Amith Yamasani
2011-09-26 10:27:43 -07:00
parent 0b174b3883
commit cf26bb2dcc
3 changed files with 54 additions and 37 deletions

View File

@@ -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"
/>

View File

@@ -16,17 +16,6 @@
<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
android:key="unlock_set_off"
android:title="@string/unlock_set_unlock_off_title"
@@ -63,6 +52,4 @@
android:summary="@string/unlock_set_unlock_password_summary"
android:persistent="false"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -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;
@@ -118,6 +121,21 @@ public class ChooseLockGeneric extends PreferenceActivity {
return handled;
}
@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);
@@ -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);