Search in sources :

Example 26 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiTetherSecurityPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mConfig = new WifiConfiguration();
    mConfig.SSID = "test_1234";
    mConfig.preSharedKey = "test_password";
    mConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA2_PSK);
    mContext = spy(RuntimeEnvironment.application);
    when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
    when(mWifiManager.getWifiApConfiguration()).thenReturn(mConfig);
    when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mConnectivityManager);
    when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[] { "1", "2" });
    when(mScreen.findPreference(anyString())).thenReturn(mPreference);
    mController = new WifiTetherSecurityPreferenceController(mContext, mListener);
    mPreference = new ListPreference(RuntimeEnvironment.application);
    mController.mPreference = mPreference;
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) ListPreference(androidx.preference.ListPreference) Before(org.junit.Before)

Example 27 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothAudioCodecPriorityPreferenceController method updateBluetoothAudioCodecPriorityOptions.

private void updateBluetoothAudioCodecPriorityOptions() {
    final int value = Settings.System.getInt(mContext.getContentResolver(), Settings.System.A2DP_SOURCE_CODEC_PRIORITY, 0);
    // default
    int index = 0;
    for (int i = 0; i < mListValues.length; i++) {
        int val = Integer.parseInt(mListValues[i]);
        if (val >= value) {
            index = i;
            break;
        }
    }
    final ListPreference listPreference = (ListPreference) mPreference;
    listPreference.setValue(mListValues[index]);
    listPreference.setSummary(mListSummaries[index]);
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 28 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BackgroundProcessLimitPreferenceController method updateAppProcessLimitOptions.

private void updateAppProcessLimitOptions() {
    try {
        final int limit = getActivityManagerService().getProcessLimit();
        // default
        int index = 0;
        for (int i = 0; i < mListValues.length; i++) {
            int val = Integer.parseInt(mListValues[i]);
            if (val >= limit) {
                index = i;
                break;
            }
        }
        final ListPreference listPreference = (ListPreference) mPreference;
        listPreference.setValue(mListValues[index]);
        listPreference.setSummary(mListSummaries[index]);
    } catch (RemoteException e) {
    // intentional no-op
    }
}
Also used : ListPreference(androidx.preference.ListPreference) RemoteException(android.os.RemoteException)

Example 29 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NightModePreferenceController method displayPreference.

@Override
public void displayPreference(PreferenceScreen screen) {
    if (!isAvailable()) {
        setVisible(screen, KEY_NIGHT_MODE, false);
        return;
    }
    final ListPreference mNightModePreference = screen.findPreference(KEY_NIGHT_MODE);
    if (mNightModePreference != null) {
        final UiModeManager uiManager = (UiModeManager) mContext.getSystemService(UI_MODE_SERVICE);
        final int currentNightMode = uiManager.getNightMode();
        mNightModePreference.setValue(String.valueOf(currentNightMode));
        mNightModePreference.setOnPreferenceChangeListener(this);
    }
}
Also used : UiModeManager(android.app.UiModeManager) ListPreference(androidx.preference.ListPreference)

Example 30 with ListPreference

use of androidx.preference.ListPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class EnabledNetworkModePreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    super.updateState(preference);
    final ListPreference listPreference = (ListPreference) preference;
    final int networkMode = getPreferredNetworkMode();
    updatePreferenceEntries(listPreference);
    updatePreferenceValueAndSummary(listPreference, networkMode);
}
Also used : ListPreference(androidx.preference.ListPreference)

Aggregations

ListPreference (androidx.preference.ListPreference)170 Test (org.junit.Test)24 Before (org.junit.Before)23 Preference (androidx.preference.Preference)20 EditTextPreference (androidx.preference.EditTextPreference)10 PreferenceScreen (androidx.preference.PreferenceScreen)10 SwitchPreference (androidx.preference.SwitchPreference)9 Context (android.content.Context)8 ContentResolver (android.content.ContentResolver)7 Intent (android.content.Intent)7 PersistableBundle (android.os.PersistableBundle)6 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)6 Resources (android.content.res.Resources)5 Bundle (android.os.Bundle)5 RemoteException (android.os.RemoteException)5 RestrictionEntry (android.content.RestrictionEntry)4 OverlayInfo (android.content.om.OverlayInfo)4 ApplicationInfo (android.content.pm.ApplicationInfo)4 PackageInfo (android.content.pm.PackageInfo)4 WifiConfiguration (android.net.wifi.WifiConfiguration)4