blob: deeaf71cebd46f5f83709c3a4eb3e501c4caf489 [file] [log] [blame]
Maurice Lamecd2b7b2014-12-01 10:41:49 -08001/*
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
17package com.android.settings;
18
Maurice Lamecd2b7b2014-12-01 10:41:49 -080019import android.content.Context;
20import android.content.Intent;
21import android.content.res.Resources;
22import android.os.Bundle;
Udam Sainid553abc2016-02-16 17:54:13 -080023import android.support.v7.widget.RecyclerView;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080024import android.view.LayoutInflater;
25import android.view.View;
26import android.view.ViewGroup;
Udam Saini71fde522016-03-30 13:38:05 -070027import android.widget.LinearLayout;
Udam Sainid553abc2016-02-16 17:54:13 -080028import android.widget.TextView;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080029
Maurice Lam190ec1c2016-04-22 16:41:18 -070030import com.android.setupwizardlib.GlifPreferenceLayout;
Jason Monk39b46742015-09-10 15:52:51 -040031
Maurice Lamecd2b7b2014-12-01 10:41:49 -080032/**
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 */
Maurice Lam83301b52015-04-18 20:11:59 -070039public class SetupEncryptionInterstitial extends EncryptionInterstitial {
Maurice Lamecd2b7b2014-12-01 10:41:49 -080040
41 public static Intent createStartIntent(Context ctx, int quality,
Udam Sainiedac1362015-12-08 17:28:19 -080042 boolean requirePasswordDefault, Intent unlockMethodIntent) {
Maurice Lamecd2b7b2014-12-01 10:41:49 -080043 Intent startIntent = EncryptionInterstitial.createStartIntent(ctx, quality,
Udam Sainiedac1362015-12-08 17:28:19 -080044 requirePasswordDefault, unlockMethodIntent);
Maurice Lamecd2b7b2014-12-01 10:41:49 -080045 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
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
60 protected boolean isValidFragment(String fragmentName) {
61 return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName);
62 }
63
64 @Override
65 protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
Maurice Lam598be1e2015-04-08 21:13:42 -070066 resid = SetupWizardUtils.getTheme(getIntent());
Maurice Lamecd2b7b2014-12-01 10:41:49 -080067 super.onApplyThemeResource(theme, resid, first);
68 }
69
Udam Saini71fde522016-03-30 13:38:05 -070070 @Override
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
Maurice Lam190ec1c2016-04-22 16:41:18 -070077 public static class SetupEncryptionInterstitialFragment extends EncryptionInterstitialFragment {
Maurice Lamecd2b7b2014-12-01 10:41:49 -080078
79 @Override
Maurice Lam7e831032015-07-20 16:08:38 -070080 public void onViewCreated(View view, Bundle savedInstanceState) {
81 super.onViewCreated(view, savedInstanceState);
82
Maurice Lam190ec1c2016-04-22 16:41:18 -070083 final GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
Udam Sainid553abc2016-02-16 17:54:13 -080084 layout.setDividerInset(getContext().getResources().getDimensionPixelSize(
Maurice Lam190ec1c2016-04-22 16:41:18 -070085 R.dimen.suw_items_glif_icon_divider_inset));
86 layout.setIcon(getContext().getDrawable(R.drawable.ic_lock));
Maurice Lam83301b52015-04-18 20:11:59 -070087
Udam Sainid553abc2016-02-16 17:54:13 -080088 layout.setHeaderText(R.string.encryption_interstitial_header);
Udam Sainid553abc2016-02-16 17:54:13 -080089
90 // Use the dividers in SetupWizardRecyclerLayout. Suppress the dividers in
91 // PreferenceFragment.
92 setDivider(null);
93 }
94
95 @Override
96 protected TextView createHeaderView() {
97 TextView message = (TextView) LayoutInflater.from(getActivity()).inflate(
98 R.layout.setup_encryption_interstitial_header, null, false);
99 return message;
100 }
101
102 @Override
103 public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
104 Bundle savedInstanceState) {
Maurice Lam190ec1c2016-04-22 16:41:18 -0700105 GlifPreferenceLayout layout = (GlifPreferenceLayout) parent;
Udam Sainid553abc2016-02-16 17:54:13 -0800106 return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
Maurice Lamecd2b7b2014-12-01 10:41:49 -0800107 }
Maurice Lamecd2b7b2014-12-01 10:41:49 -0800108 }
109}