Search in sources :

Example 11 with RadioButtonPreference

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;
}
Also used : RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference)

Example 12 with RadioButtonPreference

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);
    }
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) CandidateInfo(com.android.settingslib.widget.CandidateInfo) RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference)

Example 13 with RadioButtonPreference

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());
}
Also used : RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference)

Example 14 with RadioButtonPreference

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;
}
Also used : RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference)

Example 15 with RadioButtonPreference

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);
}
Also used : RadioButtonPreference(com.android.settingslib.widget.RadioButtonPreference) Test(org.junit.Test)

Aggregations

RadioButtonPreference (com.android.settingslib.widget.RadioButtonPreference)52 Test (org.junit.Test)27 Before (org.junit.Before)8 DefaultAppInfo (com.android.settingslib.applications.DefaultAppInfo)6 PreferenceScreen (androidx.preference.PreferenceScreen)5 CandidateInfo (com.android.settingslib.widget.CandidateInfo)3 Preference (androidx.preference.Preference)2 PreferenceCategory (androidx.preference.PreferenceCategory)2 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)2 FooterPreference (com.android.settingslib.widget.FooterPreference)2 AppOpsManager (android.app.AppOpsManager)1 SettingsEnums (android.app.settings.SettingsEnums)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 PackageManager (android.content.pm.PackageManager)1 Resources (android.content.res.Resources)1 Drawable (android.graphics.drawable.Drawable)1 BatteryStats (android.os.BatteryStats)1 Bundle (android.os.Bundle)1