blob: 4939aeaf7a777bb7ddbd62eba7d4c034c3b038a7 [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;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080023import android.os.Bundle;
24import android.view.LayoutInflater;
25import android.view.View;
26import android.view.ViewGroup;
Maurice Lam25e30812015-06-04 17:17:07 -070027
28import com.android.settings.notification.RedactionInterstitial;
29import com.android.setupwizardlib.SetupWizardLayout;
30import com.android.setupwizardlib.view.NavigationBar;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080031
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);
Alex Chauccade402015-06-12 11:45:08 +010043 if (startIntent != null) {
44 startIntent.setClass(ctx, SetupRedactionInterstitial.class);
45 startIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)
46 .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
47 }
Maurice Lamecd2b7b2014-12-01 10:41:49 -080048 return startIntent;
49 }
50
51 @Override
52 public Intent getIntent() {
53 Intent modIntent = new Intent(super.getIntent());
54 modIntent.putExtra(EXTRA_SHOW_FRAGMENT,
55 SetupEncryptionInterstitialFragment.class.getName());
56 return modIntent;
57 }
58
59 @Override
60 protected boolean isValidFragment(String fragmentName) {
61 return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName);
62 }
63
64 @Override
65 protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
Maurice Lam598be1e2015-04-08 21:13:42 -070066 resid = SetupWizardUtils.getTheme(getIntent());
Maurice Lamecd2b7b2014-12-01 10:41:49 -080067 super.onApplyThemeResource(theme, resid, first);
68 }
69
Maurice Lam83301b52015-04-18 20:11:59 -070070 public static class SetupEncryptionInterstitialFragment extends RedactionInterstitialFragment
71 implements NavigationBar.NavigationBarListener {
Maurice Lamecd2b7b2014-12-01 10:41:49 -080072
73 @Override
74 public View onCreateView(LayoutInflater inflater, ViewGroup container,
75 Bundle savedInstanceState) {
Maurice Lam25e30812015-06-04 17:17:07 -070076 return inflater.inflate(R.layout.setup_redaction_interstitial, container, false);
77 }
Maurice Lam83301b52015-04-18 20:11:59 -070078
Maurice Lam25e30812015-06-04 17:17:07 -070079 @Override
80 public void onViewCreated(View view, Bundle savedInstanceState) {
81 super.onViewCreated(view, savedInstanceState);
82 final SetupWizardLayout layout =
83 (SetupWizardLayout) view.findViewById(R.id.setup_wizard_layout);
Maurice Lam83301b52015-04-18 20:11:59 -070084
85 final NavigationBar navigationBar = layout.getNavigationBar();
86 navigationBar.setNavigationBarListener(this);
Maurice Lam25e30812015-06-04 17:17:07 -070087 navigationBar.getBackButton().setVisibility(View.GONE);
Maurice Lam83301b52015-04-18 20:11:59 -070088 SetupWizardUtils.setImmersiveMode(getActivity());
Maurice Lamecd2b7b2014-12-01 10:41:49 -080089 }
90
91 @Override
Maurice Lam83301b52015-04-18 20:11:59 -070092 public void onNavigateBack() {
93 final Activity activity = getActivity();
94 if (activity != null) {
95 activity.onBackPressed();
96 }
97 }
98
99 @Override
100 public void onNavigateNext() {
101 final SetupRedactionInterstitial activity = (SetupRedactionInterstitial) getActivity();
102 if (activity != null) {
103 activity.setResult(RESULT_OK, activity.getResultIntentData());
104 finish();
105 }
Maurice Lamecd2b7b2014-12-01 10:41:49 -0800106 }
107 }
108}