Fix 2373088: Update SecuritySettings with new layout and minor logic tweaks.

This commit is contained in:
Jim Miller
2010-02-09 19:08:02 -08:00
parent 42241e75d2
commit 2f9dbcb491
13 changed files with 317 additions and 470 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 B

View File

@@ -0,0 +1,102 @@
<?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">
<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: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"
/>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@android:drawable/bottom_bar">
<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/password_cancel_button_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/password_ok_button_label"
/>
</RelativeLayout>
</LinearLayout>

View File

@@ -1,84 +0,0 @@
<?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,27 @@
<?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 basically the same layout now, but will likely change -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<include
layout="@layout/choose_lock_password"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</merge>

View File

@@ -1,83 +0,0 @@
<?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

@@ -16,9 +16,6 @@
** limitations under the License. ** limitations under the License.
*/ */
--> -->
<!-- TODO: think about moving to frameworks/base/res -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
@@ -26,11 +23,6 @@
android:background="@android:color/background_dark" android:background="@android:color/background_dark"
android:gravity="center_horizontal"> 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') --> <!-- header text ('Enter Pin') -->
<TextView android:id="@+id/headerText" <TextView android:id="@+id/headerText"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@@ -39,42 +31,72 @@
android:lines="2" android:lines="2"
android:textAppearance="?android:attr/textAppearanceLarge"/> android:textAppearance="?android:attr/textAppearanceLarge"/>
<!-- password entry --> <!-- spacer above text entry field -->
<LinearLayout <View
android:id="@+id/spacerBottom"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="1dip"
android:orientation="horizontal" android:layout_marginTop="6dip"
android:layout_marginRight="6dip" android:background="@android:drawable/divider_horizontal_dark"
android:layout_marginLeft="6dip" />
android:gravity="center_vertical"
android:background="@android:drawable/edit_text">
<!-- displays dots as user enters pin --> <!-- Password entry field -->
<TextView android:id="@+id/pinDisplay" <EditText android:id="@+id/password_entry"
android:layout_width="0dip" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:singleLine="true"
android:maxLines="1"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:textStyle="bold" android:textStyle="bold"
android:inputType="textPassword" 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"
/> />
<ImageButton android:id="@+id/backspace" <!-- Spacer between password entry and keyboard -->
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 <View
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="0dip" android:layout_height="0dip"
android:layout_weight="1" 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"
android:background="@android:drawable/bottom_bar">
<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/password_cancel_button_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/password_ok_button_label"
/>
</RelativeLayout>
</LinearLayout> </LinearLayout>

View File

@@ -1,83 +0,0 @@
<?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,27 @@
<?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 basically the same layout now, but will likely change -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<include
layout="@layout/choose_lock_password"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</merge>

View File

@@ -1,83 +0,0 @@
<?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

@@ -534,6 +534,10 @@
<string name="manage_device_admin">Select device administrators</string> <string name="manage_device_admin">Select device administrators</string>
<!-- Summary of preference to manage device policies --> <!-- Summary of preference to manage device policies -->
<string name="manage_device_admin_summary">Add or remove device administrators</string> <string name="manage_device_admin_summary">Add or remove device administrators</string>
<!-- Label for ChoosePassword/PIN OK button -->
<string name="password_ok_button_label">OK</string>
<!-- Label for ChoosePassword/PIN OK button -->
<string name="password_cancel_button_label">Cancel</string>
<!-- Bluetooth settings --> <!-- Bluetooth settings -->
<!-- Bluetooth settings check box title on Main Settings screen --> <!-- Bluetooth settings check box title on Main Settings screen -->

View File

@@ -20,26 +20,30 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.PasswordEntryKeyboardHelper;
import com.android.internal.widget.PasswordEntryKeyboardView;
import com.android.settings.ChooseLockPattern.LeftButtonMode; import com.android.settings.ChooseLockPattern.LeftButtonMode;
import com.android.settings.ChooseLockPattern.RightButtonMode; import com.android.settings.ChooseLockPattern.RightButtonMode;
import com.android.settings.ChooseLockPattern.Stage; import com.android.settings.ChooseLockPattern.Stage;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.PixelFormat;
import android.inputmethodservice.KeyboardView;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
public class ChooseLockPassword extends Activity implements OnClickListener { 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, private TextView mPasswordEntry;
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 mPasswordMinLength = 4;
private int mPasswordMaxLength = 8; private int mPasswordMaxLength = 8;
private LockPatternUtils mLockPatternUtils; private LockPatternUtils mLockPatternUtils;
@@ -48,6 +52,8 @@ public class ChooseLockPassword extends Activity implements OnClickListener {
private com.android.settings.ChooseLockPassword.Stage mUiStage = Stage.Introduction; private com.android.settings.ChooseLockPassword.Stage mUiStage = Stage.Introduction;
private TextView mHeaderText; private TextView mHeaderText;
private String mFirstPin; private String mFirstPin;
private KeyboardView mKeyboardView;
private PasswordEntryKeyboardHelper mKeyboardHelper;
public static final String PASSWORD_MIN_KEY = "lockscreen.password_min"; 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_MAX_KEY = "lockscreen.password_max";
private static Handler mHandler = new Handler(); private static Handler mHandler = new Handler();
@@ -79,7 +85,7 @@ public class ChooseLockPassword extends Activity implements OnClickListener {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mLockPatternUtils = new LockPatternUtils(this); mLockPatternUtils = new LockPatternUtils(this);
mRequestedMode = getIntent().getIntExtra("password_mode", mRequestedMode); mRequestedMode = getIntent().getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, mRequestedMode);
mPasswordMinLength = getIntent().getIntExtra("password_min_length", mPasswordMinLength); mPasswordMinLength = getIntent().getIntExtra("password_min_length", mPasswordMinLength);
mPasswordMaxLength = getIntent().getIntExtra("password_max_length", mPasswordMaxLength); mPasswordMaxLength = getIntent().getIntExtra("password_max_length", mPasswordMaxLength);
int minMode = mLockPatternUtils.getRequestedPasswordMode(); int minMode = mLockPatternUtils.getRequestedPasswordMode();
@@ -99,25 +105,38 @@ public class ChooseLockPassword extends Activity implements OnClickListener {
} }
private void initViews() { private void initViews() {
switch(mRequestedMode) { setContentView(R.layout.choose_lock_password);
case LockPatternUtils.MODE_PIN: // Disable IME on our window since we provide our own keyboard
case LockPatternUtils.MODE_PASSWORD: getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
case LockPatternUtils.MODE_PATTERN: WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
setContentView(R.layout.choose_lock_pin);
// TODO: alphanumeric layout findViewById(R.id.cancel_button).setOnClickListener(this);
// setContentView(R.layout.choose_lock_password); findViewById(R.id.next_button).setOnClickListener(this);
for (int i = 0; i < digitIds.length; i++) {
Button button = (Button) findViewById(digitIds[i]); mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
button.setOnClickListener(this); mPasswordEntry = (TextView) findViewById(R.id.password_entry);
button.setText(Integer.toString(i));
} final boolean isAlpha = LockPatternUtils.MODE_PASSWORD == mRequestedMode;
break; mKeyboardHelper = new PasswordEntryKeyboardHelper(this, mKeyboardView, mPasswordEntry);
} mKeyboardHelper.setKeyboardMode(isAlpha ? PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
findViewById(R.id.ok).setOnClickListener(this); : PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
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 = (TextView) findViewById(R.id.headerText);
mKeyboardView.requestFocus();
}
@Override
protected void onPause() {
super.onPause();
mKeyboardView.requestFocus();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
updateStage(mUiStage);
mKeyboardView.requestFocus();
} }
@Override @Override
@@ -136,7 +155,7 @@ public class ChooseLockPassword extends Activity implements OnClickListener {
protected void updateStage(Stage stage) { protected void updateStage(Stage stage) {
mHeaderText.setText(stage.headerMessage); mHeaderText.setText(stage.headerMessage);
mPasswordTextView.setText(""); mPasswordEntry.setText("");
mUiStage = stage; mUiStage = stage;
} }
@@ -172,9 +191,9 @@ public class ChooseLockPassword extends Activity implements OnClickListener {
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.ok: case R.id.next_button:
{ {
final String pin = mPasswordTextView.getText().toString(); final String pin = mPasswordEntry.getText().toString();
if (TextUtils.isEmpty(pin)) { if (TextUtils.isEmpty(pin)) {
break; break;
} }
@@ -203,35 +222,15 @@ public class ChooseLockPassword extends Activity implements OnClickListener {
} }
break; break;
case R.id.backspace: case R.id.cancel_button:
{
final Editable digits = mPasswordTextView.getEditableText();
final int len = digits.length();
if (len > 0) {
digits.delete(len-1, len);
}
}
break;
case R.id.cancel:
finish(); finish();
break; 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) { private void showError(String msg, final Stage next) {
mHeaderText.setText(msg); mHeaderText.setText(msg);
mPasswordTextView.setText(""); mPasswordEntry.setText("");
mHandler.postDelayed(new Runnable() { mHandler.postDelayed(new Runnable() {
public void run() { public void run() {
updateStage(next); updateStage(next);

View File

@@ -17,24 +17,27 @@
package com.android.settings; package com.android.settings;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.PasswordEntryKeyboardHelper;
import com.android.internal.widget.PasswordEntryKeyboardView;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.Editable; import android.text.Editable;
import android.view.View; import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
public class ConfirmLockPassword extends Activity implements OnClickListener { public class ConfirmLockPassword extends Activity implements OnClickListener {
private static final long ERROR_MESSAGE_TIMEOUT = 3000; 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, private TextView mPasswordEntry;
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 LockPatternUtils mLockPatternUtils;
private TextView mHeaderText; private TextView mHeaderText;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private PasswordEntryKeyboardHelper mKeyboardHelper;
private PasswordEntryKeyboardView mKeyboardView;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@@ -45,27 +48,43 @@ public class ConfirmLockPassword extends Activity implements OnClickListener {
private void initViews() { private void initViews() {
int mode = mLockPatternUtils.getPasswordMode(); int mode = mLockPatternUtils.getPasswordMode();
if (LockPatternUtils.MODE_PIN == mode || LockPatternUtils.MODE_PASSWORD == mode) { setContentView(R.layout.confirm_lock_password);
setContentView(R.layout.confirm_lock_pin); // Disable IME on our window since we provide our own keyboard
for (int i = 0; i < digitIds.length; i++) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
Button button = (Button) findViewById(digitIds[i]); WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
button.setOnClickListener(this);
button.setText(Integer.toString(i)); findViewById(R.id.cancel_button).setOnClickListener(this);
} findViewById(R.id.next_button).setOnClickListener(this);
findViewById(R.id.ok).setOnClickListener(this); mPasswordEntry = (TextView) findViewById(R.id.password_entry);
findViewById(R.id.cancel).setOnClickListener(this); mKeyboardView = (PasswordEntryKeyboardView) findViewById(R.id.keyboard);
}
findViewById(R.id.backspace).setOnClickListener(this);
mPasswordTextView = (TextView) findViewById(R.id.pinDisplay);
mHeaderText = (TextView) findViewById(R.id.headerText); mHeaderText = (TextView) findViewById(R.id.headerText);
mHeaderText.setText(R.string.lockpassword_confirm_your_password_header); mHeaderText.setText(R.string.lockpassword_confirm_your_password_header);
final boolean isAlpha =
LockPatternUtils.MODE_PASSWORD == mLockPatternUtils.getPasswordMode();
mKeyboardHelper = new PasswordEntryKeyboardHelper(this, mKeyboardView, mPasswordEntry);
mKeyboardHelper.setKeyboardMode(isAlpha ? PasswordEntryKeyboardHelper.KEYBOARD_MODE_ALPHA
: PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
mKeyboardView.requestFocus();
}
@Override
protected void onPause() {
super.onPause();
mKeyboardView.requestFocus();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
mKeyboardView.requestFocus();
} }
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.ok: case R.id.next_button:
{ {
final String pin = mPasswordTextView.getText().toString(); final String pin = mPasswordEntry.getText().toString();
if (mLockPatternUtils.checkPassword(pin)) { if (mLockPatternUtils.checkPassword(pin)) {
setResult(RESULT_OK); setResult(RESULT_OK);
finish(); finish();
@@ -75,36 +94,16 @@ public class ConfirmLockPassword extends Activity implements OnClickListener {
} }
break; break;
case R.id.backspace: case R.id.cancel_button:
{
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); setResult(RESULT_CANCELED);
finish(); finish();
break; 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) { private void showError(int msg) {
mHeaderText.setText(msg); mHeaderText.setText(msg);
mPasswordTextView.setText(null); mPasswordEntry.setText(null);
mHandler.postDelayed(new Runnable() { mHandler.postDelayed(new Runnable() {
public void run() { public void run() {
mHeaderText.setText(R.string.lockpassword_confirm_your_password_header); mHeaderText.setText(R.string.lockpassword_confirm_your_password_header);