Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 821ef949 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add scroll up and scroll down logging." into tm-qpr-dev

parents 41235d52 0de35265
Loading
Loading
Loading
Loading
+32 −2
Original line number Diff line number Diff line
@@ -17,7 +17,11 @@ package com.android.launcher3.allapps;

import static android.view.View.MeasureSpec.UNSPECIFIED;

import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SCROLLED;
import static com.android.launcher3.logger.LauncherAtom.ContainerInfo;
import static com.android.launcher3.logger.LauncherAtom.SearchResultContainer;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SCROLLED_DOWN;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SCROLLED_UNKNOWN_DIRECTION;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SCROLLED_UP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END;
import static com.android.launcher3.util.LogConfig.SEARCH_LOGGING;
@@ -31,6 +35,7 @@ import android.util.SparseIntArray;
import androidx.recyclerview.widget.RecyclerView;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.ExtendedEditText;
import com.android.launcher3.FastScrollRecyclerView;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
@@ -56,6 +61,7 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
    private final SparseIntArray mViewHeights = new SparseIntArray();
    private final SparseIntArray mCachedScrollPositions = new SparseIntArray();
    private final AllAppsFastScrollHelper mFastScrollHelper;
    private int mCumulativeVerticalScroll;


    private final AdapterDataObserver mObserver = new RecyclerView.AdapterDataObserver() {
@@ -157,7 +163,7 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
        StatsLogManager mgr = ActivityContext.lookupContext(getContext()).getStatsLogManager();
        switch (state) {
            case SCROLL_STATE_DRAGGING:
                mgr.logger().log(LAUNCHER_ALLAPPS_SCROLLED);
                mCumulativeVerticalScroll = 0;
                requestFocus();
                mgr.logger().sendToInteractionJankMonitor(
                        LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN, this);
@@ -166,10 +172,17 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
            case SCROLL_STATE_IDLE:
                mgr.logger().sendToInteractionJankMonitor(
                        LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END, this);
                logCumulativeVerticalScroll();
                break;
        }
    }

    @Override
    public void onScrolled(int dx, int dy) {
        super.onScrolled(dx, dy);
        mCumulativeVerticalScroll += dy;
    }

    /**
     * Maps the touch (from 0..1) to the adapter position that should be visible.
     */
@@ -349,4 +362,21 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView {
    public boolean hasOverlappingRendering() {
        return false;
    }

    private void logCumulativeVerticalScroll() {
        ActivityContext context = ActivityContext.lookupContext(getContext());
        StatsLogManager mgr = context.getStatsLogManager();
        ExtendedEditText editText = context.getAppsView().getSearchUiManager().getEditText();
        ContainerInfo containerInfo = ContainerInfo.newBuilder().setSearchResultContainer(
                SearchResultContainer
                        .newBuilder()
                        .setQueryLength((editText == null) ? -1 : editText.length())).build();

        // mCumulativeVerticalScroll == 0 when user comes back to original position, we don't
        // know the direction of scrolling.
        mgr.logger().withContainerInfo(containerInfo).log(
                mCumulativeVerticalScroll == 0 ? LAUNCHER_ALLAPPS_SCROLLED_UNKNOWN_DIRECTION
                        : (mCumulativeVerticalScroll > 0) ? LAUNCHER_ALLAPPS_SCROLLED_DOWN
                                : LAUNCHER_ALLAPPS_SCROLLED_UP);
    }
}
+14 −0
Original line number Diff line number Diff line
@@ -555,6 +555,20 @@ public class StatsLogManager implements ResourceBasedOverride {
                + "result page etc.")
        LAUNCHER_ALLAPPS_SCROLLED(985),

        @UiEvent(doc = "User scrolled up on one of the all apps surfaces such as A-Z list, search "
                + "result page etc.")
        LAUNCHER_ALLAPPS_SCROLLED_UP(1229),

        @UiEvent(doc =
                "User scrolled down on one of the all apps surfaces such as A-Z list, search "
                        + "result page etc.")
        LAUNCHER_ALLAPPS_SCROLLED_DOWN(1230),

        @UiEvent(doc = "User scrolled on one of the all apps surfaces such as A-Z list, search "
                + "result page etc and we don't know the direction since user came back to "
                + "original position from which they scrolled.")
        LAUNCHER_ALLAPPS_SCROLLED_UNKNOWN_DIRECTION(1231),

        @UiEvent(doc = "User tapped taskbar home button")
        LAUNCHER_TASKBAR_HOME_BUTTON_TAP(1003),