• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.settings;
18 
19 import android.app.Fragment;
20 import android.content.Context;
21 import android.content.Intent;
22 import android.content.res.Resources;
23 import android.os.Bundle;
24 import android.widget.LinearLayout;
25 
26 /**
27  * Setup Wizard's version of ChooseLockPassword screen. It inherits the logic and basic structure
28  * from ChooseLockPassword class, and should remain similar to that behaviorally. This class should
29  * only overload base methods for minor theme and behavior differences specific to Setup Wizard.
30  * Other changes should be done to ChooseLockPassword class instead and let this class inherit
31  * those changes.
32  */
33 public class SetupChooseLockPassword extends ChooseLockPassword {
34 
createIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, boolean confirmCredentials)35     public static Intent createIntent(Context context, int quality,
36             int minLength, final int maxLength, boolean requirePasswordToDecrypt,
37             boolean confirmCredentials) {
38         Intent intent = ChooseLockPassword.createIntent(context, quality, minLength,
39                 maxLength, requirePasswordToDecrypt, confirmCredentials);
40         intent.setClass(context, SetupChooseLockPassword.class);
41         intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false);
42         return intent;
43     }
44 
createIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, String password)45     public static Intent createIntent(Context context, int quality,
46             int minLength, final int maxLength, boolean requirePasswordToDecrypt, String password) {
47         Intent intent = ChooseLockPassword.createIntent(context, quality, minLength, maxLength,
48                 requirePasswordToDecrypt, password);
49         intent.setClass(context, SetupChooseLockPassword.class);
50         intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false);
51         return intent;
52     }
53 
createIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, long challenge)54     public static Intent createIntent(Context context, int quality,
55             int minLength, final int maxLength, boolean requirePasswordToDecrypt, long challenge) {
56         Intent intent = ChooseLockPassword.createIntent(context, quality, minLength, maxLength,
57                 requirePasswordToDecrypt, challenge);
58         intent.setClass(context, SetupChooseLockPassword.class);
59         intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false);
60         return intent;
61     }
62 
63     @Override
isValidFragment(String fragmentName)64     protected boolean isValidFragment(String fragmentName) {
65         return SetupChooseLockPasswordFragment.class.getName().equals(fragmentName);
66     }
67 
68     @Override
getFragmentClass()69     /* package */ Class<? extends Fragment> getFragmentClass() {
70         return SetupChooseLockPasswordFragment.class;
71     }
72 
73     @Override
onCreate(Bundle savedInstance)74     protected void onCreate(Bundle savedInstance) {
75         super.onCreate(savedInstance);
76         LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent);
77         layout.setFitsSystemWindows(false);
78     }
79 
80     @Override
onApplyThemeResource(Resources.Theme theme, int resid, boolean first)81     protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
82         resid = SetupWizardUtils.getTheme(getIntent());
83         super.onApplyThemeResource(theme, resid, first);
84     }
85 
86     public static class SetupChooseLockPasswordFragment extends ChooseLockPasswordFragment {
87 
88         @Override
getRedactionInterstitialIntent(Context context)89         protected Intent getRedactionInterstitialIntent(Context context) {
90             return null;
91         }
92     }
93 }
94