[FRP] Theming for Pattern and Password screens

Basic theming for pattern and password screens. Create subclasses for
ChooseLockPassword and ChooseLockPattern, and copied their XML
layouts.

This CL mainly uses the buttons in the original screens as-is, with a
follow-up CL coming to change to use the nav bar buttons.

Bug: 18482708
Change-Id: I81751f781de633aff23fc68657589360007c235a
This commit is contained in:
Maurice Lam
2014-11-25 19:25:56 -08:00
parent c868f7035a
commit 6b19fa9017
14 changed files with 708 additions and 16 deletions

View File

@@ -1159,8 +1159,17 @@
android:excludeFromRecents="true" android:excludeFromRecents="true"
/> />
<activity android:name="SetupChooseLockPattern"
android:exported="false"
android:theme="@style/SetupWizardDisableAppStartingTheme" />
<activity android:name="ChooseLockPattern" android:exported="false"/> <activity android:name="ChooseLockPattern" android:exported="false"/>
<activity android:name="SetupChooseLockPassword"
android:exported="false"
android:theme="@style/SetupWizardDisableAppStartingTheme"
android:windowSoftInputMode="stateVisible|adjustResize" />
<activity android:name="ChooseLockPassword" android:exported="false" <activity android:name="ChooseLockPassword" android:exported="false"
android:windowSoftInputMode="stateVisible|adjustResize"/> android:windowSoftInputMode="stateVisible|adjustResize"/>

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp">
<FrameLayout
android:id="@+id/title_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@drawable/setup_illustration_bg"
android:elevation="@dimen/setup_wizard_title_area_elevation">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/wifi_setup_title"
style="@style/SetupTitle"/>
</FrameLayout>
<ScrollView
android:id="@+id/bottom_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title_area"
android:layout_alignParentBottom="true"
android:fillViewport="true">
<FrameLayout android:id="@+id/setup_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"/>
</ScrollView>
</RelativeLayout>
<fragment android:name="com.android.setupwizard.navigationbar.SetupWizardNavBar"
android:id="@+id/navigation_bar"
android:layout_width="match_parent"
android:layout_height="56dip"
style="@style/setup_wizard_navbar_style"/>
</LinearLayout>

View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.android.settings.widget.SetupWizardIllustration
android:id="@+id/illustration_tablet"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/setup_illustration_bg"
android:foreground="@drawable/setup_illustration_wifi_wide">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="start|top"
android:weightSum="16">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/setup_wizard_tablet_illustration_height"
android:layout_weight="6"
android:text="@string/wifi_setup_title"
style="@style/SetupCardTitle"/>
<ScrollView
android:id="@+id/bottom_scroll_view"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/setup_wizard_card_land_margin_top"
android:layout_weight="8"
android:background="@drawable/setup_wizard_card_bg"
android:elevation="@dimen/setup_wizard_card_elevation"
android:fillViewport="true">
<FrameLayout android:id="@+id/setup_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"/>
</ScrollView>
</LinearLayout>
</com.android.settings.widget.SetupWizardIllustration>
<fragment android:name="com.android.setupwizard.navigationbar.SetupWizardNavBar"
android:id="@+id/navigation_bar"
android:layout_width="match_parent"
android:layout_height="56dip"
style="@style/setup_wizard_navbar_style"/>
</LinearLayout>

View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.android.settings.widget.SetupWizardIllustration
android:id="@+id/illustration_tablet"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/setup_illustration_bg"
android:foreground="@drawable/setup_illustration_wifi_wide">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/setup_wizard_tablet_illustration_height"
android:orientation="vertical"
android:paddingStart="@dimen/setup_wizard_card_port_margin_sides"
android:paddingEnd="@dimen/setup_wizard_card_port_margin_sides">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/wifi_setup_title"
style="@style/SetupCardTitle"/>
<ScrollView
android:id="@+id/bottom_scroll_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/setup_wizard_card_bg"
android:elevation="@dimen/setup_wizard_card_elevation"
android:fillViewport="true">
<FrameLayout
android:id="@+id/setup_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"/>
</ScrollView>
</LinearLayout>
</com.android.settings.widget.SetupWizardIllustration>
<fragment android:name="com.android.setupwizard.navigationbar.SetupWizardNavBar"
android:id="@+id/navigation_bar"
android:layout_width="match_parent"
android:layout_height="56dip"
style="@style/setup_wizard_navbar_style"/>
</LinearLayout>

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<!-- header text ('Enter Pin') -->
<TextView android:id="@+id/headerText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:lines="2"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<!-- Password entry field -->
<EditText android:id="@+id/password_entry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="30dip"
android:layout_marginEnd="30dip"
android:gravity="center"
android:inputType="textPassword"
android:imeOptions="actionNext"
android:textSize="24sp"
style="@style/TextAppearance.PasswordEntry"/>
<!-- Spacer between password entry and keyboard -->
<View
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
style="@style/SecurityPreferenceButtonContainer">
<!-- left : cancel -->
<Button android:id="@+id/cancel_button"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/lockpassword_cancel_label"
style="@style/SecurityPreferenceButton"/>
<!-- right : continue -->
<Button android:id="@+id/next_button"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/lockpassword_continue_label"
style="@style/SecurityPreferenceButton"/>
</LinearLayout>
<!-- Alphanumeric keyboard -->
<com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00000000"
android:keyBackground="@*android:drawable/btn_keyboard_key_fulltrans"
android:visibility="gone"/>
</LinearLayout>

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- takes up all space above button bar at bottom -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView android:id="@+id/headerText"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center"
android:minHeight="50dp"
android:textSize="18sp"/>
<com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="4"
android:background="@color/lock_pattern_background"/>
<TextView android:id="@+id/footerText"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center"
android:minHeight="50dp"
android:textSize="14sp"/>
</LinearLayout>
<!-- Buttons are hidden during setup, and use the buttons in setup navigation bar instead -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
style="@style/SecurityPreferenceButtonContainer">
<!-- left : cancel, or re-try -->
<Button android:id="@+id/footerLeftButton"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/lockpattern_tutorial_cancel_label"
style="@style/SecurityPreferenceButton"/>
<!-- right : confirm or ok -->
<Button android:id="@+id/footerRightButton"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/lockpattern_tutorial_continue_label"
style="@style/SecurityPreferenceButton"/>
</LinearLayout>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>

View File

@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/bottom_scroll_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false">
<com.android.settings.widget.SetupWizardIllustration
android:id="@+id/illustration_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="@dimen/setup_wizard_title_area_elevation"
android:background="@drawable/setup_illustration_bg"
android:foreground="@drawable/setup_illustration_wifi"
android:tag="stickyContainer"
settings:aspectRatio="2.22">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tag="sticky"
android:text="@string/wifi_setup_title"
style="@style/SetupTitle"/>
</com.android.settings.widget.SetupWizardIllustration>
<FrameLayout
android:id="@+id/setup_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/illustration_phone"
android:clipChildren="false"/>
</RelativeLayout>
</ScrollView>
<fragment android:name="com.android.setupwizard.navigationbar.SetupWizardNavBar"
android:id="@+id/navigation_bar"
android:layout_width="match_parent"
android:layout_height="56dip"
style="@style/setup_wizard_navbar_style"/>
</LinearLayout>

View File

@@ -18,7 +18,6 @@ package com.android.settings;
import android.accessibilityservice.AccessibilityServiceInfo; import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManagerNative;
import android.app.Fragment; import android.app.Fragment;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
@@ -27,8 +26,6 @@ import android.content.Intent;
import android.content.pm.UserInfo; import android.content.pm.UserInfo;
import android.os.Bundle; import android.os.Bundle;
import android.os.Process; import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
@@ -404,6 +401,19 @@ public class ChooseLockGeneric extends SettingsActivity {
return intent; return intent;
} }
protected Intent getLockPasswordIntent(Context context, int quality,
final boolean isFallback, int minLength, final int maxLength,
boolean requirePasswordToDecrypt, boolean confirmCredentials) {
return ChooseLockPassword.createIntent(context, quality, isFallback, minLength,
maxLength, requirePasswordToDecrypt, confirmCredentials);
}
protected Intent getLockPatternIntent(Context context, final boolean isFallback,
final boolean requirePassword, final boolean confirmCredentials) {
return ChooseLockPattern.createIntent(context, isFallback, requirePassword,
confirmCredentials);
}
/** /**
* Invokes an activity to change the user's pattern, password or PIN based on given quality * Invokes an activity to change the user's pattern, password or PIN based on given quality
* and minimum quality specified by DevicePolicyManager. If quality is * and minimum quality specified by DevicePolicyManager. If quality is
@@ -424,14 +434,15 @@ public class ChooseLockGeneric extends SettingsActivity {
quality = upgradeQuality(quality, null); quality = upgradeQuality(quality, null);
final Context context = getActivity();
if (quality >= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC) { if (quality >= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC) {
int minLength = mDPM.getPasswordMinimumLength(null); int minLength = mDPM.getPasswordMinimumLength(null);
if (minLength < MIN_PASSWORD_LENGTH) { if (minLength < MIN_PASSWORD_LENGTH) {
minLength = MIN_PASSWORD_LENGTH; minLength = MIN_PASSWORD_LENGTH;
} }
final int maxLength = mDPM.getPasswordMaximumLength(quality); final int maxLength = mDPM.getPasswordMaximumLength(quality);
Intent intent = ChooseLockPassword.createIntent(getActivity(), quality, isFallback, Intent intent = getLockPasswordIntent(context, quality, isFallback, minLength,
minLength, maxLength, mRequirePassword, false /* confirm credentials */); maxLength, mRequirePassword, /* confirm credentials */false);
if (isFallback) { if (isFallback) {
startActivityForResult(intent, FALLBACK_REQUEST); startActivityForResult(intent, FALLBACK_REQUEST);
return; return;
@@ -441,8 +452,8 @@ public class ChooseLockGeneric extends SettingsActivity {
startActivity(intent); startActivity(intent);
} }
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) { } else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
Intent intent = ChooseLockPattern.createIntent(getActivity(), Intent intent = getLockPatternIntent(context, isFallback, mRequirePassword,
isFallback, mRequirePassword, false /* confirm credentials */); /* confirm credentials */false);
if (isFallback) { if (isFallback) {
startActivityForResult(intent, FALLBACK_REQUEST); startActivityForResult(intent, FALLBACK_REQUEST);
return; return;

View File

@@ -61,7 +61,7 @@ public class ChooseLockPassword extends SettingsActivity {
@Override @Override
public Intent getIntent() { public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent()); Intent modIntent = new Intent(super.getIntent());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockPasswordFragment.class.getName()); modIntent.putExtra(EXTRA_SHOW_FRAGMENT, getFragmentClass().getName());
return modIntent; return modIntent;
} }
@@ -84,6 +84,10 @@ public class ChooseLockPassword extends SettingsActivity {
return false; return false;
} }
/* package */ Class<? extends Fragment> getFragmentClass() {
return ChooseLockPasswordFragment.class;
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
// TODO: Fix on phones // TODO: Fix on phones
@@ -200,8 +204,12 @@ public class ChooseLockPassword extends SettingsActivity {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
return inflater.inflate(R.layout.choose_lock_password, container, false);
}
View view = inflater.inflate(R.layout.choose_lock_password, null); @Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mCancelButton = (Button) view.findViewById(R.id.cancel_button); mCancelButton = (Button) view.findViewById(R.id.cancel_button);
mCancelButton.setOnClickListener(this); mCancelButton.setOnClickListener(this);
@@ -254,8 +262,6 @@ public class ChooseLockPassword extends SettingsActivity {
CharSequence title = getText(id); CharSequence title = getText(id);
sa.setTitle(title); sa.setTitle(title);
} }
return view;
} }
@Override @Override

View File

@@ -65,7 +65,7 @@ public class ChooseLockPattern extends SettingsActivity {
@Override @Override
public Intent getIntent() { public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent()); Intent modIntent = new Intent(super.getIntent());
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockPatternFragment.class.getName()); modIntent.putExtra(EXTRA_SHOW_FRAGMENT, getFragmentClass().getName());
return modIntent; return modIntent;
} }
@@ -85,6 +85,10 @@ public class ChooseLockPattern extends SettingsActivity {
return false; return false;
} }
/* package */ Class<? extends Fragment> getFragmentClass() {
return ChooseLockPatternFragment.class;
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
// requestWindowFeature(Window.FEATURE_NO_TITLE); // requestWindowFeature(Window.FEATURE_NO_TITLE);
@@ -327,9 +331,12 @@ public class ChooseLockPattern extends SettingsActivity {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
return inflater.inflate(R.layout.choose_lock_pattern, container, false);
}
// setupViews() @Override
View view = inflater.inflate(R.layout.choose_lock_pattern, null); public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mHeaderText = (TextView) view.findViewById(R.id.headerText); mHeaderText = (TextView) view.findViewById(R.id.headerText);
mLockPatternView = (LockPatternView) view.findViewById(R.id.lockPattern); mLockPatternView = (LockPatternView) view.findViewById(R.id.lockPattern);
mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener); mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener);
@@ -377,7 +384,6 @@ public class ChooseLockPattern extends SettingsActivity {
updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]); updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
} }
mDone = false; mDone = false;
return view;
} }
public void onClick(View v) { public void onClick(View v) {

View File

@@ -18,7 +18,8 @@ package com.android.settings;
import com.android.setupwizard.navigationbar.SetupWizardNavBar; import com.android.setupwizard.navigationbar.SetupWizardNavBar;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
@@ -81,5 +82,24 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
SetupWizardUtils.setHeaderText(getActivity(), getActivity().getTitle()); SetupWizardUtils.setHeaderText(getActivity(), getActivity().getTitle());
} }
@Override
protected Intent getLockPasswordIntent(Context context, int quality, boolean isFallback,
int minLength, int maxLength, boolean requirePasswordToDecrypt,
boolean confirmCredentials) {
final Intent intent = SetupChooseLockPassword.createIntent(context, quality,
isFallback, minLength, maxLength, requirePasswordToDecrypt, confirmCredentials);
SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
return intent;
}
@Override
protected Intent getLockPatternIntent(Context context, boolean isFallback,
boolean requirePassword, boolean confirmCredentials) {
final Intent intent = SetupChooseLockPattern.createIntent(context, isFallback,
requirePassword, confirmCredentials);
SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
return intent;
}
} }
} }

View File

@@ -0,0 +1,90 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings;
import com.android.setupwizard.navigationbar.SetupWizardNavBar;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class SetupChooseLockPassword extends ChooseLockPassword
implements SetupWizardNavBar.NavigationBarListener {
public static Intent createIntent(Context context, int quality, final boolean isFallback,
int minLength, final int maxLength, boolean requirePasswordToDecrypt,
boolean confirmCredentials) {
Intent intent = ChooseLockPassword.createIntent(context, quality, isFallback, minLength,
maxLength, requirePasswordToDecrypt, confirmCredentials);
intent.setClass(context, SetupChooseLockPassword.class);
intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false);
return intent;
}
@Override
protected boolean isValidFragment(String fragmentName) {
return SetupChooseLockPasswordFragment.class.getName().equals(fragmentName);
}
@Override
/* package */ Class<? extends Fragment> getFragmentClass() {
return SetupChooseLockPasswordFragment.class;
}
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
resid = SetupWizardUtils.getTheme(getIntent(), resid);
super.onApplyThemeResource(theme, resid, first);
}
@Override
public void onNavigationBarCreated(SetupWizardNavBar bar) {
SetupWizardUtils.setImmersiveMode(this, bar);
}
@Override
public void onNavigateBack() {
onBackPressed();
}
@Override
public void onNavigateNext() {
}
public static class SetupChooseLockPasswordFragment extends ChooseLockPasswordFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.setup_template, container, false);
ViewGroup setupContent = (ViewGroup) view.findViewById(R.id.setup_content);
inflater.inflate(R.layout.setup_choose_lock_password, setupContent, true);
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
SetupWizardUtils.setHeaderText(getActivity(), getActivity().getTitle());
}
}
}

View File

@@ -0,0 +1,88 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings;
import com.android.setupwizard.navigationbar.SetupWizardNavBar;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class SetupChooseLockPattern extends ChooseLockPattern
implements SetupWizardNavBar.NavigationBarListener {
public static Intent createIntent(Context context, final boolean isFallback,
boolean requirePassword, boolean confirmCredentials) {
Intent intent = ChooseLockPattern.createIntent(context, isFallback, requirePassword,
confirmCredentials);
intent.setClass(context, SetupChooseLockPattern.class);
return intent;
}
@Override
protected boolean isValidFragment(String fragmentName) {
return SetupChooseLockPatternFragment.class.getName().equals(fragmentName);
}
@Override
/* package */ Class<? extends Fragment> getFragmentClass() {
return SetupChooseLockPatternFragment.class;
}
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
resid = SetupWizardUtils.getTheme(getIntent(), resid);
super.onApplyThemeResource(theme, resid, first);
}
@Override
public void onNavigationBarCreated(SetupWizardNavBar bar) {
SetupWizardUtils.setImmersiveMode(this, bar);
}
@Override
public void onNavigateBack() {
onBackPressed();
}
@Override
public void onNavigateNext() {
}
public static class SetupChooseLockPatternFragment extends ChooseLockPatternFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.setup_template, container, false);
ViewGroup setupContent = (ViewGroup) view.findViewById(R.id.setup_content);
inflater.inflate(R.layout.setup_choose_lock_pattern, setupContent, true);
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
SetupWizardUtils.setHeaderText(getActivity(), getActivity().getTitle());
}
}
}

View File

@@ -103,4 +103,10 @@ public class SetupWizardUtils {
public static void setHeaderText(Activity activity, CharSequence text) { public static void setHeaderText(Activity activity, CharSequence text) {
getHeader(activity).setText(text); getHeader(activity).setText(text);
} }
public static void copySetupExtras(Intent fromIntent, Intent toIntent) {
toIntent.putExtra(EXTRA_THEME, fromIntent.getStringExtra(EXTRA_THEME));
toIntent.putExtra(EXTRA_USE_IMMERSIVE_MODE,
fromIntent.getBooleanExtra(EXTRA_USE_IMMERSIVE_MODE, false));
}
} }