Search in sources :

Example 21 with ValidatedEditTextPreference

use of com.android.settings.widget.ValidatedEditTextPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiTetherPasswordPreferenceController method updateDisplay.

@Override
public void updateDisplay() {
    final WifiConfiguration config = mWifiManager.getWifiApConfiguration();
    if (config == null || (config.getAuthType() == WifiConfiguration.KeyMgmt.WPA2_PSK && TextUtils.isEmpty(config.preSharedKey))) {
        mPassword = generateRandomPassword();
    } else {
        mPassword = config.preSharedKey;
    }
    ((ValidatedEditTextPreference) mPreference).setValidator(this);
    ((ValidatedEditTextPreference) mPreference).setIsPassword(true);
    ((ValidatedEditTextPreference) mPreference).setIsSummaryPassword(true);
    updatePasswordDisplay((EditTextPreference) mPreference);
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) ValidatedEditTextPreference(com.android.settings.widget.ValidatedEditTextPreference)

Example 22 with ValidatedEditTextPreference

use of com.android.settings.widget.ValidatedEditTextPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiTetherSSIDPreferenceController method updateDisplay.

@Override
public void updateDisplay() {
    final WifiConfiguration config = mWifiManager.getWifiApConfiguration();
    if (config != null) {
        mSSID = config.SSID;
    } else {
        mSSID = DEFAULT_SSID;
    }
    ((ValidatedEditTextPreference) mPreference).setValidator(this);
    if (mWifiManager.isWifiApEnabled() && config != null) {
        final Intent intent = WifiDppUtils.getHotspotConfiguratorIntentOrNull(mContext, mWifiManager, config);
        if (intent == null) {
            Log.e(TAG, "Invalid security to share hotspot");
            ((WifiTetherSsidPreference) mPreference).setButtonVisible(false);
        } else {
            ((WifiTetherSsidPreference) mPreference).setButtonOnClickListener(view -> shareHotspotNetwork(intent));
            ((WifiTetherSsidPreference) mPreference).setButtonVisible(true);
        }
    } else {
        ((WifiTetherSsidPreference) mPreference).setButtonVisible(false);
    }
    updateSsidDisplay((EditTextPreference) mPreference);
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) ValidatedEditTextPreference(com.android.settings.widget.ValidatedEditTextPreference) Intent(android.content.Intent)

Example 23 with ValidatedEditTextPreference

use of com.android.settings.widget.ValidatedEditTextPreference in project android_packages_apps_Settings by omnirom.

the class WifiTetherPasswordPreferenceController method updatePasswordDisplay.

private void updatePasswordDisplay(EditTextPreference preference) {
    ValidatedEditTextPreference pref = (ValidatedEditTextPreference) preference;
    pref.setText(mPassword);
    if (!TextUtils.isEmpty(mPassword)) {
        pref.setIsSummaryPassword(true);
        pref.setSummary(mPassword);
        pref.setVisible(true);
    } else {
        pref.setIsSummaryPassword(false);
        pref.setSummary(R.string.wifi_hotspot_no_password_subtext);
        pref.setVisible(false);
    }
}
Also used : ValidatedEditTextPreference(com.android.settings.widget.ValidatedEditTextPreference)

Example 24 with ValidatedEditTextPreference

use of com.android.settings.widget.ValidatedEditTextPreference in project android_packages_apps_Settings by omnirom.

the class WifiTetherPasswordPreferenceController method updateDisplay.

@Override
public void updateDisplay() {
    final SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
    if (config.getSecurityType() != SoftApConfiguration.SECURITY_TYPE_OPEN && TextUtils.isEmpty(config.getPassphrase())) {
        mPassword = generateRandomPassword();
    } else {
        mPassword = config.getPassphrase();
    }
    mSecurityType = config.getSecurityType();
    ((ValidatedEditTextPreference) mPreference).setValidator(this);
    ((ValidatedEditTextPreference) mPreference).setIsPassword(true);
    ((ValidatedEditTextPreference) mPreference).setIsSummaryPassword(true);
    updatePasswordDisplay((EditTextPreference) mPreference);
}
Also used : ValidatedEditTextPreference(com.android.settings.widget.ValidatedEditTextPreference) SoftApConfiguration(android.net.wifi.SoftApConfiguration)

Example 25 with ValidatedEditTextPreference

use of com.android.settings.widget.ValidatedEditTextPreference in project android_packages_apps_Settings by omnirom.

the class WifiTetherSSIDPreferenceController method updateDisplay.

@Override
public void updateDisplay() {
    final SoftApConfiguration config = mWifiManager.getSoftApConfiguration();
    if (config != null) {
        mSSID = config.getSsid();
    } else {
        mSSID = DEFAULT_SSID;
    }
    ((ValidatedEditTextPreference) mPreference).setValidator(this);
    if (mWifiManager.isWifiApEnabled() && config != null) {
        final Intent intent = WifiDppUtils.getHotspotConfiguratorIntentOrNull(mContext, mWifiManager, config);
        if (intent == null) {
            Log.e(TAG, "Invalid security to share hotspot");
            ((WifiTetherSsidPreference) mPreference).setButtonVisible(false);
        } else {
            ((WifiTetherSsidPreference) mPreference).setButtonOnClickListener(view -> shareHotspotNetwork(intent));
            ((WifiTetherSsidPreference) mPreference).setButtonVisible(true);
        }
    } else {
        ((WifiTetherSsidPreference) mPreference).setButtonVisible(false);
    }
    updateSsidDisplay((EditTextPreference) mPreference);
}
Also used : ValidatedEditTextPreference(com.android.settings.widget.ValidatedEditTextPreference) Intent(android.content.Intent) SoftApConfiguration(android.net.wifi.SoftApConfiguration)

Aggregations

ValidatedEditTextPreference (com.android.settings.widget.ValidatedEditTextPreference)27 WifiConfiguration (android.net.wifi.WifiConfiguration)15 Before (org.junit.Before)15 SoftApConfiguration (android.net.wifi.SoftApConfiguration)3 Intent (android.content.Intent)2 PreferenceManager (androidx.preference.PreferenceManager)1 ShadowApplication (org.robolectric.shadows.ShadowApplication)1