use of com.android.settingslib.widget.CandidateInfo in project android_packages_apps_Settings by omnirom.
the class ScreenTimeoutSettings method updateCandidates.
@Override
public void updateCandidates() {
final String defaultKey = getDefaultKey();
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
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);
screen.addPreference(pref);
}
final long selectedTimeout = Long.parseLong(defaultKey);
final long maxTimeout = getMaxScreenTimeout(getContext());
if (!candidateList.isEmpty() && (selectedTimeout > maxTimeout)) {
// The selected time out value is longer than the max timeout allowed by the admin.
// Select the largest value from the list by default.
final RadioButtonPreference preferenceWithLargestTimeout = (RadioButtonPreference) screen.getPreference(candidateList.size() - 1);
preferenceWithLargestTimeout.setChecked(true);
}
mPrivacyPreference = new FooterPreference(mContext);
mPrivacyPreference.setIcon(R.drawable.ic_privacy_shield_24dp);
mPrivacyPreference.setTitle(R.string.adaptive_sleep_privacy);
mPrivacyPreference.setSelectable(false);
mPrivacyPreference.setLayoutResource(R.layout.preference_footer);
if (isScreenAttentionAvailable(getContext())) {
mAdaptiveSleepPermissionController.addToScreen(screen);
mAdaptiveSleepCameraStatePreferenceController.addToScreen(screen);
mAdaptiveSleepBatterySaverPreferenceController.addToScreen(screen);
mAdaptiveSleepController.addToScreen(screen);
screen.addPreference(mPrivacyPreference);
}
if (mAdmin != null) {
setupDisabledFooterPreference();
screen.addPreference(mDisableOptionsPreference);
}
}
use of com.android.settingslib.widget.CandidateInfo in project android_packages_apps_Settings by omnirom.
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();
}
Aggregations