From 4a024c08345b4f2341869580cbfae2a7532e7454 Mon Sep 17 00:00:00 2001 From: Brandon Dayauon Date: Mon, 22 Jul 2024 15:12:34 -0700 Subject: [PATCH] Make a dummy view at the bottom of all apps This is so that user can scroll all the way to bottom of all apps. - updated tests to account for this new view bug:340936636 Test manually: before:https://drive.google.com/file/d/18mKMAedQh2uUOR2G4U_ZORIKP2tkRmEk/view?usp=sharing after:https://drive.google.com/file/d/1UEl3kBfeInqxsgF2HwCfzOBEcsEqdbJ4/view?usp=sharing Flag: NONE addingViewToBottomOfAllApps Change-Id: Ib4b67a66cfc7ec2ba0dbbe211a241f244d204aaf --- .../allapps/AlphabeticalAppsList.java | 9 +++++++++ .../launcher3/allapps/BaseAllAppsAdapter.java | 6 +++++- .../allapps/AlphabeticalAppsListTest.java | 19 ++++++++++++------- .../allapps/PrivateSpaceHeaderViewTest.java | 17 +++++++++-------- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java index 5d03a93254..92715963f1 100644 --- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java +++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java @@ -15,6 +15,7 @@ */ package com.android.launcher3.allapps; +import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_BOTTOM_VIEW_TO_SCROLL_TO; import static com.android.launcher3.allapps.SectionDecorationInfo.ROUND_BOTTOM_LEFT; import static com.android.launcher3.allapps.SectionDecorationInfo.ROUND_BOTTOM_RIGHT; import static com.android.launcher3.allapps.SectionDecorationInfo.ROUND_NOTHING; @@ -295,6 +296,14 @@ public class AlphabeticalAppsList implement if (Flags.enablePrivateSpace()) { position = addPrivateSpaceItems(position); } + if (!mFastScrollerSections.isEmpty()) { + // After all the adapterItems are added, add a view to the bottom so that user can + // scroll all the way down. + mAdapterItems.add(new AdapterItem(VIEW_TYPE_BOTTOM_VIEW_TO_SCROLL_TO)); + mFastScrollerSections.add(new FastScrollSectionInfo( + mFastScrollerSections.get(mFastScrollerSections.size() - 1).sectionName, + position++)); + } } mAccessibilityResultsCount = (int) mAdapterItems.stream() .filter(AdapterItem::isCountedForAccessibility).count(); diff --git a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java index 4b38df8e28..60bf3eacc6 100644 --- a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java +++ b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java @@ -68,7 +68,8 @@ public abstract class BaseAllAppsAdapter ex public static final int VIEW_TYPE_WORK_DISABLED_CARD = 1 << 5; public static final int VIEW_TYPE_PRIVATE_SPACE_HEADER = 1 << 6; public static final int VIEW_TYPE_PRIVATE_SPACE_SYS_APPS_DIVIDER = 1 << 7; - public static final int NEXT_ID = 8; + public static final int VIEW_TYPE_BOTTOM_VIEW_TO_SCROLL_TO = 1 << 8; + public static final int NEXT_ID = 9; // Common view type masks public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER; @@ -247,6 +248,8 @@ public abstract class BaseAllAppsAdapter ex case VIEW_TYPE_PRIVATE_SPACE_HEADER: return new ViewHolder(mLayoutInflater.inflate( R.layout.private_space_header, parent, false)); + case VIEW_TYPE_BOTTOM_VIEW_TO_SCROLL_TO: + return new ViewHolder(new View(mActivityContext)); default: if (mAdapterProvider.isViewSupported(viewType)) { return mAdapterProvider.onCreateViewHolder(mLayoutInflater, parent, viewType); @@ -324,6 +327,7 @@ public abstract class BaseAllAppsAdapter ex == STATE_DISABLED ? null : new SectionDecorationInfo(mActivityContext, ROUND_NOTHING, true /* decorateTogether */); break; + case VIEW_TYPE_BOTTOM_VIEW_TO_SCROLL_TO: case VIEW_TYPE_ALL_APPS_DIVIDER: case VIEW_TYPE_WORK_DISABLED_CARD: // nothing to do diff --git a/tests/multivalentTests/src/com/android/launcher3/allapps/AlphabeticalAppsListTest.java b/tests/multivalentTests/src/com/android/launcher3/allapps/AlphabeticalAppsListTest.java index d2238ffda4..d93811929b 100644 --- a/tests/multivalentTests/src/com/android/launcher3/allapps/AlphabeticalAppsListTest.java +++ b/tests/multivalentTests/src/com/android/launcher3/allapps/AlphabeticalAppsListTest.java @@ -65,6 +65,7 @@ public class AlphabeticalAppsListTest { private static final int PRIVATE_SPACE_HEADER_ITEM_COUNT = 1; private static final int MAIN_USER_APP_COUNT = 2; private static final int PRIVATE_USER_APP_COUNT = 2; + private static final int VIEW_AT_END_OF_APP_LIST = 1; private static final int NUM_APP_COLS = 4; private static final int NUM_APP_ROWS = 3; private static final int PRIVATE_SPACE_SYS_APP_SEPARATOR_ITEM_COUNT = 1; @@ -107,7 +108,8 @@ public class AlphabeticalAppsListTest { && info.user.equals(MAIN_HANDLE)); assertEquals(MAIN_USER_APP_COUNT + PRIVATE_SPACE_HEADER_ITEM_COUNT - + PRIVATE_USER_APP_COUNT, mAlphabeticalAppsList.getAdapterItems().size()); + + PRIVATE_USER_APP_COUNT + VIEW_AT_END_OF_APP_LIST, + mAlphabeticalAppsList.getAdapterItems().size()); assertEquals(PRIVATE_SPACE_HEADER_ITEM_COUNT, mAlphabeticalAppsList.getAdapterItems().stream().filter(item -> item.viewType == VIEW_TYPE_PRIVATE_SPACE_HEADER).toList().size()); @@ -136,7 +138,7 @@ public class AlphabeticalAppsListTest { && info.user.equals(MAIN_HANDLE)); assertEquals(MAIN_USER_APP_COUNT + PRIVATE_SPACE_HEADER_ITEM_COUNT - + PRIVATE_SPACE_SYS_APP_SEPARATOR_ITEM_COUNT + + PRIVATE_SPACE_SYS_APP_SEPARATOR_ITEM_COUNT + VIEW_AT_END_OF_APP_LIST + PRIVATE_USER_APP_COUNT, mAlphabeticalAppsList.getAdapterItems().size()); assertEquals(PRIVATE_SPACE_HEADER_ITEM_COUNT, mAlphabeticalAppsList.getAdapterItems().stream().filter(item -> @@ -166,7 +168,8 @@ public class AlphabeticalAppsListTest { mAlphabeticalAppsList.updateItemFilter(info -> info != null && info.user.equals(MAIN_HANDLE)); - assertEquals(MAIN_USER_APP_COUNT + PRIVATE_SPACE_HEADER_ITEM_COUNT, + assertEquals(MAIN_USER_APP_COUNT + PRIVATE_SPACE_HEADER_ITEM_COUNT + + VIEW_AT_END_OF_APP_LIST, mAlphabeticalAppsList.getAdapterItems().size()); assertEquals(PRIVATE_SPACE_HEADER_ITEM_COUNT, mAlphabeticalAppsList .getAdapterItems().stream().filter(item -> @@ -187,8 +190,8 @@ public class AlphabeticalAppsListTest { mAlphabeticalAppsList.updateItemFilter(info -> info != null && info.user.equals(MAIN_HANDLE)); - assertEquals(MAIN_USER_APP_COUNT + PRIVATE_SPACE_HEADER_ITEM_COUNT, - mAlphabeticalAppsList.getAdapterItems().size()); + assertEquals(MAIN_USER_APP_COUNT + PRIVATE_SPACE_HEADER_ITEM_COUNT + + VIEW_AT_END_OF_APP_LIST, mAlphabeticalAppsList.getAdapterItems().size()); assertEquals(PRIVATE_SPACE_HEADER_ITEM_COUNT, mAlphabeticalAppsList .getAdapterItems().stream().filter(item -> item.viewType == VIEW_TYPE_PRIVATE_SPACE_HEADER).toList().size()); @@ -206,7 +209,8 @@ public class AlphabeticalAppsListTest { mAlphabeticalAppsList.updateItemFilter(info -> info != null && info.user.equals(MAIN_HANDLE)); - assertEquals(MAIN_USER_APP_COUNT, mAlphabeticalAppsList.getAdapterItems().size()); + assertEquals(MAIN_USER_APP_COUNT + VIEW_AT_END_OF_APP_LIST, + mAlphabeticalAppsList.getAdapterItems().size()); assertEquals(0, mAlphabeticalAppsList.getAdapterItems().stream().filter(item -> item.viewType == VIEW_TYPE_PRIVATE_SPACE_HEADER).toList().size()); assertEquals(0, mAlphabeticalAppsList.getAdapterItems().stream().filter(item -> @@ -222,7 +226,8 @@ public class AlphabeticalAppsListTest { mAlphabeticalAppsList.updateItemFilter(info -> info != null && info.user.equals(MAIN_HANDLE)); - assertEquals(2, mAlphabeticalAppsList.getAdapterItems().size()); + assertEquals(MAIN_USER_APP_COUNT + VIEW_AT_END_OF_APP_LIST, + mAlphabeticalAppsList.getAdapterItems().size()); assertEquals(0, mAlphabeticalAppsList.getAdapterItems().stream().filter(item -> item.itemInfo != null && item.itemInfo.itemType == VIEW_TYPE_PRIVATE_SPACE_HEADER) diff --git a/tests/src/com/android/launcher3/allapps/PrivateSpaceHeaderViewTest.java b/tests/src/com/android/launcher3/allapps/PrivateSpaceHeaderViewTest.java index de48432492..398f9c5e3e 100644 --- a/tests/src/com/android/launcher3/allapps/PrivateSpaceHeaderViewTest.java +++ b/tests/src/com/android/launcher3/allapps/PrivateSpaceHeaderViewTest.java @@ -86,6 +86,8 @@ public class PrivateSpaceHeaderViewTest { private static final String CAMERA_PACKAGE_NAME = "com.android.launcher3.tests.camera"; private static final int CONTAINER_HEADER_ELEMENT_COUNT = 1; private static final int LOCK_UNLOCK_BUTTON_COUNT = 1; + private static final int MAIN_USER_APP_COUNT = 1; + private static final int VIEW_AT_END_OF_APP_LIST = 1; private static final int PS_SETTINGS_BUTTON_COUNT_VISIBLE = 1; private static final int PS_SETTINGS_BUTTON_COUNT_INVISIBLE = 0; private static final int PS_TRANSITION_IMAGE_COUNT = 1; @@ -300,8 +302,8 @@ public class PrivateSpaceHeaderViewTest { int rows = (int) (ALL_APPS_HEIGHT - PS_HEADER_HEIGHT - HEADER_PROTECTION_HEIGHT); int position = rows * NUM_APP_COLS - (NUM_APP_COLS-1) + 1; - // The number of adapterItems should be the private space apps + one main app + header. - assertEquals(NUM_PRIVATE_SPACE_APPS + 1 + 1, + assertEquals(NUM_PRIVATE_SPACE_APPS + MAIN_USER_APP_COUNT + + CONTAINER_HEADER_ELEMENT_COUNT + VIEW_AT_END_OF_APP_LIST, mAlphabeticalAppsList.getAdapterItems().size()); assertEquals(position, privateProfileManager.scrollForHeaderToBeVisibleInContainer( @@ -335,8 +337,8 @@ public class PrivateSpaceHeaderViewTest { int rows = (int) (ALL_APPS_HEIGHT - PS_HEADER_HEIGHT - HEADER_PROTECTION_HEIGHT) - 1; int position = rows * NUM_APP_COLS - (NUM_APP_COLS-1) + 1; - // The number of adapterItems should be the private space apps + one main app + header. - assertEquals(NUM_PRIVATE_SPACE_APPS + 1 + 1, + assertEquals(NUM_PRIVATE_SPACE_APPS + MAIN_USER_APP_COUNT + + CONTAINER_HEADER_ELEMENT_COUNT + VIEW_AT_END_OF_APP_LIST, mAlphabeticalAppsList.getAdapterItems().size()); assertEquals(position, privateProfileManager.scrollForHeaderToBeVisibleInContainer( @@ -370,8 +372,8 @@ public class PrivateSpaceHeaderViewTest { int rows = (int) (ALL_APPS_HEIGHT - BIGGER_PS_HEADER_HEIGHT - HEADER_PROTECTION_HEIGHT); int position = rows * NUM_APP_COLS - (NUM_APP_COLS-1) + 1; - // The number of adapterItems should be the private space apps + one main app + header. - assertEquals(NUM_PRIVATE_SPACE_APPS + 1 + 1, + assertEquals(NUM_PRIVATE_SPACE_APPS + MAIN_USER_APP_COUNT + + CONTAINER_HEADER_ELEMENT_COUNT + VIEW_AT_END_OF_APP_LIST, mAlphabeticalAppsList.getAdapterItems().size()); assertEquals(position, privateProfileManager.scrollForHeaderToBeVisibleInContainer( @@ -399,8 +401,7 @@ public class PrivateSpaceHeaderViewTest { mAlphabeticalAppsList.updateItemFilter(info -> info != null && info.user.equals(MAIN_HANDLE)); - // The number of adapterItems should be the private space apps + one main app. - assertEquals(NUM_PRIVATE_SPACE_APPS + 1, + assertEquals(NUM_PRIVATE_SPACE_APPS + MAIN_USER_APP_COUNT + VIEW_AT_END_OF_APP_LIST, mAlphabeticalAppsList.getAdapterItems().size()); assertEquals(SCROLL_NO_WHERE, privateProfileManager.scrollForHeaderToBeVisibleInContainer( new AllAppsRecyclerView(mContext),