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

Commit fa699566 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Adding an optional QSB in hotseat" into sc-dev

parents 74bd4f32 c373e1c6
Loading
Loading
Loading
Loading
+0 −8
Original line number Original line Diff line number Diff line
@@ -27,7 +27,6 @@ import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.BACKGROUND_APP;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
import static com.android.launcher3.anim.Interpolators.EXAGGERATED_EASE;
import static com.android.launcher3.anim.Interpolators.EXAGGERATED_EASE;
@@ -67,7 +66,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Nullable;


import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.shortcuts.DeepShortcutView;
@@ -148,9 +146,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
    public static final int CONTENT_ALPHA_DURATION = 217;
    public static final int CONTENT_ALPHA_DURATION = 217;
    protected static final int CONTENT_TRANSLATION_DURATION = 350;
    protected static final int CONTENT_TRANSLATION_DURATION = 350;


    // Progress = 0: All apps is fully pulled up, Progress = 1: All apps is fully pulled down.
    public static final float ALL_APPS_PROGRESS_OFF_SCREEN = 1.3059858f;

    private static final int MAX_NUM_TASKS = 5;
    private static final int MAX_NUM_TASKS = 5;


    protected final BaseQuickstepLauncher mLauncher;
    protected final BaseQuickstepLauncher mLauncher;
@@ -429,9 +424,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
                appsView.setLayerType(View.LAYER_TYPE_NONE, null);
                appsView.setLayerType(View.LAYER_TYPE_NONE, null);
            };
            };
        } else if (mLauncher.isInState(OVERVIEW)) {
        } else if (mLauncher.isInState(OVERVIEW)) {
            AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
            launcherAnimator.play(ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS,
                    allAppsController.getProgress(), ALL_APPS_PROGRESS_OFF_SCREEN));
            endListener = composeViewContentAnimator(launcherAnimator, alphas, trans);
            endListener = composeViewContentAnimator(launcherAnimator, alphas, trans);
        } else {
        } else {
            mDragLayerAlpha.setValue(alphas[0]);
            mDragLayerAlpha.setValue(alphas[0]);
+0 −10
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package com.android.launcher3.appprediction;
package com.android.launcher3.appprediction;


import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.ALL_APPS;


import android.annotation.TargetApi;
import android.annotation.TargetApi;
@@ -30,7 +29,6 @@ import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.View;
import android.view.View;
import android.view.animation.Interpolator;


import androidx.annotation.ColorInt;
import androidx.annotation.ColorInt;
import androidx.core.content.ContextCompat;
import androidx.core.content.ContextCompat;
@@ -41,7 +39,6 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.allapps.FloatingHeaderRow;
import com.android.launcher3.allapps.FloatingHeaderRow;
import com.android.launcher3.allapps.FloatingHeaderView;
import com.android.launcher3.allapps.FloatingHeaderView;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.statemanager.StateManager.StateListener;
import com.android.launcher3.statemanager.StateManager.StateListener;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.Themes;


@@ -286,13 +283,6 @@ public class AppsDividerView extends View implements StateListener<LauncherState
        setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
        setPadding(leftRightPadding, getPaddingTop(), leftRightPadding, getPaddingBottom());
    }
    }


    @Override
    public void setContentVisibility(boolean hasHeaderExtra, boolean hasAllAppsContent,
            PropertySetter setter, Interpolator headerFade, Interpolator allAppsFade) {
        // Don't use setViewAlpha as we want to control the visibility ourselves.
        setter.setFloat(this, VIEW_ALPHA, hasAllAppsContent ? 1 : 0, allAppsFade);
    }

    @Override
    @Override
    public void setVerticalScroll(int scroll, boolean isScrolledOut) {
    public void setVerticalScroll(int scroll, boolean isScrolledOut) {
        setTranslationY(scroll);
        setTranslationY(scroll);
+3 −92
Original line number Original line Diff line number Diff line
@@ -16,20 +16,14 @@


package com.android.launcher3.appprediction;
package com.android.launcher3.appprediction;


import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;

import android.annotation.TargetApi;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.Build;
import android.os.Build;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.util.IntProperty;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View;
import android.view.animation.Interpolator;
import android.widget.LinearLayout;
import android.widget.LinearLayout;


import androidx.annotation.NonNull;
import androidx.annotation.NonNull;
@@ -44,7 +38,6 @@ import com.android.launcher3.R;
import com.android.launcher3.allapps.FloatingHeaderRow;
import com.android.launcher3.allapps.FloatingHeaderRow;
import com.android.launcher3.allapps.FloatingHeaderView;
import com.android.launcher3.allapps.FloatingHeaderView;
import com.android.launcher3.anim.AlphaUpdateListener;
import com.android.launcher3.anim.AlphaUpdateListener;
import com.android.launcher3.anim.PropertySetter;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.keyboard.FocusIndicatorHelper;
import com.android.launcher3.keyboard.FocusIndicatorHelper;
import com.android.launcher3.keyboard.FocusIndicatorHelper.SimpleFocusIndicatorHelper;
import com.android.launcher3.keyboard.FocusIndicatorHelper.SimpleFocusIndicatorHelper;
@@ -53,8 +46,6 @@ import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.util.Themes;
import com.android.quickstep.AnimatedFloat;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.List;
@@ -63,22 +54,6 @@ import java.util.List;
public class PredictionRowView extends LinearLayout implements
public class PredictionRowView extends LinearLayout implements
        OnDeviceProfileChangeListener, FloatingHeaderRow {
        OnDeviceProfileChangeListener, FloatingHeaderRow {


    private static final IntProperty<PredictionRowView> TEXT_ALPHA =
            new IntProperty<PredictionRowView>("textAlpha") {
                @Override
                public void setValue(PredictionRowView view, int alpha) {
                    view.setTextAlpha(alpha);
                }

                @Override
                public Integer get(PredictionRowView view) {
                    return view.mIconLastSetTextAlpha;
                }
            };

    private static final Interpolator ALPHA_FACTOR_INTERPOLATOR =
            (t) -> (t < 0.8f) ? 0 : (t - 0.8f) / 0.2f;

    private final Launcher mLauncher;
    private final Launcher mLauncher;
    private int mNumPredictedAppsPerRow;
    private int mNumPredictedAppsPerRow;


@@ -88,21 +63,9 @@ public class PredictionRowView extends LinearLayout implements
    // The set of predicted apps resolved from the component names and the current set of apps
    // The set of predicted apps resolved from the component names and the current set of apps
    private final List<WorkspaceItemInfo> mPredictedApps = new ArrayList<>();
    private final List<WorkspaceItemInfo> mPredictedApps = new ArrayList<>();


    private final int mIconTextColor;
    private final int mIconFullTextAlpha;
    private int mIconLastSetTextAlpha;
    // Might use mIconFullTextAlpha instead of mIconLastSetTextAlpha if we are translucent.
    private int mIconCurrentTextAlpha;

    private FloatingHeaderView mParent;
    private FloatingHeaderView mParent;
    private boolean mScrolledOut;
    private boolean mScrolledOut;


    private float mScrollTranslation = 0;
    private final AnimatedFloat mContentAlphaFactor =
            new AnimatedFloat(this::updateTranslationAndAlpha);
    private final AnimatedFloat mOverviewScrollFactor =
            new AnimatedFloat(this::updateTranslationAndAlpha);

    private boolean mPredictionsEnabled = false;
    private boolean mPredictionsEnabled = false;


    @Nullable
    @Nullable
@@ -117,15 +80,9 @@ public class PredictionRowView extends LinearLayout implements
        setOrientation(LinearLayout.HORIZONTAL);
        setOrientation(LinearLayout.HORIZONTAL);


        mFocusHelper = new SimpleFocusIndicatorHelper(this);
        mFocusHelper = new SimpleFocusIndicatorHelper(this);

        mNumPredictedAppsPerRow = LauncherAppState.getIDP(context).numAllAppsColumns;
        mNumPredictedAppsPerRow = LauncherAppState.getIDP(context).numAllAppsColumns;
        mLauncher = Launcher.getLauncher(context);
        mLauncher = Launcher.getLauncher(context);
        mLauncher.addOnDeviceProfileChangeListener(this);
        mLauncher.addOnDeviceProfileChangeListener(this);

        mIconTextColor = Themes.getAttrColor(context, android.R.attr.textColorSecondary);
        mIconFullTextAlpha = Color.alpha(mIconTextColor);
        mIconCurrentTextAlpha = mIconFullTextAlpha;

        updateVisibility();
        updateVisibility();
    }
    }


@@ -246,7 +203,6 @@ public class PredictionRowView extends LinearLayout implements
        }
        }


        int predictionCount = mPredictedApps.size();
        int predictionCount = mPredictedApps.size();
        int iconColor = setColorAlphaBound(mIconTextColor, mIconCurrentTextAlpha);


        for (int i = 0; i < getChildCount(); i++) {
        for (int i = 0; i < getChildCount(); i++) {
            BubbleTextView icon = (BubbleTextView) getChildAt(i);
            BubbleTextView icon = (BubbleTextView) getChildAt(i);
@@ -254,7 +210,6 @@ public class PredictionRowView extends LinearLayout implements
            if (predictionCount > i) {
            if (predictionCount > i) {
                icon.setVisibility(View.VISIBLE);
                icon.setVisibility(View.VISIBLE);
                icon.applyFromWorkspaceItem(mPredictedApps.get(i));
                icon.applyFromWorkspaceItem(mPredictedApps.get(i));
                icon.setTextColor(iconColor);
            } else {
            } else {
                icon.setVisibility(predictionCount == 0 ? GONE : INVISIBLE);
                icon.setVisibility(predictionCount == 0 ? GONE : INVISIBLE);
            }
            }
@@ -269,27 +224,6 @@ public class PredictionRowView extends LinearLayout implements
        mParent.onHeightUpdated();
        mParent.onHeightUpdated();
    }
    }


    public void setTextAlpha(int textAlpha) {
        mIconLastSetTextAlpha = textAlpha;
        if (getAlpha() < 1 && textAlpha > 0) {
            // If the entire header is translucent, make sure the text is at full opacity so it's
            // not double-translucent. However, we support keeping the text invisible (alpha == 0).
            textAlpha = mIconFullTextAlpha;
        }
        mIconCurrentTextAlpha = textAlpha;
        int iconColor = setColorAlphaBound(mIconTextColor, mIconCurrentTextAlpha);
        for (int i = 0; i < getChildCount(); i++) {
            ((BubbleTextView) getChildAt(i)).setTextColor(iconColor);
        }
    }

    @Override
    public void setAlpha(float alpha) {
        super.setAlpha(alpha);
        // Reapply text alpha so that we update it to be full alpha if the row is now translucent.
        setTextAlpha(mIconLastSetTextAlpha);
    }

    @Override
    @Override
    public boolean hasOverlappingRendering() {
    public boolean hasOverlappingRendering() {
        return false;
        return false;
@@ -299,35 +233,12 @@ public class PredictionRowView extends LinearLayout implements
    @Override
    @Override
    public void setVerticalScroll(int scroll, boolean isScrolledOut) {
    public void setVerticalScroll(int scroll, boolean isScrolledOut) {
        mScrolledOut = isScrolledOut;
        mScrolledOut = isScrolledOut;
        updateTranslationAndAlpha();
        if (!isScrolledOut) {
        if (!isScrolledOut) {
            mScrollTranslation = scroll;
            setTranslationY(scroll);
            updateTranslationAndAlpha();
        }
        }
    }
        setAlpha(mScrolledOut ? 0 : 1);

    private void updateTranslationAndAlpha() {
        if (mPredictionsEnabled) {
            setTranslationY((1 - mOverviewScrollFactor.value) * mScrollTranslation);

            float factor = ALPHA_FACTOR_INTERPOLATOR.getInterpolation(mOverviewScrollFactor.value);
            float endAlpha = factor + (1 - factor) * (mScrolledOut ? 0 : 1);
            setAlpha(mContentAlphaFactor.value * endAlpha);
        AlphaUpdateListener.updateVisibility(this);
        AlphaUpdateListener.updateVisibility(this);
    }
    }
    }

    @Override
    public void setContentVisibility(boolean hasHeaderExtra, boolean hasAllAppsContent,
            PropertySetter setter, Interpolator headerFade, Interpolator allAppsFade) {
        // Text follows all apps visibility
        int textAlpha = hasHeaderExtra && hasAllAppsContent ? mIconFullTextAlpha : 0;
        setter.setInt(this, TEXT_ALPHA, textAlpha, allAppsFade);
        setter.setFloat(mOverviewScrollFactor, AnimatedFloat.VALUE,
                (hasHeaderExtra && !hasAllAppsContent) ? 1 : 0, LINEAR);
        setter.setFloat(mContentAlphaFactor, AnimatedFloat.VALUE, hasHeaderExtra ? 1 : 0,
                headerFade);
    }


    @Override
    @Override
    public void setInsets(Rect insets, DeviceProfile grid) {
    public void setInsets(Rect insets, DeviceProfile grid) {
+6 −1
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@ import androidx.annotation.Nullable;


import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.BaseQuickstepLauncher;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Hotseat;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.QuickstepTransitionManager;
import com.android.launcher3.QuickstepTransitionManager;
@@ -470,8 +471,12 @@ public class TaskbarController {
     */
     */
    public void alignRealHotseatWithTaskbar() {
    public void alignRealHotseatWithTaskbar() {
        Rect hotseatBounds = new Rect();
        Rect hotseatBounds = new Rect();
        DeviceProfile grid = mLauncher.getDeviceProfile();
        int hotseatHeight = grid.workspacePadding.bottom + grid.getInsets().bottom;
        int hotseatTopDiff = hotseatHeight - grid.taskbarSize;

        mTaskbarView.getHotseatBoundsAtScale(getTaskbarScaleOnHome()).roundOut(hotseatBounds);
        mTaskbarView.getHotseatBoundsAtScale(getTaskbarScaleOnHome()).roundOut(hotseatBounds);
        mLauncher.getHotseat().setPadding(hotseatBounds.left, hotseatBounds.top,
        mLauncher.getHotseat().setPadding(hotseatBounds.left, hotseatBounds.top + hotseatTopDiff,
                mTaskbarView.getWidth() - hotseatBounds.right,
                mTaskbarView.getWidth() - hotseatBounds.right,
                mTaskbarView.getHeight() - hotseatBounds.bottom);
                mTaskbarView.getHeight() - hotseatBounds.bottom);
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -234,7 +234,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
    @Override
    @Override
    public void onDestroy() {
    public void onDestroy() {
        super.onDestroy();
        super.onDestroy();
        getAppsView().getSearchUiManager().destroy();
        getAppsView().getSearchUiManager().destroySearch();
        mHotseatPredictionController.destroy();
        mHotseatPredictionController.destroy();
    }
    }


Loading