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

Commit 734be0b5 authored by Tony Wickham's avatar Tony Wickham
Browse files

Add OnComputeInsetsListener to TaskbarContainerView

Instead of updating visibility of TaskbarContainerView, keep it
VISIBLE but with alpha 0, and update touchableInsets to allow
touches to pass through. This avoids sending insets changed
when Taskbar is hidden.

Test: Swipe to Overview, no jumping/jank due to insets change;
also tap where Taskbar would be and ensure it doesn't launch

Bug: 171917176
Change-Id: I9ccb4335e0301f34eec459657f3bbaf88b0d8a52
parent 63fc59b8
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -15,6 +15,9 @@
 */
package com.android.launcher3.taskbar;

import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_FRAME;
import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
@@ -22,10 +25,18 @@ import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.anim.AlphaUpdateListener;
import com.android.systemui.shared.system.ViewTreeObserverWrapper;

/**
 * Top-level ViewGroup that hosts the TaskbarView as well as Views created by it such as Folder.
 */
public class TaskbarContainerView extends FrameLayout {

    // Initialized in init.
    private TaskbarView mTaskbarView;
    private ViewTreeObserverWrapper.OnComputeInsetsListener mTaskbarInsetsComputer;

    public TaskbarContainerView(@NonNull Context context) {
        this(context, null);
    }
@@ -43,4 +54,41 @@ public class TaskbarContainerView extends FrameLayout {
            int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    protected void init(TaskbarView taskbarView) {
        mTaskbarView = taskbarView;
        mTaskbarInsetsComputer = createTaskbarInsetsComputer();
    }

    private ViewTreeObserverWrapper.OnComputeInsetsListener createTaskbarInsetsComputer() {
        return insetsInfo -> {
            if (getAlpha() < AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD) {
                // We're invisible, let touches pass through us.
                insetsInfo.touchableRegion.setEmpty();
                insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
            } else {
                 // We're visible again, accept touches anywhere in our bounds.
                insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_FRAME);
            }
        };
    }

    protected void cleanup() {
        ViewTreeObserverWrapper.removeOnComputeInsetsListener(mTaskbarInsetsComputer);
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();

        ViewTreeObserverWrapper.addOnComputeInsetsListener(getViewTreeObserver(),
                mTaskbarInsetsComputer);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();

        cleanup();
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.QuickstepAppTransitionManagerImpl;
import com.android.launcher3.R;
import com.android.launcher3.anim.AlphaUpdateListener;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.states.StateAnimationConfig;
@@ -107,7 +106,6 @@ public class TaskbarController {
            @Override
            public void updateTaskbarVisibilityAlpha(float alpha) {
                mTaskbarContainerView.setAlpha(alpha);
                AlphaUpdateListener.updateVisibility(mTaskbarContainerView);
            }
        };
    }
@@ -167,6 +165,7 @@ public class TaskbarController {
    public void init() {
        mTaskbarView.init(mHotseatController.getNumHotseatIcons(),
                mRecentsController.getNumRecentIcons());
        mTaskbarContainerView.init(mTaskbarView);
        addToWindowManager();
        mTaskbarStateHandler.setTaskbarCallbacks(createTaskbarStateHandlerCallbacks());
        mTaskbarVisibilityController.init();
@@ -188,6 +187,7 @@ public class TaskbarController {
     */
    public void cleanup() {
        mTaskbarView.cleanup();
        mTaskbarContainerView.cleanup();
        removeFromWindowManager();
        mTaskbarStateHandler.setTaskbarCallbacks(null);
        mTaskbarVisibilityController.cleanup();