• 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.content.Context;
20 import android.content.Intent;
21 import android.content.res.Resources;
22 import android.os.Bundle;
23 import android.support.v7.widget.RecyclerView;
24 import android.view.LayoutInflater;
25 import android.view.View;
26 import android.view.ViewGroup;
27 import android.widget.LinearLayout;
28 
29 import com.android.settings.utils.SettingsDividerItemDecoration;
30 import com.android.setupwizardlib.GlifPreferenceLayout;
31 
32 /**
33  * Setup Wizard's version of EncryptionInterstitial screen. It inherits the logic and basic
34  * structure from EncryptionInterstitial class, and should remain similar to that behaviorally. This
35  * class should only overload base methods for minor theme and behavior differences specific to
36  * Setup Wizard. Other changes should be done to EncryptionInterstitial class instead and let this
37  * class inherit those changes.
38  */
39 public class SetupEncryptionInterstitial extends EncryptionInterstitial {
40 
createStartIntent(Context ctx, int quality, boolean requirePasswordDefault, Intent unlockMethodIntent)41     public static Intent createStartIntent(Context ctx, int quality,
42             boolean requirePasswordDefault, Intent unlockMethodIntent) {
43         Intent startIntent = EncryptionInterstitial.createStartIntent(ctx, quality,
44                 requirePasswordDefault, unlockMethodIntent);
45         startIntent.setClass(ctx, SetupEncryptionInterstitial.class);
46         startIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)
47                 .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
48         return startIntent;
49     }
50 
51     @Override
getIntent()52     public Intent getIntent() {
53         Intent modIntent = new Intent(super.getIntent());
54         modIntent.putExtra(EXTRA_SHOW_FRAGMENT,
55                 SetupEncryptionInterstitialFragment.class.getName());
56         return modIntent;
57     }
58 
59     @Override
isValidFragment(String fragmentName)60     protected boolean isValidFragment(String fragmentName) {
61         return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName);
62     }
63 
64     @Override
onApplyThemeResource(Resources.Theme theme, int resid, boolean first)65     protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
66         resid = SetupWizardUtils.getTheme(getIntent());
67         super.onApplyThemeResource(theme, resid, first);
68     }
69 
70     @Override
onCreate(Bundle savedInstance)71     protected void onCreate(Bundle savedInstance) {
72         super.onCreate(savedInstance);
73         LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent);
74         layout.setFitsSystemWindows(false);
75     }
76 
77     public static class SetupEncryptionInterstitialFragment extends EncryptionInterstitialFragment {
78 
79         @Override
onViewCreated(View view, Bundle savedInstanceState)80         public void onViewCreated(View view, Bundle savedInstanceState) {
81             super.onViewCreated(view, savedInstanceState);
82 
83             final GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
84             layout.setDividerItemDecoration(new SettingsDividerItemDecoration(getContext()));
85             layout.setDividerInset(getContext().getResources().getDimensionPixelSize(
86                     R.dimen.suw_items_glif_icon_divider_inset));
87             layout.setIcon(getContext().getDrawable(R.drawable.ic_lock));
88 
89             layout.setHeaderText(R.string.encryption_interstitial_header);
90 
91             // Use the dividers in SetupWizardRecyclerLayout. Suppress the dividers in
92             // PreferenceFragment.
93             setDivider(null);
94         }
95 
96         @Override
onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)97         public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
98                                                  Bundle savedInstanceState) {
99             GlifPreferenceLayout layout = (GlifPreferenceLayout) parent;
100             return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
101         }
102     }
103 }
104