blob: 266a0490ca5741ce3f47099e2ff02407bb7984ae [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
19import com.android.settings.notification.RedactionInterstitial;
20import com.android.setupwizard.navigationbar.SetupWizardNavBar;
21
22import android.content.Context;
23import android.content.Intent;
24import android.content.res.Resources;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080025import android.os.Bundle;
26import android.view.LayoutInflater;
27import android.view.View;
28import android.view.ViewGroup;
29
30/**
31 * Setup Wizard's version of RedactionInterstitial screen. It inherits the logic and basic structure
32 * from RedactionInterstitial class, and should remain similar to that behaviorally. This class
33 * should only overload base methods for minor theme and behavior differences specific to Setup
34 * Wizard. Other changes should be done to RedactionInterstitial class instead and let this class
35 * inherit those changes.
36 */
37public class SetupRedactionInterstitial extends RedactionInterstitial
38 implements SetupWizardNavBar.NavigationBarListener{
39
40 public static Intent createStartIntent(Context ctx) {
41 Intent startIntent = RedactionInterstitial.createStartIntent(ctx);
42 startIntent.setClass(ctx, SetupRedactionInterstitial.class);
43 startIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)
44 .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
45 return startIntent;
46 }
47
48 @Override
49 public Intent getIntent() {
50 Intent modIntent = new Intent(super.getIntent());
51 modIntent.putExtra(EXTRA_SHOW_FRAGMENT,
52 SetupEncryptionInterstitialFragment.class.getName());
53 return modIntent;
54 }
55
56 @Override
57 protected boolean isValidFragment(String fragmentName) {
58 return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName);
59 }
60
61 @Override
62 protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
Maurice Lam598be1e2015-04-08 21:13:42 -070063 resid = SetupWizardUtils.getTheme(getIntent());
Maurice Lamecd2b7b2014-12-01 10:41:49 -080064 super.onApplyThemeResource(theme, resid, first);
65 }
66
67 @Override
68 public void onNavigationBarCreated(SetupWizardNavBar bar) {
Maurice Lambddc5662015-03-03 18:27:48 -080069 SetupWizardUtils.setImmersiveMode(this);
Maurice Lam9066a5c2015-01-22 18:35:11 -080070 bar.getBackButton().setEnabled(false);
Maurice Lamecd2b7b2014-12-01 10:41:49 -080071 }
72
73 @Override
74 public void onNavigateBack() {
75 onBackPressed();
76 }
77
78 @Override
79 public void onNavigateNext() {
80 setResult(RESULT_OK, getResultIntentData());
81 finish();
82 }
83
84 public static class SetupEncryptionInterstitialFragment extends RedactionInterstitialFragment {
85
86 @Override
87 public View onCreateView(LayoutInflater inflater, ViewGroup container,
88 Bundle savedInstanceState) {
89 View view = inflater.inflate(R.layout.setup_template, container, false);
90 ViewGroup setupContent = (ViewGroup) view.findViewById(R.id.setup_content);
91 View content = super.onCreateView(inflater, setupContent, savedInstanceState);
92 setupContent.addView(content);
93 return view;
94 }
95
96 @Override
97 public void onViewCreated(View view, Bundle savedInstanceState) {
98 super.onViewCreated(view, savedInstanceState);
Maurice Lam1227a192014-12-03 16:12:31 -080099 SetupWizardUtils.setIllustration(getActivity(),
100 R.drawable.setup_illustration_lock_screen);
Maurice Lamecd2b7b2014-12-01 10:41:49 -0800101 SetupWizardUtils.setHeaderText(getActivity(), R.string.notification_section_header);
102 }
103 }
104}