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

Commit 13c45045 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update preference to set password field" into pi-dev

parents 72982970 d35c8d67
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ public class ValidatedEditTextPreference extends CustomEditTextPreference {
            editText.removeTextChangedListener(mTextWatcher);
            if (mIsPassword) {
                editText.setInputType(
                        InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                        InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                editText.setMaxLines(1);
            }
            editText.addTextChangedListener(mTextWatcher);
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ public class WifiTetherPasswordPreferenceController extends WifiTetherBasePrefer
            mPassword = generateRandomPassword();
        }
        ((ValidatedEditTextPreference) mPreference).setValidator(this);
        ((ValidatedEditTextPreference) mPreference).setIsPassword(true);
        ((ValidatedEditTextPreference) mPreference).setIsSummaryPassword(true);
        updatePasswordDisplay((EditTextPreference) mPreference);
    }
+1 −1
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ public class ValidatedEditTextPreferenceTest {
        mPreference.onBindDialogView(mView);

        assertThat(editText.getInputType()
                & (InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT))
                & (InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_CLASS_TEXT))
                .isNotEqualTo(0);
    }

+17 −0
Original line number Diff line number Diff line
@@ -145,4 +145,21 @@ public class WifiTetherPasswordPreferenceControllerTest {
        assertThat(mController.getSecuritySettingForPassword())
                .isEqualTo(WifiConfiguration.KeyMgmt.WPA2_PSK);
    }

    @Test
    public void updateDisplay_shouldSetInputType() {
        // Set controller password to anything and verify is set.
        mController.displayPreference(mScreen);
        mController.onPreferenceChange(mPreference, "1");
        assertThat(mController.getPassword()).isEqualTo("1");

        // Create a new config using different password
        final WifiConfiguration config = new WifiConfiguration();
        config.preSharedKey = "test_1234";
        when(mWifiManager.getWifiApConfiguration()).thenReturn(config);

        // Call updateDisplay and verify it's changed.
        mController.updateDisplay();
        assertThat(mPreference.isPassword()).isTrue();
    }
}