use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class UsbDetailsFunctionsController method getProfilePreference.
/**
* Gets a switch preference for the particular option, creating it if needed.
*/
private RadioButtonPreference getProfilePreference(String key, int titleId) {
RadioButtonPreference pref = mProfilesContainer.findPreference(key);
if (pref == null) {
pref = new RadioButtonPreference(mProfilesContainer.getContext());
pref.setKey(key);
pref.setTitle(titleId);
pref.setSingleLineTitle(false);
pref.setOnClickListener(this);
mProfilesContainer.addPreference(pref);
}
return pref;
}
use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class RadioButtonPickerFragment method updateCandidates.
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.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class BugReportHandlerPickerTest method testClickingItemSuccess.
private void testClickingItemSuccess() {
when(mBugReportHandlerUtil.getValidBugReportHandlerInfos(any())).thenReturn(Collections.singletonList(Pair.create(createApplicationInfo(PACKAGE_NAME), USER_ID)));
when(mBugReportHandlerUtil.setCurrentBugReportHandlerAppAndUser(any(), eq(PACKAGE_NAME), eq(USER_ID))).thenReturn(true);
RadioButtonPreference defaultPackagePref = mock(RadioButtonPreference.class);
when(defaultPackagePref.getKey()).thenReturn(BugReportHandlerPicker.getKey(PACKAGE_NAME, USER_ID));
mPicker.onRadioButtonClicked(defaultPackagePref);
verify(mBugReportHandlerUtil, times(1)).setCurrentBugReportHandlerAppAndUser(any(), eq(PACKAGE_NAME), eq(USER_ID));
verify(mPicker, times(1)).updateCheckedState(BugReportHandlerPicker.getKey(PACKAGE_NAME, USER_ID));
verify(mBugReportHandlerUtil, never()).showInvalidChoiceToast(any());
}
use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class OpenSupportedLinks method makeRadioPreference.
private RadioButtonPreference makeRadioPreference(String key, int stringId) {
final RadioButtonPreference pref = new RadioButtonPreference(mPreferenceCategory.getContext());
pref.setKey(key);
pref.setTitle(stringId);
pref.setOnClickListener(this);
mPreferenceCategory.addPreference(pref);
return pref;
}
use of com.android.settingslib.widget.RadioButtonPreference in project android_packages_apps_Settings by omnirom.
the class UsbDetailsDataRoleControllerTest method onClickDeviceTwice_hostEnabled_shouldSetDeviceOnce.
@Test
public void onClickDeviceTwice_hostEnabled_shouldSetDeviceOnce() {
mDetailsDataRoleController.displayPreference(mScreen);
when(mUsbBackend.getDataRole()).thenReturn(DATA_ROLE_HOST);
final RadioButtonPreference devicePref = getRadioPreference(DATA_ROLE_DEVICE);
devicePref.performClick();
assertThat(devicePref.getSummary()).isEqualTo(mContext.getString(R.string.usb_switching));
devicePref.performClick();
verify(mUsbBackend).setDataRole(DATA_ROLE_DEVICE);
}
Aggregations