Search in sources :

Example 71 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by omnirom.

the class GesturePreferenceControllerTest method updateState_preferenceSetUncheckedWhenSettingIsOff.

@Test
public void updateState_preferenceSetUncheckedWhenSettingIsOff() {
    // Mock a TwoStatePreference
    final TwoStatePreference preference = mock(TwoStatePreference.class);
    // Set the setting to be disabled.
    mController.mIsPrefEnabled = false;
    // Run through updateState
    mController.updateState(preference);
    // Verify pref is unchecked (as setting is disabled).
    verify(preference).setChecked(false);
}
Also used : TwoStatePreference(android.support.v7.preference.TwoStatePreference) Test(org.junit.Test)

Example 72 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by omnirom.

the class BadgingNotificationPreferenceControllerTest method updateState_preferenceSetCheckedWhenSettingIsOn.

@Test
public void updateState_preferenceSetCheckedWhenSettingIsOn() {
    final TwoStatePreference preference = mock(TwoStatePreference.class);
    final Context context = ShadowApplication.getInstance().getApplicationContext();
    Settings.Secure.putInt(context.getContentResolver(), NOTIFICATION_BADGING, 1);
    mController = new BadgingNotificationPreferenceController(context);
    mController.updateState(preference);
    verify(preference).setChecked(true);
}
Also used : Context(android.content.Context) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Test(org.junit.Test)

Example 73 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by omnirom.

the class WorkSoundPreferenceController method updateWorkPreferences.

private void updateWorkPreferences() {
    if (mWorkPreferenceCategory == null) {
        return;
    }
    final boolean isAvailable = isAvailable();
    mWorkPreferenceCategory.setVisible(isAvailable);
    if (!isAvailable) {
        return;
    }
    if (mWorkUsePersonalSounds == null) {
        mWorkUsePersonalSounds = (TwoStatePreference) mWorkPreferenceCategory.findPreference(KEY_WORK_USE_PERSONAL_SOUNDS);
        mWorkUsePersonalSounds.setOnPreferenceChangeListener((Preference p, Object value) -> {
            if ((boolean) value) {
                UnifyWorkDialogFragment.show(mParent);
                return false;
            } else {
                disableWorkSync();
                return true;
            }
        });
    }
    if (mWorkPhoneRingtonePreference == null) {
        mWorkPhoneRingtonePreference = initWorkPreference(mWorkPreferenceCategory, KEY_WORK_PHONE_RINGTONE);
    }
    if (mWorkNotificationRingtonePreference == null) {
        mWorkNotificationRingtonePreference = initWorkPreference(mWorkPreferenceCategory, KEY_WORK_NOTIFICATION_RINGTONE);
    }
    if (mWorkAlarmRingtonePreference == null) {
        mWorkAlarmRingtonePreference = initWorkPreference(mWorkPreferenceCategory, KEY_WORK_ALARM_RINGTONE);
    }
    if (!mVoiceCapable) {
        mWorkPhoneRingtonePreference.setVisible(false);
        mWorkPhoneRingtonePreference = null;
    }
    final Context managedProfileContext = getManagedProfileContext();
    if (Settings.Secure.getIntForUser(managedProfileContext.getContentResolver(), Settings.Secure.SYNC_PARENT_SOUNDS, 0, mManagedProfileId) == 1) {
        enableWorkSyncSettings();
    } else {
        disableWorkSyncSettings();
    }
}
Also used : Context(android.content.Context) TwoStatePreference(android.support.v7.preference.TwoStatePreference) DefaultRingtonePreference(com.android.settings.DefaultRingtonePreference) Preference(android.support.v7.preference.Preference)

Example 74 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by DirtyUnicorns.

the class WorkSoundPreferenceController method updateWorkPreferences.

private void updateWorkPreferences() {
    if (mWorkPreferenceCategory == null) {
        return;
    }
    final boolean isAvailable = isAvailable();
    mWorkPreferenceCategory.setVisible(isAvailable);
    if (!isAvailable) {
        return;
    }
    if (mWorkUsePersonalSounds == null) {
        mWorkUsePersonalSounds = (TwoStatePreference) mWorkPreferenceCategory.findPreference(KEY_WORK_USE_PERSONAL_SOUNDS);
        mWorkUsePersonalSounds.setOnPreferenceChangeListener((Preference p, Object value) -> {
            if ((boolean) value) {
                UnifyWorkDialogFragment.show(mParent);
                return false;
            } else {
                disableWorkSync();
                return true;
            }
        });
    }
    if (mWorkPhoneRingtonePreference == null) {
        mWorkPhoneRingtonePreference = initWorkPreference(mWorkPreferenceCategory, KEY_WORK_PHONE_RINGTONE);
    }
    if (mWorkNotificationRingtonePreference == null) {
        mWorkNotificationRingtonePreference = initWorkPreference(mWorkPreferenceCategory, KEY_WORK_NOTIFICATION_RINGTONE);
    }
    if (mWorkAlarmRingtonePreference == null) {
        mWorkAlarmRingtonePreference = initWorkPreference(mWorkPreferenceCategory, KEY_WORK_ALARM_RINGTONE);
    }
    if (!mVoiceCapable) {
        mWorkPhoneRingtonePreference.setVisible(false);
        mWorkPhoneRingtonePreference = null;
    }
    final Context managedProfileContext = getManagedProfileContext();
    if (Settings.Secure.getIntForUser(managedProfileContext.getContentResolver(), Settings.Secure.SYNC_PARENT_SOUNDS, 0, mManagedProfileId) == 1) {
        enableWorkSyncSettings();
    } else {
        disableWorkSyncSettings();
    }
}
Also used : Context(android.content.Context) TwoStatePreference(android.support.v7.preference.TwoStatePreference) DefaultRingtonePreference(com.android.settings.DefaultRingtonePreference) Preference(android.support.v7.preference.Preference)

Example 75 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by DirtyUnicorns.

the class VibrateWhenRingPreferenceControllerTest method updateState_settingIsOff_preferenceShouldNotBeChecked.

@Test
public void updateState_settingIsOff_preferenceShouldNotBeChecked() {
    final TwoStatePreference preference = mock(TwoStatePreference.class);
    final Context context = ShadowApplication.getInstance().getApplicationContext();
    Settings.System.putInt(context.getContentResolver(), VIBRATE_WHEN_RINGING, 0);
    mController = new VibrateWhenRingPreferenceController(context);
    mController.updateState(preference);
    verify(preference).setChecked(false);
}
Also used : Context(android.content.Context) TwoStatePreference(android.support.v7.preference.TwoStatePreference) Test(org.junit.Test)

Aggregations

TwoStatePreference (android.support.v7.preference.TwoStatePreference)94 Context (android.content.Context)50 Test (org.junit.Test)48 Preference (android.support.v7.preference.Preference)26 ComponentName (android.content.ComponentName)7 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 DropDownPreference (android.support.v7.preference.DropDownPreference)6 DefaultRingtonePreference (com.android.settings.DefaultRingtonePreference)6 Calendar (java.util.Calendar)6 Date (java.util.Date)6 InputMethodInfo (android.view.inputmethod.InputMethodInfo)5 ConfigKey (cx.ring.model.ConfigKey)5 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)4 EditTextPreference (android.support.v7.preference.EditTextPreference)3 PreferenceScreen (android.support.v7.preference.PreferenceScreen)3 File (java.io.File)3 PackageManager (android.content.pm.PackageManager)2 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)2 ListPreference (android.support.v7.preference.ListPreference)2 SwitchPreferenceCompat (android.support.v7.preference.SwitchPreferenceCompat)2