blob: 96f4dffd099d559041b5b739006c9d7ed0eb783b [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;
25import android.graphics.Color;
26import android.os.Bundle;
27import android.view.LayoutInflater;
28import android.view.View;
29import android.view.ViewGroup;
30
31/**
32 * Setup Wizard's version of RedactionInterstitial screen. It inherits the logic and basic structure
33 * from RedactionInterstitial class, and should remain similar to that behaviorally. This class
34 * should only overload base methods for minor theme and behavior differences specific to Setup
35 * Wizard. Other changes should be done to RedactionInterstitial class instead and let this class
36 * inherit those changes.
37 */
38public class SetupRedactionInterstitial extends RedactionInterstitial
39 implements SetupWizardNavBar.NavigationBarListener{
40
41 public static Intent createStartIntent(Context ctx) {
42 Intent startIntent = RedactionInterstitial.createStartIntent(ctx);
43 startIntent.setClass(ctx, SetupRedactionInterstitial.class);
44 startIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)
45 .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
46 return startIntent;
47 }
48
49 @Override
50 public Intent getIntent() {
51 Intent modIntent = new Intent(super.getIntent());
52 modIntent.putExtra(EXTRA_SHOW_FRAGMENT,
53 SetupEncryptionInterstitialFragment.class.getName());
54 return modIntent;
55 }
56
57 @Override
58 protected boolean isValidFragment(String fragmentName) {
59 return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName);
60 }
61
62 @Override
63 protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
64 resid = SetupWizardUtils.getTheme(getIntent(), resid);
65 super.onApplyThemeResource(theme, resid, first);
66 }
67
68 @Override
69 public void onNavigationBarCreated(SetupWizardNavBar bar) {
70 SetupWizardUtils.setImmersiveMode(this, bar);
71 }
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);
99 SetupWizardUtils.setHeaderText(getActivity(), R.string.notification_section_header);
100 }
101 }
102}