• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.certinstaller;
18 
19 import android.app.AlertDialog;
20 import android.app.Activity;
21 import android.app.Dialog;
22 import android.content.Context;
23 import android.view.LayoutInflater;
24 import android.view.View;
25 import android.os.Bundle;
26 import android.content.DialogInterface;
27 import android.widget.TextView;
28 
29 public class CredentialsInstallDialog extends Activity {
30     private static final String NETWORK_NAME = "network_name";
31     private static final String INSTALL_STATE = "install_state";
32 
33     @Override
onCreate(Bundle savedInstanceState)34     protected void onCreate(Bundle savedInstanceState) {
35         super.onCreate(savedInstanceState);
36     }
37 
38     @Override
onResume()39     protected void onResume() {
40         super.onResume();
41         displayDialog();
42     }
43 
displayDialog()44     public void displayDialog() {
45         AlertDialog.Builder builder = new AlertDialog.Builder(this);
46         View layout = getLayoutInflater().inflate(R.layout.credentials_installed_dialog, null);
47         builder.setView(layout);
48         Bundle bundle = getIntent().getExtras();
49         int installState = getIntent().getIntExtra(INSTALL_STATE, 0);
50         TextView text = (TextView) layout.findViewById(R.id.credential_installed_content);
51         if (installState == WiFiInstaller.INSTALL_SUCCESS) {
52             String networkName = bundle.getString(NETWORK_NAME);
53             text.setText(String.format(getResources().getString(R.string.install_done), networkName));
54             builder.setTitle(getResources().getString(R.string.install_done_title));
55         } else if (installState == WiFiInstaller.INSTALL_FAIL){
56             text.setText(getResources().getString(R.string.wifi_installer_fail));
57             builder.setTitle(R.string.wifi_installer_fail_title);
58         } else if (installState == WiFiInstaller.INSTALL_FAIL_NO_WIFI) {
59             text.setText(getResources().getString(R.string.wifi_installer_fail_no_wifi));
60             builder.setTitle(R.string.wifi_installer_fail_no_wifi_title);
61         }
62         builder.setPositiveButton(R.string.done_label, new DialogInterface.OnClickListener() {
63             @Override
64             public void onClick(DialogInterface dialog, int which) {
65                 dialog.dismiss();
66                 finish();
67             }
68         });
69         builder.create().show();
70     }
71 }
72