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

Commit e19c572a authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Hook up luma sampling state change from CommandQueue" into main

parents 0a1c916f cf5407df
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.launcher3.taskbar;

import static android.view.Display.DEFAULT_DISPLAY;

import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN;

import android.animation.Animator;
@@ -83,6 +85,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT

    // States that affect whether region sampling is enabled or not
    private boolean mIsStashed;
    private boolean mIsLumaSamplingEnabled;
    private boolean mTaskbarHidden;

    private float mTranslationYForSwipe;
@@ -234,8 +237,21 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
    /** Called when taskbar is stashed or unstashed. */
    public void onIsStashedChanged() {
        mIsStashed = isStashedHandleVisible();
        updateSamplingState();
    }

    public void onNavigationBarLumaSamplingEnabled(int displayId, boolean enable) {
        if (DEFAULT_DISPLAY != displayId) {
            return;
        }

        mIsLumaSamplingEnabled = enable;
        updateSamplingState();
    }

    private void updateSamplingState() {
        updateRegionSamplingWindowVisibility();
        if (mIsStashed) {
        if (shouldSample()) {
            mStashedHandleView.updateSampledRegion(mStashedHandleBounds);
            mRegionSamplingHelper.start(mStashedHandleView.getSampledRegion());
        } else {
@@ -243,6 +259,10 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
        }
    }

    private boolean shouldSample() {
        return mIsStashed && mIsLumaSamplingEnabled;
    }

    protected void updateStashedHandleHintScale() {
        mStashedHandleView.setScaleX(mTaskbarStashedHandleHintScale.value);
        mStashedHandleView.setScaleY(mTaskbarStashedHandleHintScale.value);
@@ -282,7 +302,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
    }

    private void updateRegionSamplingWindowVisibility() {
        mRegionSamplingHelper.setWindowVisible(mIsStashed && !mTaskbarHidden);
        mRegionSamplingHelper.setWindowVisible(shouldSample() && !mTaskbarHidden);
    }

    public boolean isStashedHandleVisible() {
+7 −0
Original line number Diff line number Diff line
@@ -377,6 +377,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        onSystemBarAttributesChanged(sharedState.systemBarAttrsDisplayId,
                sharedState.systemBarAttrsBehavior);
        onNavButtonsDarkIntensityChanged(sharedState.navButtonsDarkIntensity);
        onNavigationBarLumaSamplingEnabled(sharedState.mLumaSamplingDisplayId,
                sharedState.mIsLumaSamplingEnabled);

        if (ENABLE_TASKBAR_NAVBAR_UNIFICATION) {
            // W/ the flag not set this entire class gets re-created, which resets the value of
@@ -845,6 +847,11 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                .updateValue(darkIntensity);
    }

    public void onNavigationBarLumaSamplingEnabled(int displayId, boolean enable) {
        mControllers.stashedHandleViewController.onNavigationBarLumaSamplingEnabled(displayId,
                enable);
    }

    /**
     * Called to update a {@link AutohideSuspendFlag} with a new value.
     */
+8 −0
Original line number Diff line number Diff line
@@ -540,6 +540,14 @@ public class TaskbarManager {
        }
    }

    public void onNavigationBarLumaSamplingEnabled(int displayId, boolean enable) {
        mSharedState.mLumaSamplingDisplayId = displayId;
        mSharedState.mIsLumaSamplingEnabled = enable;
        if (mTaskbarActivityContext != null) {
            mTaskbarActivityContext.onNavigationBarLumaSamplingEnabled(displayId, enable);
        }
    }

    private void removeActivityCallbacksAndListeners() {
        if (mActivity != null) {
            mActivity.removeOnDeviceProfileChangeListener(mDebugActivityDeviceProfileChanged);
+4 −0
Original line number Diff line number Diff line
@@ -52,6 +52,10 @@ public class TaskbarSharedState {
    // TaskbarManager#onNavButtonsDarkIntensityChanged()
    public float navButtonsDarkIntensity;

    // TaskbarManager#onNavigationBarLumaSamplingEnabled()
    public int mLumaSamplingDisplayId;
    public boolean mIsLumaSamplingEnabled;

    public boolean setupUIVisible = false;

    public boolean allAppsVisible = false;
+6 −0
Original line number Diff line number Diff line
@@ -372,6 +372,12 @@ public class TouchInteractionService extends Service {
                    taskbarManager.onNavButtonsDarkIntensityChanged(darkIntensity));
        }

        @Override
        public void onNavigationBarLumaSamplingEnabled(int displayId, boolean enable) {
            executeForTaskbarManager(taskbarManager ->
                    taskbarManager.onNavigationBarLumaSamplingEnabled(displayId, enable));
        }

        private void executeForTouchInteractionService(
                @NonNull Consumer<TouchInteractionService> tisConsumer) {
            TouchInteractionService tis = mTis.get();