From 1bfd24e13f1446244ecde2f3ff19248c76630f26 Mon Sep 17 00:00:00 2001 From: thiruram Date: Fri, 12 Feb 2021 20:09:12 -0800 Subject: [PATCH] [AA+] Fixes duplicate LAUNCHER_ALLAPPS_SWITCHED_TO_MAIN_TAB logs. LAUNCHER_ALLAPPS_SWITCHED_TO_MAIN_TAB is logged when transistioning from AllApps search results view to all apps view. Bug: 178562918 Test: Manual Change-Id: Ie02e23ae9eaabad719ad2a1fc8f08a9e4c36936f --- .../launcher3/allapps/AllAppsContainerView.java | 16 ++++++++++++++-- .../launcher3/allapps/AllAppsPagedView.java | 16 ++++++++++++++++ .../allapps/LauncherAllAppsContainerView.java | 10 ---------- .../launcher3/logging/StatsLogManager.java | 14 ++++++++++---- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index ec2a6d5b85..4fd25770e0 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -16,6 +16,8 @@ package com.android.launcher3.allapps; import static com.android.launcher3.allapps.AllAppsGridAdapter.AdapterItem; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB; import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCUT_PERMISSION; import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_CHANGE_PERMISSION; import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_ENABLED; @@ -432,9 +434,19 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo mAH[AdapterHolder.WORK].setup(mViewPager.getChildAt(1), mWorkMatcher); mViewPager.getPageIndicator().setActiveMarker(AdapterHolder.MAIN); findViewById(R.id.tab_personal) - .setOnClickListener((View view) -> mViewPager.snapToPage(AdapterHolder.MAIN)); + .setOnClickListener((View view) -> { + if (mViewPager.snapToPage(AdapterHolder.MAIN)) { + mLauncher.getStatsLogManager().logger() + .log(LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB); + } + }); findViewById(R.id.tab_work) - .setOnClickListener((View view) -> mViewPager.snapToPage(AdapterHolder.WORK)); + .setOnClickListener((View view) -> { + if (mViewPager.snapToPage(AdapterHolder.WORK)) { + mLauncher.getStatsLogManager().logger() + .log(LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB); + } + }); onActivePageChanged(mViewPager.getNextPage()); } else { mAH[AdapterHolder.MAIN].setup(findViewById(R.id.apps_list_view), null); diff --git a/src/com/android/launcher3/allapps/AllAppsPagedView.java b/src/com/android/launcher3/allapps/AllAppsPagedView.java index 647402b9e1..14e3b5140f 100644 --- a/src/com/android/launcher3/allapps/AllAppsPagedView.java +++ b/src/com/android/launcher3/allapps/AllAppsPagedView.java @@ -15,9 +15,13 @@ */ package com.android.launcher3.allapps; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SWIPE_TO_PERSONAL_TAB; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SWIPE_TO_WORK_TAB; + import android.content.Context; import android.util.AttributeSet; +import com.android.launcher3.Launcher; import com.android.launcher3.PagedView; import com.android.launcher3.R; import com.android.launcher3.config.FeatureFlags; @@ -44,4 +48,16 @@ public class AllAppsPagedView extends PersonalWorkPagedView { R.dimen.all_apps_header_top_padding); setPadding(0, topPadding, 0, 0); } + + @Override + protected boolean snapToPageWithVelocity(int whichPage, int velocity) { + boolean resp = super.snapToPageWithVelocity(whichPage, velocity); + if (resp && whichPage != mCurrentPage) { + Launcher.getLauncher(getContext()).getStatsLogManager().logger() + .log(mCurrentPage < whichPage + ? LAUNCHER_ALLAPPS_SWIPE_TO_WORK_TAB + : LAUNCHER_ALLAPPS_SWIPE_TO_PERSONAL_TAB); + } + return resp; + } } diff --git a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java index bc2e66c36b..13ddc1244f 100644 --- a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java @@ -16,8 +16,6 @@ package com.android.launcher3.allapps; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_KEYBOARD_CLOSED; -import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SWITCHED_TO_MAIN_TAB; -import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_SWITCHED_TO_WORK_TAB; import android.content.Context; import android.graphics.Rect; @@ -90,14 +88,6 @@ public class LauncherAllAppsContainerView extends AllAppsContainerView { public void onActivePageChanged(int currentActivePage) { super.onActivePageChanged(currentActivePage); if (mUsingTabs) { - // Log tab switches only when the launcher is in AllApps state - if (mLauncher.getStateManager().getCurrentStableState() == LauncherState.ALL_APPS) { - mLauncher.getStatsLogManager().logger() - .log(currentActivePage == AdapterHolder.WORK - ? LAUNCHER_ALLAPPS_SWITCHED_TO_WORK_TAB - : LAUNCHER_ALLAPPS_SWITCHED_TO_MAIN_TAB); - } - if (currentActivePage == AdapterHolder.WORK) { WorkEduView.showWorkEduIfNeeded(mLauncher); } else { diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index 431d5342d3..876ed35959 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -362,11 +362,11 @@ public class StatsLogManager implements ResourceBasedOverride { @UiEvent(doc = "User closed the AllApps keyboard.") LAUNCHER_ALLAPPS_KEYBOARD_CLOSED(694), - @UiEvent(doc = "User switched to Main tab in AllApps screen.") - LAUNCHER_ALLAPPS_SWITCHED_TO_MAIN_TAB(695), + @UiEvent(doc = "User switched to AllApps Main/Personal tab by swiping left.") + LAUNCHER_ALLAPPS_SWIPE_TO_PERSONAL_TAB(695), - @UiEvent(doc = "User switched to Work tab in AllApps screen.") - LAUNCHER_ALLAPPS_SWITCHED_TO_WORK_TAB(696), + @UiEvent(doc = "User switched to AllApps Work tab by swiping right.") + LAUNCHER_ALLAPPS_SWIPE_TO_WORK_TAB(696), @UiEvent(doc = "Default event when dedicated UI event is not available for the user action" + " on slice .") @@ -398,6 +398,12 @@ public class StatsLogManager implements ResourceBasedOverride { @UiEvent(doc = "Launcher entered into AllApps state with device search enabled.") LAUNCHER_ALLAPPS_ENTRY_WITH_DEVICE_SEARCH(720), + + @UiEvent(doc = "User switched to AllApps Main/Personal tab by tapping on it.") + LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB(721), + + @UiEvent(doc = "User switched to AllApps Work tab by tapping on it.") + LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB(722), ; // ADD MORE