Fix 3148496: Initial pass at fragmentizing lockscreen settings.

This converts most of the existing activities to fragments and wraps
them in PreferenceActivities so they can be launched as before
(e.g. by a DevicePolicyManager)

Upload after sync/rebase.

Change-Id: I4f351b75d9fca0498bcb04b4e11ff3b70765a4ba
This commit is contained in:
Jim Miller
2010-12-07 20:41:41 -08:00
parent 1c7e49ba67
commit 17e9e19330
17 changed files with 2120 additions and 1267 deletions

View File

@@ -651,9 +651,8 @@
<!-- 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 android:name="ConfirmLockPassword"/>>
</activity>
<activity android:name="ChooseLockGeneric"> <activity android:name="ChooseLockGeneric">
<intent-filter> <intent-filter>
@@ -669,7 +668,6 @@
<activity android:name="ChooseLockPassword" <activity android:name="ChooseLockPassword"
android:label="@string/lockpattern_change_lock_pin_label" android:label="@string/lockpattern_change_lock_pin_label"
android:theme="@android:style/Theme.NoTitleBar"
android:exported="false"> android:exported="false">
</activity> </activity>

View File

@@ -0,0 +1,109 @@
<?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.
*/
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- "Enter PIN(Password) to unlock" -->
<TextView android:id="@+id/headerText"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginRight="6dip"
android:layout_marginLeft="6dip"
android:layout_marginTop="10dip"
android:layout_marginBottom="10dip"
android:gravity="left"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
<!-- Password entry field -->
<EditText android:id="@+id/password_entry"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:textStyle="bold"
android:inputType="textPassword"
android:gravity="center"
android:layout_gravity="center"
android:textSize="24sp"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="@drawable/password_field_default"
android:textColor="#ffffffff"
/>
</LinearLayout>
<!-- Spacer between password entry and keyboard -->
<View
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<!-- Alphanumeric keyboard -->
<com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:keyBackground="@*android:drawable/btn_keyboard_key_fulltrans"
android:visibility="gone"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<Button android:id="@+id/cancel_button"
android:layout_height="wrap_content"
android:layout_width="140dip"
android:ellipsize="marquee"
android:singleLine="true"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@id/next_button"
android:text="@string/lockpassword_cancel_label"
/>
<Button android:id="@+id/next_button"
android:layout_width="140dip"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="@string/lockpassword_continue_label"
/>
</RelativeLayout>
</LinearLayout>

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 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.
-->
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- left side: lock pattern -->
<com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<!-- right side: pattern and messages -->
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1.0">
<!-- header message -->
<TextView android:id="@+id/headerText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:gravity="left"/>
<!-- footer message -->
<TextView android:id="@+id/footerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="22sp"
android:layout_marginTop="40dip"
android:visibility="gone"/>
<!-- confirm / restart buttons -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<!-- right / bottom button: confirm or ok -->
<Button android:id="@+id/footerRightButton"
android:layout_height="wrap_content"
android:layout_width="140dip"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:ellipsize="marquee"
android:singleLine="true"
android:text="@string/lockpattern_confirm_button_text"/>
<!-- left / top button: skip, or re-try -->
<Button android:id="@+id/footerLeftButton"
android:layout_height="wrap_content"
android:layout_width="140dip"
android:layout_toLeftOf="@id/footerRightButton"
android:layout_alignParentBottom="true"
android:ellipsize="marquee"
android:singleLine="true"
android:text="@string/lockpattern_restart_button_text"/>
</RelativeLayout>
</LinearLayout>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>

View File

@@ -0,0 +1,108 @@
<?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 the same layout as choose_lock_password. TODO: find out why merge fails -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center_horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- "Enter PIN(Password) to unlock" -->
<TextView android:id="@+id/headerText"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_marginRight="6dip"
android:layout_marginLeft="6dip"
android:layout_marginTop="10dip"
android:layout_marginBottom="10dip"
android:gravity="left"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
<!-- Password entry field -->
<EditText android:id="@+id/password_entry"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:textStyle="bold"
android:inputType="textPassword"
android:gravity="center"
android:layout_gravity="center"
android:textSize="24sp"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="@drawable/password_field_default"
android:textColor="#ffffffff"
/>
</LinearLayout>
<!-- Spacer between password entry and keyboard -->
<View
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<!-- Alphanumeric keyboard -->
<com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:keyBackground="@*android:drawable/btn_keyboard_key_fulltrans"
android:visibility="gone"
/>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:visibility="visible">
<Button android:id="@+id/cancel_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_toLeftOf="@id/next_button"
android:text="@string/lockpassword_cancel_label"
/>
<Button android:id="@+id/next_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentRight="true"
android:drawableRight="@drawable/ic_btn_next"
android:drawablePadding="10dip"
android:text="@string/lockpassword_continue_label"
/>
</RelativeLayout>
</LinearLayout>

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 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.
-->
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- left side: lock pattern -->
<com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!-- right side: instructions and buttons -->
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1.0">
<!-- header message -->
<TextView android:id="@+id/headerText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:textSize="22sp"/>
<!-- footer message -->
<TextView android:id="@+id/footerText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dip"
android:gravity="left"
android:textSize="22sp"/>
</LinearLayout>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>

View File

@@ -0,0 +1,101 @@
<?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.
*/
-->
<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">
<!-- 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"/>
<!-- spacer above text entry field -->
<View
android:id="@+id/spacerBottom"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_marginTop="6dip"
android:background="@android:drawable/divider_horizontal_dark"
/>
<!-- Password entry field -->
<EditText android:id="@+id/password_entry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textStyle="bold"
android:inputType="textPassword"
android:gravity="center"
android:layout_gravity="center"
android:textSize="32sp"
android:layout_marginTop="15dip"
android:layout_marginLeft="30dip"
android:layout_marginRight="30dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="@drawable/password_field_default"
android:textColor="#ffffffff"
/>
<!-- Spacer between password entry and keyboard -->
<View
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<!-- Alphanumeric keyboard -->
<com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:layout_marginBottom="30dip"
android:keyBackground="@*android:drawable/btn_keyboard_key_fulltrans"
/>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<Button android:id="@+id/cancel_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentLeft="true"
android:text="@string/lockpassword_cancel_label"
/>
<Button android:id="@+id/next_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentRight="true"
android:drawableRight="@drawable/ic_btn_next"
android:drawablePadding="10dip"
android:text="@string/lockpassword_continue_label"
/>
</RelativeLayout>
</LinearLayout>

View File

@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 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.
-->
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/black">
<!-- takes up all space above button bar at bottom -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<TextView android:id="@+id/headerText"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center"
android:textSize="18sp"/>
<View
android:background="@*android:drawable/code_lock_top"
android:layout_width="match_parent"
android:layout_height="2dip" />
<com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!-- bottom line looks bad when button bar is their too, omit in this case -->
<!--View
android:background="@*android:drawable/code_lock_bottom"
android:layout_width="match_parent"
android:layout_height="8dip" /-->
<TextView android:id="@+id/footerText"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center"
android:textSize="14sp"/>
</LinearLayout>
<LinearLayout style="@android:style/ButtonBar"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button android:id="@+id/footerLeftButton"
android:layout_height="wrap_content"
android:layout_width="140dip"
android:ellipsize="marquee"
android:singleLine="true"
android:text="@string/lockpattern_restart_button_text"/>
<View
android:visibility="invisible"
android:layout_height="0dip"
android:layout_width="1dip"
android:layout_weight="1" />
<Button android:id="@+id/footerRightButton"
android:layout_height="wrap_content"
android:layout_width="140dip"
android:ellipsize="marquee"
android:singleLine="true"
android:drawableRight="@drawable/ic_btn_next"
android:drawablePadding="3dip"
android:text="@string/lockpattern_confirm_button_text"/>
</LinearLayout>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>

View File

@@ -0,0 +1,105 @@
<?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 the same layout as choose_lock_password -->
<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">
<!-- 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"/>
<!-- spacer above text entry field -->
<View
android:id="@+id/spacerBottom"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_marginTop="6dip"
android:background="@android:drawable/divider_horizontal_dark"
/>
<!-- Password entry field -->
<EditText android:id="@+id/password_entry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textStyle="bold"
android:inputType="textPassword"
android:gravity="center"
android:layout_gravity="center"
android:textSize="32sp"
android:layout_marginTop="15dip"
android:layout_marginLeft="30dip"
android:layout_marginRight="30dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="@drawable/password_field_default"
android:textColor="#ffffffff"
/>
<!-- Spacer between password entry and keyboard -->
<View
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<!-- Alphanumeric keyboard -->
<com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:layout_marginBottom="30dip"
android:keyBackground="@*android:drawable/btn_keyboard_key_fulltrans"
/>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<Button android:id="@+id/cancel_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentLeft="true"
android:text="@string/lockpassword_cancel_label"
/>
<Button android:id="@+id/next_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentRight="true"
android:drawableRight="@drawable/ic_btn_next"
android:drawablePadding="10dip"
android:text="@string/lockpassword_continue_label"
/>
</RelativeLayout>
</LinearLayout>

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 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.
-->
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/black">
<TextView android:id="@+id/headerText"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1.0"
android:gravity="center"
android:textSize="18sp"/>
<View
android:background="@*android:drawable/code_lock_top"
android:layout_width="match_parent"
android:layout_height="2dip" />
<com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<View
android:background="@*android:drawable/code_lock_bottom"
android:layout_width="match_parent"
android:layout_height="8dip" />
<TextView android:id="@+id/footerText"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1.0"
android:gravity="center"
android:textSize="14sp"/>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>

View File

@@ -18,6 +18,7 @@ package com.android.settings;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import android.app.Activity;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -28,6 +29,16 @@ import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
public class ChooseLockGeneric extends PreferenceActivity { public class ChooseLockGeneric extends PreferenceActivity {
@Override
public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockGenericFragment.class.getName());
modIntent.putExtra(EXTRA_NO_HEADERS, true);
return modIntent;
}
public static class ChooseLockGenericFragment extends SettingsPreferenceFragment {
private static final int MIN_PASSWORD_LENGTH = 4; private static final int MIN_PASSWORD_LENGTH = 4;
private static final String KEY_UNLOCK_SET_OFF = "unlock_set_off"; private static final String KEY_UNLOCK_SET_OFF = "unlock_set_off";
private static final String KEY_UNLOCK_SET_NONE = "unlock_set_none"; private static final String KEY_UNLOCK_SET_NONE = "unlock_set_none";
@@ -43,18 +54,18 @@ public class ChooseLockGeneric extends PreferenceActivity {
private boolean mPasswordConfirmed = false; private boolean mPasswordConfirmed = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this); mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this.getActivity());
if (savedInstanceState != null) { if (savedInstanceState != null) {
mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED); mPasswordConfirmed = savedInstanceState.getBoolean(PASSWORD_CONFIRMED);
} }
if (!mPasswordConfirmed) { if (!mPasswordConfirmed) {
ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this); ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this.getActivity(), this);
if (!helper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST, null, null)) { if (!helper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST, null, null)) {
mPasswordConfirmed = true; // no password set, so no need to confirm mPasswordConfirmed = true; // no password set, so no need to confirm
updatePreferencesOrFinish(); updatePreferencesOrFinish();
@@ -86,26 +97,26 @@ public class ChooseLockGeneric extends PreferenceActivity {
} }
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == RESULT_OK) { if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == Activity.RESULT_OK) {
mPasswordConfirmed = true; mPasswordConfirmed = true;
updatePreferencesOrFinish(); updatePreferencesOrFinish();
} else { } else {
setResult(RESULT_CANCELED); getActivity().setResult(Activity.RESULT_CANCELED);
finish(); finish();
} }
} }
@Override @Override
protected void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
// Saved so we don't force user to re-enter their password if configuration changes // Saved so we don't force user to re-enter their password if configuration changes
outState.putBoolean(PASSWORD_CONFIRMED, mPasswordConfirmed); outState.putBoolean(PASSWORD_CONFIRMED, mPasswordConfirmed);
} }
private void updatePreferencesOrFinish() { private void updatePreferencesOrFinish() {
int quality = getIntent().getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, -1); int quality = getActivity().getIntent().getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, -1);
if (quality == -1) { if (quality == -1) {
// If caller didn't specify password quality, show the UI and allow the user to choose. // If caller didn't specify password quality, show the UI and allow the user to choose.
quality = mChooseLockSettingsHelper.utils().getKeyguardStoredPasswordQuality(); quality = mChooseLockSettingsHelper.utils().getKeyguardStoredPasswordQuality();
@@ -179,7 +190,7 @@ public class ChooseLockGeneric extends PreferenceActivity {
minLength = MIN_PASSWORD_LENGTH; minLength = MIN_PASSWORD_LENGTH;
} }
final int maxLength = mDPM.getPasswordMaximumLength(quality); final int maxLength = mDPM.getPasswordMaximumLength(quality);
Intent intent = new Intent().setClass(this, ChooseLockPassword.class); Intent intent = new Intent().setClass(getActivity(), ChooseLockPassword.class);
intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, quality); intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, quality);
intent.putExtra(ChooseLockPassword.PASSWORD_MIN_KEY, minLength); intent.putExtra(ChooseLockPassword.PASSWORD_MIN_KEY, minLength);
intent.putExtra(ChooseLockPassword.PASSWORD_MAX_KEY, maxLength); intent.putExtra(ChooseLockPassword.PASSWORD_MAX_KEY, maxLength);
@@ -189,7 +200,7 @@ public class ChooseLockGeneric extends PreferenceActivity {
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) { } else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
boolean showTutorial = !mChooseLockSettingsHelper.utils().isPatternEverChosen(); boolean showTutorial = !mChooseLockSettingsHelper.utils().isPatternEverChosen();
Intent intent = new Intent(); Intent intent = new Intent();
intent.setClass(this, showTutorial intent.setClass(getActivity(), showTutorial
? ChooseLockPatternTutorial.class ? ChooseLockPatternTutorial.class
: ChooseLockPattern.class); : ChooseLockPattern.class);
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
@@ -199,8 +210,9 @@ public class ChooseLockGeneric extends PreferenceActivity {
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) { } else if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
mChooseLockSettingsHelper.utils().clearLock(); mChooseLockSettingsHelper.utils().clearLock();
mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled); mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled);
setResult(RESULT_OK); getActivity().setResult(Activity.RESULT_OK);
} }
finish(); finish();
} }
}
} }

View File

@@ -21,19 +21,22 @@ import com.android.internal.widget.PasswordEntryKeyboardHelper;
import com.android.internal.widget.PasswordEntryKeyboardView; import com.android.internal.widget.PasswordEntryKeyboardView;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.Intent; import android.content.Intent;
import android.inputmethodservice.KeyboardView; import android.inputmethodservice.KeyboardView;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceActivity;
import android.text.Editable; import android.text.Editable;
import android.text.Selection; import android.text.Selection;
import android.text.Spannable; import android.text.Spannable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.ViewGroup;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.Button; import android.widget.Button;
@@ -41,8 +44,35 @@ import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener; import android.widget.TextView.OnEditorActionListener;
public class ChooseLockPassword extends Activity implements OnClickListener, OnEditorActionListener, public class ChooseLockPassword extends PreferenceActivity {
TextWatcher { public static final String PASSWORD_MIN_KEY = "lockscreen.password_min";
public static final String PASSWORD_MAX_KEY = "lockscreen.password_max";
public static final String PASSWORD_MIN_LETTERS_KEY = "lockscreen.password_min_letters";
public static final String PASSWORD_MIN_LOWERCASE_KEY = "lockscreen.password_min_lowercase";
public static final String PASSWORD_MIN_UPPERCASE_KEY = "lockscreen.password_min_uppercase";
public static final String PASSWORD_MIN_NUMERIC_KEY = "lockscreen.password_min_numeric";
public static final String PASSWORD_MIN_SYMBOLS_KEY = "lockscreen.password_min_symbols";
public static final String PASSWORD_MIN_NONLETTER_KEY = "lockscreen.password_min_nonletter";
@Override
public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockPasswordFragment.class.getName());
modIntent.putExtra(EXTRA_NO_HEADERS, true);
return modIntent;
}
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO: Fix on phones
// Disable IME on our window since we provide our own keyboard
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
//WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
super.onCreate(savedInstanceState);
}
public static class ChooseLockPasswordFragment extends Fragment
implements OnClickListener, OnEditorActionListener, TextWatcher {
private static final String KEY_FIRST_PIN = "first_pin"; private static final String KEY_FIRST_PIN = "first_pin";
private static final String KEY_UI_STAGE = "ui_stage"; private static final String KEY_UI_STAGE = "ui_stage";
private TextView mPasswordEntry; private TextView mPasswordEntry;
@@ -57,7 +87,7 @@ public class ChooseLockPassword extends Activity implements OnClickListener, OnE
private LockPatternUtils mLockPatternUtils; private LockPatternUtils mLockPatternUtils;
private int mRequestedQuality = DevicePolicyManager.PASSWORD_QUALITY_NUMERIC; private int mRequestedQuality = DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
private ChooseLockSettingsHelper mChooseLockSettingsHelper; private ChooseLockSettingsHelper mChooseLockSettingsHelper;
private com.android.settings.ChooseLockPassword.Stage mUiStage = Stage.Introduction; private Stage mUiStage = Stage.Introduction;
private TextView mHeaderText; private TextView mHeaderText;
private String mFirstPin; private String mFirstPin;
private KeyboardView mKeyboardView; private KeyboardView mKeyboardView;
@@ -65,14 +95,6 @@ public class ChooseLockPassword extends Activity implements OnClickListener, OnE
private boolean mIsAlphaMode; private boolean mIsAlphaMode;
private Button mCancelButton; private Button mCancelButton;
private Button mNextButton; private Button mNextButton;
public static final String PASSWORD_MIN_KEY = "lockscreen.password_min";
public static final String PASSWORD_MAX_KEY = "lockscreen.password_max";
public static final String PASSWORD_MIN_LETTERS_KEY = "lockscreen.password_min_letters";
public static final String PASSWORD_MIN_LOWERCASE_KEY = "lockscreen.password_min_lowercase";
public static final String PASSWORD_MIN_UPPERCASE_KEY = "lockscreen.password_min_uppercase";
public static final String PASSWORD_MIN_NUMERIC_KEY = "lockscreen.password_min_numeric";
public static final String PASSWORD_MIN_SYMBOLS_KEY = "lockscreen.password_min_symbols";
public static final String PASSWORD_MIN_NONLETTER_KEY = "lockscreen.password_min_nonletter";
private static Handler mHandler = new Handler(); private static Handler mHandler = new Handler();
private static final int CONFIRM_EXISTING_REQUEST = 58; private static final int CONFIRM_EXISTING_REQUEST = 58;
static final int RESULT_FINISHED = RESULT_FIRST_USER; static final int RESULT_FINISHED = RESULT_FIRST_USER;
@@ -109,104 +131,109 @@ public class ChooseLockPassword extends Activity implements OnClickListener, OnE
public final int buttonText; public final int buttonText;
} }
// required constructor for fragments
public ChooseLockPasswordFragment() {
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mLockPatternUtils = new LockPatternUtils(this); mLockPatternUtils = new LockPatternUtils(getActivity());
mRequestedQuality = Math.max(getIntent().getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, Intent intent = getActivity().getIntent();
mRequestedQuality = Math.max(intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY,
mRequestedQuality), mLockPatternUtils.getRequestedPasswordQuality()); mRequestedQuality), mLockPatternUtils.getRequestedPasswordQuality());
mPasswordMinLength = Math.max( mPasswordMinLength = Math.max(
getIntent().getIntExtra(PASSWORD_MIN_KEY, mPasswordMinLength), mLockPatternUtils intent.getIntExtra(PASSWORD_MIN_KEY, mPasswordMinLength), mLockPatternUtils
.getRequestedMinimumPasswordLength()); .getRequestedMinimumPasswordLength());
mPasswordMaxLength = getIntent().getIntExtra(PASSWORD_MAX_KEY, mPasswordMaxLength); mPasswordMaxLength = intent.getIntExtra(PASSWORD_MAX_KEY, mPasswordMaxLength);
mPasswordMinLetters = Math.max(getIntent().getIntExtra(PASSWORD_MIN_LETTERS_KEY, mPasswordMinLetters = Math.max(intent.getIntExtra(PASSWORD_MIN_LETTERS_KEY,
mPasswordMinLetters), mLockPatternUtils.getRequestedPasswordMinimumLetters()); mPasswordMinLetters), mLockPatternUtils.getRequestedPasswordMinimumLetters());
mPasswordMinUpperCase = Math.max(getIntent().getIntExtra(PASSWORD_MIN_UPPERCASE_KEY, mPasswordMinUpperCase = Math.max(intent.getIntExtra(PASSWORD_MIN_UPPERCASE_KEY,
mPasswordMinUpperCase), mLockPatternUtils.getRequestedPasswordMinimumUpperCase()); mPasswordMinUpperCase), mLockPatternUtils.getRequestedPasswordMinimumUpperCase());
mPasswordMinLowerCase = Math.max(getIntent().getIntExtra(PASSWORD_MIN_LOWERCASE_KEY, mPasswordMinLowerCase = Math.max(intent.getIntExtra(PASSWORD_MIN_LOWERCASE_KEY,
mPasswordMinLowerCase), mLockPatternUtils.getRequestedPasswordMinimumLowerCase()); mPasswordMinLowerCase), mLockPatternUtils.getRequestedPasswordMinimumLowerCase());
mPasswordMinNumeric = Math.max(getIntent().getIntExtra(PASSWORD_MIN_NUMERIC_KEY, mPasswordMinNumeric = Math.max(intent.getIntExtra(PASSWORD_MIN_NUMERIC_KEY,
mPasswordMinNumeric), mLockPatternUtils.getRequestedPasswordMinimumNumeric()); mPasswordMinNumeric), mLockPatternUtils.getRequestedPasswordMinimumNumeric());
mPasswordMinSymbols = Math.max(getIntent().getIntExtra(PASSWORD_MIN_SYMBOLS_KEY, mPasswordMinSymbols = Math.max(intent.getIntExtra(PASSWORD_MIN_SYMBOLS_KEY,
mPasswordMinSymbols), mLockPatternUtils.getRequestedPasswordMinimumSymbols()); mPasswordMinSymbols), mLockPatternUtils.getRequestedPasswordMinimumSymbols());
mPasswordMinNonLetter = Math.max(getIntent().getIntExtra(PASSWORD_MIN_NONLETTER_KEY, mPasswordMinNonLetter = Math.max(intent.getIntExtra(PASSWORD_MIN_NONLETTER_KEY,
mPasswordMinNonLetter), mLockPatternUtils.getRequestedPasswordMinimumNonLetter()); mPasswordMinNonLetter), mLockPatternUtils.getRequestedPasswordMinimumNonLetter());
final boolean confirmCredentials = getIntent().getBooleanExtra("confirm_credentials", true);
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity());
}
initViews(); @Override
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this); public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.choose_lock_password, null);
mCancelButton = (Button) view.findViewById(R.id.cancel_button);
mCancelButton.setOnClickListener(this);
mNextButton = (Button) view.findViewById(R.id.next_button);
mNextButton.setOnClickListener(this);
mIsAlphaMode = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == mRequestedQuality
|| DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC == mRequestedQuality
|| DevicePolicyManager.PASSWORD_QUALITY_COMPLEX == mRequestedQuality;
mKeyboardView = (PasswordEntryKeyboardView) view.findViewById(R.id.keyboard);
mPasswordEntry = (TextView) view.findViewById(R.id.password_entry);
mPasswordEntry.setOnEditorActionListener(this);
mPasswordEntry.addTextChangedListener(this);
mKeyboardHelper = new PasswordEntryKeyboardHelper(getActivity(),
mKeyboardView, mPasswordEntry);
mKeyboardHelper.setKeyboardMode(mIsAlphaMode ?
PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
: PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
mHeaderText = (TextView) view.findViewById(R.id.headerText);
mKeyboardView.requestFocus();
Intent intent = getActivity().getIntent();
final boolean confirmCredentials = intent.getBooleanExtra("confirm_credentials", true);
if (savedInstanceState == null) { if (savedInstanceState == null) {
updateStage(Stage.Introduction); updateStage(Stage.Introduction);
if (confirmCredentials) { if (confirmCredentials) {
mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST, mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST,
null, null); null, null);
} }
} } else {
}
private void initViews() {
setContentView(R.layout.choose_lock_password);
// Disable IME on our window since we provide our own keyboard
getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
mCancelButton = (Button) findViewById(R.id.cancel_button);
mCancelButton.setOnClickListener(this);
mNextButton = (Button) findViewById(R.id.next_button);
mNextButton.setOnClickListener(this);
mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
mPasswordEntry = (TextView) findViewById(R.id.password_entry);
mPasswordEntry.setOnEditorActionListener(this);
mPasswordEntry.addTextChangedListener(this);
mIsAlphaMode = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == mRequestedQuality
|| DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC == mRequestedQuality
|| DevicePolicyManager.PASSWORD_QUALITY_COMPLEX == mRequestedQuality;
mKeyboardHelper = new PasswordEntryKeyboardHelper(this, mKeyboardView, mPasswordEntry);
mKeyboardHelper.setKeyboardMode(mIsAlphaMode ?
PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
: PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
mHeaderText = (TextView) findViewById(R.id.headerText);
mKeyboardView.requestFocus();
}
@Override
protected void onResume() {
super.onResume();
updateStage(mUiStage);
mKeyboardView.requestFocus();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(KEY_UI_STAGE, mUiStage.name());
outState.putString(KEY_FIRST_PIN, mFirstPin);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
String state = savedInstanceState.getString(KEY_UI_STAGE);
mFirstPin = savedInstanceState.getString(KEY_FIRST_PIN); mFirstPin = savedInstanceState.getString(KEY_FIRST_PIN);
final String state = savedInstanceState.getString(KEY_UI_STAGE);
if (state != null) { if (state != null) {
mUiStage = Stage.valueOf(state); mUiStage = Stage.valueOf(state);
updateStage(mUiStage); updateStage(mUiStage);
} }
} }
return view;
}
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, public void onResume() {
super.onResume();
updateStage(mUiStage);
mKeyboardView.requestFocus();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(KEY_UI_STAGE, mUiStage.name());
outState.putString(KEY_FIRST_PIN, mFirstPin);
}
@Override
public void onActivityResult(int requestCode, int resultCode,
Intent data) { Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) { switch (requestCode) {
case CONFIRM_EXISTING_REQUEST: case CONFIRM_EXISTING_REQUEST:
if (resultCode != Activity.RESULT_OK) { if (resultCode != Activity.RESULT_OK) {
setResult(RESULT_FINISHED); getActivity().setResult(RESULT_FINISHED);
finish(); getActivity().finish();
} }
break; break;
} }
@@ -326,7 +353,7 @@ public class ChooseLockPassword extends Activity implements OnClickListener, OnE
if (mFirstPin.equals(pin)) { if (mFirstPin.equals(pin)) {
mLockPatternUtils.clearLock(); mLockPatternUtils.clearLock();
mLockPatternUtils.saveLockPassword(pin, mRequestedQuality); mLockPatternUtils.saveLockPassword(pin, mRequestedQuality);
finish(); getActivity().finish();
} else { } else {
updateStage(Stage.ConfirmWrong); updateStage(Stage.ConfirmWrong);
CharSequence tmp = mPasswordEntry.getText(); CharSequence tmp = mPasswordEntry.getText();
@@ -347,7 +374,7 @@ public class ChooseLockPassword extends Activity implements OnClickListener, OnE
break; break;
case R.id.cancel_button: case R.id.cancel_button:
finish(); getActivity().finish();
break; break;
} }
} }
@@ -414,4 +441,5 @@ public class ChooseLockPassword extends Activity implements OnClickListener, OnE
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
} }
}
} }

View File

@@ -22,14 +22,18 @@ import com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternView; import com.android.internal.widget.LockPatternView;
import com.android.internal.widget.LockPatternView.Cell; import com.android.internal.widget.LockPatternView.Cell;
import static com.android.internal.widget.LockPatternView.DisplayMode; import static com.android.internal.widget.LockPatternView.DisplayMode;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
@@ -44,7 +48,7 @@ import java.util.List;
* - asks for confirmation / restart * - asks for confirmation / restart
* - saves chosen password when confirmed * - saves chosen password when confirmed
*/ */
public class ChooseLockPattern extends Activity implements View.OnClickListener{ public class ChooseLockPattern extends PreferenceActivity {
/** /**
* 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,6 +60,30 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
*/ */
static final int RESULT_FINISHED = RESULT_FIRST_USER; static final int RESULT_FINISHED = RESULT_FIRST_USER;
@Override
public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockPatternFragment.class.getName());
modIntent.putExtra(EXTRA_NO_HEADERS, true);
return modIntent;
}
@Override
public void onCreate(Bundle savedInstanceState) {
// requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// *** TODO ***
// chooseLockPatternFragment.onKeyDown(keyCode, event);
return super.onKeyDown(keyCode, event);
}
public static class ChooseLockPatternFragment extends Fragment
implements View.OnClickListener {
public static final int CONFIRM_EXISTING_REQUEST = 55; 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
@@ -85,14 +113,14 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
)); ));
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, public void onActivityResult(int requestCode, int resultCode,
Intent data) { Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) { switch (requestCode) {
case CONFIRM_EXISTING_REQUEST: case CONFIRM_EXISTING_REQUEST:
if (resultCode != Activity.RESULT_OK) { if (resultCode != Activity.RESULT_OK) {
setResult(RESULT_FINISHED); getActivity().setResult(RESULT_FINISHED);
finish(); getActivity().finish();
} }
updateStage(Stage.Introduction); updateStage(Stage.Introduction);
break; break;
@@ -103,7 +131,8 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
* The pattern listener that responds according to a user choosing a new * The pattern listener that responds according to a user choosing a new
* lock pattern. * lock pattern.
*/ */
protected LockPatternView.OnPatternListener mChooseNewLockPatternListener = new LockPatternView.OnPatternListener() { protected LockPatternView.OnPatternListener mChooseNewLockPatternListener =
new LockPatternView.OnPatternListener() {
public void onPatternStart() { public void onPatternStart() {
mLockPatternView.removeCallbacks(mClearPatternRunnable); mLockPatternView.removeCallbacks(mClearPatternRunnable);
@@ -116,7 +145,8 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
public void onPatternDetected(List<LockPatternView.Cell> pattern) { public void onPatternDetected(List<LockPatternView.Cell> pattern) {
if (mUiStage == Stage.NeedToConfirm || mUiStage == Stage.ConfirmWrong) { if (mUiStage == Stage.NeedToConfirm || mUiStage == Stage.ConfirmWrong) {
if (mChosenPattern == null) throw new IllegalStateException("null chosen pattern in stage 'need to confirm"); if (mChosenPattern == null) throw new IllegalStateException(
"null chosen pattern in stage 'need to confirm");
if (mChosenPattern.equals(pattern)) { if (mChosenPattern.equals(pattern)) {
updateStage(Stage.ChoiceConfirmed); updateStage(Stage.ChoiceConfirmed);
} else { } else {
@@ -266,30 +296,49 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
private static final String KEY_PATTERN_CHOICE = "chosenPattern"; private static final String KEY_PATTERN_CHOICE = "chosenPattern";
@Override @Override
protected void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this); mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity());
requestWindowFeature(Window.FEATURE_NO_TITLE); }
setupViews(); @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// setupViews()
View view = inflater.inflate(R.layout.choose_lock_pattern, null);
mHeaderText = (TextView) view.findViewById(R.id.headerText);
mLockPatternView = (LockPatternView) view.findViewById(R.id.lockPattern);
mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener);
mLockPatternView.setTactileFeedbackEnabled(
mChooseLockSettingsHelper.utils().isTactileFeedbackEnabled());
mFooterText = (TextView) view.findViewById(R.id.footerText);
mFooterLeftButton = (TextView) view.findViewById(R.id.footerLeftButton);
mFooterRightButton = (TextView) view.findViewById(R.id.footerRightButton);
mFooterLeftButton.setOnClickListener(this);
mFooterRightButton.setOnClickListener(this);
// 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
= (LinearLayoutWithDefaultTouchRecepient) findViewById( = (LinearLayoutWithDefaultTouchRecepient) view.findViewById(
R.id.topLayout); R.id.topLayout);
topLayout.setDefaultTouchRecepient(mLockPatternView); topLayout.setDefaultTouchRecepient(mLockPatternView);
final boolean confirmCredentials = getIntent().getBooleanExtra("confirm_credentials", true); final boolean confirmCredentials = getActivity().getIntent()
.getBooleanExtra("confirm_credentials", true);
if (savedInstanceState == null) { if (savedInstanceState == null) {
if (confirmCredentials) { if (confirmCredentials) {
// first launch. As a security measure, we're in NeedToConfirm mode until we know // first launch. As a security measure, we're in NeedToConfirm mode until we
// there isn't an existing password or the user confirms their password. // know there isn't an existing password or the user confirms their password.
updateStage(Stage.NeedToConfirm); updateStage(Stage.NeedToConfirm);
boolean launchedConfirmationActivity = boolean launchedConfirmationActivity =
mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST, mChooseLockSettingsHelper.launchConfirmationActivity(
null, null); CONFIRM_EXISTING_REQUEST, null, null);
if (!launchedConfirmationActivity) { if (!launchedConfirmationActivity) {
updateStage(Stage.Introduction); updateStage(Stage.Introduction);
} }
@@ -304,29 +353,7 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
} }
updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]); updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
} }
} return view;
/**
* Keep all "find view" related stuff confined to this function since in
* case someone needs to subclass and customize.
*/
protected void setupViews() {
setContentView(R.layout.choose_lock_pattern);
mHeaderText = (TextView) findViewById(R.id.headerText);
mLockPatternView = (LockPatternView) findViewById(R.id.lockPattern);
mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener);
mLockPatternView.setTactileFeedbackEnabled(
mChooseLockSettingsHelper.utils().isTactileFeedbackEnabled());
mFooterText = (TextView) findViewById(R.id.footerText);
mFooterLeftButton = (TextView) findViewById(R.id.footerLeftButton);
mFooterRightButton = (TextView) findViewById(R.id.footerRightButton);
mFooterLeftButton.setOnClickListener(this);
mFooterRightButton.setOnClickListener(this);
} }
public void onClick(View v) { public void onClick(View v) {
@@ -337,8 +364,8 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
updateStage(Stage.Introduction); updateStage(Stage.Introduction);
} else if (mUiStage.leftMode == LeftButtonMode.Cancel) { } else if (mUiStage.leftMode == LeftButtonMode.Cancel) {
// They are canceling the entire wizard // They are canceling the entire wizard
setResult(RESULT_FINISHED); getActivity().setResult(RESULT_FINISHED);
finish(); getActivity().finish();
} else { } else {
throw new IllegalStateException("left footer button pressed, but stage of " + throw new IllegalStateException("left footer button pressed, but stage of " +
mUiStage + " doesn't make sense"); mUiStage + " doesn't make sense");
@@ -369,7 +396,6 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
} }
} }
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
if (mUiStage == Stage.HelpScreen) { if (mUiStage == Stage.HelpScreen) {
@@ -381,21 +407,19 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
updateStage(Stage.HelpScreen); updateStage(Stage.HelpScreen);
return true; return true;
} }
return false;
return super.onKeyDown(keyCode, event);
} }
@Override public void onSaveInstanceState(Bundle outState) {
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putInt(KEY_UI_STAGE, mUiStage.ordinal()); outState.putInt(KEY_UI_STAGE, mUiStage.ordinal());
if (mChosenPattern != null) { if (mChosenPattern != null) {
outState.putString(KEY_PATTERN_CHOICE, LockPatternUtils.patternToString(mChosenPattern)); outState.putString(KEY_PATTERN_CHOICE,
LockPatternUtils.patternToString(mChosenPattern));
} }
} }
/** /**
* Updates the messages and buttons appropriate to what stage the user * Updates the messages and buttons appropriate to what stage the user
* is at in choosing a view. This doesn't handle clearing out the pattern; * is at in choosing a view. This doesn't handle clearing out the pattern;
@@ -489,7 +513,8 @@ public class ChooseLockPattern extends Activity implements View.OnClickListener{
utils.setTactileFeedbackEnabled(false); utils.setTactileFeedbackEnabled(false);
} }
setResult(RESULT_FINISHED); getActivity().setResult(RESULT_FINISHED);
finish(); getActivity().finish();
}
} }
} }

View File

@@ -16,15 +16,34 @@
package com.android.settings; package com.android.settings;
import android.app.Activity; import android.app.Fragment;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceActivity;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
public class ChooseLockPatternExample extends Activity implements View.OnClickListener { public class ChooseLockPatternExample extends PreferenceActivity {
// required constructor for fragments
public ChooseLockPatternExample() {
}
@Override
public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockPatternExampleFragment.class.getName());
modIntent.putExtra(EXTRA_NO_HEADERS, true);
return modIntent;
}
public static class ChooseLockPatternExampleFragment extends Fragment
implements View.OnClickListener {
private static final long START_DELAY = 1000; private static final long START_DELAY = 1000;
protected static final String TAG = "Settings"; protected static final String TAG = "Settings";
private View mNextButton; private View mNextButton;
@@ -39,20 +58,30 @@ public class ChooseLockPatternExample extends Activity implements View.OnClickLi
}; };
@Override @Override
protected void onCreate(Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container,
super.onCreate(savedInstanceState); Bundle savedInstanceState) {
setContentView(R.layout.choose_lock_pattern_example); View view = inflater.inflate(R.layout.choose_lock_pattern_example, null);
initViews(); mNextButton = view.findViewById(R.id.next_button);
mNextButton.setOnClickListener(this);
mSkipButton = view.findViewById(R.id.skip_button);
mSkipButton.setOnClickListener(this);
mImageView = (ImageView) view.findViewById(R.id.lock_anim);
mImageView.setBackgroundResource(R.drawable.lock_anim);
mImageView.setOnClickListener(this);
mAnimation = (AnimationDrawable) mImageView.getBackground();
return view;
} }
@Override @Override
protected void onResume() { public void onResume() {
super.onResume(); super.onResume();
mHandler.postDelayed(mRunnable, START_DELAY); mHandler.postDelayed(mRunnable, START_DELAY);
} }
@Override @Override
protected void onPause() { public void onPause() {
super.onPause(); super.onPause();
stopAnimation(mAnimation); stopAnimation(mAnimation);
} }
@@ -60,31 +89,18 @@ public class ChooseLockPatternExample extends Activity implements View.OnClickLi
public void onClick(View v) { public void onClick(View v) {
if (v == mSkipButton) { if (v == mSkipButton) {
// Canceling, so finish all // Canceling, so finish all
setResult(ChooseLockPattern.RESULT_FINISHED); getActivity().setResult(ChooseLockPattern.RESULT_FINISHED);
finish(); getActivity().finish();
} else if (v == mNextButton) { } else if (v == mNextButton) {
stopAnimation(mAnimation); stopAnimation(mAnimation);
Intent intent = new Intent(this, ChooseLockPattern.class); Intent intent = new Intent(getActivity(), ChooseLockPattern.class);
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
intent.putExtra("confirm_credentials", false); intent.putExtra("confirm_credentials", false);
startActivity(intent); startActivity(intent);
finish(); getActivity().finish();
} }
} }
private void initViews() {
mNextButton = findViewById(R.id.next_button);
mNextButton.setOnClickListener(this);
mSkipButton = findViewById(R.id.skip_button);
mSkipButton.setOnClickListener(this);
mImageView = (ImageView) findViewById(R.id.lock_anim);
mImageView.setBackgroundResource(R.drawable.lock_anim);
mImageView.setOnClickListener(this);
mAnimation = (AnimationDrawable) mImageView.getBackground();
}
protected void startAnimation(final AnimationDrawable animation) { protected void startAnimation(final AnimationDrawable animation) {
if (animation != null && !animation.isRunning()) { if (animation != null && !animation.isRunning()) {
animation.run(); animation.run();
@@ -94,5 +110,6 @@ public class ChooseLockPatternExample extends Activity implements View.OnClickLi
protected void stopAnimation(final AnimationDrawable animation) { protected void stopAnimation(final AnimationDrawable animation) {
if (animation != null && animation.isRunning()) animation.stop(); if (animation != null && animation.isRunning()) animation.stop();
} }
}
} }

View File

@@ -18,49 +18,70 @@ package com.android.settings;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import android.app.Activity; import android.app.Fragment;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
public class ChooseLockPatternTutorial extends Activity implements View.OnClickListener { public class ChooseLockPatternTutorial extends PreferenceActivity {
// required constructor for fragments
public ChooseLockPatternTutorial() {
}
@Override
public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockPatternTutorialFragment.class.getName());
modIntent.putExtra(EXTRA_NO_HEADERS, true);
return modIntent;
}
public static class ChooseLockPatternTutorialFragment extends Fragment
implements View.OnClickListener {
private View mNextButton; private View mNextButton;
private View mSkipButton; private View mSkipButton;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Don't show the tutorial if the user has seen it before. // Don't show the tutorial if the user has seen it before.
LockPatternUtils lockPatternUtils = new LockPatternUtils(this); LockPatternUtils lockPatternUtils = new LockPatternUtils(getActivity());
if (savedInstanceState == null && lockPatternUtils.isPatternEverChosen()) { if (savedInstanceState == null && lockPatternUtils.isPatternEverChosen()) {
Intent intent = new Intent(this, ChooseLockPattern.class); Intent intent = new Intent(getActivity(), ChooseLockPattern.class);
intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
intent.putExtra("confirm_credentials", false); intent.putExtra("confirm_credentials", false);
startActivity(intent); startActivity(intent);
finish(); getActivity().finish();
} else {
initViews();
} }
} }
private void initViews() { @Override
setContentView(R.layout.choose_lock_pattern_tutorial); public View onCreateView(LayoutInflater inflater, ViewGroup container,
mNextButton = findViewById(R.id.next_button); Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.choose_lock_pattern_tutorial, null);
mNextButton = view.findViewById(R.id.next_button);
mNextButton.setOnClickListener(this); mNextButton.setOnClickListener(this);
mSkipButton = findViewById(R.id.skip_button); mSkipButton = view.findViewById(R.id.skip_button);
mSkipButton.setOnClickListener(this); mSkipButton.setOnClickListener(this);
return view;
} }
public void onClick(View v) { public void onClick(View v) {
if (v == mSkipButton) { if (v == mSkipButton) {
// Canceling, so finish all // Canceling, so finish all
setResult(ChooseLockPattern.RESULT_FINISHED); getActivity().setResult(ChooseLockPattern.RESULT_FINISHED);
finish(); getActivity().finish();
} else if (v == mNextButton) { } else if (v == mNextButton) {
Intent intent = new Intent(this, ChooseLockPatternExample.class); Intent intent = new Intent(getActivity(), ChooseLockPatternExample.class);
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(intent); startActivity(intent);
finish(); getActivity().finish();
}
} }
} }
} }

View File

@@ -20,21 +20,40 @@ import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.PasswordEntryKeyboardHelper; import com.android.internal.widget.PasswordEntryKeyboardHelper;
import com.android.internal.widget.PasswordEntryKeyboardView; import com.android.internal.widget.PasswordEntryKeyboardView;
import android.app.Activity; import android.app.Fragment;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.Editable; import android.preference.PreferenceActivity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.ViewGroup;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener; import android.widget.TextView.OnEditorActionListener;
public class ConfirmLockPassword extends Activity implements OnClickListener, public class ConfirmLockPassword extends PreferenceActivity {
@Override
public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ConfirmLockPasswordFragment.class.getName());
modIntent.putExtra(EXTRA_NO_HEADERS, true);
return modIntent;
}
@Override
public void onCreate(Bundle savedInstanceState) {
// Disable IME on our window since we provide our own keyboard
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
//WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
super.onCreate(savedInstanceState);
}
public static class ConfirmLockPasswordFragment extends Fragment implements OnClickListener,
OnEditorActionListener { OnEditorActionListener {
private static final long ERROR_MESSAGE_TIMEOUT = 3000; private static final long ERROR_MESSAGE_TIMEOUT = 3000;
private TextView mPasswordEntry; private TextView mPasswordEntry;
@@ -44,45 +63,52 @@ public class ConfirmLockPassword extends Activity implements OnClickListener,
private PasswordEntryKeyboardHelper mKeyboardHelper; private PasswordEntryKeyboardHelper mKeyboardHelper;
private PasswordEntryKeyboardView mKeyboardView; private PasswordEntryKeyboardView mKeyboardView;
@Override
protected void onCreate(Bundle savedInstanceState) { // required constructor for fragments
super.onCreate(savedInstanceState); public ConfirmLockPasswordFragment() {
mLockPatternUtils = new LockPatternUtils(this);
initViews();
} }
private void initViews() { @Override
final int storedQuality = mLockPatternUtils.getKeyguardStoredPasswordQuality(); public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.confirm_lock_password); super.onCreate(savedInstanceState);
// Disable IME on our window since we provide our own keyboard mLockPatternUtils = new LockPatternUtils(getActivity());
getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, }
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
findViewById(R.id.cancel_button).setOnClickListener(this); @Override
findViewById(R.id.next_button).setOnClickListener(this); public View onCreateView(LayoutInflater inflater, ViewGroup container,
mPasswordEntry = (TextView) findViewById(R.id.password_entry); Bundle savedInstanceState) {
final int storedQuality = mLockPatternUtils.getKeyguardStoredPasswordQuality();
View view = inflater.inflate(R.layout.confirm_lock_password, null);
// Disable IME on our window since we provide our own keyboard
view.findViewById(R.id.cancel_button).setOnClickListener(this);
view.findViewById(R.id.next_button).setOnClickListener(this);
mPasswordEntry = (TextView) view.findViewById(R.id.password_entry);
mPasswordEntry.setOnEditorActionListener(this); mPasswordEntry.setOnEditorActionListener(this);
mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard); mKeyboardView = (PasswordEntryKeyboardView) view.findViewById(R.id.keyboard);
mHeaderText = (TextView) findViewById(R.id.headerText); mHeaderText = (TextView) view.findViewById(R.id.headerText);
final boolean isAlpha = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == storedQuality final boolean isAlpha = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == storedQuality
|| DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC == storedQuality || DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC == storedQuality
|| DevicePolicyManager.PASSWORD_QUALITY_COMPLEX == storedQuality; || DevicePolicyManager.PASSWORD_QUALITY_COMPLEX == storedQuality;
mHeaderText.setText(isAlpha ? R.string.lockpassword_confirm_your_password_header mHeaderText.setText(isAlpha ? R.string.lockpassword_confirm_your_password_header
: R.string.lockpassword_confirm_your_pin_header); : R.string.lockpassword_confirm_your_pin_header);
mKeyboardHelper = new PasswordEntryKeyboardHelper(this, mKeyboardView, mPasswordEntry); mKeyboardHelper = new PasswordEntryKeyboardHelper(getActivity(),
mKeyboardView, mPasswordEntry);
mKeyboardHelper.setKeyboardMode(isAlpha ? PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA mKeyboardHelper.setKeyboardMode(isAlpha ? PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
: PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC); : PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
mKeyboardView.requestFocus(); mKeyboardView.requestFocus();
return view;
} }
@Override @Override
protected void onPause() { public void onPause() {
super.onPause(); super.onPause();
mKeyboardView.requestFocus(); mKeyboardView.requestFocus();
} }
@Override @Override
protected void onResume() { public void onResume() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
super.onResume(); super.onResume();
mKeyboardView.requestFocus(); mKeyboardView.requestFocus();
@@ -91,8 +117,8 @@ public class ConfirmLockPassword extends Activity implements OnClickListener,
private void handleNext() { private void handleNext() {
final String pin = mPasswordEntry.getText().toString(); final String pin = mPasswordEntry.getText().toString();
if (mLockPatternUtils.checkPassword(pin)) { if (mLockPatternUtils.checkPassword(pin)) {
setResult(RESULT_OK); getActivity().setResult(RESULT_OK);
finish(); getActivity().finish();
} else { } else {
showError(R.string.lockpattern_need_to_unlock_wrong); showError(R.string.lockpattern_need_to_unlock_wrong);
} }
@@ -105,8 +131,8 @@ public class ConfirmLockPassword extends Activity implements OnClickListener,
break; break;
case R.id.cancel_button: case R.id.cancel_button:
setResult(RESULT_CANCELED); getActivity().setResult(RESULT_CANCELED);
finish(); getActivity().finish();
break; break;
} }
} }
@@ -129,4 +155,5 @@ public class ConfirmLockPassword extends Activity implements OnClickListener,
} }
return false; return false;
} }
}
} }

View File

@@ -22,12 +22,16 @@ import com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient;
import com.android.internal.widget.LockPatternView.Cell; import com.android.internal.widget.LockPatternView.Cell;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.content.Intent; import android.content.Intent;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.widget.TextView; import android.widget.TextView;
import android.view.Window; import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.List; import java.util.List;
@@ -37,7 +41,7 @@ import java.util.List;
* Sets an activity result of {@link Activity#RESULT_OK} when the user * Sets an activity result of {@link Activity#RESULT_OK} when the user
* successfully confirmed their pattern. * successfully confirmed their pattern.
*/ */
public class ConfirmLockPattern extends Activity { public class ConfirmLockPattern extends PreferenceActivity {
/** /**
* Names of {@link CharSequence} fields within the originating {@link Intent} * Names of {@link CharSequence} fields within the originating {@link Intent}
@@ -45,10 +49,27 @@ public class ConfirmLockPattern extends Activity {
* The view will use the system-defined resource strings for any labels that * The view will use the system-defined resource strings for any labels that
* the caller does not supply. * the caller does not supply.
*/ */
public static final String HEADER_TEXT = "com.android.settings.ConfirmLockPattern.header"; public static final String PACKAGE = "com.android.settings";
public static final String FOOTER_TEXT = "com.android.settings.ConfirmLockPattern.footer"; public static final String HEADER_TEXT = PACKAGE + ".ConfirmLockPattern.header";
public static final String HEADER_WRONG_TEXT = "com.android.settings.ConfirmLockPattern.header_wrong"; public static final String FOOTER_TEXT = PACKAGE + ".ConfirmLockPattern.footer";
public static final String FOOTER_WRONG_TEXT = "com.android.settings.ConfirmLockPattern.footer_wrong"; public static final String HEADER_WRONG_TEXT = PACKAGE + ".ConfirmLockPattern.header_wrong";
public static final String FOOTER_WRONG_TEXT = PACKAGE + ".ConfirmLockPattern.footer_wrong";
private enum Stage {
NeedToUnlock,
NeedToUnlockWrong,
LockedOut
}
@Override
public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ConfirmLockPatternFragment.class.getName());
modIntent.putExtra(EXTRA_NO_HEADERS, true);
return modIntent;
}
public static class ConfirmLockPatternFragment extends Fragment {
// how long we wait to clear a wrong pattern // how long we wait to clear a wrong pattern
private static final int WRONG_PATTERN_CLEAR_TIMEOUT_MS = 2000; private static final int WRONG_PATTERN_CLEAR_TIMEOUT_MS = 2000;
@@ -69,34 +90,32 @@ public class ConfirmLockPattern extends Activity {
private CharSequence mHeaderWrongText; private CharSequence mHeaderWrongText;
private CharSequence mFooterWrongText; private CharSequence mFooterWrongText;
// required constructor for fragments
public ConfirmLockPatternFragment() {
private enum Stage {
NeedToUnlock,
NeedToUnlockWrong,
LockedOut
} }
@Override @Override
protected void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mLockPatternUtils = new LockPatternUtils(getActivity());
}
mLockPatternUtils = new LockPatternUtils(this); @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
requestWindowFeature(Window.FEATURE_NO_TITLE); Bundle savedInstanceState) {
setContentView(R.layout.confirm_lock_pattern); View view = inflater.inflate(R.layout.confirm_lock_pattern, null);
mHeaderTextView = (TextView) view.findViewById(R.id.headerText);
mHeaderTextView = (TextView) findViewById(R.id.headerText); mLockPatternView = (LockPatternView) view.findViewById(R.id.lockPattern);
mLockPatternView = (LockPatternView) findViewById(R.id.lockPattern); mFooterTextView = (TextView) view.findViewById(R.id.footerText);
mFooterTextView = (TextView) findViewById(R.id.footerText);
// 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
= (LinearLayoutWithDefaultTouchRecepient) findViewById( = (LinearLayoutWithDefaultTouchRecepient) view.findViewById(R.id.topLayout);
R.id.topLayout);
topLayout.setDefaultTouchRecepient(mLockPatternView); topLayout.setDefaultTouchRecepient(mLockPatternView);
Intent intent = getIntent(); Intent intent = getActivity().getIntent();
if (intent != null) { if (intent != null) {
mHeaderText = intent.getCharSequenceExtra(HEADER_TEXT); mHeaderText = intent.getCharSequenceExtra(HEADER_TEXT);
mFooterText = intent.getCharSequenceExtra(FOOTER_TEXT); mFooterText = intent.getCharSequenceExtra(FOOTER_TEXT);
@@ -115,20 +134,21 @@ public class ConfirmLockPattern extends Activity {
// success (don't want user to get stuck confirming something that // success (don't want user to get stuck confirming something that
// doesn't exist). // doesn't exist).
if (!mLockPatternUtils.savedPatternExists()) { if (!mLockPatternUtils.savedPatternExists()) {
setResult(RESULT_OK); getActivity().setResult(Activity.RESULT_OK);
finish(); getActivity().finish();
} }
} }
return view;
} }
@Override @Override
protected void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
// deliberately not calling super since we are managing this in full // deliberately not calling super since we are managing this in full
outState.putInt(KEY_NUM_WRONG_ATTEMPTS, mNumWrongConfirmAttempts); outState.putInt(KEY_NUM_WRONG_ATTEMPTS, mNumWrongConfirmAttempts);
} }
@Override @Override
protected void onPause() { public void onPause() {
super.onPause(); super.onPause();
if (mCountdownTimer != null) { if (mCountdownTimer != null) {
@@ -137,7 +157,7 @@ public class ConfirmLockPattern extends Activity {
} }
@Override @Override
protected void onResume() { public void onResume() {
super.onResume(); super.onResume();
// if the user is currently locked out, enforce it. // if the user is currently locked out, enforce it.
@@ -212,7 +232,8 @@ public class ConfirmLockPattern extends Activity {
* The pattern listener that responds according to a user confirming * The pattern listener that responds according to a user confirming
* an existing lock pattern. * an existing lock pattern.
*/ */
private LockPatternView.OnPatternListener mConfirmExistingLockPatternListener = new LockPatternView.OnPatternListener() { private LockPatternView.OnPatternListener mConfirmExistingLockPatternListener
= new LockPatternView.OnPatternListener() {
public void onPatternStart() { public void onPatternStart() {
mLockPatternView.removeCallbacks(mClearPatternRunnable); mLockPatternView.removeCallbacks(mClearPatternRunnable);
@@ -228,11 +249,12 @@ public class ConfirmLockPattern extends Activity {
public void onPatternDetected(List<LockPatternView.Cell> pattern) { public void onPatternDetected(List<LockPatternView.Cell> pattern) {
if (mLockPatternUtils.checkPattern(pattern)) { if (mLockPatternUtils.checkPattern(pattern)) {
setResult(RESULT_OK); getActivity().setResult(Activity.RESULT_OK);
finish(); getActivity().finish();
} else { } else {
if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL && if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL &&
++mNumWrongConfirmAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) { ++mNumWrongConfirmAttempts
>= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(); long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
handleAttemptLockout(deadline); handleAttemptLockout(deadline);
} else { } else {
@@ -267,4 +289,5 @@ public class ConfirmLockPattern extends Activity {
} }
}.start(); }.start();
} }
}
} }

View File

@@ -90,6 +90,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123; private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
private static final int FALLBACK_LOCK_AFTER_TIMEOUT_VALUE = 5000; // compatible with pre-Froyo private static final int FALLBACK_LOCK_AFTER_TIMEOUT_VALUE = 5000; // compatible with pre-Froyo
private static final String TAG = "SecuritySettings";
// Credential storage // Credential storage
private final CredentialStorage mCredentialStorage = new CredentialStorage(); private final CredentialStorage mCredentialStorage = new CredentialStorage();
@@ -359,8 +361,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils(); final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
if (KEY_UNLOCK_SET_OR_CHANGE.equals(key)) { if (KEY_UNLOCK_SET_OR_CHANGE.equals(key)) {
Intent intent = new Intent(getActivity(), ChooseLockGeneric.class); startFragment(this, "com.android.settings.ChooseLockGeneric$ChooseLockGenericFragment",
startActivityForResult(intent, SET_OR_CHANGE_LOCK_METHOD_REQUEST); SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
} else if (KEY_LOCK_ENABLED.equals(key)) { } else if (KEY_LOCK_ENABLED.equals(key)) {
lockPatternUtils.setLockPatternEnabled(isToggled(preference)); lockPatternUtils.setLockPatternEnabled(isToggled(preference));
} else if (KEY_VISIBLE_PATTERN.equals(key)) { } else if (KEY_VISIBLE_PATTERN.equals(key)) {