| Maurice Lam | 52c75ba | 2014-11-25 14:06:38 -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 | 52c75ba | 2014-11-25 14:06:38 -0800 | [diff] [blame] | 19 | import android.app.Activity; |
| Maurice Lam | 3f7c09b | 2015-01-22 11:33:28 -0800 | [diff] [blame] | 20 | import android.app.Dialog; |
| Maurice Lam | 52c75ba | 2014-11-25 14:06:38 -0800 | [diff] [blame] | 21 | import android.content.Intent; |
| Maurice Lam | 52c75ba | 2014-11-25 14:06:38 -0800 | [diff] [blame] | 22 | |
| Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 23 | import com.android.setupwizardlib.util.SystemBarHelper; |
| 24 | import com.android.setupwizardlib.util.WizardManagerHelper; |
| 25 | |
| Maurice Lam | 52c75ba | 2014-11-25 14:06:38 -0800 | [diff] [blame] | 26 | public class SetupWizardUtils { |
| Maurice Lam | 52c75ba | 2014-11-25 14:06:38 -0800 | [diff] [blame] | 27 | |
| Maurice Lam | 598be1e | 2015-04-08 21:13:42 -0700 | [diff] [blame] | 28 | public static int getTheme(Intent intent) { |
| Maurice Lam | bddc566 | 2015-03-03 18:27:48 -0800 | [diff] [blame] | 29 | if (WizardManagerHelper.isLightTheme(intent, true)) { |
| Maurice Lam | 598be1e | 2015-04-08 21:13:42 -0700 | [diff] [blame] | 30 | return R.style.SetupWizardTheme_Light; |
| Maurice Lam | bddc566 | 2015-03-03 18:27:48 -0800 | [diff] [blame] | 31 | } else { |
| 32 | return R.style.SetupWizardTheme; |
| Maurice Lam | 52c75ba | 2014-11-25 14:06:38 -0800 | [diff] [blame] | 33 | } |
| Maurice Lam | 52c75ba | 2014-11-25 14:06:38 -0800 | [diff] [blame] | 34 | } |
| 35 | |
| Maurice Lam | dd3e243 | 2015-11-05 18:51:05 -0800 | [diff] [blame] | 36 | 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 Lam | 52c75ba | 2014-11-25 14:06:38 -0800 | [diff] [blame] | 44 | /** |
| 45 | * Sets the immersive mode related flags based on the extra in the intent which started the |
| 46 | * activity. |
| 47 | */ |
| Maurice Lam | bddc566 | 2015-03-03 18:27:48 -0800 | [diff] [blame] | 48 | public static void setImmersiveMode(Activity activity) { |
| 49 | final boolean useImmersiveMode = activity.getIntent().getBooleanExtra( |
| 50 | WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, false); |
| Maurice Lam | 52c75ba | 2014-11-25 14:06:38 -0800 | [diff] [blame] | 51 | if (useImmersiveMode) { |
| Maurice Lam | bddc566 | 2015-03-03 18:27:48 -0800 | [diff] [blame] | 52 | SystemBarHelper.hideSystemBars(activity.getWindow()); |
| Maurice Lam | 52c75ba | 2014-11-25 14:06:38 -0800 | [diff] [blame] | 53 | } |
| 54 | } |
| 55 | |
| Maurice Lam | 3f7c09b | 2015-01-22 11:33:28 -0800 | [diff] [blame] | 56 | public static void applyImmersiveFlags(final Dialog dialog) { |
| Maurice Lam | bddc566 | 2015-03-03 18:27:48 -0800 | [diff] [blame] | 57 | SystemBarHelper.hideSystemBars(dialog); |
| Maurice Lam | 3f7c09b | 2015-01-22 11:33:28 -0800 | [diff] [blame] | 58 | } |
| 59 | |
| Maurice Lam | 6b19fa9 | 2014-11-25 19:25:56 -0800 | [diff] [blame] | 60 | public static void copySetupExtras(Intent fromIntent, Intent toIntent) { |
| Maurice Lam | bddc566 | 2015-03-03 18:27:48 -0800 | [diff] [blame] | 61 | 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 Lam | 6b19fa9 | 2014-11-25 19:25:56 -0800 | [diff] [blame] | 65 | } |
| Maurice Lam | 52c75ba | 2014-11-25 14:06:38 -0800 | [diff] [blame] | 66 | } |