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 android.content.ComponentName;
20 import android.content.Context;
21 import android.content.Intent;
22 import android.content.pm.PackageManager;
23 import android.content.res.Resources;
24 
25 import com.android.settings.notification.RedactionInterstitial;
26 
27 /**
28  * Setup Wizard's version of RedactionInterstitial screen. It inherits the logic and basic structure
29  * from RedactionInterstitial class, and should remain similar to that behaviorally. This class
30  * should only overload base methods for minor theme and behavior differences specific to Setup
31  * Wizard. Other changes should be done to RedactionInterstitial class instead and let this class
32  * inherit those changes.
33  */
34 public class SetupRedactionInterstitial extends RedactionInterstitial {
35 
36     /**
37      * Set the enabled state of SetupRedactionInterstitial activity to configure whether it is shown
38      * as part of setup wizard's optional steps.
39      */
setEnabled(Context context, boolean enabled)40     public static void setEnabled(Context context, boolean enabled) {
41         PackageManager packageManager = context.getPackageManager();
42         ComponentName componentName = new ComponentName(context, SetupRedactionInterstitial.class);
43         packageManager.setComponentEnabledSetting(
44                 componentName,
45                 enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
46                         : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
47                 PackageManager.DONT_KILL_APP);
48     }
49 
50     @Override
getIntent()51     public Intent getIntent() {
52         Intent modIntent = new Intent(super.getIntent());
53         modIntent.putExtra(EXTRA_SHOW_FRAGMENT,
54                 SetupRedactionInterstitialFragment.class.getName());
55         return modIntent;
56     }
57 
58     @Override
isValidFragment(String fragmentName)59     protected boolean isValidFragment(String fragmentName) {
60         return SetupRedactionInterstitialFragment.class.getName().equals(fragmentName);
61     }
62 
63     @Override
onApplyThemeResource(Resources.Theme theme, int resid, boolean first)64     protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
65         resid = SetupWizardUtils.getTheme(getIntent());
66         super.onApplyThemeResource(theme, resid, first);
67     }
68 
69     public static class SetupRedactionInterstitialFragment extends RedactionInterstitialFragment {
70 
71         // Setup wizard specific UI customizations can be done here
72     }
73 }
74