use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class CreateShortcutPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
if (!(preference instanceof PreferenceGroup)) {
return;
}
final PreferenceGroup group = (PreferenceGroup) preference;
group.removeAll();
final List<ResolveInfo> shortcuts = queryShortcuts();
final Context uiContext = preference.getContext();
if (shortcuts.isEmpty()) {
return;
}
PreferenceCategory category = new PreferenceCategory(uiContext);
group.addPreference(category);
int bucket = 0;
for (ResolveInfo info : shortcuts) {
// Priority is not consecutive (aka, jumped), add a divider between prefs.
final int currentBucket = info.priority / 10;
boolean needDivider = currentBucket != bucket;
bucket = currentBucket;
if (needDivider) {
// add a new Category
category = new PreferenceCategory(uiContext);
group.addPreference(category);
}
final Preference pref = new Preference(uiContext);
pref.setTitle(info.loadLabel(mPackageManager));
pref.setKey(info.activityInfo.getComponentName().flattenToString());
pref.setOnPreferenceClickListener(clickTarget -> {
if (mHost == null) {
return false;
}
final Intent shortcutIntent = createResultIntent(buildShortcutIntent(info), info, clickTarget.getTitle());
mHost.setResult(Activity.RESULT_OK, shortcutIntent);
logCreateShortcut(info);
mHost.finish();
return true;
});
category.addPreference(pref);
}
}
use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PrivateVolumeSettings method addCategory.
private PreferenceCategory addCategory(PreferenceGroup group, CharSequence title) {
PreferenceCategory category;
if (mHeaderPoolIndex < mHeaderPreferencePool.size()) {
category = mHeaderPreferencePool.get(mHeaderPoolIndex);
} else {
category = new PreferenceCategory(getPrefContext());
mHeaderPreferencePool.add(category);
}
category.setTitle(title);
category.removeAll();
addPreference(group, category);
++mHeaderPoolIndex;
return category;
}
use of androidx.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConfigureNotificationSettings method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
final PreferenceScreen screen = getPreferenceScreen();
final Bundle arguments = getArguments();
if (screen == null) {
return;
}
if (arguments != null) {
final String highlightKey = arguments.getString(EXTRA_FRAGMENT_ARG_KEY);
if (!TextUtils.isEmpty(highlightKey)) {
final PreferenceCategory advancedCategory = screen.findPreference(KEY_ADVANCED_CATEGORY);
// Has highlight row - expand everything
advancedCategory.setInitialExpandedChildrenCount(Integer.MAX_VALUE);
scrollToPreference(advancedCategory);
}
}
}
use of androidx.preference.PreferenceCategory in project Signal-Android by signalapp.
the class CorrectedPreferenceFragment method onCreateAdapter.
@Override
@SuppressLint("RestrictedApi")
protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
return new PreferenceGroupAdapter(preferenceScreen) {
@Override
public void onBindViewHolder(PreferenceViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
Preference preference = getItem(position);
if (preference instanceof PreferenceCategory) {
setZeroPaddingToLayoutChildren(holder.itemView);
} else {
View iconFrame = holder.itemView.findViewById(R.id.icon_frame);
if (iconFrame != null) {
iconFrame.setVisibility(preference.getIcon() == null ? View.GONE : View.VISIBLE);
}
}
}
};
}
use of androidx.preference.PreferenceCategory in project android_packages_apps_Settings by omnirom.
the class PhysicalKeyboardFragment method updateHardKeyboards.
private void updateHardKeyboards(@NonNull List<HardKeyboardDeviceInfo> newHardKeyboards) {
if (Objects.equals(mLastHardKeyboards, newHardKeyboards)) {
// Nothing has changed. Ignore.
return;
}
// TODO(yukawa): Maybe we should follow the style used in ConnectedDeviceDashboardFragment.
mLastHardKeyboards.clear();
mLastHardKeyboards.addAll(newHardKeyboards);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.removeAll();
final PreferenceCategory category = new PreferenceCategory(getPrefContext());
category.setTitle(R.string.builtin_keyboard_settings_title);
category.setOrder(0);
preferenceScreen.addPreference(category);
for (HardKeyboardDeviceInfo hardKeyboardDeviceInfo : newHardKeyboards) {
// TODO(yukawa): Consider using com.android.settings.widget.GearPreference
final Preference pref = new Preference(getPrefContext());
pref.setTitle(hardKeyboardDeviceInfo.mDeviceName);
pref.setSummary(hardKeyboardDeviceInfo.mLayoutLabel);
pref.setOnPreferenceClickListener(preference -> {
showKeyboardLayoutDialog(hardKeyboardDeviceInfo.mDeviceIdentifier);
return true;
});
category.addPreference(pref);
}
mKeyboardAssistanceCategory.setOrder(1);
preferenceScreen.addPreference(mKeyboardAssistanceCategory);
updateShowVirtualKeyboardSwitch();
}
Aggregations