use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceDeferredSetupCardRendererHelperTest method buildSlice.
private Slice buildSlice() {
final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
final PendingIntent pendingIntent = PendingIntent.getActivity(mActivity, TITLE.hashCode(), /* requestCode */
new Intent("test action"), 0);
final SliceAction action = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, TITLE);
return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY).addRow(new ListBuilder.RowBuilder().addEndItem(icon, ListBuilder.ICON_IMAGE).setTitle(TITLE).setSubtitle(SUMMARY).setPrimaryAction(action)).build();
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceFullCardRendererHelperTest method buildSlice.
private Slice buildSlice() {
final String title = "test_title";
final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
final PendingIntent pendingIntent = PendingIntent.getActivity(mActivity, title.hashCode(), /* requestCode */
new Intent("test action"), 0);
final SliceAction action = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, title);
return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY).addRow(new ListBuilder.RowBuilder().addEndItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setPrimaryAction(action)).build();
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MobileDataSliceTest method getSlice_shouldHaveTitleAndToggle.
@Test
public void getSlice_shouldHaveTitleAndToggle() {
final Slice mobileData = mMobileDataSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, mobileData);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.mobile_data_settings_title));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, R.drawable.ic_network_cell);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceBuilderUtilsTest method getSafeIcon_invalidResource_shouldFallbackToSettingsIcon.
@Test
public void getSafeIcon_invalidResource_shouldFallbackToSettingsIcon() {
final int settingsIcon = R.drawable.ic_settings_accent;
final int badIcon = 0x12345678;
final SliceData data = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH, badIcon);
final IconCompat actualIcon = SliceBuilderUtils.getSafeIcon(mContext, data);
final int actualIconResource = actualIcon.toIcon().getResId();
assertThat(actualIconResource).isEqualTo(settingsIcon);
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceBuilderUtilsTest method getSafeIcon_replacesEmptyIconWithSettingsIcon.
@Test
public void getSafeIcon_replacesEmptyIconWithSettingsIcon() {
final int settingsIcon = R.drawable.ic_settings_accent;
final int zeroIcon = 0x0;
final SliceData data = getDummyData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH, zeroIcon);
final IconCompat actualIcon = SliceBuilderUtils.getSafeIcon(mContext, data);
final int actualIconResource = actualIcon.toIcon().getResId();
assertThat(actualIconResource).isNotEqualTo(zeroIcon);
assertThat(actualIconResource).isEqualTo(settingsIcon);
}
Aggregations