Fix 2332563: Add password-lock support to lockscreen

This commit is contained in:
Jim Miller
2009-12-22 19:04:57 -08:00
parent 8edfd3a76b
commit 00d2476d8f
15 changed files with 1261 additions and 206 deletions

View File

@@ -406,6 +406,9 @@
<!-- Second and third-level settings --> <!-- Second and third-level settings -->
<activity android:name="ConfirmLockPattern"/> <activity android:name="ConfirmLockPattern"/>
<activity android:name="ConfirmLockPassword"
android:theme="@android:style/Theme.NoTitleBar">
</activity>
<activity android:name="ChooseLockPattern" android:label="@string/lockpattern_change_lock_pattern_label"> <activity android:name="ChooseLockPattern" android:label="@string/lockpattern_change_lock_pattern_label">
<intent-filter> <intent-filter>
@@ -413,9 +416,15 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="ChooseLockPassword" android:label="@string/lockpattern_change_lock_pin_label"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="ChooseLockPatternTutorial" <activity android:name="ChooseLockPatternTutorial"
android:label="@string/lockpattern_change_lock_pattern_label" android:label="@string/lockpattern_change_lock_pattern_label">
>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.DEFAULT" /> <action android:name="android.intent.action.DEFAULT" />
</intent-filter> </intent-filter>

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2008, 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.
*/
-->
<!-- TODO: think about moving to frameworks/base/res -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="@android:color/background_dark">
<LinearLayout android:id="@+id/topDisplayGroup"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- password entry -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginRight="6dip"
android:layout_marginLeft="6dip"
android:gravity="center_vertical"
android:background="@android:drawable/edit_text">
<!-- displays dots as user enters pin -->
<TextView android:id="@+id/pinDisplay"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:textStyle="bold"
android:inputType="textPassword"
/>
<ImageButton android:id="@+id/backspace"
android:src="@android:drawable/ic_input_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-3dip"
android:layout_marginBottom="-3dip"
/>
</LinearLayout>
<!-- header text ('Enter Pin') -->
<TextView android:id="@+id/headerText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:lines="2"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>
<include
android:id="@+id/keyPad"
layout="@layout/twelve_key_entry"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_below="@id/topDisplayGroup"
android:layout_marginTop="10dip"
/>
</LinearLayout>

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2008, 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.
*/
-->
<!-- TODO: think about moving to frameworks/base/res -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@android:color/background_dark"
android:gravity="center_horizontal">
<LinearLayout android:id="@+id/topDisplayGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- header text ('Enter Pin') -->
<TextView android:id="@+id/headerText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:lines="2"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<!-- password entry -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginRight="6dip"
android:layout_marginLeft="6dip"
android:gravity="center_vertical"
android:background="@android:drawable/edit_text">
<!-- displays dots as user enters pin -->
<TextView android:id="@+id/pinDisplay"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:textStyle="bold"
android:inputType="textPassword"
/>
<ImageButton android:id="@+id/backspace"
android:src="@android:drawable/ic_input_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-3dip"
android:layout_marginBottom="-3dip"
/>
</LinearLayout>
</LinearLayout>
<include
android:id="@+id/keyPad"
layout="@layout/twelve_key_entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/topDisplayGroup"
android:layout_marginTop="10dip"
/>
</LinearLayout>

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2008, 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.
*/
-->
<!-- TODO: think about moving to frameworks/base/res -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@android:color/background_dark"
android:gravity="center_horizontal">
<LinearLayout android:id="@+id/topDisplayGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- header text ('Enter Pin') -->
<TextView android:id="@+id/headerText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:lines="2"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<!-- password entry -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginRight="6dip"
android:layout_marginLeft="6dip"
android:gravity="center_vertical"
android:background="@android:drawable/edit_text">
<!-- displays dots as user enters pin -->
<TextView android:id="@+id/pinDisplay"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:textStyle="bold"
android:inputType="textPassword"
/>
<ImageButton android:id="@+id/backspace"
android:src="@android:drawable/ic_input_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-3dip"
android:layout_marginBottom="-3dip"
/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
/>
</LinearLayout>

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2008, 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.
*/
-->
<!-- TODO: think about moving to frameworks/base/res -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@android:color/background_dark"
android:gravity="center_horizontal">
<LinearLayout android:id="@+id/topDisplayGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- header text ('Enter Pin') -->
<TextView android:id="@+id/headerText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:lines="2"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<!-- password entry -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginRight="6dip"
android:layout_marginLeft="6dip"
android:gravity="center_vertical"
android:background="@android:drawable/edit_text">
<!-- displays dots as user enters pin -->
<TextView android:id="@+id/pinDisplay"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:textStyle="bold"
android:inputType="textPassword"
/>
<ImageButton android:id="@+id/backspace"
android:src="@android:drawable/ic_input_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-3dip"
android:layout_marginBottom="-3dip"
/>
</LinearLayout>
</LinearLayout>
<include
android:id="@+id/keyPad"
layout="@layout/twelve_key_entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/topDisplayGroup"
android:layout_marginTop="10dip"
/>
</LinearLayout>

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2008, 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.
*/
-->
<!-- TODO: think about moving to frameworks/base/res -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@android:color/background_dark"
android:gravity="center_horizontal">
<LinearLayout android:id="@+id/topDisplayGroup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- header text ('Enter Pin') -->
<TextView android:id="@+id/headerText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:lines="2"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<!-- password entry -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginRight="6dip"
android:layout_marginLeft="6dip"
android:gravity="center_vertical"
android:background="@android:drawable/edit_text">
<!-- displays dots as user enters pin -->
<TextView android:id="@+id/pinDisplay"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:textStyle="bold"
android:inputType="textPassword"
/>
<ImageButton android:id="@+id/backspace"
android:src="@android:drawable/ic_input_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="-3dip"
android:layout_marginBottom="-3dip"
/>
</LinearLayout>
</LinearLayout>
<include
android:id="@+id/keyPad"
layout="@layout/twelve_key_entry"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/topDisplayGroup"
android:layout_marginTop="10dip"
/>
</LinearLayout>

View File

@@ -0,0 +1,181 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2008, 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.
*/
-->
<!-- This is not a standalone element it can be included into apps that need 12-key input -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="64dip"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:orientation="horizontal">
<Button android:id="@+id/one"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"
/>
<Button android:id="@+id/two"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"
/>
<Button android:id="@+id/three"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="64dip"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:orientation="horizontal">
<Button android:id="@+id/four"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"
/>
<Button android:id="@+id/five"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"
/>
<Button android:id="@+id/six"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="64dip"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:orientation="horizontal">
<Button android:id="@+id/seven"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"
/>
<Button android:id="@+id/eight"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"
/>
<Button android:id="@+id/nine"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="64dip"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:orientation="horizontal">
<Button android:id="@+id/ok"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:text="@android:string/ok"
/>
<Button android:id="@+id/zero"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold"
/>
<Button android:id="@+id/cancel"
android:layout_width="0sp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="2dip"
android:layout_marginRight="2dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:text="@android:string/cancel"
/>
</LinearLayout>
</LinearLayout>

View File

@@ -23,19 +23,19 @@
strings. --> <skip /> strings. --> <skip />
<!-- The time zone picker screen has two levels. The first level allows the user to choose a region. --> <!-- The time zone picker screen has two levels. The first level allows the user to choose a region. -->
<string-array name="timezone_filters"> <string-array name="timezone_filters">
<!-- The next level of the time zoner picker should show time zones from the Americas. --> <!-- The next level of the time zoner picker should show time zones from the Americas. -->
<item>America</item> <item>America</item>
<!-- The next level of the time zoner picker should show time zones from Europe. --> <!-- The next level of the time zoner picker should show time zones from Europe. -->
<item>Europe</item> <item>Europe</item>
<!-- The next level of the time zoner picker should show time zones from Africa. --> <!-- The next level of the time zoner picker should show time zones from Africa. -->
<item>Africa</item> <item>Africa</item>
<!-- The next level of the time zoner picker should show time zones from Asia. --> <!-- The next level of the time zoner picker should show time zones from Asia. -->
<item>Asia</item> <item>Asia</item>
<!-- The next level of the time zoner picker should show time zones from Australia. --> <!-- The next level of the time zoner picker should show time zones from Australia. -->
<item>Australia</item> <item>Australia</item>
<!-- The next level of the time zoner picker should show time zones from Pacific. --> <!-- The next level of the time zoner picker should show time zones from Pacific. -->
<item>Pacific</item> <item>Pacific</item>
<!-- The next level of the time zoner picker should show time zones from ALL regions. --> <!-- The next level of the time zoner picker should show time zones from ALL regions. -->
<item>All</item> <item>All</item>
</string-array> </string-array>
@@ -98,6 +98,22 @@
<item>1800000</item> <item>1800000</item>
</string-array> </string-array>
<!-- Unlock method in SecuritySettings --><skip/>
<string-array name="unlock_method_entries">
<item>Password</item>
<item>PIN</item>
<item>Pattern</item>
<item>None</item>
</string-array>
<!-- Do not translate. -->
<string-array name="unlock_method_values" translatable="false">
<item>password</item>
<item>pin</item>
<item>pattern</item>
<item>none</item>
</string-array>
<!-- TTS settings --> <!-- TTS settings -->
<!-- Default speech rate choices --> <!-- Default speech rate choices -->
@@ -133,7 +149,7 @@
<item>120</item> <item>120</item>
<item>150</item> <item>150</item>
</string-array> </string-array>
<!-- Default language choices --> <!-- Default language choices -->
<string-array name="tts_lang_entries"> <string-array name="tts_lang_entries">
<item>American English</item> <item>American English</item>
@@ -202,7 +218,7 @@
<!-- WEP key that is in hexadecimal. --> <!-- WEP key that is in hexadecimal. -->
<item>WEP hexadecimal</item> <item>WEP hexadecimal</item>
</string-array> </string-array>
<!-- Wi-Fi settings. Presented as a list dialog to the user to choose the Wi-Fi sleep policy. --> <!-- Wi-Fi settings. Presented as a list dialog to the user to choose the Wi-Fi sleep policy. -->
<string-array name="wifi_sleep_policy_entries"> <string-array name="wifi_sleep_policy_entries">
<!-- Wi-Fi should go to sleep when the screen turns off. --> <!-- Wi-Fi should go to sleep when the screen turns off. -->

View File

@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -135,7 +135,7 @@
<string name="battery_info_awake_plugged">Awake time when charging:</string> <string name="battery_info_awake_plugged">Awake time when charging:</string>
<!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed --> <!-- Battery Info screen. Label for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="battery_info_screen_on">Screen ON time:</string> <string name="battery_info_screen_on">Screen ON time:</string>
<!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed --> <!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="battery_info_status_unknown">Unknown</string> <string name="battery_info_status_unknown">Unknown</string>
@@ -158,7 +158,7 @@
<string name="battery_info_power_usb">USB</string> <string name="battery_info_power_usb">USB</string>
<string name="battery_info_power_ac_usb">AC+USB</string> <string name="battery_info_power_ac_usb">AC+USB</string>
<string name="battery_info_power_unknown">Unknown</string> <string name="battery_info_power_unknown">Unknown</string>
<!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed --> <!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="battery_info_health_unknown">Unknown</string> <string name="battery_info_health_unknown">Unknown</string>
<!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed --> <!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
@@ -516,6 +516,18 @@
<string name="cdma_security_settings_summary">Set My Location, screen unlock, credential storage lock</string> <string name="cdma_security_settings_summary">Set My Location, screen unlock, credential storage lock</string>
<!-- In the security screen, the header title for settings related to Passwords--> <!-- In the security screen, the header title for settings related to Passwords-->
<string name="security_passwords_title">Passwords</string> <string name="security_passwords_title">Passwords</string>
<!-- Name shown for changing the unlock method -->
<string name="unlock_method_title">Unlock Method</string>
<!-- Summary shown for changing the unlock method -->
<string name="unlock_method_summary">Change the method used to unlock your phone</string>
<!-- Error shown in popup when PIN is too short -->
<string name="pin_password_too_short">Password must be at least %d digits</string>
<!-- Error shown in popup when PIN is too long -->
<string name="pin_password_too_long">Password can be no longer than %d digits</string>
<!-- Error shown when in PIN mode and user enters a non-digit -->
<string name="pin_password_illegal_character">PIN must contain only digits 0-9</string>
<!-- Error shown when in PASSWORD mode and user enters an invalid character -->
<string name="pin_password_contains_non_digits">Password contains an illegal character</string>
<!-- Bluetooth settings --> <!-- Bluetooth settings -->
<!-- Bluetooth settings check box title on Main Settings screen --> <!-- Bluetooth settings check box title on Main Settings screen -->
@@ -553,7 +565,7 @@
<!-- Title for BT error dialogs. --> <!-- Title for BT error dialogs. -->
<string name="bluetooth_error_title">Attention</string> <string name="bluetooth_error_title">Attention</string>
<!-- Message for the error dialog when BT pairing fails generically. --> <!-- Message for the error dialog when BT pairing fails generically. -->
<string name="bluetooth_pairing_error_message">There was a problem pairing with <xliff:g id="device_name">%1$s</xliff:g>.</string> <string name="bluetooth_pairing_error_message">There was a problem pairing with <xliff:g id="device_name">%1$s</xliff:g>.</string>
<!-- Message for the error dialog when BT pairing fails because the PIN / <!-- Message for the error dialog when BT pairing fails because the PIN /
Passkey entered is incorrect. --> Passkey entered is incorrect. -->
<string name="bluetooth_pairing_pin_error_message">There was a problem pairing with <xliff:g id="device_name">%1$s</xliff:g> because the PIN or Passkey is incorrect.</string> <string name="bluetooth_pairing_pin_error_message">There was a problem pairing with <xliff:g id="device_name">%1$s</xliff:g> because the PIN or Passkey is incorrect.</string>
@@ -563,7 +575,7 @@
<string name="bluetooth_pairing_rejected_error_message">Pairing rejected by <xliff:g id="device_name">%1$s</xliff:g>.</string> <string name="bluetooth_pairing_rejected_error_message">Pairing rejected by <xliff:g id="device_name">%1$s</xliff:g>.</string>
<!-- Message for the error dialog when BT connecting operation fails generically. --> <!-- Message for the error dialog when BT connecting operation fails generically. -->
<string name="bluetooth_connecting_error_message">There was a problem connecting to <xliff:g id="device_name">%1$s</xliff:g>.</string> <string name="bluetooth_connecting_error_message">There was a problem connecting to <xliff:g id="device_name">%1$s</xliff:g>.</string>
<!-- Do not translate --> <!-- Do not translate -->
<string name="bluetooth_device_info_alias">Device alias</string> <string name="bluetooth_device_info_alias">Device alias</string>
@@ -576,7 +588,7 @@
<!-- Bluetooth settings: The title of the preference (list item) that initiates a scan for devices --> <!-- Bluetooth settings: The title of the preference (list item) that initiates a scan for devices -->
<string name="bluetooth_preference_scan_title">Scan for devices</string> <string name="bluetooth_preference_scan_title">Scan for devices</string>
<!-- Bluetooth settings. Context menu item for a device. Action will connect to all profiles on the device. --> <!-- Bluetooth settings. Context menu item for a device. Action will connect to all profiles on the device. -->
<string name="bluetooth_device_context_connect">Connect</string> <string name="bluetooth_device_context_connect">Connect</string>
<!-- Bluetooth settings. Context menu item for a device. Action will disconnect from all profiles on the device. --> <!-- Bluetooth settings. Context menu item for a device. Action will disconnect from all profiles on the device. -->
@@ -588,8 +600,8 @@
<!-- Bluetooth settings. Context menu item for a device. Action will disconnect and remove pairing with the device. --> <!-- Bluetooth settings. Context menu item for a device. Action will disconnect and remove pairing with the device. -->
<string name="bluetooth_device_context_disconnect_unpair">Disconnect &amp; unpair</string> <string name="bluetooth_device_context_disconnect_unpair">Disconnect &amp; unpair</string>
<!-- Bluetooth settings. Context menu item for a device. Action will take the user to another screen where they can choose exactly which profiles to connect to. --> <!-- Bluetooth settings. Context menu item for a device. Action will take the user to another screen where they can choose exactly which profiles to connect to. -->
<string name="bluetooth_device_context_connect_advanced">Options\u2026</string> <string name="bluetooth_device_context_connect_advanced">Options\u2026</string>
<!-- Bluetooth settings. The title of the screen to pick which profiles to connect to on the device. For example, headphones may have both A2DP and headset, this allows the user to choose which one he wants to connect to. --> <!-- Bluetooth settings. The title of the screen to pick which profiles to connect to on the device. For example, headphones may have both A2DP and headset, this allows the user to choose which one he wants to connect to. -->
<string name="bluetooth_connect_specific_profiles_title">Connect to\u2026</string> <string name="bluetooth_connect_specific_profiles_title">Connect to\u2026</string>
@@ -807,7 +819,7 @@
<string name="wifi_setting_sleep_policy_summary">Specify when to switch from Wi-Fi to mobile data</string> <string name="wifi_setting_sleep_policy_summary">Specify when to switch from Wi-Fi to mobile data</string>
<!-- Wi-Fi settings screen, generic error message when the sleep policy could not be set. --> <!-- Wi-Fi settings screen, generic error message when the sleep policy could not be set. -->
<string name="wifi_setting_sleep_policy_error">There was a problem setting the sleep policy.</string> <string name="wifi_setting_sleep_policy_error">There was a problem setting the sleep policy.</string>
<!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's MAC address. --> <!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's MAC address. -->
<string name="wifi_advanced_mac_address_title">MAC address</string> <string name="wifi_advanced_mac_address_title">MAC address</string>
@@ -1253,10 +1265,10 @@
<string name="error_mnc_not23">MNC field must be 2 or 3 digits.</string> <string name="error_mnc_not23">MNC field must be 2 or 3 digits.</string>
<!-- The message of dialog indicated restoring default APN settings in progress --> <!-- The message of dialog indicated restoring default APN settings in progress -->
<string name="restore_default_apn">Restoring default APN settings</string> <string name="restore_default_apn">Restoring default APN settings</string>
<!-- APNs screen menu option to reset default APN settings --> <!-- APNs screen menu option to reset default APN settings -->
<string name="menu_restore">Reset to default</string> <string name="menu_restore">Reset to default</string>
<!-- APNs screen toast message to inform reset default APN settings is completed --> <!-- APNs screen toast message to inform reset default APN settings is completed -->
<string name="restore_default_apn_completed">Reset default APN settings completed</string> <string name="restore_default_apn_completed">Reset default APN settings completed</string>
<!-- Master Clear --> <!-- Master Clear -->
<!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading --> <!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading -->
@@ -1378,12 +1390,24 @@
<!-- About phone settings screen, Safety Legal dialog title until the link is fully loaded --> <!-- About phone settings screen, Safety Legal dialog title until the link is fully loaded -->
<string name="settings_safetylegal_activity_loading">Loading\u2026</string> <string name="settings_safetylegal_activity_loading">Loading\u2026</string>
<!-- Lock Pattern settings -->
<!-- Header on first screen of choose password/PIN flow -->
<string name="lockpassword_choose_your_password_header">Choose your password</string>
<!-- Header on password confirm screen -->
<string name="lockpassword_confirm_your_password_header">Confirm password</string>
<!-- Header on password confirm screen if second password doesn't match the first. -->
<string name="lockpassword_confirm_passwords_dont_match">Passwords don\'t match</string>
<!-- Header shown if passwords match -->
<string name="lockpassword_password_confirmed_header">Password confirmed</string>
<!-- Lock Pattern settings --> <!-- Lock Pattern settings -->
<!-- Security & location settings screen, header --> <!-- Security & location settings screen, header -->
<string name="lock_settings_title">Screen unlock pattern</string> <string name="lock_settings_title">Screen unlock pattern</string>
<!-- Security & location settings screen, setting option name --> <!-- Security & location settings screen, setting option name -->
<string name="lockpattern_change_lock_pattern_label">Change unlock pattern</string> <string name="lockpattern_change_lock_pattern_label">Change unlock pattern</string>
<!-- Security & location settings screen, change unlock pattern screen instruction when the user chooses "Change unlock pattern". We first ask the user toe nter the current pattern, and this is the message seen --> <!-- Security & location settings screen, change unlock pattern screen instruction when the user chooses "Change unlock pattern". We first ask the user toe nter the current pattern, and this is the message seen -->
<string name="lockpattern_change_lock_pin_label">Change unlock PIN</string>
<!-- Security & location settings screen, change unlock pattern screen instruction when the user chooses "Change unlock pattern". We first ask the user toe nter the current pattern, and this is the message seen -->
<string name="lockpattern_need_to_unlock">Confirm saved pattern</string> <string name="lockpattern_need_to_unlock">Confirm saved pattern</string>
<!-- Do not translate. --> <!-- Do not translate. -->
<string name="lockpattern_need_to_unlock_footer"></string> <string name="lockpattern_need_to_unlock_footer"></string>
@@ -1447,8 +1471,8 @@
\n<font height="17">\n</font><b>3</b>\u00A0 Redraw your pattern to confirm. \n<font height="17">\n</font><b>3</b>\u00A0 Redraw your pattern to confirm.
\n<font height="17">\n</font><b>Ready to start? Touch \u201CNext\u201D</b>. \n<font height="17">\n</font><b>Ready to start? Touch \u201CNext\u201D</b>.
\n<font height="3">\n</font>To leave your phone unprotected, touch \u201CCancel\u201D.</font> \n<font height="3">\n</font>To leave your phone unprotected, touch \u201CCancel\u201D.</font>
</string> </string>
<!-- ChooseLockPatternExample --> <skip /> <!-- ChooseLockPatternExample --> <skip />
<!-- ChooseLockPatternExample, screen title that shows an example pattern --> <!-- ChooseLockPatternExample, screen title that shows an example pattern -->
<string name="lock_example_title">Example pattern</string> <string name="lock_example_title">Example pattern</string>
@@ -1528,7 +1552,7 @@
<!-- Text for filter option in ManageApps screen to display all installed <!-- Text for filter option in ManageApps screen to display all installed
applications --> applications -->
<string name="filter_apps_all">All</string> <string name="filter_apps_all">All</string>
<!-- Text for filter option in ManageApps screen to display third party <!-- Text for filter option in ManageApps screen to display third party
applications only --> applications only -->
<string name="filter_apps_third_party">Downloaded</string> <string name="filter_apps_third_party">Downloaded</string>
<!-- Text for filter option in ManageApps screen to display list of running <!-- Text for filter option in ManageApps screen to display list of running
@@ -1598,7 +1622,7 @@ found in the list of installed applications.</string>
<string name="service_foreground_processes">Other: <xliff:g id="memory">%2$s</xliff:g> in <xliff:g id="count">%1$d</xliff:g></string> <string name="service_foreground_processes">Other: <xliff:g id="memory">%2$s</xliff:g> in <xliff:g id="count">%1$d</xliff:g></string>
<!-- Text to label a process entry with the process name. --> <!-- Text to label a process entry with the process name. -->
<string name="service_process_name">Process: <xliff:g id="process">%1$s</xliff:g></string> <string name="service_process_name">Process: <xliff:g id="process">%1$s</xliff:g></string>
<!-- Language Settings --> <skip /> <!-- Language Settings --> <skip />
<!-- Title of setting on main settings screen. This item will take the user to the screen to tweak settings realted to locale and text --> <!-- Title of setting on main settings screen. This item will take the user to the screen to tweak settings realted to locale and text -->
<string name="language_settings">Language &amp; keyboard</string> <string name="language_settings">Language &amp; keyboard</string>
@@ -1639,7 +1663,7 @@ found in the list of installed applications.</string>
card numbers. It comes from the application card numbers. It comes from the application
<xliff:g id="ime_application_name">%1$s</xliff:g>. <xliff:g id="ime_application_name">%1$s</xliff:g>.
Use this input method?</string> Use this input method?</string>
<!-- User dictionary settings --><skip /> <!-- User dictionary settings --><skip />
<!-- User dictionary settings, The titlebar text of the User dictionary settings screen. --> <!-- User dictionary settings, The titlebar text of the User dictionary settings screen. -->
<string name="user_dict_settings_titlebar">User dictionary</string> <string name="user_dict_settings_titlebar">User dictionary</string>
@@ -1731,7 +1755,7 @@ found in the list of installed applications.</string>
(or other screens that can host gadgets). Note to translators: we're still determining (or other screens that can host gadgets). Note to translators: we're still determining
the final name for Gadgets/Widgets, so please translate both for now. --> the final name for Gadgets/Widgets, so please translate both for now. -->
<string name="gadget_picker_title">Choose gadget</string> <string name="gadget_picker_title">Choose gadget</string>
<!-- Title for the screen that lets the user choose a widget to add to the home screen <!-- Title for the screen that lets the user choose a widget to add to the home screen
(or other screens that can host widgets). Note to translators: we're still determining (or other screens that can host widgets). Note to translators: we're still determining
the final name for Gadgets/Widgets, so please translate both for now. --> the final name for Gadgets/Widgets, so please translate both for now. -->
@@ -1784,52 +1808,52 @@ found in the list of installed applications.</string>
<!-- Used to head a list of packages that share a given user id BatteryHistory --> <!-- Used to head a list of packages that share a given user id BatteryHistory -->
<string name="battery_history_packages_sharing_this_uid">Packages sharing this UID:</string> <string name="battery_history_packages_sharing_this_uid">Packages sharing this UID:</string>
<!-- Used when no battery data available in BatteryHistory --> <!-- Used when no battery data available in BatteryHistory -->
<string name="battery_history_no_data">No battery usage data available</string> <string name="battery_history_no_data">No battery usage data available</string>
<!-- Used for Sensor detail screen in BatteryHistory --> <!-- Used for Sensor detail screen in BatteryHistory -->
<string name="battery_history_sensor">Sensor:</string> <string name="battery_history_sensor">Sensor:</string>
<!-- Used for Wakelock detail screen in BatteryHistory --> <!-- Used for Wakelock detail screen in BatteryHistory -->
<string name="battery_history_wakelock">Partial Wakelock:</string> <string name="battery_history_wakelock">Partial Wakelock:</string>
<!-- Used for Sensor detail screen in BatteryHistory --> <!-- Used for Sensor detail screen in BatteryHistory -->
<string name="battery_history_used_by_packages">Sensor used by packages:</string> <string name="battery_history_used_by_packages">Sensor used by packages:</string>
<!-- Used for Sensor detail screen in BatteryHistory --> <!-- Used for Sensor detail screen in BatteryHistory -->
<string name="battery_history_sensor_usage">Used <xliff:g id="count">%1$d</xliff:g> times by <xliff:g id="package">%2$s</xliff:g></string> <string name="battery_history_sensor_usage">Used <xliff:g id="count">%1$d</xliff:g> times by <xliff:g id="package">%2$s</xliff:g></string>
<!-- Used for Sensor detail screen in BatteryHistory --> <!-- Used for Sensor detail screen in BatteryHistory -->
<string name="battery_history_sensor_usage_multi">Used <xliff:g id="count">%1$d</xliff:g> times by one of:</string> <string name="battery_history_sensor_usage_multi">Used <xliff:g id="count">%1$d</xliff:g> times by one of:</string>
<!-- Used for label of awake bar in BatteryHistory --> <!-- Used for label of awake bar in BatteryHistory -->
<string name="battery_history_awake_label">Running</string> <string name="battery_history_awake_label">Running</string>
<!-- Used for label of screen on bar in BatteryHistory --> <!-- Used for label of screen on bar in BatteryHistory -->
<string name="battery_history_screen_on_label">Screen on</string> <string name="battery_history_screen_on_label">Screen on</string>
<!-- Used for label of phone on bar in BatteryHistory --> <!-- Used for label of phone on bar in BatteryHistory -->
<string name="battery_history_phone_on_label">Phone on</string> <string name="battery_history_phone_on_label">Phone on</string>
<!-- Used for awake time message in BatteryHistory --> <!-- Used for awake time message in BatteryHistory -->
<string name="battery_history_awake">Time spent without sleeping:</string> <string name="battery_history_awake">Time spent without sleeping:</string>
<!-- Used for Screen on time message in BatteryHistory --> <!-- Used for Screen on time message in BatteryHistory -->
<string name="battery_history_screen_on">Time spent with screen on:</string> <string name="battery_history_screen_on">Time spent with screen on:</string>
<!-- Used for Phone on time message in BatteryHistory --> <!-- Used for Phone on time message in BatteryHistory -->
<string name="battery_history_phone_on">Time spent with phone on:</string> <string name="battery_history_phone_on">Time spent with phone on:</string>
<!-- Used for Screen on time message in BatteryHistory --> <!-- Used for Screen on time message in BatteryHistory -->
<string name="battery_history_screen_on_battery">On battery:</string> <string name="battery_history_screen_on_battery">On battery:</string>
<!-- XXX remove? Used for Screen on time message in BatteryHistory --> <!-- XXX remove? Used for Screen on time message in BatteryHistory -->
<string name="battery_history_screen_on_plugged">Plugged in:</string> <string name="battery_history_screen_on_plugged">Plugged in:</string>
<!-- XXX remove? Strings used for displaying usage statistics --> <!-- XXX remove? Strings used for displaying usage statistics -->
<string name="usage_stats_label">Usage statistics</string> <string name="usage_stats_label">Usage statistics</string>
<!-- In the Testing screen. The item title of the activity that shows usage statistics. --> <!-- In the Testing screen. The item title of the activity that shows usage statistics. -->
<string name="testing_usage_stats">Usage statistics</string> <string name="testing_usage_stats">Usage statistics</string>
<!-- label for text to indicate sort options --> <!-- label for text to indicate sort options -->
@@ -2263,7 +2287,7 @@ found in the list of installed applications.</string>
<string name="emergency_tone_title">Emergency tone</string> <string name="emergency_tone_title">Emergency tone</string>
<!-- Sound settings screen, setting option summary text --> <!-- Sound settings screen, setting option summary text -->
<string name="emergency_tone_summary">Set behavior when an emergency call is placed</string> <string name="emergency_tone_summary">Set behavior when an emergency call is placed</string>
<!-- Privacy Settings screen --><skip/> <!-- Privacy Settings screen --><skip/>
<!-- Privacy settings menu title --> <!-- Privacy settings menu title -->
<string name="privacy_settings">Privacy</string> <string name="privacy_settings">Privacy</string>

View File

@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,15 +19,15 @@
<PreferenceCategory <PreferenceCategory
android:key="location_category" android:key="location_category"
android:title="@string/location_title"> android:title="@string/location_title">
<CheckBoxPreference <CheckBoxPreference
android:key="location_network" android:key="location_network"
android:title="@string/location_network_based" android:title="@string/location_network_based"
android:summaryOn="@string/location_neighborhood_level" android:summaryOn="@string/location_neighborhood_level"
android:summaryOff="@string/location_networks_disabled"/> android:summaryOff="@string/location_networks_disabled"/>
<CheckBoxPreference <CheckBoxPreference
android:key="location_gps" android:key="location_gps"
android:title="@string/location_gps" android:title="@string/location_gps"
android:summaryOn="@string/location_street_level" android:summaryOn="@string/location_street_level"
android:summaryOff="@string/location_gps_disabled"/> android:summaryOff="@string/location_gps_disabled"/>
@@ -42,5 +42,27 @@
--> -->
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory
android:key="security_category"
android:title="@string/lock_settings_title">
<ListPreference
android:key="unlock_method"
android:title="@string/unlock_method_title"
android:summary="@string/unlock_method_summary"
android:persistent="false"
android:entries="@array/unlock_method_entries"
android:entryValues="@array/unlock_method_values"/>
<CheckBoxPreference
android:key="visiblepattern"
android:title="@string/lockpattern_settings_enable_visible_pattern_title"/>
<CheckBoxPreference
android:key="tactilefeedback"
android:title="@string/lockpattern_settings_enable_tactile_feedback_title"/>
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -0,0 +1,232 @@
/*
* Copyright (C) 2010 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;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.ChooseLockPattern.LeftButtonMode;
import com.android.settings.ChooseLockPattern.RightButtonMode;
import com.android.settings.ChooseLockPattern.Stage;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class ChooseLockPassword extends Activity implements OnClickListener {
private final int digitIds[] = new int[] { R.id.zero, R.id.one, R.id.two, R.id.three,
R.id.four, R.id.five, R.id.six, R.id.seven, R.id.eight, R.id.nine };
private TextView mPasswordTextView;
private int mPasswordMinLength = 4;
private int mPasswordMaxLength = 8;
private LockPatternUtils mLockPatternUtils;
private int mRequestedMode = LockPatternUtils.MODE_PIN;
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
private com.android.settings.ChooseLockPassword.Stage mUiStage = Stage.Introduction;
private TextView mHeaderText;
private String mFirstPin;
public static final String PASSWORD_MIN_KEY = "lockscreen.password_min";
public static final String PASSWORD_MAX_KEY = "lockscreen.password_max";
private static Handler mHandler = new Handler();
private static final int CONFIRM_EXISTING_REQUEST = 58;
static final int RESULT_FINISHED = RESULT_FIRST_USER;
private static final long ERROR_MESSAGE_TIMEOUT = 3000;
/**
* Keep track internally of where the user is in choosing a pattern.
*/
protected enum Stage {
Introduction(R.string.lockpassword_choose_your_password_header),
NeedToConfirm(R.string.lockpassword_confirm_your_password_header),
ConfirmWrong(R.string.lockpassword_confirm_passwords_dont_match),
ChoiceConfirmed(R.string.lockpassword_password_confirmed_header);
/**
* @param headerMessage The message displayed at the top.
*/
Stage(int headerMessage) {
this.headerMessage = headerMessage;
}
final int headerMessage;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLockPatternUtils = new LockPatternUtils(getContentResolver());
mRequestedMode = getIntent().getIntExtra("password_mode", mRequestedMode);
mPasswordMinLength = getIntent().getIntExtra("password_min_length", mPasswordMinLength);
mPasswordMaxLength = getIntent().getIntExtra("password_max_length", mPasswordMaxLength);
initViews();
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
if (savedInstanceState == null) {
updateStage(Stage.Introduction);
mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST);
}
}
private void initViews() {
if (LockPatternUtils.MODE_PIN == mRequestedMode
|| LockPatternUtils.MODE_PASSWORD == mRequestedMode) {
setContentView(R.layout.choose_lock_pin);
// TODO: alphanumeric layout
// setContentView(R.layout.choose_lock_password);
for (int i = 0; i < digitIds.length; i++) {
Button button = (Button) findViewById(digitIds[i]);
button.setOnClickListener(this);
button.setText(Integer.toString(i));
}
findViewById(R.id.ok).setOnClickListener(this);
findViewById(R.id.cancel).setOnClickListener(this);
}
findViewById(R.id.backspace).setOnClickListener(this);
mPasswordTextView = (TextView) findViewById(R.id.pinDisplay);
mHeaderText = (TextView) findViewById(R.id.headerText);
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case CONFIRM_EXISTING_REQUEST:
if (resultCode != Activity.RESULT_OK) {
setResult(RESULT_FINISHED);
finish();
}
break;
}
}
protected void updateStage(Stage stage) {
mHeaderText.setText(stage.headerMessage);
mPasswordTextView.setText("");
mUiStage = stage;
}
/**
* Validates PIN and returns a message to display if PIN fails test.
* @param pin
* @return message id to display to user
*/
private String validatePassword(String pin) {
if (pin.length() < mPasswordMinLength) {
return getString(R.string.pin_password_too_short, mPasswordMinLength);
}
if (pin.length() > mPasswordMaxLength) {
return getString(R.string.pin_password_too_long, mPasswordMaxLength);
}
if (LockPatternUtils.MODE_PIN == mRequestedMode) {
Pattern p = Pattern.compile("[0-9]+");
Matcher m = p.matcher(pin);
if (!m.find()) {
return getString(R.string.pin_password_contains_non_digits);
}
} else if (LockPatternUtils.MODE_PASSWORD == mRequestedMode) {
// allow Latin-1 characters only
for (int i = 0; i < pin.length(); i++) {
char c = pin.charAt(i);
if (c <= 32 || c > 127) {
return getString(R.string.pin_password_illegal_character);
}
}
}
return null;
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.ok:
{
final String pin = mPasswordTextView.getText().toString();
if (TextUtils.isEmpty(pin)) {
break;
}
String errorMsg = null;
if (mUiStage == Stage.Introduction) {
errorMsg = validatePassword(pin);
if (errorMsg == null) {
mFirstPin = pin;
updateStage(Stage.NeedToConfirm);
}
} else if (mUiStage == Stage.NeedToConfirm) {
if (mFirstPin.equals(pin)) {
// TODO: move these to LockPatternUtils
mLockPatternUtils.setLockPatternEnabled(false);
mLockPatternUtils.saveLockPattern(null);
mLockPatternUtils.saveLockPassword(pin);
finish();
} else {
int msg = R.string.lockpassword_confirm_passwords_dont_match;
errorMsg = getString(msg);
}
}
if (errorMsg != null) {
showError(errorMsg, Stage.Introduction);
}
}
break;
case R.id.backspace:
{
final Editable digits = mPasswordTextView.getEditableText();
final int len = digits.length();
if (len > 0) {
digits.delete(len-1, len);
}
}
break;
case R.id.cancel:
finish();
break;
default:
// Digits
for (int i = 0; i < digitIds.length; i++) {
if (v.getId() == digitIds[i]) {
mPasswordTextView.append(Integer.toString(i));
return;
}
}
break;
}
}
private void showError(String msg, final Stage next) {
mHeaderText.setText(msg);
mPasswordTextView.setText("");
mHandler.postDelayed(new Runnable() {
public void run() {
updateStage(next);
}
}, ERROR_MESSAGE_TIMEOUT);
}
}

View File

@@ -45,7 +45,6 @@ import java.util.List;
* - saves chosen password when confirmed * - saves chosen password when confirmed
*/ */
public class ChooseLockPattern extends Activity implements View.OnClickListener{ public class ChooseLockPattern extends Activity implements View.OnClickListener{
/** /**
* Used by the choose lock pattern wizard to indicate the wizard is * Used by the choose lock pattern wizard to indicate the wizard is
* finished, and each activity in the wizard should finish. * finished, and each activity in the wizard should finish.
@@ -56,7 +55,9 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
* result. * result.
*/ */
static final int RESULT_FINISHED = RESULT_FIRST_USER; static final int RESULT_FINISHED = RESULT_FIRST_USER;
public static final int CONFIRM_EXISTING_REQUEST = 55;
// how long after a confirmation message is shown before moving on // how long after a confirmation message is shown before moving on
static final int INFORMATION_MSG_TIMEOUT_MS = 3000; static final int INFORMATION_MSG_TIMEOUT_MS = 3000;
@@ -65,29 +66,38 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
private static final int ID_EMPTY_MESSAGE = -1; private static final int ID_EMPTY_MESSAGE = -1;
protected TextView mHeaderText; protected TextView mHeaderText;
protected LockPatternView mLockPatternView; protected LockPatternView mLockPatternView;
protected TextView mFooterText; protected TextView mFooterText;
private TextView mFooterLeftButton; private TextView mFooterLeftButton;
private TextView mFooterRightButton; private TextView mFooterRightButton;
protected List<LockPatternView.Cell> mChosenPattern = null; protected List<LockPatternView.Cell> mChosenPattern = null;
protected LockPatternUtils mLockPatternUtils;
/** /**
* The patten used during the help screen to show how to draw a pattern. * The patten used during the help screen to show how to draw a pattern.
*/ */
private final List<LockPatternView.Cell> mAnimatePattern = private final List<LockPatternView.Cell> mAnimatePattern =
Collections.unmodifiableList( Collections.unmodifiableList(Lists.newArrayList(
Lists.newArrayList( LockPatternView.Cell.of(0, 0),
LockPatternView.Cell.of(0, 0), LockPatternView.Cell.of(0, 1),
LockPatternView.Cell.of(0, 1), LockPatternView.Cell.of(1, 1),
LockPatternView.Cell.of(1, 1), LockPatternView.Cell.of(2, 1)
LockPatternView.Cell.of(2, 1) ));
));
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case CONFIRM_EXISTING_REQUEST:
if (resultCode != Activity.RESULT_OK) {
setResult(RESULT_FINISHED);
finish();
}
updateStage(Stage.Introduction);
break;
}
}
/** /**
* The pattern listener that responds according to a user choosing a new * The pattern listener that responds according to a user choosing a new
@@ -125,7 +135,7 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
} }
} }
public void onPatternCellAdded(List<Cell> pattern) { public void onPatternCellAdded(List<Cell> pattern) {
} }
@@ -250,19 +260,19 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
} }
}; };
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
private static final String KEY_UI_STAGE = "uiStage"; private static final String KEY_UI_STAGE = "uiStage";
private static final String KEY_PATTERN_CHOICE = "chosenPattern"; private static final String KEY_PATTERN_CHOICE = "chosenPattern";
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
mLockPatternUtils = new LockPatternUtils(getContentResolver());
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
setupViews(); setupViews();
// make it so unhandled touch events within the unlock screen go to the // make it so unhandled touch events within the unlock screen go to the
// lock pattern view. // lock pattern view.
final LinearLayoutWithDefaultTouchRecepient topLayout final LinearLayoutWithDefaultTouchRecepient topLayout
@@ -271,11 +281,12 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
topLayout.setDefaultTouchRecepient(mLockPatternView); topLayout.setDefaultTouchRecepient(mLockPatternView);
if (savedInstanceState == null) { if (savedInstanceState == null) {
// first launch // first launch. As a security measure, we're in NeedToConfirm mode until we know
updateStage(Stage.Introduction); // there isn't an existing password or the user confirms their password.
if (mLockPatternUtils.savedPatternExists()) { updateStage(Stage.NeedToConfirm);
confirmPattern(); if (!mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST)) {
} updateStage(Stage.Introduction);
}
} else { } else {
// restore from previous state // restore from previous state
final String patternString = savedInstanceState.getString(KEY_PATTERN_CHOICE); final String patternString = savedInstanceState.getString(KEY_PATTERN_CHOICE);
@@ -285,19 +296,20 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]); updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
} }
} }
/** /**
* Keep all "find view" related stuff confined to this function since in * Keep all "find view" related stuff confined to this function since in
* case someone needs to subclass and customize. * case someone needs to subclass and customize.
*/ */
protected void setupViews() { protected void setupViews() {
setContentView(R.layout.choose_lock_pattern); setContentView(R.layout.choose_lock_pattern);
mHeaderText = (TextView) findViewById(R.id.headerText); mHeaderText = (TextView) findViewById(R.id.headerText);
mLockPatternView = (LockPatternView) findViewById(R.id.lockPattern); mLockPatternView = (LockPatternView) findViewById(R.id.lockPattern);
mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener); mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener);
mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled()); mLockPatternView.setTactileFeedbackEnabled(
mChooseLockSettingsHelper.utils().isTactileFeedbackEnabled());
mFooterText = (TextView) findViewById(R.id.footerText); mFooterText = (TextView) findViewById(R.id.footerText);
@@ -364,35 +376,6 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
return super.onKeyDown(keyCode, event); return super.onKeyDown(keyCode, event);
} }
/**
* Launch screen to confirm the existing lock pattern.
* @see #onActivityResult(int, int, android.content.Intent)
*/
protected void confirmPattern() {
final Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPattern");
startActivityForResult(intent, 55);
}
/**
* @see #confirmPattern
*/
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode != 55) {
return;
}
if (resultCode != Activity.RESULT_OK) {
setResult(RESULT_FINISHED);
finish();
}
updateStage(Stage.Introduction);
}
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
@@ -414,7 +397,7 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
mUiStage = stage; mUiStage = stage;
// header text, footer text, visibility and // header text, footer text, visibility and
// enabled state all known from the stage // enabled state all known from the stage
if (stage == Stage.ChoiceTooShort) { if (stage == Stage.ChoiceTooShort) {
mHeaderText.setText( mHeaderText.setText(
@@ -486,16 +469,17 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
} }
private void saveChosenPatternAndFinish() { private void saveChosenPatternAndFinish() {
final boolean lockVirgin = !mLockPatternUtils.isPatternEverChosen(); LockPatternUtils utils = mChooseLockSettingsHelper.utils();
final boolean lockVirgin = !utils.isPatternEverChosen();
mLockPatternUtils.saveLockPattern(mChosenPattern); utils.saveLockPattern(mChosenPattern);
mLockPatternUtils.setLockPatternEnabled(true); utils.setLockPatternEnabled(true);
if (lockVirgin) { if (lockVirgin) {
mLockPatternUtils.setVisiblePatternEnabled(true); utils.setVisiblePatternEnabled(true);
mLockPatternUtils.setTactileFeedbackEnabled(false); utils.setTactileFeedbackEnabled(false);
} }
setResult(RESULT_FINISHED); setResult(RESULT_FINISHED);
finish(); finish();
} }

View File

@@ -0,0 +1,85 @@
/*
* Copyright (C) 2010 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;
import android.app.Activity;
import android.content.Intent;
import com.android.internal.widget.LockPatternUtils;
public class ChooseLockSettingsHelper {
private LockPatternUtils mLockPatternUtils;
private Activity mActivity;
public ChooseLockSettingsHelper(Activity activity) {
mActivity = activity;
mLockPatternUtils = new LockPatternUtils(activity.getContentResolver());
}
public LockPatternUtils utils() {
return mLockPatternUtils;
}
/**
* If a pattern, password or PIN exists, prompt the user before allowing them to change it.
* @return true if one exists and we launched an activity to confirm it
* @see #onActivityResult(int, int, android.content.Intent)
*/
protected boolean launchConfirmationActivity(int request) {
boolean launched = false;
switch (mLockPatternUtils.getPasswordMode()) {
case LockPatternUtils.MODE_PATTERN:
launched = confirmPattern(request);
break;
case LockPatternUtils.MODE_PIN:
case LockPatternUtils.MODE_PASSWORD:
launched = confirmPassword(request);
break;
}
return launched;
}
/**
* Launch screen to confirm the existing lock pattern.
* @see #onActivityResult(int, int, android.content.Intent)
* @return true if we launched an activity to confirm pattern
*/
private boolean confirmPattern(int request) {
if (!mLockPatternUtils.isLockPatternEnabled() || !mLockPatternUtils.savedPatternExists()) {
return false;
}
final Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPattern");
mActivity.startActivityForResult(intent, request);
return true;
}
/**
* Launch screen to confirm the existing lock password.
* @see #onActivityResult(int, int, android.content.Intent)
* @return true if we launched an activity to confirm password
*/
private boolean confirmPassword(int request) {
if (!mLockPatternUtils.isLockPasswordEnabled()) return false;
final Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPassword");
mActivity.startActivityForResult(intent, request);
return true;
}
}

View File

@@ -0,0 +1,114 @@
/*
* Copyright (C) 2010 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;
import com.android.internal.widget.LockPatternUtils;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class ConfirmLockPassword extends Activity implements OnClickListener {
private static final long ERROR_MESSAGE_TIMEOUT = 3000;
private final int digitIds[] = new int[] { R.id.zero, R.id.one, R.id.two, R.id.three,
R.id.four, R.id.five, R.id.six, R.id.seven, R.id.eight, R.id.nine };
private TextView mPasswordTextView;
private LockPatternUtils mLockPatternUtils;
private TextView mHeaderText;
private Handler mHandler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLockPatternUtils = new LockPatternUtils(getContentResolver());
initViews();
}
private void initViews() {
int mode = mLockPatternUtils.getPasswordMode();
if (LockPatternUtils.MODE_PIN == mode || LockPatternUtils.MODE_PASSWORD == mode) {
setContentView(R.layout.confirm_lock_pin);
for (int i = 0; i < digitIds.length; i++) {
Button button = (Button) findViewById(digitIds[i]);
button.setOnClickListener(this);
button.setText(Integer.toString(i));
}
findViewById(R.id.ok).setOnClickListener(this);
findViewById(R.id.cancel).setOnClickListener(this);
}
findViewById(R.id.backspace).setOnClickListener(this);
mPasswordTextView = (TextView) findViewById(R.id.pinDisplay);
mHeaderText = (TextView) findViewById(R.id.headerText);
mHeaderText.setText(R.string.lockpassword_confirm_your_password_header);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.ok:
{
final String pin = mPasswordTextView.getText().toString();
if (mLockPatternUtils.checkPassword(pin)) {
setResult(RESULT_OK);
finish();
} else {
showError(R.string.lockpattern_need_to_unlock_wrong);
}
}
break;
case R.id.backspace:
{
final Editable digits = mPasswordTextView.getEditableText();
final int len = digits.length();
if (len > 0) {
digits.delete(len-1, len);
}
}
break;
case R.id.cancel:
setResult(RESULT_CANCELED);
finish();
break;
default:
// Digits
for (int i = 0; i < digitIds.length; i++) {
if (v.getId() == digitIds[i]) {
mPasswordTextView.append(Integer.toString(i));
return;
}
}
break;
}
}
private void showError(int msg) {
mHeaderText.setText(msg);
mPasswordTextView.setText(null);
mHandler.postDelayed(new Runnable() {
public void run() {
mHeaderText.setText(R.string.lockpassword_confirm_your_password_header);
}
}, ERROR_MESSAGE_TIMEOUT);
}
}

View File

@@ -25,7 +25,6 @@ import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.ContentQueryMap; import android.content.ContentQueryMap;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
@@ -35,10 +34,13 @@ import android.os.ICheckinService;
import android.os.ServiceManager; import android.os.ServiceManager;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener;
import android.provider.Settings; import android.provider.Settings;
import android.security.Credentials; import android.security.Credentials;
import android.security.KeyStore; import android.security.KeyStore;
@@ -56,11 +58,18 @@ import com.android.internal.widget.LockPatternUtils;
public class SecuritySettings extends PreferenceActivity { public class SecuritySettings extends PreferenceActivity {
// Lock Settings // Lock Settings
private static final String PACKAGE = "com.android.settings";
private static final String LOCK_PATTERN_TUTORIAL = PACKAGE + ".ChooseLockPatternTutorial";
private static final String ICC_LOCK_SETTINGS = PACKAGE + ".IccLockSettings";
private static final String CHOOSE_LOCK_PATTERN = PACKAGE + ".ChooseLockPattern";
private static final String CHOOSE_LOCK_PIN = PACKAGE + ".ChooseLockPassword";
private static final String KEY_LOCK_ENABLED = "lockenabled"; private static final String KEY_LOCK_ENABLED = "lockenabled";
private static final String KEY_VISIBLE_PATTERN = "visiblepattern"; private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
private static final String KEY_TACTILE_FEEDBACK_ENABLED = "tactilefeedback"; private static final String KEY_TACTILE_FEEDBACK_ENABLED = "tactilefeedback";
private static final int CONFIRM_PATTERN_THEN_DISABLE_AND_CLEAR_REQUEST_CODE = 55; private static final String KEY_UNLOCK_METHOD = "unlock_method";
private static final int UPDATE_PASSWORD_REQUEST = 56;
private static final int CONFIRM_EXISTING_REQUEST = 57;
// Encrypted File Systems constants // Encrypted File Systems constants
private static final String PROPERTY_EFS_ENABLED = "persist.security.efs.enabled"; private static final String PROPERTY_EFS_ENABLED = "persist.security.efs.enabled";
@@ -69,11 +78,8 @@ public class SecuritySettings extends PreferenceActivity {
private static final String PREFS_NAME = "location_prefs"; private static final String PREFS_NAME = "location_prefs";
private static final String PREFS_USE_LOCATION = "use_location"; private static final String PREFS_USE_LOCATION = "use_location";
private LockPatternUtils mLockPatternUtils;
private CheckBoxPreference mLockEnabled;
private CheckBoxPreference mVisiblePattern; private CheckBoxPreference mVisiblePattern;
private CheckBoxPreference mTactileFeedback; private CheckBoxPreference mTactileFeedback;
private Preference mChoosePattern;
private CheckBoxPreference mShowPassword; private CheckBoxPreference mShowPassword;
@@ -97,6 +103,8 @@ public class SecuritySettings extends PreferenceActivity {
// This is necessary because the Network Location Provider can change settings // This is necessary because the Network Location Provider can change settings
// if the user does not confirm enabling the provider. // if the user does not confirm enabling the provider.
private ContentQueryMap mContentQueryMap; private ContentQueryMap mContentQueryMap;
private ListPreference mUnlockMethod;
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
private final class SettingsObserver implements Observer { private final class SettingsObserver implements Observer {
public void update(Observable o, Object arg) { public void update(Observable o, Object arg) {
updateToggles(); updateToggles();
@@ -108,7 +116,7 @@ public class SecuritySettings extends PreferenceActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.security_settings); addPreferencesFromResource(R.xml.security_settings);
mLockPatternUtils = new LockPatternUtils(getContentResolver()); mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
createPreferenceHierarchy(); createPreferenceHierarchy();
@@ -131,37 +139,22 @@ public class SecuritySettings extends PreferenceActivity {
// Root // Root
PreferenceScreen root = this.getPreferenceScreen(); PreferenceScreen root = this.getPreferenceScreen();
// Inline preferences PreferenceManager pm = getPreferenceManager();
PreferenceCategory inlinePrefCat = new PreferenceCategory(this);
inlinePrefCat.setTitle(R.string.lock_settings_title);
root.addPreference(inlinePrefCat);
// change pattern lock mUnlockMethod = (ListPreference) pm.findPreference(KEY_UNLOCK_METHOD);
Intent intent = new Intent(); mUnlockMethod.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
intent.setClassName("com.android.settings", public boolean onPreferenceChange(Preference preference, Object newValue) {
"com.android.settings.ChooseLockPatternTutorial"); String value = (String) newValue;
mChoosePattern = getPreferenceManager().createPreferenceScreen(this); handleUpdateUnlockMethod(value);
mChoosePattern.setIntent(intent); return false;
inlinePrefCat.addPreference(mChoosePattern); }
});
// autolock toggle
mLockEnabled = new LockEnabledPref(this);
mLockEnabled.setTitle(R.string.lockpattern_settings_enable_title);
mLockEnabled.setSummary(R.string.lockpattern_settings_enable_summary);
mLockEnabled.setKey(KEY_LOCK_ENABLED);
inlinePrefCat.addPreference(mLockEnabled);
// visible pattern // visible pattern
mVisiblePattern = new CheckBoxPreference(this); mVisiblePattern = (CheckBoxPreference) pm.findPreference(KEY_VISIBLE_PATTERN);
mVisiblePattern.setKey(KEY_VISIBLE_PATTERN);
mVisiblePattern.setTitle(R.string.lockpattern_settings_enable_visible_pattern_title);
inlinePrefCat.addPreference(mVisiblePattern);
// tactile feedback // tactile feedback
mTactileFeedback = new CheckBoxPreference(this); mTactileFeedback = (CheckBoxPreference) pm.findPreference(KEY_TACTILE_FEEDBACK_ENABLED);
mTactileFeedback.setKey(KEY_TACTILE_FEEDBACK_ENABLED);
mTactileFeedback.setTitle(R.string.lockpattern_settings_enable_tactile_feedback_title);
inlinePrefCat.addPreference(mTactileFeedback);
int activePhoneType = TelephonyManager.getDefault().getPhoneType(); int activePhoneType = TelephonyManager.getDefault().getPhoneType();
@@ -172,10 +165,7 @@ public class SecuritySettings extends PreferenceActivity {
.createPreferenceScreen(this); .createPreferenceScreen(this);
simLockPreferences.setTitle(R.string.sim_lock_settings_category); simLockPreferences.setTitle(R.string.sim_lock_settings_category);
// Intent to launch SIM lock settings // Intent to launch SIM lock settings
intent = new Intent(); simLockPreferences.setIntent(new Intent().setClassName(PACKAGE, ICC_LOCK_SETTINGS));
intent.setClassName("com.android.settings", "com.android.settings.IccLockSettings");
simLockPreferences.setIntent(intent);
PreferenceCategory simLockCat = new PreferenceCategory(this); PreferenceCategory simLockCat = new PreferenceCategory(this);
simLockCat.setTitle(R.string.sim_lock_settings_title); simLockCat.setTitle(R.string.sim_lock_settings_title);
root.addPreference(simLockCat); root.addPreference(simLockCat);
@@ -209,23 +199,41 @@ public class SecuritySettings extends PreferenceActivity {
return root; return root;
} }
protected void handleUpdateUnlockMethod(final String value) {
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
if ("none".equals(value)) {
mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST);
} else if ("password".equals(value) || "pin".equals(value)) {
final int minLength = 4; // TODO: get from policy store.
final int maxLength = 16;
final int mode = "password".equals(value)
? LockPatternUtils.MODE_PASSWORD : LockPatternUtils.MODE_PIN;
Intent intent = new Intent().setClassName(PACKAGE, CHOOSE_LOCK_PIN);
intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, mode);
intent.putExtra(ChooseLockPassword.PASSWORD_MIN_KEY, minLength);
intent.putExtra(ChooseLockPassword.PASSWORD_MAX_KEY, maxLength);
startActivityForResult(intent, UPDATE_PASSWORD_REQUEST);
} else if ("pattern".equals(value)) {
boolean showTutorial = !lockPatternUtils.isPatternEverChosen();
Intent intent = new Intent();
intent.setClassName(PACKAGE, showTutorial ?
LOCK_PATTERN_TUTORIAL : CHOOSE_LOCK_PATTERN);
intent.putExtra("key_lock_method", value);
startActivityForResult(intent, UPDATE_PASSWORD_REQUEST);
}
}
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
boolean patternExists = mLockPatternUtils.savedPatternExists(); final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
mLockEnabled.setEnabled(patternExists); boolean patternExists = lockPatternUtils.savedPatternExists();
mVisiblePattern.setEnabled(patternExists); mVisiblePattern.setEnabled(patternExists);
mTactileFeedback.setEnabled(patternExists); mTactileFeedback.setEnabled(patternExists);
mLockEnabled.setChecked(mLockPatternUtils.isLockPatternEnabled()); mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled());
mVisiblePattern.setChecked(mLockPatternUtils.isVisiblePatternEnabled()); mTactileFeedback.setChecked(lockPatternUtils.isTactileFeedbackEnabled());
mTactileFeedback.setChecked(mLockPatternUtils.isTactileFeedbackEnabled());
int chooseStringRes = mLockPatternUtils.savedPatternExists() ?
R.string.lockpattern_settings_change_lock_pattern :
R.string.lockpattern_settings_choose_lock_pattern;
mChoosePattern.setTitle(chooseStringRes);
mShowPassword.setChecked(Settings.System.getInt(getContentResolver(), mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),
Settings.System.TEXT_SHOW_PASSWORD, 1) != 0); Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
@@ -238,12 +246,13 @@ public class SecuritySettings extends PreferenceActivity {
Preference preference) { Preference preference) {
final String key = preference.getKey(); final String key = preference.getKey();
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
if (KEY_LOCK_ENABLED.equals(key)) { if (KEY_LOCK_ENABLED.equals(key)) {
mLockPatternUtils.setLockPatternEnabled(isToggled(preference)); lockPatternUtils.setLockPatternEnabled(isToggled(preference));
} else if (KEY_VISIBLE_PATTERN.equals(key)) { } else if (KEY_VISIBLE_PATTERN.equals(key)) {
mLockPatternUtils.setVisiblePatternEnabled(isToggled(preference)); lockPatternUtils.setVisiblePatternEnabled(isToggled(preference));
} else if (KEY_TACTILE_FEEDBACK_ENABLED.equals(key)) { } else if (KEY_TACTILE_FEEDBACK_ENABLED.equals(key)) {
mLockPatternUtils.setTactileFeedbackEnabled(isToggled(preference)); lockPatternUtils.setTactileFeedbackEnabled(isToggled(preference));
} else if (preference == mShowPassword) { } else if (preference == mShowPassword) {
Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
mShowPassword.isChecked() ? 1 : 0); mShowPassword.isChecked() ? 1 : 0);
@@ -265,11 +274,6 @@ public class SecuritySettings extends PreferenceActivity {
return false; return false;
} }
private void showPrivacyPolicy() {
Intent intent = new Intent("android.settings.TERMS");
startActivity(intent);
}
/* /*
* Creates toggles for each available location provider * Creates toggles for each available location provider
*/ */
@@ -291,36 +295,6 @@ public class SecuritySettings extends PreferenceActivity {
return ((CheckBoxPreference) pref).isChecked(); return ((CheckBoxPreference) pref).isChecked();
} }
/**
* For the user to disable keyguard, we first make them verify their
* existing pattern.
*/
private class LockEnabledPref extends CheckBoxPreference {
public LockEnabledPref(Context context) {
super(context);
}
@Override
protected void onClick() {
if (mLockPatternUtils.savedPatternExists() && isChecked()) {
confirmPatternThenDisableAndClear();
} else {
super.onClick();
}
}
}
/**
* Launch screen to confirm the existing lock pattern.
* @see #onActivityResult(int, int, android.content.Intent)
*/
private void confirmPatternThenDisableAndClear() {
final Intent intent = new Intent();
intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPattern");
startActivityForResult(intent, CONFIRM_PATTERN_THEN_DISABLE_AND_CLEAR_REQUEST_CODE);
}
/** /**
* @see #confirmPatternThenDisableAndClear * @see #confirmPatternThenDisableAndClear
*/ */
@@ -330,10 +304,11 @@ public class SecuritySettings extends PreferenceActivity {
final boolean resultOk = resultCode == Activity.RESULT_OK; final boolean resultOk = resultCode == Activity.RESULT_OK;
if ((requestCode == CONFIRM_PATTERN_THEN_DISABLE_AND_CLEAR_REQUEST_CODE) LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
&& resultOk) { if ((requestCode == CONFIRM_EXISTING_REQUEST) && resultOk) {
mLockPatternUtils.setLockPatternEnabled(false); lockPatternUtils.saveLockPassword(null);
mLockPatternUtils.saveLockPattern(null); lockPatternUtils.setLockPatternEnabled(false);
lockPatternUtils.saveLockPattern(null);
} }
} }