blob: c6437e0e4583331bcc3ee25030e29f4ce9277591 [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;
31
32/**
33 * Setup Wizard's version of RedactionInterstitial screen. It inherits the logic and basic structure
34 * from RedactionInterstitial class, and should remain similar to that behaviorally. This class
35 * should only overload base methods for minor theme and behavior differences specific to Setup
36 * Wizard. Other changes should be done to RedactionInterstitial class instead and let this class
37 * inherit those changes.
38 */
Maurice Lam83301b52015-04-18 20:11:59 -070039public class SetupRedactionInterstitial extends RedactionInterstitial {
Maurice Lamecd2b7b2014-12-01 10:41:49 -080040
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) {
Maurice Lam598be1e2015-04-08 21:13:42 -070064 resid = SetupWizardUtils.getTheme(getIntent());
Maurice Lamecd2b7b2014-12-01 10:41:49 -080065 super.onApplyThemeResource(theme, resid, first);
66 }
67
Maurice Lam83301b52015-04-18 20:11:59 -070068 public static class SetupEncryptionInterstitialFragment extends RedactionInterstitialFragment
69 implements NavigationBar.NavigationBarListener {
Maurice Lamecd2b7b2014-12-01 10:41:49 -080070
71 @Override
72 public View onCreateView(LayoutInflater inflater, ViewGroup container,
73 Bundle savedInstanceState) {
Maurice Lam83301b52015-04-18 20:11:59 -070074 final SetupWizardLayout layout = new SetupWizardLayout(inflater.getContext());
75 layout.setIllustration(R.drawable.setup_illustration_lock_screen,
76 R.drawable.setup_illustration_horizontal_tile);
77 layout.setBackgroundTile(R.drawable.setup_illustration_tile);
78 layout.setHeaderText(R.string.notification_section_header);
79
80 View content = super.onCreateView(inflater, layout, savedInstanceState);
81 layout.addView(content);
82
83 final NavigationBar navigationBar = layout.getNavigationBar();
84 navigationBar.setNavigationBarListener(this);
85 navigationBar.getBackButton().setEnabled(false);
86 SetupWizardUtils.setImmersiveMode(getActivity());
87 return layout;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080088 }
89
90 @Override
Maurice Lam83301b52015-04-18 20:11:59 -070091 public void onNavigateBack() {
92 final Activity activity = getActivity();
93 if (activity != null) {
94 activity.onBackPressed();
95 }
96 }
97
98 @Override
99 public void onNavigateNext() {
100 final SetupRedactionInterstitial activity = (SetupRedactionInterstitial) getActivity();
101 if (activity != null) {
102 activity.setResult(RESULT_OK, activity.getResultIntentData());
103 finish();
104 }
Maurice Lamecd2b7b2014-12-01 10:41:49 -0800105 }
106 }
107}