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

Commit c06e151e authored by Govinda Wasserman's avatar Govinda Wasserman
Browse files

Makes Launcher hide the all apps content and scrim on assistant visible.

This hides the quick search bar and the suggested apps. Visibility is
unchanged when the all apps view is fully expanded.

Test: Tested locally
Change-Id: I6bc453b5ad89ca3d1280957e595bf2a3f074a72d
BUG:129755311
FIX:129755311
(cherry picked from commit 917af755)
parent e7cb1fca
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
    public void onAssistantVisibilityChanged(float visibility) {
        Launcher launcher = getCreatedActivity();
        if (launcher != null) {
            launcher.setQuickSearchBarAlpha(1f - visibility);
            launcher.onAssistantVisibilityChanged(visibility);
        }
    }

+47 −9
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_SNACKBAR;
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW_PEEK;
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_LAUNCHER_LOAD;
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
import static com.android.launcher3.logging.LoggerUtils.newTarget;
@@ -128,6 +130,7 @@ import com.android.launcher3.util.UiThreadHelper;
import com.android.launcher3.util.ViewOnDrawExecutor;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.OptionsPopupView;
import com.android.launcher3.views.ScrimView;
import com.android.launcher3.widget.LauncherAppWidgetHostView;
import com.android.launcher3.widget.PendingAddShortcutInfo;
import com.android.launcher3.widget.PendingAddWidgetInfo;
@@ -147,6 +150,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.function.Predicate;

import androidx.annotation.IdRes;
import androidx.annotation.Nullable;

/**
@@ -202,6 +206,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
    private static final int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5;
    @Thunk static final int NEW_APPS_ANIMATION_DELAY = 500;

    private static final int APPS_VIEW_ALPHA_CHANNEL_INDEX = 1;
    private static final int SCRIM_VIEW_ALPHA_CHANNEL_INDEX = 0;

    private LauncherAppTransitionManager mAppTransitionManager;
    private Configuration mOldConfig;

@@ -223,6 +230,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
    @Thunk AllAppsContainerView mAppsView;
    AllAppsTransitionController mAllAppsController;

    // Scrim view for the all apps and overview state.
    @Thunk ScrimView mScrimView;

    // UI and state for the overview panel
    private View mOverviewPanel;

@@ -261,6 +271,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
    final Handler mHandler = new Handler();
    private final Runnable mHandleDeferredResume = this::handleDeferredResume;

    private float mCurrentAssistantVisibility = 0f;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        RaceConditionTracker.onEvent(ON_CREATE_EVT, ENTER);
@@ -361,6 +373,24 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,

        TraceHelper.endSection("Launcher-onCreate");
        RaceConditionTracker.onEvent(ON_CREATE_EVT, EXIT);
        mStateManager.addStateListener(new LauncherStateManager.StateListener() {
            @Override
            public void onStateTransitionStart(LauncherState toState) {}

            @Override
            public void onStateTransitionComplete(LauncherState finalState) {
                float alpha = 1f - mCurrentAssistantVisibility;
                if (finalState == NORMAL) {
                    mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
                } else if (finalState == OVERVIEW || finalState == OVERVIEW_PEEK) {
                    mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
                    mScrimView.getAlphaProperty(SCRIM_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
                } else {
                    mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(1f);
                    mScrimView.getAlphaProperty(SCRIM_VIEW_ALPHA_CHANNEL_INDEX).setValue(1f);
                }
            }
        });
    }

    @Override
@@ -407,13 +437,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        onIdpChanged(idp);
    }

    public void setQuickSearchBarAlpha(float alpha) {
        View qsbAllApps = findViewById(R.id.search_container_all_apps);
        if (qsbAllApps != null) {
            qsbAllApps.setAlpha(alpha);
        }
    }

    private void onIdpChanged(InvariantDeviceProfile idp) {
        mUserEventDispatcher = null;

@@ -426,6 +449,18 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        rebindModel();
    }

    public void onAssistantVisibilityChanged(float visibility) {
        mCurrentAssistantVisibility = visibility;
        float alpha = 1f - visibility;
        LauncherState state = mStateManager.getState();
        if (state == NORMAL) {
            mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
        } else if (state == OVERVIEW || state == OVERVIEW_PEEK) {
            mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
            mScrimView.getAlphaProperty(SCRIM_VIEW_ALPHA_CHANNEL_INDEX).setValue(alpha);
        }
    }

    private void initDeviceProfile(InvariantDeviceProfile idp) {
        // Load configuration-specific DeviceProfile
        mDeviceProfile = idp.getDeviceProfile(this);
@@ -968,6 +1003,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
        // Setup Apps
        mAppsView = findViewById(R.id.apps_view);

        // Setup Scrim
        mScrimView = findViewById(R.id.scrim_view);

        // Setup the drag controller (drop targets have to be added in reverse order in priority)
        mDragController.setMoveTarget(mWorkspace);
        mDropTargetBar.setup(mDragController);
@@ -1639,7 +1677,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
    public int getCurrentState() {
        if(mStateManager.getState() == LauncherState.ALL_APPS) {
            return StatsLogUtils.LAUNCHER_STATE_ALLAPPS;
        } else if (mStateManager.getState() == LauncherState.OVERVIEW) {
        } else if (mStateManager.getState() == OVERVIEW) {
            return StatsLogUtils.LAUNCHER_STATE_OVERVIEW;
        }
        return StatsLogUtils.LAUNCHER_STATE_HOME;
@@ -1657,7 +1695,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
            LauncherState state = mStateManager.getState();
            if (state == LauncherState.ALL_APPS) {
                event.srcTarget[2].containerType = ContainerType.ALLAPPS;
            } else if (state == LauncherState.OVERVIEW) {
            } else if (state == OVERVIEW) {
                event.srcTarget[2].containerType = ContainerType.TASKSWITCHER;
            }
        }
+11 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.BottomUserEducationView;
import com.android.launcher3.views.RecyclerViewFastScroller;
@@ -70,6 +72,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
    private static final float FLING_VELOCITY_MULTIPLIER = 135f;
    // Starts the springs after at least 55% of the animation has passed.
    private static final float FLING_ANIMATION_THRESHOLD = 0.55f;
    private static final int ALPHA_CHANNEL_COUNT = 2;

    private final Launcher mLauncher;
    private final AdapterHolder[] mAH;
@@ -93,6 +96,8 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
    private RecyclerViewFastScroller mTouchHandler;
    private final Point mFastScrollerOffset = new Point();

    private final MultiValueAlpha mMultiValueAlpha;

    public AllAppsContainerView(Context context) {
        this(context, null);
    }
@@ -122,12 +127,18 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
        addSpringView(R.id.all_apps_header);
        addSpringView(R.id.apps_list_view);
        addSpringView(R.id.all_apps_tabs_view_pager);

        mMultiValueAlpha = new MultiValueAlpha(this, ALPHA_CHANNEL_COUNT);
    }

    public AllAppsStore getAppsStore() {
        return mAllAppsStore;
    }

    public AlphaProperty getAlphaProperty(int index) {
        return mMultiValueAlpha.getProperty(index);
    }

    @Override
    protected void setDampedScrollShift(float shift) {
        // Bound the shift amount to avoid content from drawing on top (Y-val) of the QSB.
+4 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.SpringObjectAnimator;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ScrimView;

@@ -64,6 +65,8 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
        }
    };

    private static final int APPS_VIEW_ALPHA_CHANNEL_INDEX = 0;

    private AllAppsContainerView mAppsView;
    private ScrimView mScrimView;

@@ -102,7 +105,7 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
        setScrollRangeDelta(mScrollRangeDelta);

        if (mIsVerticalLayout) {
            mAppsView.setAlpha(1);
            mAppsView.getAlphaProperty(APPS_VIEW_ALPHA_CHANNEL_INDEX).setValue(1);
            mLauncher.getHotseat().setTranslationY(0);
            mLauncher.getWorkspace().getPageIndicator().setTranslationY(0);
        }
+10 −0
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.uioverrides.WallpaperColorInfo.OnChangeListener;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
import com.android.launcher3.util.Themes;

import java.util.List;
@@ -92,6 +94,7 @@ public class ScrimView extends View implements Insettable, OnChangeListener,
    private static final int WALLPAPERS = R.string.wallpaper_button_text;
    private static final int WIDGETS = R.string.widget_button_text;
    private static final int SETTINGS = R.string.settings_button_text;
    private static final int ALPHA_CHANNEL_COUNT = 1;

    private final Rect mTempRect = new Rect();
    private final int[] mTempPos = new int[2];
@@ -115,6 +118,8 @@ public class ScrimView extends View implements Insettable, OnChangeListener,
    private final Rect mDragHandleBounds;
    private final RectF mHitRect = new RectF();

    private final MultiValueAlpha mMultiValueAlpha;

    private final AccessibilityHelper mAccessibilityHelper;
    @Nullable
    protected Drawable mDragHandle;
@@ -138,6 +143,11 @@ public class ScrimView extends View implements Insettable, OnChangeListener,

        mAM = (AccessibilityManager) context.getSystemService(ACCESSIBILITY_SERVICE);
        setFocusable(false);
        mMultiValueAlpha = new MultiValueAlpha(this, ALPHA_CHANNEL_COUNT);
    }

    public AlphaProperty getAlphaProperty(int index) {
        return mMultiValueAlpha.getProperty(index);
    }

    @NonNull