use of androidx.slice.core.SliceAction in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceDeferredSetupCardRendererHelper method bindView.
void bindView(RecyclerView.ViewHolder holder, ContextualCard card, Slice slice) {
final DeferredSetupCardViewHolder view = (DeferredSetupCardViewHolder) holder;
final SliceMetadata sliceMetadata = SliceMetadata.from(mContext, slice);
final SliceAction primaryAction = sliceMetadata.getPrimaryAction();
view.icon.setImageDrawable(primaryAction.getIcon().loadDrawable(mContext));
view.title.setText(primaryAction.getTitle());
view.summary.setText(sliceMetadata.getSubtitle());
view.button.setOnClickListener(v -> {
try {
primaryAction.getAction().send();
} catch (PendingIntent.CanceledException e) {
Log.w(TAG, "Failed to start intent " + primaryAction.getTitle());
}
final String log = ContextualCardLogUtils.buildCardClickLog(card, 0, /* row */
EventInfo.ACTION_TYPE_CONTENT, view.getAdapterPosition());
final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
metricsFeatureProvider.action(mContext, SettingsEnums.ACTION_CONTEXTUAL_CARD_CLICK, log);
});
}
use of androidx.slice.core.SliceAction in project android_packages_apps_Settings by omnirom.
the class RemoteMediaSliceTest method getSlice_withActiveSession_checkTitle.
@Test
public void getSlice_withActiveSession_checkTitle() {
final Slice slice = mRemoteMediaSlice.getSlice();
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
final SliceAction primaryAction = metadata.getPrimaryAction();
assertThat(primaryAction.getTitle().toString()).isEqualTo(mContext.getText(com.android.settings.R.string.remote_media_volume_option_title));
}
use of androidx.slice.core.SliceAction in project android_packages_apps_Settings by omnirom.
the class SliceBuilderUtilsTest method buildIntentSlice_noIconPassed_returnsSliceWithIcon.
@Test
public void buildIntentSlice_noIconPassed_returnsSliceWithIcon() {
final int expectedIconResource = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent).toIcon().getResId();
final SliceData sliceData = getMockData(CONTEXT_CONTROLLER, SliceData.SliceType.INTENT, 0x0);
final Slice slice = SliceBuilderUtils.buildSlice(mContext, sliceData);
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
final SliceAction primaryAction = metadata.getPrimaryAction();
final int actualIconResource = primaryAction.getIcon().toIcon().getResId();
assertThat(actualIconResource).isEqualTo(expectedIconResource);
}
use of androidx.slice.core.SliceAction in project android_packages_apps_Settings by omnirom.
the class SliceBuilderUtilsTest method buildToggleSlice_noIconPassed_returnsSliceWithIcon.
@Test
public void buildToggleSlice_noIconPassed_returnsSliceWithIcon() {
final int expectedIconResource = IconCompat.createWithResource(mContext, R.drawable.ic_settings_accent).toIcon().getResId();
final SliceData mockData = getMockData(TOGGLE_CONTROLLER, SliceData.SliceType.SWITCH, 0x0);
final Slice slice = SliceBuilderUtils.buildSlice(mContext, mockData);
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
final SliceAction primaryAction = metadata.getPrimaryAction();
final int actualIconResource = primaryAction.getIcon().toIcon().getResId();
assertThat(actualIconResource).isEqualTo(expectedIconResource);
}
use of androidx.slice.core.SliceAction in project android_packages_apps_Settings by omnirom.
the class Enhanced4gLteSliceHelperTest method testEnhanced4gLteSettingsToggleSlice.
private void testEnhanced4gLteSettingsToggleSlice(Slice slice) {
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction mainToggleAction = toggles.get(0);
// Check intent in Toggle Action
final PendingIntent togglePendingIntent = mainToggleAction.getAction();
final PendingIntent expectedToggleIntent = getBroadcastIntent(Enhanced4gLteSliceHelper.ACTION_ENHANCED_4G_LTE_CHANGED);
assertThat(togglePendingIntent).isEqualTo(expectedToggleIntent);
// Check primary intent
final PendingIntent primaryPendingIntent = metadata.getPrimaryAction().getAction();
final PendingIntent expectedPendingIntent = getActivityIntent(Enhanced4gLteSliceHelper.ACTION_MOBILE_NETWORK_SETTINGS_ACTIVITY);
assertThat(primaryPendingIntent).isEqualTo(expectedPendingIntent);
// Check the title
final List<SliceItem> sliceItems = slice.getItems();
assertTitle(sliceItems, ResourcesUtils.getResourcesString(mContext, "enhanced_4g_lte_mode_title"));
}
Aggregations