From 7313bc7800f4c6c713e2923ef9d97933ac2c3117 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Tue, 1 Aug 2023 14:18:52 -0700 Subject: [PATCH 1/2] Use window corner radius for desktop task snapshots Desktop task snapshots are shown inside the desktop tile in overview. They use the window corner radius, when shown on the desktop. Keep the same radius for the snapshots in overview. Only the desktop tile background should use the task corner radius. Bug: 280827930 Flag: persist.wm.debug.desktop_mode_2 Test: open some apps on desktop, swipe up for overview, observe the desktop task corner radius remains the same as when on desktop Change-Id: I55ced9f704b83a6c7619508aa3e7a8080ccc5c35 --- .../quickstep/views/DesktopTaskView.java | 19 ++++++++++++++++--- .../com/android/quickstep/views/TaskView.java | 14 +++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java index 1cfaf14224..83e99459ac 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.java +++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.java @@ -51,6 +51,7 @@ import com.android.quickstep.util.CancellableTask; import com.android.quickstep.util.RecentsOrientedState; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.ThumbnailData; +import com.android.systemui.shared.system.QuickStepContract; import java.util.ArrayList; import java.util.Arrays; @@ -79,7 +80,7 @@ public class DesktopTaskView extends TaskView { private static final String TAG = DesktopTaskView.class.getSimpleName(); - private static final boolean DEBUG = true; + private static final boolean DEBUG = false; @NonNull private List mTasks = new ArrayList<>(); @@ -91,6 +92,8 @@ public class DesktopTaskView extends TaskView { private final ArrayList> mPendingThumbnailRequests = new ArrayList<>(); + private final TaskView.FullscreenDrawParams mSnapshotDrawParams; + private View mBackgroundView; public DesktopTaskView(Context context) { @@ -103,6 +106,10 @@ public class DesktopTaskView extends TaskView { public DesktopTaskView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); + + mSnapshotDrawParams = new FullscreenDrawParams( + QuickStepContract.getWindowCornerRadius(context), + QuickStepContract.getWindowCornerRadius(context)); } @Override @@ -465,14 +472,20 @@ public class DesktopTaskView extends TaskView { for (int i = 0; i < mSnapshotViewMap.size(); i++) { TaskThumbnailView thumbnailView = mSnapshotViewMap.valueAt(i); thumbnailView.getTaskOverlay().setFullscreenProgress(progress); - updateSnapshotRadius(); } + updateSnapshotRadius(); } @Override protected void updateSnapshotRadius() { + super.updateSnapshotRadius(); for (int i = 0; i < mSnapshotViewMap.size(); i++) { - mSnapshotViewMap.valueAt(i).setFullscreenParams(mCurrentFullscreenParams); + if (i == 0) { + // All snapshots share the same params. Only update it with the first snapshot. + updateFullscreenParams(mSnapshotDrawParams, + mSnapshotView.getPreviewPositionHelper()); + } + mSnapshotViewMap.valueAt(i).setFullscreenParams(mSnapshotDrawParams); } } diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 6b0843ccf5..854c3c7218 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -1707,10 +1707,15 @@ public class TaskView extends FrameLayout implements Reusable { } void updateCurrentFullscreenParams(PreviewPositionHelper previewPositionHelper) { + updateFullscreenParams(mCurrentFullscreenParams, previewPositionHelper); + } + + protected void updateFullscreenParams(TaskView.FullscreenDrawParams fullscreenParams, + PreviewPositionHelper previewPositionHelper) { if (getRecentsView() == null) { return; } - mCurrentFullscreenParams.setProgress(mFullscreenProgress, getRecentsView().getScaleX(), + fullscreenParams.setProgress(mFullscreenProgress, getRecentsView().getScaleX(), getScaleX(), getWidth(), mActivity.getDeviceProfile(), previewPositionHelper); } @@ -1860,9 +1865,12 @@ public class TaskView extends FrameLayout implements Reusable { public float mCurrentDrawnCornerRadius; public FullscreenDrawParams(Context context) { - mCornerRadius = TaskCornerRadius.get(context); - mWindowCornerRadius = QuickStepContract.getWindowCornerRadius(context); + this(TaskCornerRadius.get(context), QuickStepContract.getWindowCornerRadius(context)); + } + FullscreenDrawParams(float cornerRadius, float windowCornerRadius) { + mCornerRadius = cornerRadius; + mWindowCornerRadius = windowCornerRadius; mCurrentDrawnCornerRadius = mCornerRadius; } From a163646c7ace74ec3a7931b2972f0ace4320a2a5 Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Fri, 4 Aug 2023 02:18:44 +0000 Subject: [PATCH 2/2] Revert "Make AllAppsRecyclerViewContainer GONE when hidden" This reverts commit df59c2e5352f9dd8c7cbfba480a3d886639b05a4. Reason for revert: b/293944420 Change-Id: I0ae830e1a5ba8affb6815c9e96ffee1b20c6e8d0 --- .../allapps/ActivityAllAppsContainerView.java | 54 ++++++------------- .../allapps/AllAppsRecyclerView.java | 15 +----- .../allapps/AllAppsTransitionController.java | 3 +- .../launcher3/anim/AlphaUpdateListener.java | 14 +---- .../launcher3/config/FeatureFlags.java | 9 +--- .../recyclerview/AllAppsRecyclerViewPool.kt | 17 ++---- .../launcher3/util/MultiValueAlpha.java | 9 +--- 7 files changed, 25 insertions(+), 96 deletions(-) diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 259c5cc553..4c86becfed 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -18,7 +18,6 @@ package com.android.launcher3.allapps; import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.SEARCH; import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_DISABLED_CARD; import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_EDU_CARD; -import static com.android.launcher3.config.FeatureFlags.ALL_APPS_GONE_VISIBILITY; import static com.android.launcher3.config.FeatureFlags.ENABLE_ALL_APPS_RV_PREINFLATION; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_COUNT; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB; @@ -552,14 +551,17 @@ public class ActivityAllAppsContainerView mAllAppsStore.unregisterIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView); mAllAppsStore.unregisterIconContainer(mAH.get(AdapterHolder.SEARCH).mRecyclerView); - final AllAppsRecyclerView mainRecyclerView; - final AllAppsRecyclerView workRecyclerView; if (mUsingTabs) { - mainRecyclerView = (AllAppsRecyclerView) mViewPager.getChildAt(0); - workRecyclerView = (AllAppsRecyclerView) mViewPager.getChildAt(1); - mAH.get(AdapterHolder.MAIN).setup(mainRecyclerView, mPersonalMatcher); - mAH.get(AdapterHolder.WORK).setup(workRecyclerView, mWorkManager.getMatcher()); - workRecyclerView.setId(R.id.apps_list_view_work); + mAH.get(AdapterHolder.MAIN).setup(mViewPager.getChildAt(0), mPersonalMatcher); + mAH.get(AdapterHolder.WORK).setup(mViewPager.getChildAt(1), mWorkManager.getMatcher()); + mAH.get(AdapterHolder.WORK).mRecyclerView.setId(R.id.apps_list_view_work); + if (ENABLE_ALL_APPS_RV_PREINFLATION.get()) { + // Let main and work rv share same view pool. + ((RecyclerView) mViewPager.getChildAt(0)) + .setRecycledViewPool(mAllAppsStore.getRecyclerViewPool()); + ((RecyclerView) mViewPager.getChildAt(1)) + .setRecycledViewPool(mAllAppsStore.getRecyclerViewPool()); + } if (FeatureFlags.ENABLE_EXPANDING_PAUSE_WORK_BUTTON.get()) { mAH.get(AdapterHolder.WORK).mRecyclerView.addOnScrollListener( mWorkManager.newScrollListener()); @@ -584,15 +586,13 @@ public class ActivityAllAppsContainerView onActivePageChanged(mViewPager.getNextPage()); } } else { - mainRecyclerView = findViewById(R.id.apps_list_view); - workRecyclerView = null; - mAH.get(AdapterHolder.MAIN).setup(mainRecyclerView, null); + mAH.get(AdapterHolder.MAIN).setup(findViewById(R.id.apps_list_view), null); mAH.get(AdapterHolder.WORK).mRecyclerView = null; + if (ENABLE_ALL_APPS_RV_PREINFLATION.get()) { + mAH.get(AdapterHolder.MAIN).mRecyclerView + .setRecycledViewPool(mAllAppsStore.getRecyclerViewPool()); + } } - setUpCustomRecyclerViewPool( - mainRecyclerView, - workRecyclerView, - mAllAppsStore.getRecyclerViewPool()); setupHeader(); if (isSearchBarFloating()) { @@ -609,30 +609,6 @@ public class ActivityAllAppsContainerView mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.SEARCH).mRecyclerView); } - /** - * If {@link ENABLE_ALL_APPS_RV_PREINFLATION} is enabled, wire custom - * {@link RecyclerView.RecycledViewPool} to main and work {@link AllAppsRecyclerView}. - * - * Then if {@link ALL_APPS_GONE_VISIBILITY} is enabled, update max pool size. This is because - * all apps rv's hidden visibility is changed to {@link View#GONE} from {@link View#INVISIBLE), - * thus we cannot rely on layout pass to update pool size. - */ - private static void setUpCustomRecyclerViewPool( - @NonNull AllAppsRecyclerView mainRecyclerView, - @Nullable AllAppsRecyclerView workRecyclerView, - @NonNull RecyclerView.RecycledViewPool recycledViewPool) { - if (!ENABLE_ALL_APPS_RV_PREINFLATION.get()) { - return; - } - mainRecyclerView.setRecycledViewPool(recycledViewPool); - if (workRecyclerView != null) { - workRecyclerView.setRecycledViewPool(recycledViewPool); - } - if (ALL_APPS_GONE_VISIBILITY.get()) { - mainRecyclerView.updatePoolSize(); - } - } - private void replaceAppsRVContainer(boolean showTabs) { for (int i = AdapterHolder.MAIN; i <= AdapterHolder.WORK; i++) { AdapterHolder adapterHolder = mAH.get(i); diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 7edbeac71f..602d1a38a5 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -15,7 +15,6 @@ */ package com.android.launcher3.allapps; -import static com.android.launcher3.config.FeatureFlags.ALL_APPS_GONE_VISIBILITY; 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_PERSONAL_SCROLLED_DOWN; @@ -27,8 +26,6 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORK_FAB_BUTTON_COLLAPSE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORK_FAB_BUTTON_EXTEND; -import static com.android.launcher3.recyclerview.AllAppsRecyclerViewPoolKt.EXTRA_ICONS_COUNT; -import static com.android.launcher3.recyclerview.AllAppsRecyclerViewPoolKt.PREINFLATE_ICONS_ROW_COUNT; import static com.android.launcher3.util.LogConfig.SEARCH_LOGGING; import android.content.Context; @@ -99,18 +96,8 @@ public class AllAppsRecyclerView extends FastScrollRecyclerView { int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx); pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, 1); pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER, 1); - - // If all apps' hidden visibility is INVISIBLE, we will need to preinflate one page of - // all apps icons for smooth scrolling. - int maxPoolSizeForAppIcons = (approxRows + 1) * grid.numShownAllAppsColumns; - if (ALL_APPS_GONE_VISIBILITY.get()) { - // If all apps' hidden visibility is GONE, we need to increase prefinated icons number - // by [PREINFLATE_ICONS_ROW_COUNT] rows + [EXTRA_ICONS_COUNT] for fast opening all apps. - maxPoolSizeForAppIcons += - PREINFLATE_ICONS_ROW_COUNT * grid.numShownAllAppsColumns + EXTRA_ICONS_COUNT; - } pool.setMaxRecycledViews( - AllAppsGridAdapter.VIEW_TYPE_ICON, maxPoolSizeForAppIcons); + AllAppsGridAdapter.VIEW_TYPE_ICON, (approxRows + 1) * grid.numShownAllAppsColumns); } @Override diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index c09a5b9d93..0d7b736cc8 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -438,8 +438,7 @@ public class AllAppsTransitionController mAppsView = appsView; mAppsView.setScrimView(scrimView); - mAppsViewAlpha = new MultiValueAlpha(mAppsView, APPS_VIEW_INDEX_COUNT, - FeatureFlags.ALL_APPS_GONE_VISIBILITY.get() ? View.GONE : View.INVISIBLE); + mAppsViewAlpha = new MultiValueAlpha(mAppsView, APPS_VIEW_INDEX_COUNT); mAppsViewAlpha.setUpdateVisibility(true); mAppsViewTranslationY = new MultiPropertyFactory<>( mAppsView, VIEW_TRANSLATE_Y, APPS_VIEW_INDEX_COUNT, Float::sum); diff --git a/src/com/android/launcher3/anim/AlphaUpdateListener.java b/src/com/android/launcher3/anim/AlphaUpdateListener.java index 4382174530..8dad1b4fa5 100644 --- a/src/com/android/launcher3/anim/AlphaUpdateListener.java +++ b/src/com/android/launcher3/anim/AlphaUpdateListener.java @@ -53,18 +53,8 @@ public class AlphaUpdateListener extends AnimatorListenerAdapter } public static void updateVisibility(View view) { - updateVisibility(view, View.INVISIBLE); - } - - /** - * Update view's visibility. - * - * @param view View that needs to update visibility. - * @param hiddenVisibility {@link View#GONE} or {@link View#INVISIBLE} - */ - public static void updateVisibility(View view, int hiddenVisibility) { - if (view.getAlpha() < ALPHA_CUTOFF_THRESHOLD && view.getVisibility() != hiddenVisibility) { - view.setVisibility(hiddenVisibility); + if (view.getAlpha() < ALPHA_CUTOFF_THRESHOLD && view.getVisibility() != View.INVISIBLE) { + view.setVisibility(View.INVISIBLE); } else if (view.getAlpha() > ALPHA_CUTOFF_THRESHOLD && view.getVisibility() != View.VISIBLE) { if (view instanceof ViewGroup) { diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 3989e7c4bb..e3e14009ee 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -395,15 +395,10 @@ public final class FeatureFlags { // TODO(Block 33): Clean up flags public static final BooleanFlag ENABLE_ALL_APPS_RV_PREINFLATION = getDebugFlag(288161355, - "ENABLE_ALL_APPS_RV_PREINFLATION", ENABLED, + "ENABLE_ALL_APPS_RV_PREINFLATION", DISABLED, "Enables preinflating all apps icons to avoid scrolling jank."); - // TODO(Block 34): Clean up flags - public static final BooleanFlag ALL_APPS_GONE_VISIBILITY = getDebugFlag(291651514, - "ALL_APPS_GONE_VISIBILITY", ENABLED, - "Set all apps container view's hidden visibility to GONE instead of INVISIBLE."); - - // TODO(Block 35): Empty block + // TODO(Block 34): Empty block public static class BooleanFlag { diff --git a/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt b/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt index 3c59c1d63f..26dde29d36 100644 --- a/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt +++ b/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt @@ -22,14 +22,13 @@ import androidx.recyclerview.widget.RecyclerView.RecycledViewPool import androidx.recyclerview.widget.RecyclerView.ViewHolder import com.android.launcher3.BubbleTextView import com.android.launcher3.allapps.BaseAllAppsAdapter -import com.android.launcher3.config.FeatureFlags import com.android.launcher3.util.Executors.MAIN_EXECUTOR import com.android.launcher3.util.Executors.VIEW_PREINFLATION_EXECUTOR import com.android.launcher3.views.ActivityContext import java.util.concurrent.Future -const val PREINFLATE_ICONS_ROW_COUNT = 4 -const val EXTRA_ICONS_COUNT = 2 +private const val PREINFLATE_ICONS_ROW_COUNT = 4 +private const val EXTRA_ICONS_COUNT = 2 /** * An [RecycledViewPool] that preinflates app icons ([ViewHolder] of [BubbleTextView]) of all apps @@ -82,21 +81,11 @@ class AllAppsRecyclerViewPool : RecycledViewPool() { * After testing on phone, foldable and tablet, we found [PREINFLATE_ICONS_ROW_COUNT] rows of * app icons plus [EXTRA_ICONS_COUNT] is the magic minimal count of app icons to preinflate to * suffice fast scrolling. - * - * Note that if [FeatureFlags.ALL_APPS_GONE_VISIBILITY] is enabled, we need to preinfate extra - * app icons in size of one all apps pages, so that opening all apps don't need to inflate app - * icons. */ fun getPreinflateCount(context: T): Int where T : Context, T : ActivityContext { - var targetPreinflateCount = + val targetPreinflateCount = PREINFLATE_ICONS_ROW_COUNT * context.deviceProfile.numShownAllAppsColumns + EXTRA_ICONS_COUNT - if (FeatureFlags.ALL_APPS_GONE_VISIBILITY.get()) { - val grid = ActivityContext.lookupContext(context).deviceProfile - val approxRows = - Math.ceil((grid.availableHeightPx / grid.allAppsIconSizePx).toDouble()).toInt() - targetPreinflateCount += (approxRows + 1) * grid.numShownAllAppsColumns - } val existingPreinflateCount = getRecycledViewCount(BaseAllAppsAdapter.VIEW_TYPE_ICON) return targetPreinflateCount - existingPreinflateCount } diff --git a/src/com/android/launcher3/util/MultiValueAlpha.java b/src/com/android/launcher3/util/MultiValueAlpha.java index a66a9d2d56..ac016a8595 100644 --- a/src/com/android/launcher3/util/MultiValueAlpha.java +++ b/src/com/android/launcher3/util/MultiValueAlpha.java @@ -32,15 +32,8 @@ public class MultiValueAlpha extends MultiPropertyFactory { // Whether we should change from INVISIBLE to VISIBLE and vice versa at low alpha values. private boolean mUpdateVisibility; - private final int mHiddenVisibility; - public MultiValueAlpha(View view, int size) { - this(view, size, View.INVISIBLE); - } - - public MultiValueAlpha(View view, int size, int hiddenVisibility) { super(view, VIEW_ALPHA, size, ALPHA_AGGREGATOR, 1f); - this.mHiddenVisibility = hiddenVisibility; } /** Sets whether we should update between INVISIBLE and VISIBLE based on alpha. */ @@ -52,7 +45,7 @@ public class MultiValueAlpha extends MultiPropertyFactory { protected void apply(float value) { super.apply(value); if (mUpdateVisibility) { - AlphaUpdateListener.updateVisibility(mTarget, mHiddenVisibility); + AlphaUpdateListener.updateVisibility(mTarget); } } }