2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings.wifi;
19 import com.android.settings.R;
20 import com.android.settingslib.wifi.AccessPoint;
22 import android.app.AlertDialog;
23 import android.content.Context;
24 import android.content.DialogInterface;
25 import android.os.Bundle;
26 import android.view.View;
27 import android.widget.Button;
29 class WifiDialog extends AlertDialog implements WifiConfigUiBase {
30 static final int BUTTON_SUBMIT = DialogInterface.BUTTON_POSITIVE;
31 static final int BUTTON_FORGET = DialogInterface.BUTTON_NEUTRAL;
33 private final boolean mEdit;
34 private final boolean mModify;
35 private final DialogInterface.OnClickListener mListener;
36 private final AccessPoint mAccessPoint;
39 private WifiConfigController mController;
40 private boolean mHideSubmitButton;
41 private boolean mHideForgetButton;
43 public WifiDialog(Context context, DialogInterface.OnClickListener listener,
44 AccessPoint accessPoint, boolean edit, boolean modify,
45 boolean hideSubmitButton, boolean hideForgetButton) {
46 this(context, listener, accessPoint, edit, modify);
47 mHideSubmitButton = hideSubmitButton;
48 mHideForgetButton = hideForgetButton;
51 public WifiDialog(Context context, DialogInterface.OnClickListener listener,
52 AccessPoint accessPoint, boolean edit, boolean modify) {
57 mAccessPoint = accessPoint;
58 mHideSubmitButton = false;
59 mHideForgetButton = false;
63 public WifiConfigController getController() {
68 protected void onCreate(Bundle savedInstanceState) {
69 mView = getLayoutInflater().inflate(R.layout.wifi_dialog, null);
71 setInverseBackgroundForced(true);
72 mController = new WifiConfigController(this, mView, mAccessPoint, mEdit, mModify);
73 super.onCreate(savedInstanceState);
75 if (mHideSubmitButton) {
76 mController.hideSubmitButton();
78 /* During creation, the submit button can be unavailable to determine
79 * visibility. Right after creation, update button visibility */
80 mController.enableSubmitIfAppropriate();
83 if (mHideForgetButton) {
84 mController.hideForgetButton();
88 public void onRestoreInstanceState(Bundle savedInstanceState) {
89 super.onRestoreInstanceState(savedInstanceState);
90 mController.updatePassword();
94 public boolean isEdit() {
99 public Button getSubmitButton() {
100 return getButton(BUTTON_SUBMIT);
104 public Button getForgetButton() {
105 return getButton(BUTTON_FORGET);
109 public Button getCancelButton() {
110 return getButton(BUTTON_NEGATIVE);
114 public void setSubmitButton(CharSequence text) {
115 setButton(BUTTON_SUBMIT, text, mListener);
119 public void setForgetButton(CharSequence text) {
120 setButton(BUTTON_FORGET, text, mListener);
124 public void setCancelButton(CharSequence text) {
125 setButton(BUTTON_NEGATIVE, text, mListener);