use of com.android.settingslib.widget.CandidateInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationAssistantPickerTest method candidateListHasCorrectCandidate.
@Test
public void candidateListHasCorrectCandidate() {
List<ServiceInfo> list = new ArrayList<>();
ServiceInfo serviceInfo = mock(ServiceInfo.class, RETURNS_SMART_NULLS);
serviceInfo.packageName = TEST_PKG;
serviceInfo.name = TEST_SRV;
list.add(serviceInfo);
mFragment.onServicesReloaded(list);
List<? extends CandidateInfo> candidates = mFragment.getCandidates();
boolean found = false;
for (CandidateInfo c : candidates) {
if (TEST_CMP.equals(c.getKey())) {
found = true;
break;
}
}
if (!found)
fail();
}
use of com.android.settingslib.widget.CandidateInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RadioButtonPickerFragment method updateCandidates.
@VisibleForTesting
public void updateCandidates() {
mCandidates.clear();
final List<? extends CandidateInfo> candidateList = getCandidates();
if (candidateList != null) {
for (CandidateInfo info : candidateList) {
mCandidates.put(info.getKey(), info);
}
}
final String defaultKey = getDefaultKey();
final String systemDefaultKey = getSystemDefaultKey();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
if (mIllustrationId != 0) {
addIllustration(screen);
}
if (!mAppendStaticPreferences) {
addStaticPreferences(screen);
}
final int customLayoutResId = getRadioButtonPreferenceCustomLayoutResId();
if (shouldShowItemNone()) {
final RadioButtonPreference nonePref = new RadioButtonPreference(getPrefContext());
if (customLayoutResId > 0) {
nonePref.setLayoutResource(customLayoutResId);
}
nonePref.setIcon(R.drawable.ic_remove_circle);
nonePref.setTitle(R.string.app_list_preference_none);
nonePref.setChecked(TextUtils.isEmpty(defaultKey));
nonePref.setOnClickListener(this);
screen.addPreference(nonePref);
}
if (candidateList != null) {
for (CandidateInfo info : candidateList) {
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
if (customLayoutResId > 0) {
pref.setLayoutResource(customLayoutResId);
}
bindPreference(pref, info.getKey(), info, defaultKey);
bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey);
screen.addPreference(pref);
}
}
mayCheckOnlyRadioButton();
if (mAppendStaticPreferences) {
addStaticPreferences(screen);
}
}
use of com.android.settingslib.widget.CandidateInfo in project android_packages_apps_Settings by omnirom.
the class UsbDefaultFragment method getCandidates.
@Override
protected List<? extends CandidateInfo> getCandidates() {
List<CandidateInfo> ret = Lists.newArrayList();
for (final long option : UsbDetailsFunctionsController.FUNCTIONS_MAP.keySet()) {
final String title = getContext().getString(UsbDetailsFunctionsController.FUNCTIONS_MAP.get(option));
final String key = UsbBackend.usbFunctionsToString(option);
// Only show supported functions
if (mUsbBackend.areFunctionsSupported(option)) {
ret.add(new CandidateInfo(true) {
/* enabled */
@Override
public CharSequence loadLabel() {
return title;
}
@Override
public Drawable loadIcon() {
return null;
}
@Override
public String getKey() {
return key;
}
});
}
}
return ret;
}
use of com.android.settingslib.widget.CandidateInfo in project android_packages_apps_Settings by omnirom.
the class SystemNavigationGestureSettings method updateCandidates.
@Override
public void updateCandidates() {
final String defaultKey = getDefaultKey();
final String systemDefaultKey = getSystemDefaultKey();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
screen.addPreference(mVideoPreference);
final List<? extends CandidateInfo> candidateList = getCandidates();
if (candidateList == null) {
return;
}
for (CandidateInfo info : candidateList) {
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
bindPreference(pref, info.getKey(), info, defaultKey);
bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey);
screen.addPreference(pref);
}
mayCheckOnlyRadioButton();
}
use of com.android.settingslib.widget.CandidateInfo in project android_packages_apps_Settings by omnirom.
the class NotificationAssistantPicker method onServicesReloaded.
@Override
public void onServicesReloaded(List<ServiceInfo> services) {
List<CandidateInfo> list = new ArrayList<>();
services.sort(new PackageItemInfo.DisplayNameComparator(mPm));
for (ServiceInfo service : services) {
if (mContext.getPackageManager().checkPermission(android.Manifest.permission.REQUEST_NOTIFICATION_ASSISTANT_SERVICE, service.packageName) == PackageManager.PERMISSION_GRANTED) {
final ComponentName cn = new ComponentName(service.packageName, service.name);
list.add(new DefaultAppInfo(mContext, mPm, mUserId, cn));
}
}
list.add(new CandidateNone(mContext));
mCandidateInfos = list;
}
Aggregations