* commit '86f184b3d66af3db1302471c44441e1d2dc1867e': [FRP] Theming for Pattern and Password screens
This commit is contained in:
@@ -18,7 +18,6 @@ package com.android.settings;
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.Fragment;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
@@ -27,8 +26,6 @@ import android.content.Intent;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceScreen;
|
||||
@@ -404,6 +401,19 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
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
|
||||
* and minimum quality specified by DevicePolicyManager. If quality is
|
||||
@@ -424,14 +434,15 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
|
||||
quality = upgradeQuality(quality, null);
|
||||
|
||||
final Context context = getActivity();
|
||||
if (quality >= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC) {
|
||||
int minLength = mDPM.getPasswordMinimumLength(null);
|
||||
if (minLength < MIN_PASSWORD_LENGTH) {
|
||||
minLength = MIN_PASSWORD_LENGTH;
|
||||
}
|
||||
final int maxLength = mDPM.getPasswordMaximumLength(quality);
|
||||
Intent intent = ChooseLockPassword.createIntent(getActivity(), quality, isFallback,
|
||||
minLength, maxLength, mRequirePassword, false /* confirm credentials */);
|
||||
Intent intent = getLockPasswordIntent(context, quality, isFallback, minLength,
|
||||
maxLength, mRequirePassword, /* confirm credentials */false);
|
||||
if (isFallback) {
|
||||
startActivityForResult(intent, FALLBACK_REQUEST);
|
||||
return;
|
||||
@@ -441,8 +452,8 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
startActivity(intent);
|
||||
}
|
||||
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
|
||||
Intent intent = ChooseLockPattern.createIntent(getActivity(),
|
||||
isFallback, mRequirePassword, false /* confirm credentials */);
|
||||
Intent intent = getLockPatternIntent(context, isFallback, mRequirePassword,
|
||||
/* confirm credentials */false);
|
||||
if (isFallback) {
|
||||
startActivityForResult(intent, FALLBACK_REQUEST);
|
||||
return;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
@Override
|
||||
public Intent getIntent() {
|
||||
Intent modIntent = new Intent(super.getIntent());
|
||||
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockPasswordFragment.class.getName());
|
||||
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, getFragmentClass().getName());
|
||||
return modIntent;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,10 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* package */ Class<? extends Fragment> getFragmentClass() {
|
||||
return ChooseLockPasswordFragment.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
// TODO: Fix on phones
|
||||
@@ -200,8 +204,12 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
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.setOnClickListener(this);
|
||||
@@ -254,8 +262,6 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
CharSequence title = getText(id);
|
||||
sa.setTitle(title);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,7 +65,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
@Override
|
||||
public Intent getIntent() {
|
||||
Intent modIntent = new Intent(super.getIntent());
|
||||
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockPatternFragment.class.getName());
|
||||
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, getFragmentClass().getName());
|
||||
return modIntent;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,10 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* package */ Class<? extends Fragment> getFragmentClass() {
|
||||
return ChooseLockPatternFragment.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
// requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
@@ -327,9 +331,12 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.choose_lock_pattern, container, false);
|
||||
}
|
||||
|
||||
// setupViews()
|
||||
View view = inflater.inflate(R.layout.choose_lock_pattern, null);
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mHeaderText = (TextView) view.findViewById(R.id.headerText);
|
||||
mLockPatternView = (LockPatternView) view.findViewById(R.id.lockPattern);
|
||||
mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener);
|
||||
@@ -377,7 +384,6 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
|
||||
}
|
||||
mDone = false;
|
||||
return view;
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
|
||||
@@ -18,7 +18,8 @@ package com.android.settings;
|
||||
|
||||
import com.android.setupwizard.navigationbar.SetupWizardNavBar;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceFragment;
|
||||
@@ -81,5 +82,24 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
90
src/com/android/settings/SetupChooseLockPassword.java
Normal file
90
src/com/android/settings/SetupChooseLockPassword.java
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
88
src/com/android/settings/SetupChooseLockPattern.java
Normal file
88
src/com/android/settings/SetupChooseLockPattern.java
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,4 +103,10 @@ public class SetupWizardUtils {
|
||||
public static void setHeaderText(Activity activity, CharSequence 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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user