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; 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 createStartIntent(Context ctx)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 getIntent()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 isValidFragment(String fragmentName)57 protected boolean isValidFragment(String fragmentName) { 58 return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName); 59 } 60 61 @Override onApplyThemeResource(Resources.Theme theme, int resid, boolean first)62 protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) { 63 resid = SetupWizardUtils.getTheme(getIntent(), resid); 64 super.onApplyThemeResource(theme, resid, first); 65 } 66 67 @Override onNavigationBarCreated(SetupWizardNavBar bar)68 public void onNavigationBarCreated(SetupWizardNavBar bar) { 69 SetupWizardUtils.setImmersiveMode(this, bar); 70 } 71 72 @Override onNavigateBack()73 public void onNavigateBack() { 74 onBackPressed(); 75 } 76 77 @Override onNavigateNext()78 public void onNavigateNext() { 79 setResult(RESULT_OK, getResultIntentData()); 80 finish(); 81 } 82 83 public static class SetupEncryptionInterstitialFragment extends RedactionInterstitialFragment { 84 85 @Override onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)86 public View onCreateView(LayoutInflater inflater, ViewGroup container, 87 Bundle savedInstanceState) { 88 View view = inflater.inflate(R.layout.setup_template, container, false); 89 ViewGroup setupContent = (ViewGroup) view.findViewById(R.id.setup_content); 90 View content = super.onCreateView(inflater, setupContent, savedInstanceState); 91 setupContent.addView(content); 92 return view; 93 } 94 95 @Override onViewCreated(View view, Bundle savedInstanceState)96 public void onViewCreated(View view, Bundle savedInstanceState) { 97 super.onViewCreated(view, savedInstanceState); 98 SetupWizardUtils.setIllustration(getActivity(), 99 R.drawable.setup_illustration_lock_screen); 100 SetupWizardUtils.setHeaderText(getActivity(), R.string.notification_section_header); 101 } 102 } 103 } 104