blob: d3d841e355f2a1949f46d3e0ffbb3cef4cf1eef3 [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;
Maurice Lam83301b52015-04-18 20:11:59 -070020import com.android.setupwizardlib.SetupWizardLayout;
21import com.android.setupwizardlib.view.NavigationBar;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080022
Maurice Lam83301b52015-04-18 20:11:59 -070023import android.app.Activity;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080024import android.content.Context;
25import android.content.Intent;
26import android.content.res.Resources;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080027import android.os.Bundle;
28import android.view.LayoutInflater;
29import android.view.View;
30import android.view.ViewGroup;
Maurice Lam752e5f32015-04-23 23:08:53 -070031import android.widget.Button;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080032
33/**
34 * Setup Wizard's version of RedactionInterstitial screen. It inherits the logic and basic structure
35 * from RedactionInterstitial class, and should remain similar to that behaviorally. This class
36 * should only overload base methods for minor theme and behavior differences specific to Setup
37 * Wizard. Other changes should be done to RedactionInterstitial class instead and let this class
38 * inherit those changes.
39 */
Maurice Lam83301b52015-04-18 20:11:59 -070040public class SetupRedactionInterstitial extends RedactionInterstitial {
Maurice Lamecd2b7b2014-12-01 10:41:49 -080041
42 public static Intent createStartIntent(Context ctx) {
43 Intent startIntent = RedactionInterstitial.createStartIntent(ctx);
44 startIntent.setClass(ctx, SetupRedactionInterstitial.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 RedactionInterstitialFragment
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 Lam83301b52015-04-18 20:11:59 -070075 final SetupWizardLayout layout = new SetupWizardLayout(inflater.getContext());
76 layout.setIllustration(R.drawable.setup_illustration_lock_screen,
77 R.drawable.setup_illustration_horizontal_tile);
78 layout.setBackgroundTile(R.drawable.setup_illustration_tile);
79 layout.setHeaderText(R.string.notification_section_header);
80
81 View content = super.onCreateView(inflater, layout, savedInstanceState);
82 layout.addView(content);
83
84 final NavigationBar navigationBar = layout.getNavigationBar();
85 navigationBar.setNavigationBarListener(this);
Maurice Lam752e5f32015-04-23 23:08:53 -070086 final Button backButton = navigationBar.getBackButton();
87 backButton.setVisibility(View.GONE);
Maurice Lam83301b52015-04-18 20:11:59 -070088 SetupWizardUtils.setImmersiveMode(getActivity());
89 return layout;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080090 }
91
92 @Override
Maurice Lam83301b52015-04-18 20:11:59 -070093 public void onNavigateBack() {
94 final Activity activity = getActivity();
95 if (activity != null) {
96 activity.onBackPressed();
97 }
98 }
99
100 @Override
101 public void onNavigateNext() {
102 final SetupRedactionInterstitial activity = (SetupRedactionInterstitial) getActivity();
103 if (activity != null) {
104 activity.setResult(RESULT_OK, activity.getResultIntentData());
105 finish();
106 }
Maurice Lamecd2b7b2014-12-01 10:41:49 -0800107 }
108 }
109}