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
This commit is contained in:
@@ -49,9 +49,11 @@ import android.widget.AdapterView;
|
|||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
|
|
||||||
import com.android.settings.ProxySelector;
|
import com.android.settings.ProxySelector;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -76,6 +78,7 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
// e.g. AccessPoint.SECURITY_NONE
|
// e.g. AccessPoint.SECURITY_NONE
|
||||||
private int mAccessPointSecurity;
|
private int mAccessPointSecurity;
|
||||||
private TextView mPasswordView;
|
private TextView mPasswordView;
|
||||||
|
private CheckBox mShowPassword;
|
||||||
|
|
||||||
private String unspecifiedCert = "unspecified";
|
private String unspecifiedCert = "unspecified";
|
||||||
private static final int unspecifiedCertIndex = 0;
|
private static final int unspecifiedCertIndex = 0;
|
||||||
@@ -555,8 +558,13 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
if (mPasswordView == null) {
|
if (mPasswordView == null) {
|
||||||
mPasswordView = (TextView) mView.findViewById(R.id.password);
|
mPasswordView = (TextView) mView.findViewById(R.id.password);
|
||||||
mPasswordView.addTextChangedListener(this);
|
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) {
|
if (mAccessPoint != null && mAccessPoint.networkId != INVALID_NETWORK_ID) {
|
||||||
mPasswordView.setHint(R.string.wifi_unchanged);
|
mPasswordView.setHint(R.string.wifi_unchanged);
|
||||||
}
|
}
|
||||||
@@ -866,14 +874,7 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (view.getId() == R.id.show_password) {
|
if (view.getId() == R.id.show_password) {
|
||||||
int pos = mPasswordView.getSelectionEnd();
|
updatePasswordVisibility(((CheckBox) view).isChecked());
|
||||||
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);
|
|
||||||
}
|
|
||||||
} else if (view.getId() == R.id.wifi_advanced_togglebox) {
|
} else if (view.getId() == R.id.wifi_advanced_togglebox) {
|
||||||
if (((CheckBox) view).isChecked()) {
|
if (((CheckBox) view).isChecked()) {
|
||||||
mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.VISIBLE);
|
mView.findViewById(R.id.wifi_advanced_fields).setVisibility(View.VISIBLE);
|
||||||
@@ -902,4 +903,18 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
public void onNothingSelected(AdapterView<?> parent) {
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user