Search in sources :

Example 6 with CandidateInfo

use of com.android.settingslib.widget.CandidateInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class NotificationAssistantPreferenceController method getSummary.

@Override
public CharSequence getSummary() {
    CandidateInfo appSelected = new NotificationAssistantPicker.CandidateNone(mContext);
    ComponentName assistant = mNotificationBackend.getAllowedNotificationAssistant();
    if (assistant != null) {
        appSelected = createCandidateInfo(assistant);
    }
    return appSelected.loadLabel();
}
Also used : CandidateInfo(com.android.settingslib.widget.CandidateInfo) ComponentName(android.content.ComponentName)

Example 7 with CandidateInfo

use of com.android.settingslib.widget.CandidateInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ShortcutServicePickerFragment method getCandidates.

@Override
protected List<? extends CandidateInfo> getCandidates() {
    final Context context = getContext();
    final AccessibilityManager accessibilityManager = context.getSystemService(AccessibilityManager.class);
    final List<AccessibilityServiceInfo> installedServices = accessibilityManager.getInstalledAccessibilityServiceList();
    final int numInstalledServices = installedServices.size();
    final List<CandidateInfo> candidates = new ArrayList<>(numInstalledServices);
    Map<ComponentName, ToggleableFrameworkFeatureInfo> frameworkFeatureInfoMap = AccessibilityShortcutController.getFrameworkShortcutFeaturesMap();
    for (ComponentName componentName : frameworkFeatureInfoMap.keySet()) {
        final int iconId;
        if (componentName.equals(COLOR_INVERSION_COMPONENT_NAME)) {
            iconId = R.drawable.ic_color_inversion;
        } else if (componentName.equals(DALTONIZER_COMPONENT_NAME)) {
            iconId = R.drawable.ic_daltonizer;
        } else {
            iconId = R.drawable.empty_icon;
        }
        candidates.add(new FrameworkCandidateInfo(frameworkFeatureInfoMap.get(componentName), iconId, componentName.flattenToString()));
    }
    for (int i = 0; i < numInstalledServices; i++) {
        candidates.add(new ServiceCandidateInfo(installedServices.get(i)));
    }
    return candidates;
}
Also used : Context(android.content.Context) CandidateInfo(com.android.settingslib.widget.CandidateInfo) ArrayList(java.util.ArrayList) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) AccessibilityManager(android.view.accessibility.AccessibilityManager) ComponentName(android.content.ComponentName) ToggleableFrameworkFeatureInfo(com.android.internal.accessibility.AccessibilityShortcutController.ToggleableFrameworkFeatureInfo)

Example 8 with CandidateInfo

use of com.android.settingslib.widget.CandidateInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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) {
        RadioButtonPreferenceWithExtraWidget pref = new RadioButtonPreferenceWithExtraWidget(getPrefContext());
        bindPreference(pref, info.getKey(), info, defaultKey);
        bindPreferenceExtra(pref, info.getKey(), info, defaultKey, systemDefaultKey);
        screen.addPreference(pref);
    }
    mayCheckOnlyRadioButton();
}
Also used : PreferenceScreen(androidx.preference.PreferenceScreen) CandidateInfo(com.android.settingslib.widget.CandidateInfo) RadioButtonPreferenceWithExtraWidget(com.android.settings.widget.RadioButtonPreferenceWithExtraWidget)

Example 9 with CandidateInfo

use of com.android.settingslib.widget.CandidateInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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

Example 10 with CandidateInfo

use of com.android.settingslib.widget.CandidateInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BatterySaverScheduleSettings method getCandidates.

@Override
protected List<? extends CandidateInfo> getCandidates() {
    Context context = getContext();
    List<CandidateInfo> candidates = Lists.newArrayList();
    String routineProviderApp = getContext().getResources().getString(com.android.internal.R.string.config_batterySaverScheduleProvider);
    candidates.add(new BatterySaverScheduleCandidateInfo(context.getText(R.string.battery_saver_auto_no_schedule), /* summary */
    null, BatterySaverScheduleRadioButtonsController.KEY_NO_SCHEDULE, /* enabled */
    true));
    // only add routine option if an app has been specified
    if (!TextUtils.isEmpty(routineProviderApp)) {
        candidates.add(new BatterySaverScheduleCandidateInfo(context.getText(R.string.battery_saver_auto_routine), context.getText(R.string.battery_saver_auto_routine_summary), BatterySaverScheduleRadioButtonsController.KEY_ROUTINE, /* enabled */
        true));
    } else {
        // Make sure routine is not selected if no provider app is configured
        BatterySaverUtils.revertScheduleToNoneIfNeeded(context);
    }
    candidates.add(new BatterySaverScheduleCandidateInfo(context.getText(R.string.battery_saver_auto_percentage), /* summary */
    null, BatterySaverScheduleRadioButtonsController.KEY_PERCENTAGE, /* enabled */
    true));
    return candidates;
}
Also used : Context(android.content.Context) CandidateInfo(com.android.settingslib.widget.CandidateInfo)

Aggregations

CandidateInfo (com.android.settingslib.widget.CandidateInfo)17 PreferenceScreen (androidx.preference.PreferenceScreen)5 ArrayList (java.util.ArrayList)5 ComponentName (android.content.ComponentName)4 ServiceInfo (android.content.pm.ServiceInfo)4 Test (org.junit.Test)4 Context (android.content.Context)3 RadioButtonPreference (com.android.settingslib.widget.RadioButtonPreference)3 PackageItemInfo (android.content.pm.PackageItemInfo)2 Drawable (android.graphics.drawable.Drawable)2 DefaultAppInfo (com.android.settingslib.applications.DefaultAppInfo)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)1 SpannableString (android.text.SpannableString)1 AccessibilityManager (android.view.accessibility.AccessibilityManager)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 ToggleableFrameworkFeatureInfo (com.android.internal.accessibility.AccessibilityShortcutController.ToggleableFrameworkFeatureInfo)1 RadioButtonPreferenceWithExtraWidget (com.android.settings.widget.RadioButtonPreferenceWithExtraWidget)1 FooterPreference (com.android.settingslib.widget.FooterPreference)1