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;
}
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();
}
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();
}
}
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);
}
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);
}
}
Aggregations