blob: 590788b109f33545b44fda297a6ed90e277e0a35 [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);
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 Lam25e30812015-06-04 17:17:07 -070074 return inflater.inflate(R.layout.setup_redaction_interstitial, container, false);
75 }
Maurice Lam83301b52015-04-18 20:11:59 -070076
Maurice Lam25e30812015-06-04 17:17:07 -070077 @Override
78 public void onViewCreated(View view, Bundle savedInstanceState) {
79 super.onViewCreated(view, savedInstanceState);
80 final SetupWizardLayout layout =
81 (SetupWizardLayout) view.findViewById(R.id.setup_wizard_layout);
Maurice Lam83301b52015-04-18 20:11:59 -070082
83 final NavigationBar navigationBar = layout.getNavigationBar();
84 navigationBar.setNavigationBarListener(this);
Maurice Lam25e30812015-06-04 17:17:07 -070085 navigationBar.getBackButton().setVisibility(View.GONE);
Maurice Lam83301b52015-04-18 20:11:59 -070086 SetupWizardUtils.setImmersiveMode(getActivity());
Maurice Lamecd2b7b2014-12-01 10:41:49 -080087 }
88
89 @Override
Maurice Lam83301b52015-04-18 20:11:59 -070090 public void onNavigateBack() {
91 final Activity activity = getActivity();
92 if (activity != null) {
93 activity.onBackPressed();
94 }
95 }
96
97 @Override
98 public void onNavigateNext() {
99 final SetupRedactionInterstitial activity = (SetupRedactionInterstitial) getActivity();
100 if (activity != null) {
101 activity.setResult(RESULT_OK, activity.getResultIntentData());
102 finish();
103 }
Maurice Lamecd2b7b2014-12-01 10:41:49 -0800104 }
105 }
106}