Search in sources :

Example 1 with ContextualCardFeatureProvider

use of com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceFullCardRendererHelper method bindView.

void bindView(RecyclerView.ViewHolder holder, ContextualCard card, Slice slice) {
    final SliceViewHolder cardHolder = (SliceViewHolder) holder;
    cardHolder.sliceView.setScrollable(false);
    cardHolder.sliceView.setTag(card.getSliceUri());
    // TODO(b/114009676): We will soon have a field to decide what slice mode we should set.
    cardHolder.sliceView.setMode(SliceView.MODE_LARGE);
    cardHolder.sliceView.setSlice(slice);
    // Set this listener so we can log the interaction users make on the slice
    cardHolder.sliceView.setOnSliceActionListener((eventInfo, sliceItem) -> {
        final String log = ContextualCardLogUtils.buildCardClickLog(card, eventInfo.rowIndex, eventInfo.actionType, cardHolder.getAdapterPosition());
        final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
        metricsFeatureProvider.action(mContext, SettingsEnums.ACTION_CONTEXTUAL_CARD_CLICK, log);
        final ContextualCardFeatureProvider contextualCardFeatureProvider = FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
        contextualCardFeatureProvider.logNotificationPackage(slice);
    });
    // Customize slice view for Settings
    cardHolder.sliceView.setShowTitleItems(true);
    if (card.isLargeCard()) {
        cardHolder.sliceView.setShowHeaderDivider(true);
        cardHolder.sliceView.setShowActionDividers(true);
    }
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) ContextualCardFeatureProvider(com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider)

Example 2 with ContextualCardFeatureProvider

use of com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider in project android_packages_apps_Settings by omnirom.

the class SliceContextualCardController method onDismissed.

@Override
public void onDismissed(ContextualCard card) {
    ThreadUtils.postOnBackgroundThread(() -> {
        final ContextualCardFeatureProvider cardFeatureProvider = FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
        cardFeatureProvider.markCardAsDismissed(mContext, card.getName());
    });
    showFeedbackDialog(card);
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
    metricsFeatureProvider.action(mContext, SettingsEnums.ACTION_CONTEXTUAL_CARD_DISMISS, ContextualCardLogUtils.buildCardDismissLog(card));
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) ContextualCardFeatureProvider(com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider)

Example 3 with ContextualCardFeatureProvider

use of com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider in project android_packages_apps_Settings by omnirom.

the class SliceContextualCardControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    mProvider = Robolectric.setupContentProvider(CardContentProvider.class);
    ShadowContentResolver.registerProviderInternal(CardContentProvider.CARD_AUTHORITY, mProvider);
    mResolver = mContext.getContentResolver();
    mController = spy(new SliceContextualCardController(mContext));
    mFeatureFactory = FakeFeatureFactory.setupForTest();
    final ContextualCardFeatureProvider cardFeatureProvider = new ContextualCardFeatureProviderImpl(mContext);
    mFeatureFactory.mContextualCardFeatureProvider = cardFeatureProvider;
}
Also used : CardContentProvider(com.android.settings.homepage.contextualcards.CardContentProvider) ContextualCardFeatureProvider(com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider) ContextualCardFeatureProviderImpl(com.android.settings.homepage.contextualcards.ContextualCardFeatureProviderImpl) Before(org.junit.Before)

Aggregations

ContextualCardFeatureProvider (com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider)3 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)2 CardContentProvider (com.android.settings.homepage.contextualcards.CardContentProvider)1 ContextualCardFeatureProviderImpl (com.android.settings.homepage.contextualcards.ContextualCardFeatureProviderImpl)1 Before (org.junit.Before)1