• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2015, 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.managedprovisioning;
18 
19 import android.app.Activity;
20 import android.content.res.ColorStateList;
21 import android.graphics.Color;
22 import android.graphics.drawable.Drawable;
23 import android.view.Window;
24 import android.view.WindowManager;
25 
26 import com.android.managedprovisioning.common.Utils;
27 import com.android.setupwizardlib.GlifLayout;
28 
29 /**
30  * Base class for setting up the layout.
31  */
32 public abstract class SetupLayoutActivity extends Activity {
33     protected final Utils mUtils = new Utils();
34 
initializeLayoutParams(int layoutResourceId, int headerResourceId, boolean showProgressBar)35     protected void initializeLayoutParams(int layoutResourceId, int headerResourceId,
36             boolean showProgressBar) {
37         setContentView(layoutResourceId);
38         GlifLayout layout = (GlifLayout) findViewById(R.id.setup_wizard_layout);
39         layout.setHeaderText(headerResourceId);
40         if (showProgressBar) {
41             layout.setProgressBarShown(true);
42         }
43     }
44 
maybeSetLogoAndMainColor(Integer mainColor)45     protected void maybeSetLogoAndMainColor(Integer mainColor) {
46         // null means the default value
47         if (mainColor == null) {
48             mainColor = getResources().getColor(R.color.orange);
49         }
50         // We should always use a value of 255 for the alpha.
51         mainColor = Color.argb(255, Color.red(mainColor), Color.green(mainColor),
52                 Color.blue(mainColor));
53 
54         Window window = getWindow();
55         window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
56         window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
57         window.setStatusBarColor(mainColor);
58         GlifLayout layout = (GlifLayout) findViewById(R.id.setup_wizard_layout);
59         Drawable logo = LogoUtils.getOrganisationLogo(this);
60         layout.setIcon(logo);
61         layout.setPrimaryColor(ColorStateList.valueOf(mainColor));
62     }
63 }
64