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 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 48 public WifiConfigController getController() { 49 return mController; 50 } 51 52 @Override 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 } 60 61 @Override 62 public boolean isEdit() { 63 return mEdit; 64 } 65 66 @Override 67 public Button getSubmitButton() { 68 return getButton(BUTTON_SUBMIT); 69 } 70 71 @Override 72 public Button getForgetButton() { 73 return getButton(BUTTON_FORGET); 74 } 75 76 @Override 77 public Button getCancelButton() { 78 return getButton(BUTTON_NEGATIVE); 79 } 80 81 @Override 82 public void setSubmitButton(CharSequence text) { 83 setButton(BUTTON_SUBMIT, text, mListener); 84 } 85 86 @Override 87 public void setForgetButton(CharSequence text) { 88 setButton(BUTTON_FORGET, text, mListener); 89 } 90 91 @Override 92 public void setCancelButton(CharSequence text) { 93 setButton(BUTTON_NEGATIVE, text, mListener); 94 } 95 } 96