Adds all_apps_sheet_for_handheld flag.

This flag causes All Apps to render on a background panel in
handheld mode similarly to how it does on tablets.

Demo: https://drive.google.com/file/d/11K8yueTb9Xr8oRJCM3TxcFH8V3rRFJrJ/view?usp=sharing&resourcekey=0-hMNEGzMQ5KC9D7may2Gb-g

Bug: 374186088
Bug: 372618421
Test: Manual
Flag: com.android.launcher3.all_apps_sheet_for_handheld
Change-Id: Ie0b1e784d4330fd71f7f36f39e5dd85e8ee14933
This commit is contained in:
Andy Wickham committed 2024-11-06 16:05:25 +00:00
1 parent 43da2538ff
commit 1f6a7b46be
8 files changed
+44 -70

No files matched your search

@@ -47,7 +47,6 @@ import android.os.Parcelable;
import android.os.Process;
import android.os.UserManager;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Log;
import android.util.SparseArray;
import android.view.KeyEvent;
@@ -115,19 +114,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
ScrimView.ScrimDrawingController {
public static final FloatProperty<ActivityAllAppsContainerView<?>> BOTTOM_SHEET_ALPHA =
new FloatProperty<>("bottomSheetAlpha") {
@Override
public Float get(ActivityAllAppsContainerView<?> containerView) {
return containerView.mBottomSheetAlpha;
}
@Override
public void setValue(ActivityAllAppsContainerView<?> containerView, float v) {
containerView.setBottomSheetAlpha(v);
}
};
public static final float PULL_MULTIPLIER = .02f;
public static final float FLING_VELOCITY_MULTIPLIER = 1200f;
protected static final String BUNDLE_KEY_CURRENT_PAGE = "launcher.allapps.current_page";
@@ -191,8 +177,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
private ScrimView mScrimView;
private int mHeaderColor;
private int mBottomSheetBackgroundColor;
private float mBottomSheetAlpha = 1f;
private boolean mForceBottomSheetVisible;
private int mTabsProtectionAlpha;
@Nullable private AllAppsTransitionController mAllAppsTransitionController;
@@ -351,20 +335,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
return mSearchUiManager;
}
public View getBottomSheetBackground() {
return mBottomSheetBackground;
}
/**
* Temporarily force the bottom sheet to be visible on non-tablets.
*
* @param force {@code true} means bottom sheet will be visible on phones until {@code reset()}.
*/
public void forceBottomSheetVisible(boolean force) {
mForceBottomSheetVisible = force;
updateBackgroundVisibility(mActivityContext.getDeviceProfile());
}
public View getSearchView() {
return mSearchContainer;
}
@@ -496,7 +466,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
if (mHeader != null && mHeader.getVisibility() == VISIBLE) {
mHeader.reset(animate);
}
forceBottomSheetVisible(false);
updateBackgroundVisibility(mActivityContext.getDeviceProfile());
// Reset the base recycler view after transitioning home.
updateHeaderScroll(0);
if (exitSearch) {
@@ -1002,18 +972,13 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
}
protected void updateBackgroundVisibility(DeviceProfile deviceProfile) {
boolean visible = deviceProfile.isTablet || mForceBottomSheetVisible;
mBottomSheetBackground.setVisibility(visible ? View.VISIBLE : View.GONE);
// Note: For tablets, the opaque background and header protection are added in drawOnScrim.
mBottomSheetBackground.setVisibility(
deviceProfile.shouldShowAllAppsOnSheet() ? View.VISIBLE : View.GONE);
// Note: The opaque sheet background and header protection are added in drawOnScrim.
// For the taskbar entrypoint, the scrim is drawn by its abstract slide in view container,
// so its header protection is derived from this scrim instead.
}
private void setBottomSheetAlpha(float alpha) {
// Bottom sheet alpha is always 1 for tablets.
mBottomSheetAlpha = mActivityContext.getDeviceProfile().isTablet ? 1f : alpha;
}
@VisibleForTesting
public void onAppsUpdated() {
mHasWorkApps = Stream.of(mAllAppsStore.getApps())
@@ -1151,8 +1116,8 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
applyAdapterSideAndBottomPaddings(grid);
MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
// Ignore left/right insets on tablet because we are already centered in-screen.
if (grid.isTablet) {
// Ignore left/right insets on bottom sheet because we are already centered in-screen.
if (grid.shouldShowAllAppsOnSheet()) {
mlp.leftMargin = mlp.rightMargin = 0;
} else {
mlp.leftMargin = insets.left;
@@ -1398,7 +1363,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
// Draw full background panel for tablets.
if (hasBottomSheet) {
mHeaderPaint.setColor(mBottomSheetBackgroundColor);
mHeaderPaint.setAlpha((int) (255 * mBottomSheetAlpha));
mHeaderPaint.setAlpha(255);
mTmpRectF.set(
leftWithScale,