summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2013-02-24 17:43:36 -0800
committerAmith Yamasani <yamasani@google.com>2013-02-24 17:43:36 -0800
commit265dfd22e3681edfff14f068c1a113a28b4cd45c (patch)
tree401ddde35e2ec58b4ef694aea0f1f0aaebefce41
parentb271fecb50f7cdd8d89b29f072b2166a234c7985 (diff)
downloadpackages_apps_Settings-265dfd22e3681edfff14f068c1a113a28b4cd45c.tar.gz
packages_apps_Settings-265dfd22e3681edfff14f068c1a113a28b4cd45c.tar.bz2
packages_apps_Settings-265dfd22e3681edfff14f068c1a113a28b4cd45c.zip
Apply the show_password checkbox on the text field on orientation changes
Watch for changes to the checked state and update the password field's input type. Bug: 5639618 Change-Id: I4448d888481e5488289692fdf81901410cef72aa
-rw-r--r--src/com/android/settings/wifi/WifiConfigController.java35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 60ab1ca3a..497bce92c 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -49,9 +49,11 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
+import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
+import android.widget.CompoundButton.OnCheckedChangeListener;
import com.android.settings.ProxySelector;
import com.android.settings.R;
@@ -76,6 +78,7 @@ public class WifiConfigController implements TextWatcher,
// e.g. AccessPoint.SECURITY_NONE
private int mAccessPointSecurity;
private TextView mPasswordView;
+ private CheckBox mShowPassword;
private String unspecifiedCert = "unspecified";
private static final int unspecifiedCertIndex = 0;
@@ -555,8 +558,13 @@ public class WifiConfigController implements TextWatcher,
if (mPasswordView == null) {
mPasswordView = (TextView) mView.findViewById(R.id.password);
mPasswordView.addTextChangedListener(this);
- ((CheckBox) mView.findViewById(R.id.show_password)).setOnClickListener(this);
-
+ mShowPassword = (CheckBox) mView.findViewById(R.id.show_password);
+ mShowPassword.setOnClickListener(this);
+ mShowPassword.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ updatePasswordVisibility(isChecked);
+ }
+ });
if (mAccessPoint != null && mAccessPoint.networkId != INVALID_NETWORK_ID) {
mPasswordView.setHint(R.string.wifi_unchanged);
}
@@ -866,14 +874,7 @@ public class WifiConfigController implements TextWatcher,
@Override
public void onClick(View view) {
if (view.getId() == R.id.show_password) {
- int pos = mPasswordView.getSelectionEnd();
- mPasswordView.setInputType(
- InputType.TYPE_CLASS_TEXT | (((CheckBox) view).isChecked() ?
- InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
- InputType.TYPE_TEXT_VARIATION_PASSWORD));
- if (pos >= 0) {
- ((EditText)mPasswordView).setSelection(pos);
- }
+ updatePasswordVisibility(((CheckBox) view).isChecked());
} else if (view.getId() == R.id.wifi_advanced_togglebox) {
if (((CheckBox) view).isChecked()) {
mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.VISIBLE);
@@ -902,4 +903,18 @@ public class WifiConfigController implements TextWatcher,
public void onNothingSelected(AdapterView<?> parent) {
//
}
+
+ /**
+ * Make the characters of the password visible if show_password is checked.
+ */
+ private void updatePasswordVisibility(boolean checked) {
+ int pos = mPasswordView.getSelectionEnd();
+ mPasswordView.setInputType(
+ InputType.TYPE_CLASS_TEXT | (checked ?
+ InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
+ InputType.TYPE_TEXT_VARIATION_PASSWORD));
+ if (pos >= 0) {
+ ((EditText)mPasswordView).setSelection(pos);
+ }
+ }
}