Search in sources :

Example 16 with DropDownPreference

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

the class DockAudioMediaPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    when(mSetting.getActivity()).thenReturn(mActivity);
    when(mActivity.getContentResolver()).thenReturn(mContentResolver);
    when(mActivity.getResources().getBoolean(com.android.settings.R.bool.has_dock_settings)).thenReturn(true);
    when(mActivity.getResources().getString(anyInt())).thenReturn("test string");
    mPreference = new DropDownPreference(RuntimeEnvironment.application);
    mController = new DockAudioMediaPreferenceController(mContext, mSetting, null);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    doReturn(mScreen).when(mSetting).getPreferenceScreen();
}
Also used : DropDownPreference(androidx.preference.DropDownPreference) Before(org.junit.Before)

Example 17 with DropDownPreference

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

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)

Example 18 with DropDownPreference

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

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 19 with DropDownPreference

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

the class ZenModeEventRuleSettings method onCreateInternal.

@Override
protected void onCreateInternal() {
    mCreate = true;
    final PreferenceScreen root = getPreferenceScreen();
    mCalendar = (DropDownPreference) root.findPreference(KEY_CALENDAR);
    mCalendar.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final String calendarKey = (String) newValue;
            if (calendarKey.equals(key(mEvent)))
                return false;
            String[] key = calendarKey.split(":", 3);
            mEvent.userId = Integer.parseInt(key[0]);
            mEvent.calendarId = key[1].equals("") ? null : Long.parseLong(key[1]);
            mEvent.calName = key[2].equals("") ? null : key[2];
            updateRule(ZenModeConfig.toEventConditionId(mEvent));
            return true;
        }
    });
    mReply = (DropDownPreference) root.findPreference(KEY_REPLY);
    mReply.setEntries(new CharSequence[] { getString(R.string.zen_mode_event_rule_reply_any_except_no), getString(R.string.zen_mode_event_rule_reply_yes_or_maybe), getString(R.string.zen_mode_event_rule_reply_yes) });
    mReply.setEntryValues(new CharSequence[] { Integer.toString(EventInfo.REPLY_ANY_EXCEPT_NO), Integer.toString(EventInfo.REPLY_YES_OR_MAYBE), Integer.toString(EventInfo.REPLY_YES) });
    mReply.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final int reply = Integer.parseInt((String) newValue);
            if (reply == mEvent.reply)
                return false;
            mEvent.reply = reply;
            updateRule(ZenModeConfig.toEventConditionId(mEvent));
            return true;
        }
    });
    reloadCalendar();
    updateControlsInternal();
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) Preference(androidx.preference.Preference) DropDownPreference(androidx.preference.DropDownPreference) OnPreferenceChangeListener(androidx.preference.Preference.OnPreferenceChangeListener)

Example 20 with DropDownPreference

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

the class DockAudioMediaPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    when(mSetting.getActivity()).thenReturn(mActivity);
    when(mActivity.getContentResolver()).thenReturn(mContentResolver);
    when(mActivity.getResources().getBoolean(com.android.settings.R.bool.has_dock_settings)).thenReturn(true);
    when(mActivity.getResources().getString(anyInt())).thenReturn("test string");
    mPreference = new DropDownPreference(RuntimeEnvironment.application);
    mController = new DockAudioMediaPreferenceController(mContext, mSetting, null);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    doReturn(mScreen).when(mSetting).getPreferenceScreen();
}
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