Search in sources :

Example 1 with DropDownPreference

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

the class WifiPrivacyPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    final DropDownPreference dropDownPreference = (DropDownPreference) preference;
    final int randomizationLevel = getRandomizationValue();
    dropDownPreference.setValue(Integer.toString(randomizationLevel));
    updateSummary(dropDownPreference, randomizationLevel);
    // Makes preference not selectable, when this is a ephemeral network.
    if (mIsEphemeral || mIsPasspoint) {
        preference.setSelectable(false);
        dropDownPreference.setSummary(R.string.wifi_privacy_settings_ephemeral_summary);
    }
}
Also used : DropDownPreference(androidx.preference.DropDownPreference)

Example 2 with DropDownPreference

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

the class WifiMeteredPreferenceControllerTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    mPreferenceController = spy(new WifiMeteredPreferenceController(mContext, mWifiConfiguration));
    mDropDownPreference = new DropDownPreference(mContext);
    mDropDownPreference.setEntries(R.array.wifi_metered_entries);
    mDropDownPreference.setEntryValues(R.array.wifi_metered_values);
}
Also used : DropDownPreference(androidx.preference.DropDownPreference) Before(org.junit.Before)

Example 3 with DropDownPreference

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

the class SettingPref method init.

public Preference init(SettingsPreferenceFragment settings) {
    final Context context = settings.getActivity();
    Preference p = settings.getPreferenceScreen().findPreference(mKey);
    if (p != null && !isApplicable(context)) {
        settings.getPreferenceScreen().removePreference(p);
        p = null;
    }
    if (p instanceof TwoStatePreference) {
        mTwoState = (TwoStatePreference) p;
    } else if (p instanceof DropDownPreference) {
        mDropDown = (DropDownPreference) p;
        CharSequence[] entries = new CharSequence[mValues.length];
        CharSequence[] values = new CharSequence[mValues.length];
        for (int i = 0; i < mValues.length; i++) {
            entries[i] = getCaption(context.getResources(), mValues[i]);
            values[i] = Integer.toString(mValues[i]);
        }
        mDropDown.setEntries(entries);
        mDropDown.setEntryValues(values);
    }
    update(context);
    if (mTwoState != null) {
        p.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                setSetting(context, (Boolean) newValue ? 1 : 0);
                return true;
            }
        });
        return mTwoState;
    }
    if (mDropDown != null) {
        p.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                return setSetting(context, Integer.parseInt((String) newValue));
            }
        });
        return mDropDown;
    }
    return null;
}
Also used : Context(android.content.Context) TwoStatePreference(androidx.preference.TwoStatePreference) TwoStatePreference(androidx.preference.TwoStatePreference) DropDownPreference(androidx.preference.DropDownPreference) Preference(androidx.preference.Preference) OnPreferenceChangeListener(androidx.preference.Preference.OnPreferenceChangeListener) DropDownPreference(androidx.preference.DropDownPreference)

Example 4 with DropDownPreference

use of androidx.preference.DropDownPreference in project android_packages_apps_Settings by omnirom.

the class EmergencyTonePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final Context appContext = RuntimeEnvironment.application;
    when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
    when(mTelephonyManager.getCurrentPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
    when(mSetting.getActivity()).thenReturn(mActivity);
    when(mActivity.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
    when(mActivity.getContentResolver()).thenReturn(mContentResolver);
    when(mActivity.getResources()).thenReturn(appContext.getResources());
    mPreference = new DropDownPreference(appContext);
    mController = new EmergencyTonePreferenceController(mContext, mSetting, null);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    doReturn(mScreen).when(mSetting).getPreferenceScreen();
}
Also used : Context(android.content.Context) DropDownPreference(androidx.preference.DropDownPreference) Before(org.junit.Before)

Example 5 with DropDownPreference

use of androidx.preference.DropDownPreference in project android_packages_apps_Settings by omnirom.

the class NfcForegroundPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    when(mContext.getPackageManager()).thenReturn(mManager);
    mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
    mController = new NfcForegroundPreferenceController(mContext, PREF_KEY);
    mPreference = new DropDownPreference(mContext);
    when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
}
Also used : DropDownPreference(androidx.preference.DropDownPreference) Before(org.junit.Before)

Aggregations

DropDownPreference (androidx.preference.DropDownPreference)20 Before (org.junit.Before)10 Context (android.content.Context)4 Preference (androidx.preference.Preference)4 OnPreferenceChangeListener (androidx.preference.Preference.OnPreferenceChangeListener)4 PreferenceScreen (androidx.preference.PreferenceScreen)2 TwoStatePreference (androidx.preference.TwoStatePreference)2 WifiEntry (com.android.wifitrackerlib.WifiEntry)1