SetupRedactionInterstitial.java revision 71fde52ae36f134e93835bee53bc4bfe5481bba0
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 17package com.android.settings; 18 19import android.app.Activity; 20import android.content.Context; 21import android.content.Intent; 22import android.content.res.Resources; 23import android.os.Bundle; 24import android.os.UserHandle; 25import android.view.LayoutInflater; 26import android.view.View; 27import android.view.ViewGroup; 28import android.widget.LinearLayout; 29 30import com.android.settings.notification.RedactionInterstitial; 31import com.android.setupwizardlib.SetupWizardLayout; 32import com.android.setupwizardlib.view.NavigationBar; 33 34/** 35 * Setup Wizard's version of RedactionInterstitial screen. It inherits the logic and basic structure 36 * from RedactionInterstitial class, and should remain similar to that behaviorally. This class 37 * should only overload base methods for minor theme and behavior differences specific to Setup 38 * Wizard. Other changes should be done to RedactionInterstitial class instead and let this class 39 * inherit those changes. 40 */ 41public class SetupRedactionInterstitial extends RedactionInterstitial { 42 43 @Override 44 public Intent getIntent() { 45 Intent modIntent = new Intent(super.getIntent()); 46 modIntent.putExtra(EXTRA_SHOW_FRAGMENT, 47 SetupRedactionInterstitialFragment.class.getName()); 48 return modIntent; 49 } 50 51 @Override 52 protected boolean isValidFragment(String fragmentName) { 53 return SetupRedactionInterstitialFragment.class.getName().equals(fragmentName); 54 } 55 56 @Override 57 protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) { 58 resid = SetupWizardUtils.getTheme(getIntent()); 59 super.onApplyThemeResource(theme, resid, first); 60 } 61 62 @Override 63 protected void onCreate(Bundle savedInstance) { 64 super.onCreate(savedInstance); 65 LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent); 66 layout.setFitsSystemWindows(false); 67 } 68 69 public static class SetupRedactionInterstitialFragment extends RedactionInterstitialFragment 70 implements NavigationBar.NavigationBarListener { 71 72 @Override 73 public View onCreateView(LayoutInflater inflater, ViewGroup container, 74 Bundle savedInstanceState) { 75 return inflater.inflate(R.layout.setup_redaction_interstitial, container, false); 76 } 77 78 @Override 79 public void onViewCreated(View view, Bundle savedInstanceState) { 80 super.onViewCreated(view, savedInstanceState); 81 final SetupWizardLayout layout = 82 (SetupWizardLayout) view.findViewById(R.id.setup_wizard_layout); 83 84 final NavigationBar navigationBar = layout.getNavigationBar(); 85 navigationBar.setNavigationBarListener(this); 86 navigationBar.getBackButton().setVisibility(View.GONE); 87 SetupWizardUtils.setImmersiveMode(getActivity()); 88 } 89 90 @Override 91 public void onNavigateBack() { 92 final Activity activity = getActivity(); 93 if (activity != null) { 94 activity.onBackPressed(); 95 } 96 } 97 98 @Override 99 public void onNavigateNext() { 100 final SetupRedactionInterstitial activity = (SetupRedactionInterstitial) getActivity(); 101 if (activity != null) { 102 activity.setResult(RESULT_OK, activity.getResultIntentData()); 103 finish(); 104 } 105 } 106 } 107} 108