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 | |
Maurice Lam | 83301b5 | 2015-04-18 20:11:59 -0700 | [diff] [blame] | 19 | import android.app.Activity; |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 20 | import android.content.Context; |
| 21 | import android.content.Intent; |
| 22 | import android.content.res.Resources; |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 23 | import android.os.Bundle; |
Clara Bayarri | f6077f4 | 2016-01-25 17:21:24 +0000 | [diff] [blame] | 24 | import android.os.UserHandle; |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 25 | import android.view.LayoutInflater; |
| 26 | import android.view.View; |
| 27 | import android.view.ViewGroup; |
Maurice Lam | 25e3081 | 2015-06-04 17:17:07 -0700 | [diff] [blame] | 28 | |
| 29 | import com.android.settings.notification.RedactionInterstitial; |
| 30 | import com.android.setupwizardlib.SetupWizardLayout; |
| 31 | import com.android.setupwizardlib.view.NavigationBar; |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 32 | |
| 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 Lam | 83301b5 | 2015-04-18 20:11:59 -0700 | [diff] [blame] | 40 | public class SetupRedactionInterstitial extends RedactionInterstitial { |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 41 | |
| 42 | public static Intent createStartIntent(Context ctx) { |
Clara Bayarri | f6077f4 | 2016-01-25 17:21:24 +0000 | [diff] [blame] | 43 | Intent startIntent = RedactionInterstitial.createStartIntent(ctx, UserHandle.myUserId()); |
Alex Chau | ccade40 | 2015-06-12 11:45:08 +0100 | [diff] [blame] | 44 | if (startIntent != null) { |
| 45 | startIntent.setClass(ctx, SetupRedactionInterstitial.class); |
| 46 | startIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false) |
| 47 | .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1); |
| 48 | } |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 49 | return startIntent; |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public Intent getIntent() { |
| 54 | Intent modIntent = new Intent(super.getIntent()); |
| 55 | modIntent.putExtra(EXTRA_SHOW_FRAGMENT, |
| 56 | SetupEncryptionInterstitialFragment.class.getName()); |
| 57 | return modIntent; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | protected boolean isValidFragment(String fragmentName) { |
| 62 | return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName); |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) { |
Maurice Lam | 598be1e | 2015-04-08 21:13:42 -0700 | [diff] [blame] | 67 | resid = SetupWizardUtils.getTheme(getIntent()); |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 68 | super.onApplyThemeResource(theme, resid, first); |
| 69 | } |
| 70 | |
Maurice Lam | 83301b5 | 2015-04-18 20:11:59 -0700 | [diff] [blame] | 71 | public static class SetupEncryptionInterstitialFragment extends RedactionInterstitialFragment |
| 72 | implements NavigationBar.NavigationBarListener { |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 73 | |
| 74 | @Override |
| 75 | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
| 76 | Bundle savedInstanceState) { |
Maurice Lam | 25e3081 | 2015-06-04 17:17:07 -0700 | [diff] [blame] | 77 | return inflater.inflate(R.layout.setup_redaction_interstitial, container, false); |
| 78 | } |
Maurice Lam | 83301b5 | 2015-04-18 20:11:59 -0700 | [diff] [blame] | 79 | |
Maurice Lam | 25e3081 | 2015-06-04 17:17:07 -0700 | [diff] [blame] | 80 | @Override |
| 81 | public void onViewCreated(View view, Bundle savedInstanceState) { |
| 82 | super.onViewCreated(view, savedInstanceState); |
| 83 | final SetupWizardLayout layout = |
| 84 | (SetupWizardLayout) view.findViewById(R.id.setup_wizard_layout); |
Maurice Lam | 83301b5 | 2015-04-18 20:11:59 -0700 | [diff] [blame] | 85 | |
| 86 | final NavigationBar navigationBar = layout.getNavigationBar(); |
| 87 | navigationBar.setNavigationBarListener(this); |
Maurice Lam | 25e3081 | 2015-06-04 17:17:07 -0700 | [diff] [blame] | 88 | navigationBar.getBackButton().setVisibility(View.GONE); |
Maurice Lam | 83301b5 | 2015-04-18 20:11:59 -0700 | [diff] [blame] | 89 | SetupWizardUtils.setImmersiveMode(getActivity()); |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | @Override |
Maurice Lam | 83301b5 | 2015-04-18 20:11:59 -0700 | [diff] [blame] | 93 | public void onNavigateBack() { |
| 94 | final Activity activity = getActivity(); |
| 95 | if (activity != null) { |
| 96 | activity.onBackPressed(); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | public void onNavigateNext() { |
| 102 | final SetupRedactionInterstitial activity = (SetupRedactionInterstitial) getActivity(); |
| 103 | if (activity != null) { |
| 104 | activity.setResult(RESULT_OK, activity.getResultIntentData()); |
| 105 | finish(); |
| 106 | } |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 107 | } |
| 108 | } |
| 109 | } |