Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c8029bc authored by Roman Birg's avatar Roman Birg
Browse files

Settings: add wifi ap dialog 'show password' default overlay



Allow specifying a default value for whether "Show password" is
preselected in the WiFi tethering setup dialog. Also save the state and
restore it if the user changes the value.

Change-Id: Ib2ea8c1831f1c2cbef16dbf649624a24cc06133b
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 449a3bb5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -93,4 +93,7 @@
    <!-- Using this on MSIM devices leads to weird states that break telephony's
    internal state machine. All MSIM devices should probably set this to "true"-->
    <bool name="config_disablePreferredNetworkSwitch" translatable="false">false</bool>

    <!-- The default value of whether to check "Show password" in the WiFi AP dialog -->
    <bool name="config_showWifiApPasswordDefault">false</bool>
</resources>
+16 −3
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ import com.android.settings.R;
public class WifiApDialog extends AlertDialog implements View.OnClickListener,
        TextWatcher, AdapterView.OnItemSelectedListener {

    private final String PREFS_FILE = "wifi_ap";
    private final String KEY_SHOW_PASSWORD = "show_password";

    static final int BUTTON_SUBMIT = DialogInterface.BUTTON_POSITIVE;

    private final DialogInterface.OnClickListener mListener;
@@ -131,10 +134,15 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener,
        }

        mSsid.addTextChangedListener(this);
        final CheckBox showPassword = (CheckBox) mView.findViewById(R.id.show_password);
        final boolean showPasswordChecked = getContext().getSharedPreferences(PREFS_FILE, 0)
                .getBoolean(KEY_SHOW_PASSWORD, getContext().getResources()
                        .getBoolean(R.bool.config_showWifiApPasswordDefault));
        showPassword.setChecked(showPasswordChecked);
        onClick(showPassword);
        showPassword.setOnClickListener(this);
        mPassword.addTextChangedListener(this);
        ((CheckBox) mView.findViewById(R.id.show_password)).setOnClickListener(this);
        mSecurity.setOnItemSelectedListener(this);

        super.onCreate(savedInstanceState);

        showSecurityFields();
@@ -152,10 +160,15 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener,
    }

    public void onClick(View view) {
        final boolean checked = ((CheckBox) view).isChecked();
        mPassword.setInputType(
                InputType.TYPE_CLASS_TEXT | (((CheckBox) view).isChecked() ?
                InputType.TYPE_CLASS_TEXT | (checked ?
                InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD :
                InputType.TYPE_TEXT_VARIATION_PASSWORD));
        getContext().getSharedPreferences(PREFS_FILE, 0)
                .edit()
                .putBoolean(KEY_SHOW_PASSWORD, checked)
                .apply();
    }

    public void onTextChanged(CharSequence s, int start, int before, int count) {