Fix window leak on orientation change
Use Activity managed dialogs Bug: 2571764 Bug: 2571820 Change-Id: Id506988abd4200155774e92b31dd132519e29172
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings;
|
|||||||
import com.android.settings.wifi.WifiApEnabler;
|
import com.android.settings.wifi.WifiApEnabler;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@@ -50,6 +51,9 @@ public class TetherSettings extends PreferenceActivity {
|
|||||||
private static final String WIFI_HELP_MODIFIER = "wifi_";
|
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 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 mUsbTether;
|
||||||
|
|
||||||
private CheckBoxPreference mEnableWifiAp;
|
private CheckBoxPreference mEnableWifiAp;
|
||||||
@@ -89,8 +93,35 @@ public class TetherSettings extends PreferenceActivity {
|
|||||||
getPreferenceScreen().removePreference(mWifiApSettings);
|
getPreferenceScreen().removePreference(mWifiApSettings);
|
||||||
}
|
}
|
||||||
mWifiApEnabler = new WifiApEnabler(this, mEnableWifiAp);
|
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 {
|
private class TetherChangeReceiver extends BroadcastReceiver {
|
||||||
public void onReceive(Context content, Intent intent) {
|
public void onReceive(Context content, Intent intent) {
|
||||||
@@ -244,27 +275,8 @@ public class TetherSettings extends PreferenceActivity {
|
|||||||
mUsbTether.setSummary("");
|
mUsbTether.setSummary("");
|
||||||
}
|
}
|
||||||
} else if (preference == mTetherHelp) {
|
} 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)) {
|
showDialog(DIALOG_TETHER_HELP);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.wifi;
|
package com.android.settings.wifi;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@@ -48,6 +49,8 @@ public class WifiApSettings extends PreferenceActivity
|
|||||||
private static final int OPEN_INDEX = 0;
|
private static final int OPEN_INDEX = 0;
|
||||||
private static final int WPA_INDEX = 1;
|
private static final int WPA_INDEX = 1;
|
||||||
|
|
||||||
|
private static final int DIALOG_AP_SETTINGS = 1;
|
||||||
|
|
||||||
private String[] mSecurityType;
|
private String[] mSecurityType;
|
||||||
private Preference mCreateNetwork;
|
private Preference mCreateNetwork;
|
||||||
private CheckBoxPreference mEnableWifiAp;
|
private CheckBoxPreference mEnableWifiAp;
|
||||||
@@ -84,6 +87,15 @@ public class WifiApSettings extends PreferenceActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Dialog onCreateDialog(int id) {
|
||||||
|
if (id == DIALOG_AP_SETTINGS) {
|
||||||
|
mDialog = new WifiApDialog(this, this, mWifiConfig);
|
||||||
|
return mDialog;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -99,19 +111,11 @@ public class WifiApSettings extends PreferenceActivity
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
|
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) {
|
||||||
if (preference == mCreateNetwork) {
|
if (preference == mCreateNetwork) {
|
||||||
showDialog();
|
showDialog(DIALOG_AP_SETTINGS);
|
||||||
}
|
}
|
||||||
return true;
|
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) {
|
public void onClick(DialogInterface dialogInterface, int button) {
|
||||||
|
|
||||||
if (button == DialogInterface.BUTTON_POSITIVE) {
|
if (button == DialogInterface.BUTTON_POSITIVE) {
|
||||||
|
Reference in New Issue
Block a user