Search in sources :

Example 26 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceHalfCardRendererHelper method bindView.

void bindView(RecyclerView.ViewHolder holder, ContextualCard card, Slice slice) {
    final HalfCardViewHolder view = (HalfCardViewHolder) 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.content.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);
    });
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) PendingIntent(android.app.PendingIntent)

Example 27 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider 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 28 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ConditionContextualCardRenderer method bindView.

@Override
public void bindView(RecyclerView.ViewHolder holder, ContextualCard contextualCard) {
    final ConditionalCardHolder view = (ConditionalCardHolder) holder;
    final ConditionalContextualCard card = (ConditionalContextualCard) contextualCard;
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
    metricsFeatureProvider.visible(mContext, SettingsEnums.SETTINGS_HOMEPAGE, card.getMetricsConstant());
    initializePrimaryClick(view, card, metricsFeatureProvider);
    initializeView(view, card);
    initializeActionButton(view, card, metricsFeatureProvider);
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider)

Example 29 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ConditionFooterContextualCardRenderer method bindView.

@Override
public void bindView(RecyclerView.ViewHolder holder, ContextualCard card) {
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
    holder.itemView.setOnClickListener(v -> {
        metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_SETTINGS_CONDITION_EXPAND, SettingsEnums.SETTINGS_HOMEPAGE, null, /* key */
        0);
        final ConditionContextualCardController controller = mControllerRendererPool.getController(mContext, ContextualCard.CardType.CONDITIONAL_FOOTER);
        controller.setIsExpanded(false);
        controller.onConditionsChanged();
    });
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider)

Example 30 with MetricsFeatureProvider

use of com.android.settingslib.core.instrumentation.MetricsFeatureProvider in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ConditionHeaderContextualCardRenderer method bindView.

@Override
public void bindView(RecyclerView.ViewHolder holder, ContextualCard contextualCard) {
    final ConditionHeaderContextualCard headerCard = (ConditionHeaderContextualCard) contextualCard;
    final ConditionHeaderCardHolder view = (ConditionHeaderCardHolder) holder;
    final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(mContext).getMetricsFeatureProvider();
    view.icons.removeAllViews();
    headerCard.getConditionalCards().stream().forEach(card -> {
        final ImageView icon = (ImageView) LayoutInflater.from(mContext).inflate(R.layout.conditional_card_header_icon, view.icons, false);
        icon.setImageDrawable(card.getIconDrawable());
        view.icons.addView(icon);
    });
    view.itemView.setOnClickListener(v -> {
        metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_SETTINGS_CONDITION_EXPAND, SettingsEnums.SETTINGS_HOMEPAGE, null, /* key */
        1);
        final ConditionContextualCardController controller = mControllerRendererPool.getController(mContext, ContextualCard.CardType.CONDITIONAL_HEADER);
        controller.setIsExpanded(true);
        controller.onConditionsChanged();
    });
}
Also used : MetricsFeatureProvider(com.android.settingslib.core.instrumentation.MetricsFeatureProvider) ImageView(android.widget.ImageView)

Aggregations

MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)41 VisibleForTesting (androidx.annotation.VisibleForTesting)12 Context (android.content.Context)6 Test (org.junit.Test)4 PendingIntent (android.app.PendingIntent)3 SliceMetadata (androidx.slice.SliceMetadata)3 SliceAction (androidx.slice.core.SliceAction)3 JobWorkItem (android.app.job.JobWorkItem)2 ContentResolver (android.content.ContentResolver)2 Intent (android.content.Intent)2 UserHandle (android.os.UserHandle)2 UserManager (android.os.UserManager)2 ImageView (android.widget.ImageView)2 BatteryUtils (com.android.settings.fuelgauge.BatteryUtils)2 PowerUsageFeatureProvider (com.android.settings.fuelgauge.PowerUsageFeatureProvider)2 ContextualCardFeatureProvider (com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider)2 ArrayList (java.util.ArrayList)2 CardDatabaseHelper (com.android.settings.homepage.contextualcards.CardDatabaseHelper)1 PowerAllowlistBackend (com.android.settingslib.fuelgauge.PowerAllowlistBackend)1 PowerWhitelistBackend (com.android.settingslib.fuelgauge.PowerWhitelistBackend)1