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 | 957fc67 | 2017-03-30 16:18:08 -0700 | [diff] [blame] | 19 | import android.content.ComponentName; |
| 20 | import android.content.Context; |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 21 | import android.content.Intent; |
Maurice Lam | 957fc67 | 2017-03-30 16:18:08 -0700 | [diff] [blame] | 22 | import android.content.pm.PackageManager; |
alexylli | 40b7938 | 2020-06-18 14:24:55 +0800 | [diff] [blame] | 23 | import android.os.Bundle; |
Maurice Lam | 25e3081 | 2015-06-04 17:17:07 -0700 | [diff] [blame] | 24 | |
| 25 | import com.android.settings.notification.RedactionInterstitial; |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 26 | |
alexylli | 40b7938 | 2020-06-18 14:24:55 +0800 | [diff] [blame] | 27 | import com.google.android.setupcompat.util.WizardManagerHelper; |
| 28 | |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 29 | /** |
| 30 | * Setup Wizard's version of RedactionInterstitial screen. It inherits the logic and basic structure |
| 31 | * from RedactionInterstitial class, and should remain similar to that behaviorally. This class |
| 32 | * should only overload base methods for minor theme and behavior differences specific to Setup |
| 33 | * Wizard. Other changes should be done to RedactionInterstitial class instead and let this class |
| 34 | * inherit those changes. |
| 35 | */ |
Maurice Lam | 83301b5 | 2015-04-18 20:11:59 -0700 | [diff] [blame] | 36 | public class SetupRedactionInterstitial extends RedactionInterstitial { |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 37 | |
Maurice Lam | 957fc67 | 2017-03-30 16:18:08 -0700 | [diff] [blame] | 38 | /** |
| 39 | * Set the enabled state of SetupRedactionInterstitial activity to configure whether it is shown |
| 40 | * as part of setup wizard's optional steps. |
| 41 | */ |
| 42 | public static void setEnabled(Context context, boolean enabled) { |
| 43 | PackageManager packageManager = context.getPackageManager(); |
| 44 | ComponentName componentName = new ComponentName(context, SetupRedactionInterstitial.class); |
| 45 | packageManager.setComponentEnabledSetting( |
| 46 | componentName, |
| 47 | enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED |
| 48 | : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, |
| 49 | PackageManager.DONT_KILL_APP); |
| 50 | } |
| 51 | |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 52 | @Override |
alexylli | 40b7938 | 2020-06-18 14:24:55 +0800 | [diff] [blame] | 53 | protected void onCreate(Bundle savedInstance) { |
| 54 | // Only allow to start the activity from Setup Wizard. |
| 55 | if (!WizardManagerHelper.isAnySetupWizard(getIntent())) { |
| 56 | finish(); |
| 57 | } |
| 58 | super.onCreate(savedInstance); |
| 59 | } |
| 60 | |
| 61 | @Override |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 62 | public Intent getIntent() { |
| 63 | Intent modIntent = new Intent(super.getIntent()); |
| 64 | modIntent.putExtra(EXTRA_SHOW_FRAGMENT, |
Udam Saini | dd05ab7 | 2016-03-21 17:35:08 -0700 | [diff] [blame] | 65 | SetupRedactionInterstitialFragment.class.getName()); |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 66 | return modIntent; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | protected boolean isValidFragment(String fragmentName) { |
Udam Saini | dd05ab7 | 2016-03-21 17:35:08 -0700 | [diff] [blame] | 71 | return SetupRedactionInterstitialFragment.class.getName().equals(fragmentName); |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 72 | } |
| 73 | |
Maurice Lam | d189ac5 | 2016-06-15 13:39:34 -0700 | [diff] [blame] | 74 | public static class SetupRedactionInterstitialFragment extends RedactionInterstitialFragment { |
Udam Saini | 71fde52 | 2016-03-30 13:38:05 -0700 | [diff] [blame] | 75 | |
Maurice Lam | d189ac5 | 2016-06-15 13:39:34 -0700 | [diff] [blame] | 76 | // Setup wizard specific UI customizations can be done here |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 77 | } |
| 78 | } |