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

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

Merge "Fixing sysui visibility changing multiple times on startup" into ub-launcher3-rvc-dev

parents 1eb6b2ac de52876a
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
import static com.android.launcher3.util.SystemUiController.UI_STATE_SCRIM_VIEW;

import android.content.Context;
import android.graphics.Canvas;
@@ -187,6 +188,7 @@ public class ShelfScrimView extends ScrimView<BaseQuickstepLauncher>
            mShelfTopAtThreshold = mShiftRange * SCRIM_CATCHUP_THRESHOLD + mTopOffset;
        }
        updateColors();
        updateSysUiColors();
        updateDragHandleAlpha();
        invalidate();
    }
@@ -240,6 +242,18 @@ public class ShelfScrimView extends ScrimView<BaseQuickstepLauncher>
        }
    }

    @Override
    protected void updateSysUiColors() {
        // Use a light system UI (dark icons) if all apps is behind at least half of the
        // status bar.
        boolean forceChange = mShelfTop <= mLauncher.getDeviceProfile().getInsets().top / 2f;
        if (forceChange) {
            mLauncher.getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, !mIsScrimDark);
        } else {
            mLauncher.getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, 0);
        }
    }

    @Override
    protected boolean shouldDragHandleBeVisible() {
        boolean needsAllAppsEdu = mIsTwoZoneSwipeModel
+0 −14
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FA
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_HEADER_FADE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE;
import static com.android.launcher3.states.StateAnimationConfig.ANIM_VERTICAL_PROGRESS;
import static com.android.launcher3.util.SystemUiController.UI_STATE_ALL_APPS;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -37,7 +36,6 @@ import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.statemanager.StateManager.StateHandler;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ScrimView;
import com.android.systemui.plugins.AllAppsSearchPlugin;
import com.android.systemui.plugins.PluginListener;
@@ -75,7 +73,6 @@ public class AllAppsTransitionController implements StateHandler<LauncherState>,
    private ScrimView mScrimView;

    private final Launcher mLauncher;
    private final boolean mIsDarkTheme;
    private boolean mIsVerticalLayout;

    // Animation in this class is controlled by a single variable {@link mProgress}.
@@ -98,7 +95,6 @@ public class AllAppsTransitionController implements StateHandler<LauncherState>,
        mShiftRange = mLauncher.getDeviceProfile().heightPx;
        mProgress = 1f;

        mIsDarkTheme = Themes.getAttrBoolean(mLauncher, R.attr.isMainColorDark);
        mIsVerticalLayout = mLauncher.getDeviceProfile().isVerticalBarLayout();
        mLauncher.addOnDeviceProfileChangeListener(this);
    }
@@ -137,16 +133,6 @@ public class AllAppsTransitionController implements StateHandler<LauncherState>,
        if (mPlugin != null) {
            mPlugin.setProgress(progress);
        }

        // Use a light system UI (dark icons) if all apps is behind at least half of the
        // status bar.
        boolean forceChange = Math.min(shiftCurrent, mScrimView.getVisualTop())
                <= mLauncher.getDeviceProfile().getInsets().top / 2f;
        if (forceChange) {
            mLauncher.getSystemUiController().updateUiState(UI_STATE_ALL_APPS, !mIsDarkTheme);
        } else {
            mLauncher.getSystemUiController().updateUiState(UI_STATE_ALL_APPS, 0);
        }
    }

    public float getProgress() {
+27 −14
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ public class SystemUiController {

    // Various UI states in increasing order of priority
    public static final int UI_STATE_BASE_WINDOW = 0;
    public static final int UI_STATE_ALL_APPS = 1;
    public static final int UI_STATE_SCRIM_VIEW = 1;
    public static final int UI_STATE_WIDGET_BOTTOM_SHEET = 2;
    public static final int UI_STATE_OVERVIEW = 3;

@@ -61,23 +61,36 @@ public class SystemUiController {
        // Apply the state flags in priority order
        int newFlags = oldFlags;
        for (int stateFlag : mStates) {
            newFlags = getSysUiVisibilityFlags(stateFlag, newFlags);
        }
        if (newFlags != oldFlags) {
            mWindow.getDecorView().setSystemUiVisibility(newFlags);
        }
    }

    /**
     * Returns the sysui visibility for the base layer
     */
    public int getBaseSysuiVisibility() {
        return getSysUiVisibilityFlags(
                mStates[UI_STATE_BASE_WINDOW], mWindow.getDecorView().getSystemUiVisibility());
    }

    private int getSysUiVisibilityFlags(int stateFlag, int currentVisibility) {
        if (Utilities.ATLEAST_OREO) {
            if ((stateFlag & FLAG_LIGHT_NAV) != 0) {
                    newFlags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
                currentVisibility |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
            } else if ((stateFlag & FLAG_DARK_NAV) != 0) {
                    newFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
                currentVisibility &= ~(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
            }
        }

        if ((stateFlag & FLAG_LIGHT_STATUS) != 0) {
                newFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
            currentVisibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        } else if ((stateFlag & FLAG_DARK_STATUS) != 0) {
                newFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            }
        }
        if (newFlags != oldFlags) {
            mWindow.getDecorView().setSystemUiVisibility(newFlags);
            currentVisibility &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }
        return currentVisibility;
    }

    @Override
+16 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.clampToProgress;
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
import static com.android.launcher3.util.SystemUiController.UI_STATE_SCRIM_VIEW;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -53,6 +54,7 @@ import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeL

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat;
@@ -77,7 +79,6 @@ import com.android.launcher3.widget.WidgetsFullSheet;

import java.util.List;


/**
 * Simple scrim which draws a flat color
 */
@@ -115,6 +116,7 @@ public class ScrimView<T extends Launcher> extends View implements Insettable, O
    private final WallpaperColorInfo mWallpaperColorInfo;
    private final AccessibilityManager mAM;
    protected final int mEndScrim;
    protected final boolean mIsScrimDark;

    private final StateListener<LauncherState> mAccessibilityLauncherStateListener =
            new StateListener<LauncherState>() {
@@ -156,6 +158,7 @@ public class ScrimView<T extends Launcher> extends View implements Insettable, O
        mLauncher = Launcher.cast(Launcher.getLauncher(context));
        mWallpaperColorInfo = WallpaperColorInfo.INSTANCE.get(context);
        mEndScrim = Themes.getAttrColor(context, R.attr.allAppsScrimColor);
        mIsScrimDark = ColorUtils.calculateLuminance(mEndScrim) < 0.5f;

        mMaxScrimAlpha = 0.7f;

@@ -233,6 +236,7 @@ public class ScrimView<T extends Launcher> extends View implements Insettable, O
            mProgress = progress;
            stopDragHandleEducationAnim();
            updateColors();
            updateSysUiColors();
            updateDragHandleAlpha();
            invalidate();
        }
@@ -245,6 +249,17 @@ public class ScrimView<T extends Launcher> extends View implements Insettable, O
                mEndFlatColor, Math.round((1 - mProgress) * mEndFlatColorAlpha));
    }

    protected void updateSysUiColors() {
        // Use a light system UI (dark icons) if all apps is behind at least half of the
        // status bar.
        boolean forceChange = mProgress <= 0.1f;
        if (forceChange) {
            mLauncher.getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, !mIsScrimDark);
        } else {
            mLauncher.getSystemUiController().updateUiState(UI_STATE_SCRIM_VIEW, 0);
        }
    }

    protected void updateDragHandleAlpha() {
        if (mDragHandle != null) {
            mDragHandle.setAlpha(mDragHandleAlpha);