Search in sources :

Example 66 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MediaOutputSlice method getActiveDeviceHeaderRow.

private ListBuilder.RowBuilder getActiveDeviceHeaderRow(MediaDevice device) {
    final String title = device.getName();
    final IconCompat icon = getDeviceIconCompat(device);
    final PendingIntent broadcastAction = getBroadcastIntent(mContext, device.getId(), device.hashCode());
    final SliceAction primarySliceAction = SliceAction.createDeeplink(broadcastAction, icon, ListBuilder.ICON_IMAGE, title);
    final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setSubtitle(device.getSummary()).setPrimaryAction(primarySliceAction);
    return rowBuilder;
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Example 67 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ContextualWifiSliceTest method getWifiSlice_previousDisplayed_hasActiveConnection_shouldHaveTitleAndToggle.

@Test
public void getWifiSlice_previousDisplayed_hasActiveConnection_shouldHaveTitleAndToggle() {
    mWifiSlice.sActiveUiSession = mFeatureFactory.slicesFeatureProvider.getUiSessionToken();
    mWifiSlice.sPreviouslyDisplayed = true;
    connectToWifi(makeValidatedNetworkCapabilities());
    final Slice wifiSlice = mWifiSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.wifi_settings));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 68 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ContextualWifiSliceTest method getWifiSlice_isCaptivePortal_shouldHaveTitleAndToggle.

@Test
public void getWifiSlice_isCaptivePortal_shouldHaveTitleAndToggle() {
    mWifiSlice.sPreviouslyDisplayed = false;
    connectToWifi(WifiSliceTest.makeCaptivePortalNetworkCapabilities());
    final Slice wifiSlice = mWifiSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.wifi_settings));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 69 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiSliceTest method getWifiSlice_isCaptivePortal_shouldHaveCaptivePortalItems.

@Test
public void getWifiSlice_isCaptivePortal_shouldHaveCaptivePortalItems() {
    setWorkerResults(createAccessPoint(AP1_NAME, true, true));
    doReturn(makeCaptivePortalNetworkCapabilities()).when(mConnectivityManager).getNetworkCapabilities(any());
    final IconCompat expectedIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent);
    final Slice wifiSlice = mWifiSlice.getSlice();
    final List<SliceItem> sliceItems = wifiSlice.getItems();
    SliceTester.assertAnySliceItemContainsTitle(sliceItems, AP1_NAME);
    SliceTester.assertAnySliceItemContainsIcon(sliceItems, expectedIcon);
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceItem(androidx.slice.SliceItem) Test(org.junit.Test)

Example 70 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiSliceTest method getWifiSlice_shouldHaveTitleAndToggle.

@Test
public void getWifiSlice_shouldHaveTitleAndToggle() {
    final Slice wifiSlice = mWifiSlice.getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.wifi_settings));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Aggregations

IconCompat (androidx.core.graphics.drawable.IconCompat)103 ListBuilder (androidx.slice.builders.ListBuilder)55 PendingIntent (android.app.PendingIntent)42 SliceAction (androidx.slice.builders.SliceAction)39 Test (org.junit.Test)25 ColorInt (android.annotation.ColorInt)22 RowBuilder (androidx.slice.builders.ListBuilder.RowBuilder)21 SliceMetadata (androidx.slice.SliceMetadata)18 SliceAction (androidx.slice.core.SliceAction)18 Intent (android.content.Intent)15 Slice (androidx.slice.Slice)14 Drawable (android.graphics.drawable.Drawable)7 ShortcutInfoCompat (androidx.core.content.pm.ShortcutInfoCompat)7 SliceItem (androidx.slice.SliceItem)6 ColorDrawable (android.graphics.drawable.ColorDrawable)5 Bitmap (android.graphics.Bitmap)4 SpannableString (android.text.SpannableString)4 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)4 Resources (android.content.res.Resources)3 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)3