Search in sources :

Example 61 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SoundSettings method initIncreasingRing.

// === Increasing ringtone ===
private void initIncreasingRing() {
    PreferenceScreen root = getPreferenceScreen();
    mIncreasingRing = (TwoStatePreference) root.findPreference(CMSettings.System.INCREASING_RING);
    mIncreasingRingVolume = (IncreasingRingVolumePreference) root.findPreference(KEY_INCREASING_RING_VOLUME);
    if (mIncreasingRing == null || mIncreasingRingVolume == null || !mVoiceCapable) {
        if (mIncreasingRing != null) {
            root.removePreference(mIncreasingRing);
            mIncreasingRing = null;
        }
        if (mIncreasingRingVolume != null) {
            root.removePreference(mIncreasingRingVolume);
            mIncreasingRingVolume = null;
        }
    } else {
        mIncreasingRingVolume.setCallback(mIncreasingRingVolumeCallback);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen)

Example 62 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodAndSubtypeEnabler method updateImplicitlyEnabledSubtypes.

private void updateImplicitlyEnabledSubtypes(final String targetImiId, final boolean check) {
    // When targetImiId is null, apply to all subtypes of all IMEs
    for (final InputMethodInfo imi : mInputMethodInfoList) {
        final String imiId = imi.getId();
        final TwoStatePreference autoSelectionPref = mAutoSelectionPrefsMap.get(imiId);
        // "subtype auto selection".
        if (autoSelectionPref == null || !autoSelectionPref.isChecked()) {
            continue;
        }
        if (imiId.equals(targetImiId) || targetImiId == null) {
            updateImplicitlyEnabledSubtypesOf(imi, check);
        }
    }
}
Also used : TwoStatePreference(android.support.v7.preference.TwoStatePreference) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 63 with TwoStatePreference

use of android.support.v7.preference.TwoStatePreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodAndSubtypeUtil method setSubtypesPreferenceEnabled.

static void setSubtypesPreferenceEnabled(final SettingsPreferenceFragment context, final List<InputMethodInfo> inputMethodProperties, final String id, final boolean enabled) {
    final PreferenceScreen preferenceScreen = context.getPreferenceScreen();
    for (final InputMethodInfo imi : inputMethodProperties) {
        if (id.equals(imi.getId())) {
            final int subtypeCount = imi.getSubtypeCount();
            for (int i = 0; i < subtypeCount; ++i) {
                final InputMethodSubtype subtype = imi.getSubtypeAt(i);
                final TwoStatePreference pref = (TwoStatePreference) preferenceScreen.findPreference(id + subtype.hashCode());
                if (pref != null) {
                    pref.setEnabled(enabled);
                }
            }
        }
    }
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) TwoStatePreference(android.support.v7.preference.TwoStatePreference) PreferenceScreen(android.support.v7.preference.PreferenceScreen) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 64 with TwoStatePreference

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

the class AssistFlashScreenPreferenceController method updatePreference.

private void updatePreference() {
    if (mPreference == null || !(mPreference instanceof TwoStatePreference)) {
        return;
    }
    if (isAvailable()) {
        if (mScreen.findPreference(getPreferenceKey()) == null) {
            // add it if it's not on scree
            mScreen.addPreference(mPreference);
        }
    } else {
        mScreen.removePreference(mPreference);
    }
    ComponentName assistant = getCurrentAssist();
    boolean isContextChecked = AssistContextPreferenceController.isChecked(mContext);
    mPreference.setEnabled(isContextChecked && isPreInstalledAssistant(assistant));
    ((TwoStatePreference) mPreference).setChecked(willShowFlash(assistant));
}
Also used : TwoStatePreference(android.support.v7.preference.TwoStatePreference) ComponentName(android.content.ComponentName)

Example 65 with TwoStatePreference

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

the class GesturePreferenceControllerTest method updateState_preferenceSetCheckedWhenSettingIsOn.

@Test
public void updateState_preferenceSetCheckedWhenSettingIsOn() {
    // Mock a TwoStatePreference
    final TwoStatePreference preference = mock(TwoStatePreference.class);
    // Set the setting to be enabled.
    mController.mIsPrefEnabled = true;
    // Run through updateState
    mController.updateState(preference);
    // Verify pref is checked (as setting is enabled).
    verify(preference).setChecked(true);
}
Also used : 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