1 /** 2 * Copyright (C) 2022 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.bluetooth; 18 19 import android.content.Intent; 20 import android.os.Bundle; 21 import android.os.SystemProperties; 22 23 import androidx.fragment.app.FragmentManager; 24 25 import com.android.settings.R; 26 import com.android.settingslib.core.lifecycle.ObservableActivity; 27 28 import com.google.android.setupdesign.util.ThemeHelper; 29 import com.google.android.setupdesign.util.ThemeResolver; 30 31 public abstract class QrCodeScanModeBaseActivity extends ObservableActivity { 32 33 private static final String THEME_KEY = "setupwizard.theme"; 34 private static final String THEME_DEFAULT_VALUE = "SudThemeGlifV3_DayNight"; 35 protected FragmentManager mFragmentManager; 36 handleIntent(Intent intent)37 protected abstract void handleIntent(Intent intent); 38 39 @Override onCreate(Bundle savedInstanceState)40 protected void onCreate(Bundle savedInstanceState) { 41 super.onCreate(savedInstanceState); 42 43 int defaultTheme = 44 ThemeHelper.isSetupWizardDayNightEnabled(this) 45 ? com.google.android.setupdesign.R.style.SudThemeGlifV3_DayNight 46 : com.google.android.setupdesign.R.style.SudThemeGlifV3_Light; 47 ThemeResolver themeResolver = 48 new ThemeResolver.Builder(ThemeResolver.getDefault()) 49 .setDefaultTheme(defaultTheme) 50 .setUseDayNight(true) 51 .build(); 52 setTheme(themeResolver.resolve( 53 SystemProperties.get(THEME_KEY, THEME_DEFAULT_VALUE), 54 /* suppressDayNight= */ !ThemeHelper.isSetupWizardDayNightEnabled(this))); 55 56 setContentView(R.layout.qrcode_scan_mode_activity); 57 mFragmentManager = getSupportFragmentManager(); 58 59 if (savedInstanceState == null) { 60 handleIntent(getIntent()); 61 } 62 } 63 } 64