import com.android.settings.wifi.WifiApEnabler;
import android.app.AlertDialog;
+import android.app.Dialog;
import android.os.Bundle;
import android.os.SystemProperties;
import android.content.BroadcastReceiver;
private static final String WIFI_HELP_MODIFIER = "wifi_";
private static final String HELP_URL = "file:///android_asset/html/%y_%z/tethering_%xhelp.html";
+ private static final int DIALOG_TETHER_HELP = 1;
+
+ private WebView mView;
private CheckBoxPreference mUsbTether;
private CheckBoxPreference mEnableWifiAp;
getPreferenceScreen().removePreference(mWifiApSettings);
}
mWifiApEnabler = new WifiApEnabler(this, mEnableWifiAp);
+ mView = new WebView(this);
}
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ if (id == DIALOG_TETHER_HELP) {
+ Locale locale = Locale.getDefault();
+ String url = HELP_URL.replace("%y", locale.getLanguage().toLowerCase());
+ url = url.replace("%z", locale.getCountry().toLowerCase());
+
+ if ((mUsbRegexs.length != 0) && (mWifiRegexs.length == 0)) {
+ url = url.replace("%x", USB_HELP_MODIFIER);
+ } else if ((mWifiRegexs.length != 0) && (mUsbRegexs.length == 0)) {
+ url = url.replace("%x", WIFI_HELP_MODIFIER);
+ } else {
+ // could assert that both wifi and usb have regexs, but the default
+ // is to use this anyway so no check is needed
+ url = url.replace("%x", "");
+ }
+ mView.loadUrl(url);
+
+ return new AlertDialog.Builder(this)
+ .setCancelable(true)
+ .setTitle(R.string.tethering_help_button_text)
+ .setView(mView)
+ .create();
+ }
+ return null;
+ }
private class TetherChangeReceiver extends BroadcastReceiver {
public void onReceive(Context content, Intent intent) {
mUsbTether.setSummary("");
}
} else if (preference == mTetherHelp) {
- Locale locale = Locale.getDefault();
- String url = HELP_URL.replace("%y", locale.getLanguage().toLowerCase());
- url = url.replace("%z", locale.getCountry().toLowerCase());
- if ((mUsbRegexs.length != 0) && (mWifiRegexs.length == 0)) {
- url = url.replace("%x", USB_HELP_MODIFIER);
- } else if ((mWifiRegexs.length != 0) && (mUsbRegexs.length == 0)) {
- url = url.replace("%x", WIFI_HELP_MODIFIER);
- } else {
- // could assert that both wifi and usb have regexs, but the default
- // is to use this anyway so no check is needed
- url = url.replace("%x", "");
- }
- WebView view = new WebView(this);
- view.loadUrl(url);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setCancelable(true);
- builder.setTitle(R.string.tethering_help_button_text);
- builder.setView(view);
- builder.show();
+ showDialog(DIALOG_TETHER_HELP);
}
return false;
}
package com.android.settings.wifi;
import com.android.settings.R;
+import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
private static final int OPEN_INDEX = 0;
private static final int WPA_INDEX = 1;
+ private static final int DIALOG_AP_SETTINGS = 1;
+
private String[] mSecurityType;
private Preference mCreateNetwork;
private CheckBoxPreference mEnableWifiAp;
}
@Override
+ protected Dialog onCreateDialog(int id) {
+ if (id == DIALOG_AP_SETTINGS) {
+ mDialog = new WifiApDialog(this, this, mWifiConfig);
+ return mDialog;
+ }
+ return null;
+ }
+
+ @Override
protected void onResume() {
super.onResume();
mWifiApEnabler.resume();
@Override
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
if (preference == mCreateNetwork) {
- showDialog();
+ showDialog(DIALOG_AP_SETTINGS);
}
return true;
}
- private void showDialog() {
- if (mDialog != null) {
- mDialog.dismiss();
- }
- mDialog = new WifiApDialog(this, this, mWifiConfig);
- mDialog.show();
- }
-
public void onClick(DialogInterface dialogInterface, int button) {
if (button == DialogInterface.BUTTON_POSITIVE) {