Search in sources :

Example 96 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.

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"), PendingIntent.FLAG_IMMUTABLE);
    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();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Example 97 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.

the class SliceHalfCardRendererHelperTest 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"), PendingIntent.FLAG_IMMUTABLE);
    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();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Example 98 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.

the class PanelFragmentTest method supportIcon_displayIconHeaderLayout.

@Test
public void supportIcon_displayIconHeaderLayout() {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_android);
    mFakePanelContent.setIcon(icon);
    mFakePanelContent.setSubTitle(SUBTITLE);
    final ActivityController<FakeSettingsPanelActivity> activityController = Robolectric.buildActivity(FakeSettingsPanelActivity.class);
    activityController.setup();
    final PanelFragment panelFragment = (PanelFragment) Objects.requireNonNull(activityController.get().getSupportFragmentManager().findFragmentById(R.id.main_content));
    final View titleView = panelFragment.mLayoutView.findViewById(R.id.panel_title);
    final LinearLayout panelHeader = panelFragment.mLayoutView.findViewById(R.id.panel_header);
    final TextView headerTitle = panelFragment.mLayoutView.findViewById(R.id.header_title);
    final TextView headerSubtitle = panelFragment.mLayoutView.findViewById(R.id.header_subtitle);
    // Check visibility
    assertThat(panelHeader.getVisibility()).isEqualTo(View.VISIBLE);
    assertThat(titleView.getVisibility()).isEqualTo(View.GONE);
    // Check content
    assertThat(headerTitle.getText()).isEqualTo(FakePanelContent.TITLE);
    assertThat(headerSubtitle.getText()).isEqualTo(SUBTITLE);
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) Test(org.junit.Test)

Example 99 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.

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());
}
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 100 with IconCompat

use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.

the class LocationSliceTest method getLocationSlice_correctSliceContent.

@Test
public void getLocationSlice_correctSliceContent() {
    final Slice LocationSlice = new LocationSlice(mContext).getSlice();
    final SliceMetadata metadata = SliceMetadata.from(mContext, LocationSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.location_settings_title));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).isEmpty();
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_signal_location);
    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