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

Commit 9165c004 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I9ccb4335,I0d2f9be8 into sc-dev

* changes:
  Add OnComputeInsetsListener to TaskbarContainerView
  Use SYSTEM_APPLICATION_OVERLAY instead of SYSTEM_ALERT_WINDOW for Taskbar
parents 1508e062 734be0b5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@
    <uses-permission android:name="android.permission.MANAGE_ACCESSIBILITY"/>

    <uses-permission android:name="${packageName}.permission.HOTSEAT_EDU" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.SYSTEM_APPLICATION_OVERLAY" />

    <application android:backupAgent="com.android.launcher3.LauncherBackupAgent"
         android:fullBackupOnly="true"
+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();
    }
}
+3 −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();
@@ -218,6 +218,7 @@ public class TaskbarController {
        mWindowLayoutParams.setFitInsetsTypes(0);
        mWindowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
        mWindowLayoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
        mWindowLayoutParams.setSystemApplicationOverlay(true);

        WindowManagerWrapper wmWrapper = WindowManagerWrapper.getInstance();
        wmWrapper.setProvidesInsetsTypes(