blob: 5563c3b48eb54139c47721d4b49bf653d8e613d9 [file] [log] [blame]
Maurice Lam52c75ba2014-11-25 14:06:38 -08001/*
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
Maurice Lam52c75ba2014-11-25 14:06:38 -080019import android.app.Activity;
Maurice Lam3f7c09b2015-01-22 11:33:28 -080020import android.app.Dialog;
Maurice Lam52c75ba2014-11-25 14:06:38 -080021import android.content.Intent;
Maurice Lam52c75ba2014-11-25 14:06:38 -080022
Jason Monk39b46742015-09-10 15:52:51 -040023import com.android.setupwizardlib.util.SystemBarHelper;
24import com.android.setupwizardlib.util.WizardManagerHelper;
25
Maurice Lam52c75ba2014-11-25 14:06:38 -080026public class SetupWizardUtils {
Maurice Lam52c75ba2014-11-25 14:06:38 -080027
Maurice Lam598be1e2015-04-08 21:13:42 -070028 public static int getTheme(Intent intent) {
Maurice Lambddc5662015-03-03 18:27:48 -080029 if (WizardManagerHelper.isLightTheme(intent, true)) {
Maurice Lam598be1e2015-04-08 21:13:42 -070030 return R.style.SetupWizardTheme_Light;
Maurice Lambddc5662015-03-03 18:27:48 -080031 } else {
32 return R.style.SetupWizardTheme;
Maurice Lam52c75ba2014-11-25 14:06:38 -080033 }
Maurice Lam52c75ba2014-11-25 14:06:38 -080034 }
35
Maurice Lamdd3e2432015-11-05 18:51:05 -080036 public static int getTransparentTheme(Intent intent) {
37 if (WizardManagerHelper.isLightTheme(intent, true)) {
38 return R.style.SetupWizardTheme_Light_Transparent;
39 } else {
40 return R.style.SetupWizardTheme_Transparent;
41 }
42 }
43
Maurice Lam52c75ba2014-11-25 14:06:38 -080044 /**
45 * Sets the immersive mode related flags based on the extra in the intent which started the
46 * activity.
47 */
Maurice Lambddc5662015-03-03 18:27:48 -080048 public static void setImmersiveMode(Activity activity) {
49 final boolean useImmersiveMode = activity.getIntent().getBooleanExtra(
50 WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, false);
Maurice Lam52c75ba2014-11-25 14:06:38 -080051 if (useImmersiveMode) {
Maurice Lambddc5662015-03-03 18:27:48 -080052 SystemBarHelper.hideSystemBars(activity.getWindow());
Maurice Lam52c75ba2014-11-25 14:06:38 -080053 }
54 }
55
Maurice Lam3f7c09b2015-01-22 11:33:28 -080056 public static void applyImmersiveFlags(final Dialog dialog) {
Maurice Lambddc5662015-03-03 18:27:48 -080057 SystemBarHelper.hideSystemBars(dialog);
Maurice Lam3f7c09b2015-01-22 11:33:28 -080058 }
59
Maurice Lam6b19fa92014-11-25 19:25:56 -080060 public static void copySetupExtras(Intent fromIntent, Intent toIntent) {
Maurice Lambddc5662015-03-03 18:27:48 -080061 toIntent.putExtra(WizardManagerHelper.EXTRA_THEME,
62 fromIntent.getStringExtra(WizardManagerHelper.EXTRA_THEME));
63 toIntent.putExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE,
64 fromIntent.getBooleanExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, false));
Maurice Lam6b19fa92014-11-25 19:25:56 -080065 }
Maurice Lam52c75ba2014-11-25 14:06:38 -080066}