Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.settings; |
| 18 | |
| 19 | import com.android.settings.notification.RedactionInterstitial; |
| 20 | import com.android.setupwizard.navigationbar.SetupWizardNavBar; |
| 21 | |
| 22 | import android.content.Context; |
| 23 | import android.content.Intent; |
| 24 | import android.content.res.Resources; |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 25 | import android.os.Bundle; |
| 26 | import android.view.LayoutInflater; |
| 27 | import android.view.View; |
| 28 | import android.view.ViewGroup; |
| 29 | |
| 30 | /** |
| 31 | * Setup Wizard's version of RedactionInterstitial screen. It inherits the logic and basic structure |
| 32 | * from RedactionInterstitial class, and should remain similar to that behaviorally. This class |
| 33 | * should only overload base methods for minor theme and behavior differences specific to Setup |
| 34 | * Wizard. Other changes should be done to RedactionInterstitial class instead and let this class |
| 35 | * inherit those changes. |
| 36 | */ |
| 37 | public class SetupRedactionInterstitial extends RedactionInterstitial |
| 38 | implements SetupWizardNavBar.NavigationBarListener{ |
| 39 | |
| 40 | public static Intent createStartIntent(Context ctx) { |
| 41 | Intent startIntent = RedactionInterstitial.createStartIntent(ctx); |
| 42 | startIntent.setClass(ctx, SetupRedactionInterstitial.class); |
| 43 | startIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false) |
| 44 | .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1); |
| 45 | return startIntent; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public Intent getIntent() { |
| 50 | Intent modIntent = new Intent(super.getIntent()); |
| 51 | modIntent.putExtra(EXTRA_SHOW_FRAGMENT, |
| 52 | SetupEncryptionInterstitialFragment.class.getName()); |
| 53 | return modIntent; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | protected boolean isValidFragment(String fragmentName) { |
| 58 | return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName); |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) { |
Maurice Lam | 598be1e | 2015-04-08 21:13:42 -0700 | [diff] [blame] | 63 | resid = SetupWizardUtils.getTheme(getIntent()); |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 64 | super.onApplyThemeResource(theme, resid, first); |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public void onNavigationBarCreated(SetupWizardNavBar bar) { |
Maurice Lam | bddc566 | 2015-03-03 18:27:48 -0800 | [diff] [blame] | 69 | SetupWizardUtils.setImmersiveMode(this); |
Maurice Lam | 9066a5c | 2015-01-22 18:35:11 -0800 | [diff] [blame] | 70 | bar.getBackButton().setEnabled(false); |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public void onNavigateBack() { |
| 75 | onBackPressed(); |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public void onNavigateNext() { |
| 80 | setResult(RESULT_OK, getResultIntentData()); |
| 81 | finish(); |
| 82 | } |
| 83 | |
| 84 | public static class SetupEncryptionInterstitialFragment extends RedactionInterstitialFragment { |
| 85 | |
| 86 | @Override |
| 87 | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
| 88 | Bundle savedInstanceState) { |
| 89 | View view = inflater.inflate(R.layout.setup_template, container, false); |
| 90 | ViewGroup setupContent = (ViewGroup) view.findViewById(R.id.setup_content); |
| 91 | View content = super.onCreateView(inflater, setupContent, savedInstanceState); |
| 92 | setupContent.addView(content); |
| 93 | return view; |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public void onViewCreated(View view, Bundle savedInstanceState) { |
| 98 | super.onViewCreated(view, savedInstanceState); |
Maurice Lam | 1227a19 | 2014-12-03 16:12:31 -0800 | [diff] [blame] | 99 | SetupWizardUtils.setIllustration(getActivity(), |
| 100 | R.drawable.setup_illustration_lock_screen); |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 101 | SetupWizardUtils.setHeaderText(getActivity(), R.string.notification_section_header); |
| 102 | } |
| 103 | } |
| 104 | } |