Search in sources :

Example 86 with PreferenceScreen

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

the class KeyboardLayoutPickerFragment2 method createPreferenceHierarchy.

private PreferenceScreen createPreferenceHierarchy() {
    PreferenceScreen root = getPreferenceManager().createPreferenceScreen(getActivity());
    for (KeyboardLayout layout : mKeyboardLayouts) {
        Preference pref = new Preference(getPrefContext());
        pref.setTitle(layout.getLabel());
        pref.setSummary(layout.getCollection());
        root.addPreference(pref);
        mPreferenceMap.put(pref, layout);
    }
    root.setTitle(KeyboardInfoPreference.getDisplayName(getContext(), mImi, mSubtype));
    return root;
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) Preference(android.support.v7.preference.Preference) KeyboardInfoPreference(com.android.settings.inputmethod.PhysicalKeyboardFragment.KeyboardInfoPreference) KeyboardLayout(android.hardware.input.KeyboardLayout)

Example 87 with PreferenceScreen

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

the class PhysicalKeyboardFragment method onLoadFinishedInternal.

public void onLoadFinishedInternal(final int loaderId, @NonNull final List<Keyboards> keyboardsList) {
    if (!mLoaderIDs.remove(loaderId)) {
        // Already destroyed loader.  Ignore.
        return;
    }
    Collections.sort(keyboardsList);
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    preferenceScreen.removeAll();
    for (Keyboards keyboards : keyboardsList) {
        final PreferenceCategory category = new PreferenceCategory(getPrefContext(), null);
        category.setTitle(keyboards.mDeviceInfo.mDeviceName);
        category.setOrder(0);
        preferenceScreen.addPreference(category);
        for (Keyboards.KeyboardInfo info : keyboards.mKeyboardInfoList) {
            mTempKeyboardInfoList.clear();
            final InputMethodInfo imi = info.mImi;
            final InputMethodSubtype imSubtype = info.mImSubtype;
            if (imi != null) {
                KeyboardInfoPreference pref = new KeyboardInfoPreference(getPrefContext(), info);
                pref.setOnPreferenceClickListener(preference -> {
                    showKeyboardLayoutScreen(keyboards.mDeviceInfo.mDeviceIdentifier, imi, imSubtype);
                    return true;
                });
                mTempKeyboardInfoList.add(pref);
                Collections.sort(mTempKeyboardInfoList);
            }
            for (KeyboardInfoPreference pref : mTempKeyboardInfoList) {
                category.addPreference(pref);
            }
        }
    }
    mTempKeyboardInfoList.clear();
    mKeyboardAssistanceCategory.setOrder(1);
    preferenceScreen.addPreference(mKeyboardAssistanceCategory);
    updateShowVirtualKeyboardSwitch();
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) PreferenceScreen(android.support.v7.preference.PreferenceScreen) PreferenceCategory(android.support.v7.preference.PreferenceCategory) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 88 with PreferenceScreen

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

the class BluetoothSettings method updateContent.

private void updateContent(int bluetoothState) {
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    int messageId = 0;
    switch(bluetoothState) {
        case BluetoothAdapter.STATE_ON:
            mDevicePreferenceMap.clear();
            if (isUiRestricted()) {
                messageId = R.string.bluetooth_empty_list_user_restricted;
                break;
            }
            getPreferenceScreen().removeAll();
            getPreferenceScreen().addPreference(mPairedDevicesCategory);
            getPreferenceScreen().addPreference(mAvailableDevicesCategory);
            getPreferenceScreen().addPreference(mMyDevicePreference);
            // Paired devices category
            addDeviceCategory(mPairedDevicesCategory, R.string.bluetooth_preference_paired_devices, BluetoothDeviceFilter.BONDED_DEVICE_FILTER, true);
            int numberOfPairedDevices = mPairedDevicesCategory.getPreferenceCount();
            if (isUiRestricted() || numberOfPairedDevices <= 0) {
                if (preferenceScreen.findPreference(KEY_PAIRED_DEVICES) != null) {
                    preferenceScreen.removePreference(mPairedDevicesCategory);
                }
            } else {
                if (preferenceScreen.findPreference(KEY_PAIRED_DEVICES) == null) {
                    preferenceScreen.addPreference(mPairedDevicesCategory);
                }
            }
            // Available devices category
            addDeviceCategory(mAvailableDevicesCategory, R.string.bluetooth_preference_found_devices, BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER, mInitialScanStarted);
            if (!mInitialScanStarted) {
                startScanning();
            }
            final Resources res = getResources();
            final Locale locale = res.getConfiguration().getLocales().get(0);
            final BidiFormatter bidiFormatter = BidiFormatter.getInstance(locale);
            mMyDevicePreference.setSummary(res.getString(R.string.bluetooth_is_visible_message, bidiFormatter.unicodeWrap(mLocalAdapter.getName())));
            getActivity().invalidateOptionsMenu();
            // threads to execute.
            if (mInitiateDiscoverable) {
                // Make the device visible to other devices.
                mLocalAdapter.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
                mInitiateDiscoverable = false;
            }
            // not break
            return;
        case BluetoothAdapter.STATE_TURNING_OFF:
            messageId = R.string.bluetooth_turning_off;
            break;
        case BluetoothAdapter.STATE_OFF:
            setOffMessage();
            if (isUiRestricted()) {
                messageId = R.string.bluetooth_empty_list_user_restricted;
            }
            break;
        case BluetoothAdapter.STATE_TURNING_ON:
            messageId = R.string.bluetooth_turning_on;
            mInitialScanStarted = false;
            break;
    }
    setDeviceListGroup(preferenceScreen);
    removeAllDevices();
    if (messageId != 0) {
        getEmptyTextView().setText(messageId);
    }
    if (!isUiRestricted()) {
        getActivity().invalidateOptionsMenu();
    }
}
Also used : Locale(java.util.Locale) PreferenceScreen(android.support.v7.preference.PreferenceScreen) BidiFormatter(android.text.BidiFormatter) Resources(android.content.res.Resources)

Example 89 with PreferenceScreen

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

the class ToggleBackupSettingFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
    PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(getActivity());
    setPreferenceScreen(preferenceScreen);
    mSummaryPreference = new Preference(getPrefContext()) {

        @Override
        public void onBindViewHolder(PreferenceViewHolder view) {
            super.onBindViewHolder(view);
            final TextView summaryView = (TextView) view.findViewById(android.R.id.summary);
            summaryView.setText(getSummary());
        }
    };
    mSummaryPreference.setPersistent(false);
    mSummaryPreference.setLayoutResource(R.layout.text_description_preference);
    preferenceScreen.addPreference(mSummaryPreference);
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) Preference(android.support.v7.preference.Preference) TextView(android.widget.TextView) PreferenceViewHolder(android.support.v7.preference.PreferenceViewHolder)

Example 90 with PreferenceScreen

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

the class LocationSettings method addLocationServices.

/**
     * Add the settings injected by external apps into the "App Settings" category. Hides the
     * category if there are no injected settings.
     *
     * Reloads the settings whenever receives
     * {@link SettingInjectorService#ACTION_INJECTED_SETTING_CHANGED}.
     */
private void addLocationServices(Context context, PreferenceScreen root, boolean lockdownOnLocationAccess) {
    PreferenceCategory categoryLocationServices = (PreferenceCategory) root.findPreference(KEY_LOCATION_SERVICES);
    injector = new SettingsInjector(context);
    // If location access is locked down by device policy then we only show injected settings
    // for the primary profile.
    List<Preference> locationServices = injector.getInjectedSettings(lockdownOnLocationAccess ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
    mReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "Received settings change intent: " + intent);
            }
            injector.reloadStatusMessages();
        }
    };
    IntentFilter filter = new IntentFilter();
    filter.addAction(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
    context.registerReceiver(mReceiver, filter);
    if (locationServices.size() > 0) {
        addPreferencesSorted(locationServices, categoryLocationServices);
    } else {
        // If there's no item to display, remove the whole category.
        root.removePreference(categoryLocationServices);
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) PreferenceCategory(android.support.v7.preference.PreferenceCategory) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference) DimmableIconPreference(com.android.settings.DimmableIconPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Aggregations

PreferenceScreen (android.support.v7.preference.PreferenceScreen)115 Preference (android.support.v7.preference.Preference)42 ContentResolver (android.content.ContentResolver)35 SwitchPreference (android.support.v14.preference.SwitchPreference)21 Context (android.content.Context)19 Resources (android.content.res.Resources)16 PreferenceCategory (android.support.v7.preference.PreferenceCategory)14 Intent (android.content.Intent)12 ArrayList (java.util.ArrayList)9 ListPreference (android.support.v7.preference.ListPreference)8 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 PreferenceGroup (android.support.v7.preference.PreferenceGroup)7 PackageManager (android.content.pm.PackageManager)6 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)6 PreferenceManager (android.support.v7.preference.PreferenceManager)6 Activity (android.app.Activity)5 SharedPreferences (android.content.SharedPreferences)4 Bundle (android.os.Bundle)4 InputMethodInfo (android.view.inputmethod.InputMethodInfo)4 ComponentName (android.content.ComponentName)3