• 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.widget.Button;
21 
22 import com.android.setupwizardlib.SetupWizardLayout;
23 import com.android.setupwizardlib.view.NavigationBar;
24 import com.android.setupwizardlib.view.NavigationBar.NavigationBarListener;
25 
26 /**
27  * Base class for setting up the layout.
28  */
29 public abstract class SetupLayoutActivity extends Activity implements NavigationBarListener {
30 
31     protected Button mNextButton;
32     protected Button mBackButton;
33 
34     public static final int NEXT_BUTTON_EMPTY_LABEL = 0;
35 
initializeLayoutParams(int layoutResourceId, int headerResourceId, boolean showProgressBar)36     public void initializeLayoutParams(int layoutResourceId, int headerResourceId,
37             boolean showProgressBar) {
38         setContentView(layoutResourceId);
39         SetupWizardLayout layout = (SetupWizardLayout) findViewById(R.id.setup_wizard_layout);
40         layout.setHeaderText(headerResourceId);
41         if (showProgressBar) {
42             layout.showProgressBar();
43         }
44         setupNavigationBar(layout.getNavigationBar());
45     }
46 
setupNavigationBar(NavigationBar bar)47     private void setupNavigationBar(NavigationBar bar) {
48         bar.setNavigationBarListener(this);
49         mNextButton = bar.getNextButton();
50         mBackButton = bar.getBackButton();
51     }
52 
configureNavigationButtons(int nextButtonResourceId, int nextButtonVisibility, int backButtonVisibility)53     public void configureNavigationButtons(int nextButtonResourceId, int nextButtonVisibility,
54             int backButtonVisibility) {
55         if (nextButtonResourceId != NEXT_BUTTON_EMPTY_LABEL) {
56             mNextButton.setText(nextButtonResourceId);
57         }
58         mNextButton.setVisibility(nextButtonVisibility);
59         mBackButton.setVisibility(backButtonVisibility);
60     }
61 
62     @Override
onNavigateBack()63     public void onNavigateBack() {
64         onBackPressed();
65     }
66 
67     @Override
onNavigateNext()68     public void onNavigateNext() {
69     }
70 }