1 /* 2 * Copyright (C) 2019 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.car.developeroptions; 18 19 import android.content.Intent; 20 import android.sysprop.SetupWizardProperties; 21 22 import com.google.android.setupcompat.util.WizardManagerHelper; 23 import com.google.android.setupdesign.util.ThemeHelper; 24 25 26 public class SetupWizardUtils { 27 getTheme(Intent intent)28 public static int getTheme(Intent intent) { 29 String theme = intent.getStringExtra(WizardManagerHelper.EXTRA_THEME); 30 if (theme == null) { 31 theme = SetupWizardProperties.theme().orElse(""); 32 } 33 // TODO(yukl): Move to ThemeResolver and add any additional required attributes in 34 // onApplyThemeResource using Theme overlays 35 if (theme != null) { 36 if (WizardManagerHelper.isAnySetupWizard(intent)) { 37 switch (theme) { 38 case ThemeHelper.THEME_GLIF_V3_LIGHT: 39 return R.style.GlifV3Theme_Light; 40 case ThemeHelper.THEME_GLIF_V3: 41 return R.style.GlifV3Theme; 42 case ThemeHelper.THEME_GLIF_V2_LIGHT: 43 return R.style.GlifV2Theme_Light; 44 case ThemeHelper.THEME_GLIF_V2: 45 return R.style.GlifV2Theme; 46 case ThemeHelper.THEME_GLIF_LIGHT: 47 return R.style.GlifTheme_Light; 48 case ThemeHelper.THEME_GLIF: 49 return R.style.GlifTheme; 50 } 51 } else { 52 switch (theme) { 53 case ThemeHelper.THEME_GLIF_V3_LIGHT: 54 case ThemeHelper.THEME_GLIF_V3: 55 return R.style.GlifV3Theme; 56 case ThemeHelper.THEME_GLIF_V2_LIGHT: 57 case ThemeHelper.THEME_GLIF_V2: 58 return R.style.GlifV2Theme; 59 case ThemeHelper.THEME_GLIF_LIGHT: 60 case ThemeHelper.THEME_GLIF: 61 return R.style.GlifTheme; 62 } 63 } 64 } 65 return R.style.GlifTheme; 66 } 67 getTransparentTheme(Intent intent)68 public static int getTransparentTheme(Intent intent) { 69 final int suwTheme = getTheme(intent); 70 int transparentTheme = R.style.GlifV2Theme_Light_Transparent; 71 if (suwTheme == R.style.GlifV3Theme) { 72 transparentTheme = R.style.GlifV3Theme_Transparent; 73 } else if (suwTheme == R.style.GlifV3Theme_Light) { 74 transparentTheme = R.style.GlifV3Theme_Light_Transparent; 75 } else if (suwTheme == R.style.GlifV2Theme) { 76 transparentTheme = R.style.GlifV2Theme_Transparent; 77 } else if (suwTheme == R.style.GlifTheme_Light) { 78 transparentTheme = R.style.SetupWizardTheme_Light_Transparent; 79 } else if (suwTheme == R.style.GlifTheme) { 80 transparentTheme = R.style.SetupWizardTheme_Transparent; 81 } 82 return transparentTheme; 83 } 84 copySetupExtras(Intent fromIntent, Intent toIntent)85 public static void copySetupExtras(Intent fromIntent, Intent toIntent) { 86 WizardManagerHelper.copyWizardManagerExtras(fromIntent, toIntent); 87 } 88 } 89