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

Commit bf285015 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9772861 from 5b014860 to tm-qpr3-release

Change-Id: Iab0f3891377d4261833d2d3d2beb2a06a444438e
parents 696370df 5b014860
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -77,14 +77,13 @@ public class FallbackTaskbarUIController extends TaskbarUIController {

    /**
     * Creates an animation to animate the taskbar for the given state (but does not start it).
     * Currently this animation just force stashes the taskbar in Overview.
     */
    public Animator createAnimToRecentsState(RecentsState toState, long duration) {
        // Force stash the taskbar in overview modal state or when going home.
        boolean useStashedLauncherState =
                toState.hasOverviewActions() || toState == RecentsState.HOME;
        boolean stashedLauncherState = useStashedLauncherState && (
                (FeatureFlags.ENABLE_GRID_ONLY_OVERVIEW.get() && toState == RecentsState.MODAL_TASK)
                        || toState == RecentsState.HOME);
        boolean useStashedLauncherState = toState.hasOverviewActions();
        boolean stashedLauncherState =
                useStashedLauncherState && FeatureFlags.ENABLE_GRID_ONLY_OVERVIEW.get()
                        && toState == RecentsState.MODAL_TASK;
        TaskbarStashController stashController = mControllers.taskbarStashController;
        // Set both FLAG_IN_STASHED_LAUNCHER_STATE and FLAG_IN_APP to ensure the state is respected.
        // For all other states, just use the current stashed-in-app setting (e.g. if long clicked).
+20 −3
Original line number Diff line number Diff line
@@ -89,8 +89,22 @@ import java.util.StringJoiner;
    // We skip any view synchronizations during init/destroy.
    private boolean mCanSyncViews;

    private boolean mIsQsbInline;

    private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener =
            dp -> updateIconAlphaForHome(mIconAlphaForHome.getValue());
            new DeviceProfile.OnDeviceProfileChangeListener() {
                @Override
                public void onDeviceProfileChanged(DeviceProfile dp) {
                    if (mIsQsbInline && !dp.isQsbInline) {
                        // We only modify QSB alpha if isQsbInline = true. If we switch to a DP
                        // where isQsbInline = false, then we need to reset the alpha.
                        mLauncher.getHotseat().setQsbAlpha(1f);
                    }
                    mIsQsbInline = dp.isQsbInline;
                    TaskbarLauncherStateController.this.updateIconAlphaForHome(
                            mIconAlphaForHome.getValue());
                }
            };

    private final StateManager.StateListener<LauncherState> mStateListener =
            new StateManager.StateListener<LauncherState>() {
@@ -131,6 +145,8 @@ import java.util.StringJoiner;
        mControllers = controllers;
        mLauncher = launcher;

        mIsQsbInline = mLauncher.getDeviceProfile().isQsbInline;

        mTaskbarBackgroundAlpha = mControllers.taskbarDragLayerController
                .getTaskbarBackgroundAlpha();
        mTaskbarCornerRoundness = mControllers.getTaskbarCornerRoundness();
@@ -497,8 +513,9 @@ import java.util.StringJoiner;
                "updateIconAlphaForHome - setIconsAlpha(" + (hotseatVisible ? 1 : 0)
                        + "), isTaskbarPresent: " + mLauncher.getDeviceProfile().isTaskbarPresent);
        mLauncher.getHotseat().setIconsAlpha(hotseatVisible ? 1 : 0);
        mLauncher.getHotseat().setQsbAlpha(
                mLauncher.getDeviceProfile().isQsbInline && !hotseatVisible ? 0 : 1);
        if (mIsQsbInline) {
            mLauncher.getHotseat().setQsbAlpha(hotseatVisible ? 1 : 0);
        }
    }

    private final class TaskBarRecentsAnimationListener implements
+1 −4
Original line number Diff line number Diff line
@@ -184,7 +184,6 @@ public class TaskbarModelCallbacks implements
        int predictionSize = mPredictedItems.size();
        int predictionNextIndex = 0;

        boolean isHotseatEmpty = true;
        for (int i = 0; i < hotseatItemInfos.length; i++) {
            hotseatItemInfos[i] = mHotseatItems.get(i);
            if (hotseatItemInfos[i] == null && predictionNextIndex < predictionSize) {
@@ -192,13 +191,11 @@ public class TaskbarModelCallbacks implements
                hotseatItemInfos[i].screenId = i;
                predictionNextIndex++;
            }
            if (hotseatItemInfos[i] != null) {
                isHotseatEmpty = false;
            }
        }
        hotseatItemInfos = mControllers.taskbarRecentAppsController
                .updateHotseatItemInfos(hotseatItemInfos);
        mContainer.updateHotseatItems(hotseatItemInfos);
        mControllers.taskbarViewController.updateIconsBackground();
    }

    @Override
+0 −24
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.widget.FrameLayout;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;

import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
@@ -60,11 +59,8 @@ import java.util.function.Predicate;
public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconParent, Insettable {
    private static final String TAG = TaskbarView.class.getSimpleName();

    private static final float TASKBAR_BACKGROUND_LUMINANCE = 0.30f;
    private static final Rect sTmpRect = new Rect();

    public int mThemeIconsBackground;

    private final int[] mTempOutLocation = new int[2];
    private final Rect mIconLayoutBounds;
    private final int mIconTouchSize;
@@ -139,8 +135,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
        // Needed to draw folder leave-behind when opening one.
        setWillNotDraw(false);

        mThemeIconsBackground = calculateThemeIconsBackground();

        if (!mActivityContext.getPackageManager().hasSystemFeature(FEATURE_PC)) {
            mAllAppsButton = (IconButtonView) LayoutInflater.from(context)
                    .inflate(R.layout.taskbar_all_apps_button, this, false);
@@ -182,13 +176,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
                .sendAccessibilityEvent(TYPE_WINDOW_CONTENT_CHANGED);
    }

    private int getColorWithGivenLuminance(int color, float luminance) {
        float[] colorHSL = new float[3];
        ColorUtils.colorToHSL(color, colorHSL);
        colorHSL[2] = luminance;
        return ColorUtils.HSLToColor(colorHSL);
    }

    /**
     * Returns the icon touch size.
     */
@@ -196,14 +183,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
        return mIconTouchSize;
    }

    private int calculateThemeIconsBackground() {
        int color = ThemedIconDrawable.getColors(mContext)[0];
        if (Utilities.isDarkTheme(mContext)) {
            return getColorWithGivenLuminance(color, TASKBAR_BACKGROUND_LUMINANCE);
        }
        return color;
    }

    protected void init(TaskbarViewController.TaskbarViewCallbacks callbacks) {
        mControllerCallbacks = callbacks;
        mIconClickListener = mControllerCallbacks.getIconOnClickListener();
@@ -332,9 +311,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
            // Always set QSB to invisible after re-adding.
            mQsb.setVisibility(View.INVISIBLE);
        }

        mThemeIconsBackground = calculateThemeIconsBackground();
        setThemedIconsBackgroundColor(mThemeIconsBackground);
    }

    /**
+30 −14
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
    // This allows the icons on the edge to stay within the taskbar background bounds.
    private static final float ICON_REVEAL_X_DURATION_MULTIPLIER = 0.8f;

    private static final float TASKBAR_DARK_THEME_ICONS_BACKGROUND_LUMINANCE = 0.30f;

    private final TaskbarActivityContext mActivity;
    private final TaskbarView mTaskbarView;
    private final MultiValueAlpha mTaskbarIconAlpha;
@@ -107,13 +109,16 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar

    private final int mTaskbarBottomMargin;
    private final int mStashedHandleHeight;
    private final int mLauncherThemedIconsBackgroundColor;
    private final int mTaskbarThemedIconsBackgroundColor;

    private final AnimatedFloat mThemeIconsBackground = new AnimatedFloat(
    /** Progress from {@code 0} for Launcher's color to {@code 1} for Taskbar's color. */
    private final AnimatedFloat mThemedIconsBackgroundProgress = new AnimatedFloat(
            this::updateIconsBackground);

    private final TaskbarModelCallbacks mModelCallbacks;

    // Captures swipe down action to close transient taskbar.
    // Captures swipe down action to close transient Taskbar.
    protected @Nullable SingleAxisSwipeDetector mSwipeDownDetector;

    // Initialized in init.
@@ -124,7 +129,6 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
    private AnimatorPlaybackController mIconAlignControllerLazy = null;
    private Runnable mOnControllerPreCreateCallback = NO_OP;

    private int mThemeIconsColor;
    private boolean mIsHotseatIconOnTopWhenAligned;

    private final DeviceProfile.OnDeviceProfileChangeListener mDeviceProfileChangeListener =
@@ -141,6 +145,16 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
                : 0;
        mStashedHandleHeight = activity.getResources()
                .getDimensionPixelSize(R.dimen.taskbar_stashed_handle_height);
        mLauncherThemedIconsBackgroundColor = ThemedIconDrawable.getColors(mActivity)[0];
        if (!Utilities.isDarkTheme(mActivity)) {
            mTaskbarThemedIconsBackgroundColor = mLauncherThemedIconsBackgroundColor;
        } else {
            // Increase luminance for dark themed icons given they are on a dark Taskbar background.
            float[] colorHSL = new float[3];
            ColorUtils.colorToHSL(mLauncherThemedIconsBackgroundColor, colorHSL);
            colorHSL[2] = TASKBAR_DARK_THEME_ICONS_BACKGROUND_LUMINANCE;
            mTaskbarThemedIconsBackgroundColor = ColorUtils.HSLToColor(colorHSL);
        }

        if (DisplayController.isTransientTaskbar(mActivity)) {
            mSwipeDownDetector = new SingleAxisSwipeDetector(activity,
@@ -174,7 +188,6 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
        mTaskbarView.getLayoutParams().height = isPhoneMode(mActivity.getDeviceProfile())
                ? mActivity.getResources().getDimensionPixelSize(R.dimen.taskbar_size)
                : mActivity.getDeviceProfile().taskbarSize;
        mThemeIconsColor = ThemedIconDrawable.getColors(mTaskbarView.getContext())[0];

        mTaskbarIconScaleForStash.updateValue(1f);

@@ -213,7 +226,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
    }

    /**
     * Should be called when the recents button is disabled, so we can hide taskbar icons as well.
     * Should be called when the recents button is disabled, so we can hide Taskbar icons as well.
     */
    public void setRecentsButtonDisabled(boolean isDisabled) {
        // TODO: check TaskbarStashController#supportsStashing(), to stash instead of setting alpha.
@@ -228,7 +241,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
    }

    /**
     * Adds one time pre draw listener to the taskbar view, it is called before
     * Adds one time pre draw listener to the Taskbar view, it is called before
     * drawing a frame and invoked only once
     * @param listener callback that will be invoked before drawing the next frame
     */
@@ -284,12 +297,15 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
                + mTaskbarIconTranslationYForSwipe);
    }

    private void updateIconsBackground() {
    /**
     * Updates the Taskbar's themed icons background according to the progress between in-app/home.
     */
    protected void updateIconsBackground() {
        mTaskbarView.setThemedIconsBackgroundColor(
                ColorUtils.blendARGB(
                        mThemeIconsColor,
                        mTaskbarView.mThemeIconsBackground,
                        mThemeIconsBackground.value
                        mLauncherThemedIconsBackgroundColor,
                        mTaskbarThemedIconsBackgroundColor,
                        mThemedIconsBackgroundProgress.value
                ));
    }

@@ -347,7 +363,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
            // We look at 'left' and 'right' values to ensure that the children stay within the
            // bounds of the stashed handle.

            // All of the taskbar icons will overlap the entirety of the stashed handle
            // All of the Taskbar icons will overlap the entirety of the stashed handle
            // And the QSB, if inline, will overlap part of stashed handle as well.
            int positionInHandle = (isQsbInline && !isQsb)
                    ? i + (isRtl ? 1 : -1)
@@ -397,7 +413,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
    }

    /**
     * Sets the taskbar icon alignment relative to Launcher hotseat icons
     * Sets the Taskbar icon alignment relative to Launcher hotseat icons
     * @param alignmentRatio [0, 1]
     *                       0 => not aligned
     *                       1 => fully aligned
@@ -419,7 +435,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
    }

    /**
     * Creates an animation for aligning the taskbar icons with the provided Launcher device profile
     * Creates an animation for aligning the Taskbar icons with the provided Launcher device profile
     */
    private AnimatorPlaybackController createIconAlignmentController(DeviceProfile launcherDp) {
        mOnControllerPreCreateCallback.run();
@@ -444,7 +460,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
        setter.setFloat(mTaskbarNavButtonTranslationYForInAppDisplay, VALUE, offsetY, interpolator);

        if (Utilities.isDarkTheme(mTaskbarView.getContext())) {
            setter.addFloat(mThemeIconsBackground, VALUE, 0f, 1f, LINEAR);
            setter.addFloat(mThemedIconsBackgroundProgress, VALUE, 1f, 0f, LINEAR);
        }

        int collapsedHeight = mActivity.getDefaultTaskbarWindowHeight();
Loading