blob: 354016d8723ccee4a76758d923cc5bbeab1bc050 [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;
Clara Bayarrif6077f42016-01-25 17:21:24 +000024import android.os.UserHandle;
Maurice Lamecd2b7b2014-12-01 10:41:49 -080025import android.view.LayoutInflater;
26import android.view.View;
27import android.view.ViewGroup;
Maurice Lam25e30812015-06-04 17:17:07 -070028
29import com.android.settings.notification.RedactionInterstitial;
30import com.android.setupwizardlib.SetupWizardLayout;
31import com.android.setupwizardlib.view.NavigationBar;
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
Maurice Lamecd2b7b2014-12-01 10:41:49 -080042 @Override
43 public Intent getIntent() {
44 Intent modIntent = new Intent(super.getIntent());
45 modIntent.putExtra(EXTRA_SHOW_FRAGMENT,
Udam Sainidd05ab72016-03-21 17:35:08 -070046 SetupRedactionInterstitialFragment.class.getName());
Maurice Lamecd2b7b2014-12-01 10:41:49 -080047 return modIntent;
48 }
49
50 @Override
51 protected boolean isValidFragment(String fragmentName) {
Udam Sainidd05ab72016-03-21 17:35:08 -070052 return SetupRedactionInterstitialFragment.class.getName().equals(fragmentName);
Maurice Lamecd2b7b2014-12-01 10:41:49 -080053 }
54
55 @Override
56 protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
Maurice Lam598be1e2015-04-08 21:13:42 -070057 resid = SetupWizardUtils.getTheme(getIntent());
Maurice Lamecd2b7b2014-12-01 10:41:49 -080058 super.onApplyThemeResource(theme, resid, first);
59 }
60
Udam Sainidd05ab72016-03-21 17:35:08 -070061 public static class SetupRedactionInterstitialFragment extends RedactionInterstitialFragment
Maurice Lam83301b52015-04-18 20:11:59 -070062 implements NavigationBar.NavigationBarListener {
Maurice Lamecd2b7b2014-12-01 10:41:49 -080063
64 @Override
65 public View onCreateView(LayoutInflater inflater, ViewGroup container,
66 Bundle savedInstanceState) {
Maurice Lam25e30812015-06-04 17:17:07 -070067 return inflater.inflate(R.layout.setup_redaction_interstitial, container, false);
68 }
Maurice Lam83301b52015-04-18 20:11:59 -070069
Maurice Lam25e30812015-06-04 17:17:07 -070070 @Override
71 public void onViewCreated(View view, Bundle savedInstanceState) {
72 super.onViewCreated(view, savedInstanceState);
73 final SetupWizardLayout layout =
74 (SetupWizardLayout) view.findViewById(R.id.setup_wizard_layout);
Maurice Lam83301b52015-04-18 20:11:59 -070075
76 final NavigationBar navigationBar = layout.getNavigationBar();
77 navigationBar.setNavigationBarListener(this);
Maurice Lam25e30812015-06-04 17:17:07 -070078 navigationBar.getBackButton().setVisibility(View.GONE);
Maurice Lam83301b52015-04-18 20:11:59 -070079 SetupWizardUtils.setImmersiveMode(getActivity());
Maurice Lamecd2b7b2014-12-01 10:41:49 -080080 }
81
82 @Override
Maurice Lam83301b52015-04-18 20:11:59 -070083 public void onNavigateBack() {
84 final Activity activity = getActivity();
85 if (activity != null) {
86 activity.onBackPressed();
87 }
88 }
89
90 @Override
91 public void onNavigateNext() {
92 final SetupRedactionInterstitial activity = (SetupRedactionInterstitial) getActivity();
93 if (activity != null) {
94 activity.setResult(RESULT_OK, activity.getResultIntentData());
95 finish();
96 }
Maurice Lamecd2b7b2014-12-01 10:41:49 -080097 }
98 }
99}