am be38a39f
: merge from open-source master
Merge commit 'be38a39fc98d8574b747c57fea2aedd5d97fd333' * commit 'be38a39fc98d8574b747c57fea2aedd5d97fd333': Fix window leak problems in settings.
This commit is contained in:
committed by
Android Git Automerger
commit
e50496fb35
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -51,6 +52,7 @@ public class ApnEditor extends PreferenceActivity
|
|||||||
private static final int MENU_DELETE = Menu.FIRST;
|
private static final int MENU_DELETE = Menu.FIRST;
|
||||||
private static final int MENU_SAVE = Menu.FIRST + 1;
|
private static final int MENU_SAVE = Menu.FIRST + 1;
|
||||||
private static final int MENU_CANCEL = Menu.FIRST + 2;
|
private static final int MENU_CANCEL = Menu.FIRST + 2;
|
||||||
|
private static final int ERROR_DIALOG_ID = 0;
|
||||||
|
|
||||||
private static String sNotSet;
|
private static String sNotSet;
|
||||||
private EditTextPreference mName;
|
private EditTextPreference mName;
|
||||||
@@ -347,19 +349,8 @@ public class ApnEditor extends PreferenceActivity
|
|||||||
String mcc = checkNotSet(mMcc.getText());
|
String mcc = checkNotSet(mMcc.getText());
|
||||||
String mnc = checkNotSet(mMnc.getText());
|
String mnc = checkNotSet(mMnc.getText());
|
||||||
|
|
||||||
String errorMsg = null;
|
if (getErrorMsg() != null && !force) {
|
||||||
if (name.length() < 1) {
|
showDialog(ERROR_DIALOG_ID);
|
||||||
errorMsg = mRes.getString(R.string.error_name_empty);
|
|
||||||
} else if (apn.length() < 1) {
|
|
||||||
errorMsg = mRes.getString(R.string.error_apn_empty);
|
|
||||||
} else if (mcc.length() != 3) {
|
|
||||||
errorMsg = mRes.getString(R.string.error_mcc_not3);
|
|
||||||
} else if ((mnc.length() & 0xFFFE) != 2) {
|
|
||||||
errorMsg = mRes.getString(R.string.error_mnc_not23);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errorMsg != null && !force) {
|
|
||||||
showErrorMessage(errorMsg);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,12 +405,54 @@ public class ApnEditor extends PreferenceActivity
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorMessage(String message) {
|
private String getErrorMsg() {
|
||||||
new AlertDialog.Builder(this)
|
String errorMsg = null;
|
||||||
|
|
||||||
|
String name = checkNotSet(mName.getText());
|
||||||
|
String apn = checkNotSet(mApn.getText());
|
||||||
|
String mcc = checkNotSet(mMcc.getText());
|
||||||
|
String mnc = checkNotSet(mMnc.getText());
|
||||||
|
|
||||||
|
if (name.length() < 1) {
|
||||||
|
errorMsg = mRes.getString(R.string.error_name_empty);
|
||||||
|
} else if (apn.length() < 1) {
|
||||||
|
errorMsg = mRes.getString(R.string.error_apn_empty);
|
||||||
|
} else if (mcc.length() != 3) {
|
||||||
|
errorMsg = mRes.getString(R.string.error_mcc_not3);
|
||||||
|
} else if ((mnc.length() & 0xFFFE) != 2) {
|
||||||
|
errorMsg = mRes.getString(R.string.error_mnc_not23);
|
||||||
|
}
|
||||||
|
|
||||||
|
return errorMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Dialog onCreateDialog(int id) {
|
||||||
|
|
||||||
|
if (id == ERROR_DIALOG_ID) {
|
||||||
|
String msg = getErrorMsg();
|
||||||
|
|
||||||
|
return new AlertDialog.Builder(this)
|
||||||
.setTitle(R.string.error_title)
|
.setTitle(R.string.error_title)
|
||||||
.setMessage(message)
|
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
.show();
|
.setMessage(msg)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onCreateDialog(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPrepareDialog(int id, Dialog dialog) {
|
||||||
|
super.onPrepareDialog(id, dialog);
|
||||||
|
|
||||||
|
if (id == ERROR_DIALOG_ID) {
|
||||||
|
String msg = getErrorMsg();
|
||||||
|
|
||||||
|
if (msg != null) {
|
||||||
|
((AlertDialog)dialog).setMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteApn() {
|
private void deleteApn() {
|
||||||
|
@@ -58,6 +58,8 @@ public class LanguageSettings extends PreferenceActivity {
|
|||||||
private String mLastInputMethodId;
|
private String mLastInputMethodId;
|
||||||
private String mLastTickedInputMethodId;
|
private String mLastTickedInputMethodId;
|
||||||
|
|
||||||
|
private AlertDialog mDialog = null;
|
||||||
|
|
||||||
static public String getInputMethodIdFromKey(String key) {
|
static public String getInputMethodIdFromKey(String key) {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
@@ -257,12 +259,10 @@ public class LanguageSettings extends PreferenceActivity {
|
|||||||
if (selImi == null) {
|
if (selImi == null) {
|
||||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||||
}
|
}
|
||||||
AlertDialog d = (new AlertDialog.Builder(this))
|
if (mDialog == null) {
|
||||||
|
mDialog = (new AlertDialog.Builder(this))
|
||||||
.setTitle(android.R.string.dialog_alert_title)
|
.setTitle(android.R.string.dialog_alert_title)
|
||||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
.setMessage(getString(R.string.ime_security_warning,
|
|
||||||
selImi.getServiceInfo().applicationInfo.loadLabel(
|
|
||||||
getPackageManager())))
|
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(android.R.string.ok,
|
.setPositiveButton(android.R.string.ok,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@@ -279,7 +279,15 @@ public class LanguageSettings extends PreferenceActivity {
|
|||||||
|
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
d.show();
|
} else {
|
||||||
|
if (mDialog.isShowing()) {
|
||||||
|
mDialog.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mDialog.setMessage(getString(R.string.ime_security_warning,
|
||||||
|
selImi.getServiceInfo().applicationInfo.loadLabel(
|
||||||
|
getPackageManager())));
|
||||||
|
mDialog.show();
|
||||||
} else if (id.equals(mLastTickedInputMethodId)) {
|
} else if (id.equals(mLastTickedInputMethodId)) {
|
||||||
mLastTickedInputMethodId = null;
|
mLastTickedInputMethodId = null;
|
||||||
}
|
}
|
||||||
@@ -307,4 +315,13 @@ public class LanguageSettings extends PreferenceActivity {
|
|||||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (mDialog != null) {
|
||||||
|
mDialog.dismiss();
|
||||||
|
mDialog = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@ package com.android.settings;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Proxy;
|
import android.net.Proxy;
|
||||||
@@ -73,6 +74,7 @@ public class ProxySelector extends Activity
|
|||||||
HOSTNAME_PATTERN = Pattern.compile(HOSTNAME_REGEXP);
|
HOSTNAME_PATTERN = Pattern.compile(HOSTNAME_REGEXP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final int ERROR_DIALOG_ID = 0;
|
||||||
|
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
@@ -84,13 +86,32 @@ public class ProxySelector extends Activity
|
|||||||
populateFields(false);
|
populateFields(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showError(int error) {
|
@Override
|
||||||
|
protected Dialog onCreateDialog(int id) {
|
||||||
|
if (id == ERROR_DIALOG_ID) {
|
||||||
|
String hostname = mHostnameField.getText().toString().trim();
|
||||||
|
String portStr = mPortField.getText().toString().trim();
|
||||||
|
String msg = getString(validate(hostname, portStr));
|
||||||
|
|
||||||
new AlertDialog.Builder(this)
|
return new AlertDialog.Builder(this)
|
||||||
.setTitle(R.string.proxy_error)
|
.setTitle(R.string.proxy_error)
|
||||||
.setMessage(error)
|
|
||||||
.setPositiveButton(R.string.proxy_error_dismiss, null)
|
.setPositiveButton(R.string.proxy_error_dismiss, null)
|
||||||
.show();
|
.setMessage(msg)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
return super.onCreateDialog(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPrepareDialog(int id, Dialog dialog) {
|
||||||
|
super.onPrepareDialog(id, dialog);
|
||||||
|
|
||||||
|
if (id == ERROR_DIALOG_ID) {
|
||||||
|
String hostname = mHostnameField.getText().toString().trim();
|
||||||
|
String portStr = mPortField.getText().toString().trim();
|
||||||
|
String msg = getString(validate(hostname, portStr));
|
||||||
|
((AlertDialog)dialog).setMessage(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initView() {
|
void initView() {
|
||||||
@@ -188,7 +209,7 @@ public class ProxySelector extends Activity
|
|||||||
|
|
||||||
int result = validate(hostname, portStr);
|
int result = validate(hostname, portStr);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
showError(result);
|
showDialog(ERROR_DIALOG_ID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,6 +40,8 @@ public class SettingsSafetyLegalActivity extends AlertActivity
|
|||||||
|
|
||||||
private WebView mWebView;
|
private WebView mWebView;
|
||||||
|
|
||||||
|
private AlertDialog mErrorDialog = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -85,14 +87,31 @@ public class SettingsSafetyLegalActivity extends AlertActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorAndFinish(String url) {
|
private void showErrorAndFinish(String url) {
|
||||||
new AlertDialog.Builder(this)
|
if (mErrorDialog == null) {
|
||||||
.setMessage(getResources()
|
mErrorDialog = new AlertDialog.Builder(this)
|
||||||
.getString(R.string.settings_safetylegal_activity_unreachable, url))
|
|
||||||
.setTitle(R.string.settings_safetylegal_activity_title)
|
.setTitle(R.string.settings_safetylegal_activity_title)
|
||||||
.setPositiveButton(android.R.string.ok, this)
|
.setPositiveButton(android.R.string.ok, this)
|
||||||
.setOnCancelListener(this)
|
.setOnCancelListener(this)
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.show();
|
.create();
|
||||||
|
} else {
|
||||||
|
if (mErrorDialog.isShowing()) {
|
||||||
|
mErrorDialog.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mErrorDialog.setMessage(getResources()
|
||||||
|
.getString(R.string.settings_safetylegal_activity_unreachable, url));
|
||||||
|
mErrorDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
|
||||||
|
if (mErrorDialog != null) {
|
||||||
|
mErrorDialog.dismiss();
|
||||||
|
mErrorDialog = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -67,6 +67,8 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
|
|
||||||
private final LocalBluetoothManager mLocalManager;
|
private final LocalBluetoothManager mLocalManager;
|
||||||
|
|
||||||
|
private AlertDialog mDialog = null;
|
||||||
|
|
||||||
private List<Callback> mCallbacks = new ArrayList<Callback>();
|
private List<Callback> mCallbacks = new ArrayList<Callback>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -199,12 +201,29 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
new AlertDialog.Builder(context)
|
if (mDialog == null) {
|
||||||
.setTitle(getName())
|
mDialog = new AlertDialog.Builder(context)
|
||||||
.setMessage(message)
|
|
||||||
.setPositiveButton(android.R.string.ok, disconnectListener)
|
.setPositiveButton(android.R.string.ok, disconnectListener)
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.show();
|
.create();
|
||||||
|
} else {
|
||||||
|
if (mDialog.isShowing()) {
|
||||||
|
mDialog.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mDialog.setTitle(getName());
|
||||||
|
mDialog.setMessage(message);
|
||||||
|
mDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void finalize() throws Throwable {
|
||||||
|
if (mDialog != null) {
|
||||||
|
mDialog.dismiss();
|
||||||
|
mDialog = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
super.finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect() {
|
public void connect() {
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings.vpn;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.vpn.L2tpIpsecProfile;
|
import android.net.vpn.L2tpIpsecProfile;
|
||||||
@@ -44,6 +45,7 @@ import android.view.View;
|
|||||||
public class VpnEditor extends PreferenceActivity {
|
public class VpnEditor extends PreferenceActivity {
|
||||||
private static final int MENU_SAVE = Menu.FIRST;
|
private static final int MENU_SAVE = Menu.FIRST;
|
||||||
private static final int MENU_CANCEL = Menu.FIRST + 1;
|
private static final int MENU_CANCEL = Menu.FIRST + 1;
|
||||||
|
private static final int CONFIRM_DIALOG_ID = 0;
|
||||||
private static final String KEY_PROFILE = "profile";
|
private static final String KEY_PROFILE = "profile";
|
||||||
private static final String KEY_ORIGINAL_PROFILE_NAME = "orig_profile_name";
|
private static final String KEY_ORIGINAL_PROFILE_NAME = "orig_profile_name";
|
||||||
|
|
||||||
@@ -98,7 +100,7 @@ public class VpnEditor extends PreferenceActivity {
|
|||||||
|
|
||||||
case MENU_CANCEL:
|
case MENU_CANCEL:
|
||||||
if (profileChanged()) {
|
if (profileChanged()) {
|
||||||
showCancellationConfirmDialog();
|
showDialog(CONFIRM_DIALOG_ID);
|
||||||
} else {
|
} else {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -171,8 +173,12 @@ public class VpnEditor extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showCancellationConfirmDialog() {
|
|
||||||
new AlertDialog.Builder(this)
|
@Override
|
||||||
|
protected Dialog onCreateDialog(int id) {
|
||||||
|
|
||||||
|
if (id == CONFIRM_DIALOG_ID) {
|
||||||
|
return new AlertDialog.Builder(this)
|
||||||
.setTitle(android.R.string.dialog_alert_title)
|
.setTitle(android.R.string.dialog_alert_title)
|
||||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
.setMessage(mAddingProfile
|
.setMessage(mAddingProfile
|
||||||
@@ -185,7 +191,21 @@ public class VpnEditor extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.vpn_mistake_button, null)
|
.setNegativeButton(R.string.vpn_mistake_button, null)
|
||||||
.show();
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onCreateDialog(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPrepareDialog(int id, Dialog dialog) {
|
||||||
|
super.onPrepareDialog(id, dialog);
|
||||||
|
|
||||||
|
if (id == CONFIRM_DIALOG_ID) {
|
||||||
|
((AlertDialog)dialog).setMessage(mAddingProfile
|
||||||
|
? getString(R.string.vpn_confirm_add_profile_cancellation)
|
||||||
|
: getString(R.string.vpn_confirm_edit_profile_cancellation));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private VpnProfile getProfile() {
|
private VpnProfile getProfile() {
|
||||||
|
Reference in New Issue
Block a user