blob: 8d061ec0aa6f3e1ca0a724a4af64574b287c2ad7 [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 Lam83301b52015-04-18 20:11:59 -070019import android.app.Activity;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080020import android.content.Context;
21import android.content.Intent;
22import android.content.res.Resources;
23import android.os.Bundle;
24import android.view.LayoutInflater;
25import android.view.View;
26import android.view.ViewGroup;
27
Jason Monk39b46742015-09-10 15:52:51 -040028import com.android.setupwizardlib.SetupWizardLayout;
29import com.android.setupwizardlib.view.NavigationBar;
30
Maurice Lamecd2b7b2014-12-01 10:41:49 -080031/**
32 * Setup Wizard's version of EncryptionInterstitial screen. It inherits the logic and basic
33 * structure from EncryptionInterstitial class, and should remain similar to that behaviorally. This
34 * class should only overload base methods for minor theme and behavior differences specific to
35 * Setup Wizard. Other changes should be done to EncryptionInterstitial class instead and let this
36 * class inherit those changes.
37 */
Maurice Lam83301b52015-04-18 20:11:59 -070038public class SetupEncryptionInterstitial extends EncryptionInterstitial {
Maurice Lamecd2b7b2014-12-01 10:41:49 -080039
40 public static Intent createStartIntent(Context ctx, int quality,
Udam Sainiedac1362015-12-08 17:28:19 -080041 boolean requirePasswordDefault, Intent unlockMethodIntent) {
Maurice Lamecd2b7b2014-12-01 10:41:49 -080042 Intent startIntent = EncryptionInterstitial.createStartIntent(ctx, quality,
Udam Sainiedac1362015-12-08 17:28:19 -080043 requirePasswordDefault, unlockMethodIntent);
Maurice Lamecd2b7b2014-12-01 10:41:49 -080044 startIntent.setClass(ctx, SetupEncryptionInterstitial.class);
45 startIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)
46 .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
47 return startIntent;
48 }
49
50 @Override
51 public Intent getIntent() {
52 Intent modIntent = new Intent(super.getIntent());
53 modIntent.putExtra(EXTRA_SHOW_FRAGMENT,
54 SetupEncryptionInterstitialFragment.class.getName());
55 return modIntent;
56 }
57
58 @Override
59 protected boolean isValidFragment(String fragmentName) {
60 return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName);
61 }
62
63 @Override
64 protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
Maurice Lam598be1e2015-04-08 21:13:42 -070065 resid = SetupWizardUtils.getTheme(getIntent());
Maurice Lamecd2b7b2014-12-01 10:41:49 -080066 super.onApplyThemeResource(theme, resid, first);
67 }
68
Maurice Lam83301b52015-04-18 20:11:59 -070069 public static class SetupEncryptionInterstitialFragment extends EncryptionInterstitialFragment
70 implements NavigationBar.NavigationBarListener {
Maurice Lamecd2b7b2014-12-01 10:41:49 -080071
72 @Override
73 public View onCreateView(LayoutInflater inflater, ViewGroup container,
74 Bundle savedInstanceState) {
Maurice Lam7e831032015-07-20 16:08:38 -070075 return inflater.inflate(R.layout.setup_encryption_interstitial, container, false);
76 }
Maurice Lam83301b52015-04-18 20:11:59 -070077
Maurice Lam7e831032015-07-20 16:08:38 -070078 @Override
79 public void onViewCreated(View view, Bundle savedInstanceState) {
80 super.onViewCreated(view, savedInstanceState);
81
82 final SetupWizardLayout layout =
83 (SetupWizardLayout) view.findViewById(R.id.setup_wizard_layout);
84
85 final NavigationBar navigationBar = layout.getNavigationBar();
86 navigationBar.setNavigationBarListener(this);
Maurice Lam83301b52015-04-18 20:11:59 -070087
88 Activity activity = getActivity();
89 if (activity != null) {
Maurice Lam15546c02015-07-20 15:03:37 -070090 activity.setTitle(R.string.encryption_interstitial_header);
Maurice Lam83301b52015-04-18 20:11:59 -070091 SetupWizardUtils.setImmersiveMode(activity);
92 }
Maurice Lamecd2b7b2014-12-01 10:41:49 -080093 }
94
95 @Override
Maurice Lam83301b52015-04-18 20:11:59 -070096 public void onNavigateBack() {
97 final Activity activity = getActivity();
98 if (activity != null) {
99 activity.onBackPressed();
100 }
101 }
102
103 @Override
104 public void onNavigateNext() {
Udam Sainiedac1362015-12-08 17:28:19 -0800105 startLockIntent();
Maurice Lamecd2b7b2014-12-01 10:41:49 -0800106 }
107 }
108}