Search in sources :

Example 1 with CandidateInfo

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

the class NotificationAssistantPickerTest method dialogTextHasAssistantName.

@Test
public void dialogTextHasAssistantName() {
    CandidateInfo c = mock(CandidateInfo.class);
    when(mContext.getString(anyInt(), anyString())).thenAnswer((InvocationOnMock invocation) -> {
        return invocation.getArgument(1);
    });
    when(c.loadLabel()).thenReturn(TEST_NAME);
    when(c.getKey()).thenReturn(TEST_CMP);
    CharSequence text = mFragment.getConfirmationMessage(c);
    assertNotNull(text);
    assertTrue(text.toString().contains(TEST_NAME));
}
Also used : CandidateInfo(com.android.settingslib.widget.CandidateInfo) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Test(org.junit.Test)

Example 2 with CandidateInfo

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

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;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) CandidateInfo(com.android.settingslib.widget.CandidateInfo) ArrayList(java.util.ArrayList) PackageItemInfo(android.content.pm.PackageItemInfo) ComponentName(android.content.ComponentName) DefaultAppInfo(com.android.settingslib.applications.DefaultAppInfo)

Example 3 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 4 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 5 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)

Aggregations

CandidateInfo (com.android.settingslib.widget.CandidateInfo)9 ComponentName (android.content.ComponentName)3 ArrayList (java.util.ArrayList)3 Context (android.content.Context)2 ServiceInfo (android.content.pm.ServiceInfo)2 PreferenceScreen (androidx.preference.PreferenceScreen)2 Test (org.junit.Test)2 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)1 PackageItemInfo (android.content.pm.PackageItemInfo)1 Drawable (android.graphics.drawable.Drawable)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 DefaultAppInfo (com.android.settingslib.applications.DefaultAppInfo)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1