1 /* 2 * Copyright (C) 2010 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.wifi; 18 19 import com.android.settings.R; 20 21 import android.app.AlertDialog; 22 import android.content.Context; 23 import android.content.DialogInterface; 24 import android.os.Bundle; 25 import android.view.View; 26 import android.widget.Button; 27 28 class WifiDialog extends AlertDialog implements WifiConfigUiBase { 29 static final int BUTTON_SUBMIT = DialogInterface.BUTTON_POSITIVE; 30 static final int BUTTON_FORGET = DialogInterface.BUTTON_NEUTRAL; 31 32 private final boolean mEdit; 33 private final DialogInterface.OnClickListener mListener; 34 private final AccessPoint mAccessPoint; 35 36 private View mView; 37 private WifiConfigController mController; 38 WifiDialog(Context context, DialogInterface.OnClickListener listener, AccessPoint accessPoint, boolean edit)39 public WifiDialog(Context context, DialogInterface.OnClickListener listener, 40 AccessPoint accessPoint, boolean edit) { 41 super(context, R.style.Theme_WifiDialog); 42 mEdit = edit; 43 mListener = listener; 44 mAccessPoint = accessPoint; 45 } 46 47 @Override getController()48 public WifiConfigController getController() { 49 return mController; 50 } 51 52 @Override onCreate(Bundle savedInstanceState)53 protected void onCreate(Bundle savedInstanceState) { 54 mView = getLayoutInflater().inflate(R.layout.wifi_dialog, null); 55 setView(mView); 56 setInverseBackgroundForced(true); 57 mController = new WifiConfigController(this, mView, mAccessPoint, mEdit); 58 super.onCreate(savedInstanceState); 59 /* During creation, the submit button can be unavailable to determine 60 * visibility. Right after creation, update button visibility */ 61 mController.enableSubmitIfAppropriate(); 62 } 63 64 @Override isEdit()65 public boolean isEdit() { 66 return mEdit; 67 } 68 69 @Override getSubmitButton()70 public Button getSubmitButton() { 71 return getButton(BUTTON_SUBMIT); 72 } 73 74 @Override getForgetButton()75 public Button getForgetButton() { 76 return getButton(BUTTON_FORGET); 77 } 78 79 @Override getCancelButton()80 public Button getCancelButton() { 81 return getButton(BUTTON_NEGATIVE); 82 } 83 84 @Override setSubmitButton(CharSequence text)85 public void setSubmitButton(CharSequence text) { 86 setButton(BUTTON_SUBMIT, text, mListener); 87 } 88 89 @Override setForgetButton(CharSequence text)90 public void setForgetButton(CharSequence text) { 91 setButton(BUTTON_FORGET, text, mListener); 92 } 93 94 @Override setCancelButton(CharSequence text)95 public void setCancelButton(CharSequence text) { 96 setButton(BUTTON_NEGATIVE, text, mListener); 97 } 98 } 99