Search in sources :

Example 16 with PreferenceScreen

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

the class InputMethodAndSubtypeEnabler method onCreate.

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    final Configuration config = getResources().getConfiguration();
    mHaveHardKeyboard = (config.keyboard == Configuration.KEYBOARD_QWERTY);
    // Input method id should be available from an Intent when this preference is launched as a
    // single Activity (see InputMethodAndSubtypeEnablerActivity). It should be available
    // from a preference argument when the preference is launched as a part of the other
    // Activity (like a right pane of 2-pane Settings app)
    final String targetImi = getStringExtraFromIntentOrArguments(android.provider.Settings.EXTRA_INPUT_METHOD_ID);
    mInputMethodInfoList = mImm.getInputMethodList();
    mCollator = Collator.getInstance();
    final PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
    final int imiCount = mInputMethodInfoList.size();
    for (int index = 0; index < imiCount; ++index) {
        final InputMethodInfo imi = mInputMethodInfoList.get(index);
        // Add subtype preferences of this IME when it is specified or no IME is specified.
        if (imi.getId().equals(targetImi) || TextUtils.isEmpty(targetImi)) {
            addInputMethodSubtypePreferences(imi, root);
        }
    }
    setPreferenceScreen(root);
}
Also used : Configuration(android.content.res.Configuration) PreferenceScreen(android.support.v7.preference.PreferenceScreen) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 17 with PreferenceScreen

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

the class KeyboardLayoutPickerFragment method createPreferenceHierarchy.

private PreferenceScreen createPreferenceHierarchy() {
    PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
    Context context = getActivity();
    for (KeyboardLayout layout : mKeyboardLayouts) {
        CheckBoxPreference pref = new CheckBoxPreference(getPrefContext());
        pref.setTitle(layout.getLabel());
        pref.setSummary(layout.getCollection());
        root.addPreference(pref);
        mPreferenceMap.put(pref, layout);
    }
    return root;
}
Also used : Context(android.content.Context) PreferenceScreen(android.support.v7.preference.PreferenceScreen) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference) KeyboardLayout(android.hardware.input.KeyboardLayout)

Example 18 with PreferenceScreen

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

the class InputMethodAndSubtypeUtil method updateSubtypesPreferenceChecked.

private static void updateSubtypesPreferenceChecked(final SettingsPreferenceFragment context, final List<InputMethodInfo> inputMethodProperties, final HashMap<String, HashSet<String>> enabledSubtypes) {
    final PreferenceScreen preferenceScreen = context.getPreferenceScreen();
    for (final InputMethodInfo imi : inputMethodProperties) {
        final String id = imi.getId();
        if (!enabledSubtypes.containsKey(id)) {
            // There is no need to enable/disable subtypes of disabled IMEs.
            continue;
        }
        final HashSet<String> enabledSubtypesSet = enabledSubtypes.get(id);
        final int subtypeCount = imi.getSubtypeCount();
        for (int i = 0; i < subtypeCount; ++i) {
            final InputMethodSubtype subtype = imi.getSubtypeAt(i);
            final String hashCode = String.valueOf(subtype.hashCode());
            if (DEBUG) {
                Log.d(TAG, "--- Set checked state: " + "id" + ", " + hashCode + ", " + enabledSubtypesSet.contains(hashCode));
            }
            final TwoStatePreference pref = (TwoStatePreference) preferenceScreen.findPreference(id + hashCode);
            if (pref != null) {
                pref.setChecked(enabledSubtypesSet.contains(hashCode));
            }
        }
    }
}
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 19 with PreferenceScreen

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

the class MiscSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.rr_misc);
    final ContentResolver resolver = getActivity().getContentResolver();
    //SELinux
    mSelinux = (SwitchPreference) findPreference(SELINUX);
    mSelinux.setOnPreferenceChangeListener(this);
    if (CMDProcessor.runShellCommand("getenforce").getStdout().contains("Enforcing")) {
        mSelinux.setChecked(true);
        mSelinux.setSummary(R.string.selinux_enforcing_title);
    } else {
        mSelinux.setChecked(false);
        mSelinux.setSummary(R.string.selinux_permissive_title);
    }
    mConfig = (SwitchPreference) findPreference(RR_OTA);
    mConfig.setChecked((Settings.System.getInt(getContentResolver(), Settings.System.RR_OTA_FAB, 0) == 1));
    mConfig.setOnPreferenceChangeListener(this);
    mFingerprintManager = (FingerprintManager) getActivity().getSystemService(Context.FINGERPRINT_SERVICE);
    mFingerprintVib = (SwitchPreference) findPreference("fingerprint_success_vib");
    if (!mFingerprintManager.isHardwareDetected()) {
        getPreferenceScreen().removePreference(mFingerprintVib);
    }
    PreferenceScreen mIncall = (PreferenceScreen) findPreference(RR_INCALL);
    if (!isVoiceCapable(getActivity())) {
        getPreferenceScreen().removePreference(mIncall);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ContentResolver(android.content.ContentResolver)

Example 20 with PreferenceScreen

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

the class LockscreenColors method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.lockscreen_colors);
    PreferenceScreen prefSet = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    int intColor;
    String hexColor;
    mLockscreenPhoneColorPicker = (ColorPickerPreference) findPreference(LOCKSCREEN_PHONE_ICON_COLOR);
    mLockscreenPhoneColorPicker.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_PHONE_ICON_COLOR, TRANSPARENT);
    hexColor = String.format("#%08x", (0x99FFFFFF & intColor));
    mLockscreenPhoneColorPicker.setSummary(hexColor);
    mLockscreenPhoneColorPicker.setNewPreviewColor(intColor);
    mLockscreenLockColorPicker = (ColorPickerPreference) findPreference(LOCKSCREEN_LOCK_ICON_COLOR);
    mLockscreenLockColorPicker.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_LOCK_ICON_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mLockscreenLockColorPicker.setSummary(hexColor);
    mLockscreenLockColorPicker.setNewPreviewColor(intColor);
    mLockscreenCameraColorPicker = (ColorPickerPreference) findPreference(LOCKSCREEN_CAMERA_ICON_COLOR);
    mLockscreenCameraColorPicker.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_CAMERA_ICON_COLOR, TRANSPARENT);
    hexColor = String.format("#%08x", (0x99FFFFFF & intColor));
    mLockscreenCameraColorPicker.setSummary(hexColor);
    mLockscreenCameraColorPicker.setNewPreviewColor(intColor);
    mShorcutsColor = (ColorPickerPreference) findPreference(SHORTCUTS_COLOR);
    mShorcutsColor.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.LS_SHORTCUT_ICON_COLOR, TRANSPARENT);
    hexColor = String.format("#%08x", (0xFFFFFFFF & intColor));
    mShorcutsColor.setSummary(hexColor);
    mShorcutsColor.setNewPreviewColor(intColor);
    mLockscreenIndicationTextColorPicker = (ColorPickerPreference) findPreference(LOCKSCREEN_INDICATION_TEXT_COLOR);
    mLockscreenIndicationTextColorPicker.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_INDICATION_TEXT_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mLockscreenIndicationTextColorPicker.setSummary(hexColor);
    mLockscreenIndicationTextColorPicker.setNewPreviewColor(intColor);
    mLockscreenClockColorPicker = (ColorPickerPreference) findPreference(LOCKSCREEN_CLOCK_COLOR);
    mLockscreenClockColorPicker.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_CLOCK_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mLockscreenClockColorPicker.setSummary(hexColor);
    mLockscreenClockColorPicker.setNewPreviewColor(intColor);
    mLockscreenClockDateColorPicker = (ColorPickerPreference) findPreference(LOCKSCREEN_CLOCK_DATE_COLOR);
    mLockscreenClockDateColorPicker.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_CLOCK_DATE_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mLockscreenClockDateColorPicker.setSummary(hexColor);
    mLockscreenClockDateColorPicker.setNewPreviewColor(intColor);
    mLockscreenOwnerInfoColorPicker = (ColorPickerPreference) findPreference(LOCKSCREEN_OWNER_INFO_COLOR);
    mLockscreenOwnerInfoColorPicker.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(resolver, Settings.System.LOCKSCREEN_OWNER_INFO_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mLockscreenOwnerInfoColorPicker.setSummary(hexColor);
    mLockscreenOwnerInfoColorPicker.setNewPreviewColor(intColor);
    mLockscreenAlarmColorPicker = (ColorPickerPreference) findPreference(LOCKSCREEN_ALARM_COLOR);
    mLockscreenAlarmColorPicker.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(resolver, Settings.System.LOCKSCREEN_ALARM_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mLockscreenAlarmColorPicker.setSummary(hexColor);
    mLockscreenAlarmColorPicker.setNewPreviewColor(intColor);
    mTempColor = (ColorPickerPreference) findPreference(LOCKSCREEN_TEMP_COLOR);
    mTempColor.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(resolver, Settings.System.LOCK_SCREEN_WEATHER_TEMP_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mTempColor.setSummary(hexColor);
    mTempColor.setNewPreviewColor(intColor);
    mConditionColor = (ColorPickerPreference) findPreference(LOCKSCREEN_CONDITION_COLOR);
    mConditionColor.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(resolver, Settings.System.LOCK_SCREEN_WEATHER_CON_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mConditionColor.setSummary(hexColor);
    mConditionColor.setNewPreviewColor(intColor);
    mCityColor = (ColorPickerPreference) findPreference(LOCKSCREEN_CITY_COLOR);
    mCityColor.setOnPreferenceChangeListener(this);
    intColor = Settings.System.getInt(resolver, Settings.System.LOCK_SCREEN_WEATHER_CITY_COLOR, DEFAULT);
    hexColor = String.format("#%08x", (0xffffffff & intColor));
    mCityColor.setSummary(hexColor);
    mCityColor.setNewPreviewColor(intColor);
    mIconColor = (ColorPickerPreference) findPreference(PREF_ICON_COLOR);
    intColor = Settings.System.getInt(resolver, Settings.System.LOCK_SCREEN_WEATHER_ICON_COLOR, -2);
    if (intColor == -2) {
        intColor = 0xffffffff;
        mIconColor.setSummary(getResources().getString(R.string.default_string));
    } else {
        hexColor = String.format("#%08x", (0xffffffff & intColor));
        mIconColor.setSummary(hexColor);
    }
    mIconColor.setNewPreviewColor(intColor);
    mIconColor.setOnPreferenceChangeListener(this);
    setHasOptionsMenu(true);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ContentResolver(android.content.ContentResolver)

Aggregations

PreferenceScreen (android.support.v7.preference.PreferenceScreen)640 Preference (android.support.v7.preference.Preference)458 Context (android.content.Context)127 Test (org.junit.Test)126 SwitchPreference (android.support.v14.preference.SwitchPreference)96 PreferenceCategory (android.support.v7.preference.PreferenceCategory)82 Intent (android.content.Intent)63 PreferenceGroup (android.support.v7.preference.PreferenceGroup)58 VisibleForTesting (android.support.annotation.VisibleForTesting)55 PreferenceManager (android.support.v7.preference.PreferenceManager)54 ContentResolver (android.content.ContentResolver)53 PackageManager (android.content.pm.PackageManager)51 StorageItemPreference (com.android.settings.deviceinfo.StorageItemPreference)48 Bundle (android.os.Bundle)46 ArrayList (java.util.ArrayList)46 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)44 ListPreference (android.support.v7.preference.ListPreference)41 ComponentName (android.content.ComponentName)31 Resources (android.content.res.Resources)30 VolumeInfo (android.os.storage.VolumeInfo)30