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

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

Merge "Enable variable size thumbnail for large screen" into sc-dev

parents e263a445 7944ee5c
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.touch.BaseSwipeDetector;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.touch.SingleAxisSwipeDetector;
@@ -150,9 +151,11 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
                        mTaskBeingDragged = view;
                        int upDirection = mRecentsView.getPagedOrientationHandler()
                                .getUpDirection(mIsRtl);
                        if (!SysUINavigationMode.getMode(mActivity).hasGestures) {
                        if (!SysUINavigationMode.getMode(mActivity).hasGestures || (
                                mActivity.getDeviceProfile().isTablet
                                        && FeatureFlags.ENABLE_OVERVIEW_GRID.get())) {
                            // Don't allow swipe down to open if we don't support swipe up
                            // to enter overview.
                            // to enter overview, or when grid layout is enabled.
                            directionsToDetectScroll = upDirection;
                            mAllowGoingUp = true;
                            mAllowGoingDown = false;
+6 −3
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.statemanager.StateManager;
@@ -174,11 +175,13 @@ public final class TaskViewUtils {

        final RecentsView recentsView = v.getRecentsView();
        int taskIndex = recentsView.indexOfChild(v);
        boolean parallaxCenterAndAdjacentTask = taskIndex != recentsView.getCurrentPage();
        int startScroll = recentsView.getScrollOffset(taskIndex);

        Context context = v.getContext();
        DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
        boolean parallaxCenterAndAdjacentTask =
                taskIndex != recentsView.getCurrentPage() && !(dp.isTablet
                        && FeatureFlags.ENABLE_OVERVIEW_GRID.get());
        int startScroll = recentsView.getScrollOffset(taskIndex);

        TaskViewSimulator topMostSimulator = null;

        if (tsv == null && targets.apps.length > 0) {
+3 −2
Original line number Diff line number Diff line
@@ -276,8 +276,9 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
            int start = mOrientationState.getOrientationHandler()
                    .getPrimaryValue(mTaskRect.left, mTaskRect.top);
            mScrollState.screenCenter = start + mScrollState.scroll + mScrollState.halfPageSize;
            mScrollState.updateInterpolation(start);
            mCurveScale = TaskView.getCurveScaleForInterpolation(mScrollState.linearInterpolation);
            mScrollState.updateInterpolation(mDp, start);
            mCurveScale = TaskView.getCurveScaleForInterpolation(mDp,
                    mScrollState.linearInterpolation);
        }

        float progress = Utilities.boundToRange(fullScreenProgress.value, 0, 1);
+73 −10
Original line number Diff line number Diff line
@@ -898,9 +898,14 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
    public void setFullscreenProgress(float fullscreenProgress) {
        mFullscreenProgress = fullscreenProgress;
        int taskCount = getTaskViewCount();
        float accumulatedTranslationX = 0;
        for (int i = 0; i < taskCount; i++) {
            getTaskViewAt(i).setFullscreenProgress(mFullscreenProgress);
            TaskView taskView = getTaskViewAt(i);
            taskView.setFullscreenProgress(mFullscreenProgress);
            taskView.setAccumulatedTranslationX(accumulatedTranslationX);
            accumulatedTranslationX += taskView.getFullscreenTranslationX();
        }

        // Fade out the actions view quickly (0.1 range)
        mActionsView.getFullscreenAlpha().setValue(
                mapToRange(fullscreenProgress, 0, 0.1f, 1f, 0f, LINEAR));
@@ -934,6 +939,11 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
        setPadding(mTempRect.left - mInsets.left, mTempRect.top - mInsets.top,
                dp.widthPx - mInsets.right - mTempRect.right,
                dp.heightPx - mInsets.bottom - mTempRect.bottom);
        // Force TaskView to update size from thumbnail
        final int taskCount = getTaskViewCount();
        for (int i = 0; i < taskCount; i++) {
            getTaskViewAt(i).updateTaskSize();
        }
    }

    public void getTaskSize(Rect outRect) {
@@ -942,6 +952,11 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
        mLastComputedTaskSize.set(outRect);
    }

    /** Gets the last computed task size */
    public Rect getLastComputedTaskSize() {
        return mLastComputedTaskSize;
    }

    /** Gets the task size for modal state. */
    public void getModalTaskSize(Rect outRect) {
        mSizeStrategy.calculateModalTaskSize(mActivity, mActivity.getDeviceProfile(), outRect);
@@ -987,7 +1002,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
        final int pageCount = getPageCount();
        for (int i = 0; i < pageCount; i++) {
            View page = getPageAt(i);
            mScrollState.updateInterpolation(
            mScrollState.updateInterpolation(mActivity.getDeviceProfile(),
                    mOrientationHandler.getChildStartWithTranslation(page));
            ((PageCallbacks) page).onPageScroll(mScrollState);
        }
@@ -1422,13 +1437,13 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
        /**
         * Updates linearInterpolation for the provided child position
         */
        public void updateInterpolation(float childStart) {
        public void updateInterpolation(DeviceProfile deviceProfile, float childStart) {
            float pageCenter = childStart + halfPageSize;
            float distanceFromScreenCenter = screenCenter - pageCenter;
            // How far the page has to move from the center to be offscreen, taking into account
            // the EDGE_SCALE_DOWN_FACTOR that will be applied at that position.
            float distanceToReachEdge = halfScreenSize
                    + halfPageSize * (1 - TaskView.EDGE_SCALE_DOWN_FACTOR);
                    + halfPageSize * (1 - TaskView.getEdgeScaleDownFactor(deviceProfile));
            linearInterpolation = Math.min(1,
                    Math.abs(distanceFromScreenCenter) / distanceToReachEdge);
        }
@@ -1444,12 +1459,13 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
        }
    }

    private void addDismissedTaskAnimations(View taskView, long duration, PendingAnimation anim) {
    private void addDismissedTaskAnimations(TaskView taskView, long duration,
            PendingAnimation anim) {
        // Use setFloat instead of setViewAlpha as we want to keep the view visible even when it's
        // alpha is set to 0 so that it can be recycled in the view pool properly
        anim.setFloat(taskView, VIEW_ALPHA, 0, ACCEL_2);
        FloatProperty<View> secondaryViewTranslate =
            mOrientationHandler.getSecondaryViewTranslate();
        FloatProperty<TaskView> secondaryViewTranslate =
                taskView.getDismissTaskTranslationProperty();
        int secondaryTaskDimension = mOrientationHandler.getSecondaryDimension(taskView);
        int verticalFactor = mOrientationHandler.getSecondaryTranslationDirectionFactor();

@@ -1515,7 +1531,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
                int scrollDiff = newScroll[i] - oldScroll[i] + offset;
                if (scrollDiff != 0) {
                    FloatProperty translationProperty = child instanceof TaskView
                            ? ((TaskView) child).getPrimaryFillDismissGapTranslationProperty()
                            ? ((TaskView) child).getFillDismissGapTranslationProperty()
                            : mOrientationHandler.getPrimaryViewTranslate();

                    ResourceProvider rp = DynamicResource.provider(mActivity);
@@ -1971,7 +1987,8 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
        // Find the task's scale based on its offscreen progress, then see how far it still needs to
        // move to be completely offscreen.
        Utilities.scaleRectFAboutCenter(taskPosition,
                TaskView.getCurveScaleForInterpolation(centerToOffscreenProgress));
                TaskView.getCurveScaleForInterpolation(mActivity.getDeviceProfile(),
                        centerToOffscreenProgress));
        distanceToOffscreen = desiredLeft - taskPosition.left;
        // Finally, we need to account for RecentsView scale, because it moves tasks based on its
        // pivot. To do this, we move the task position to where it would be offscreen at scale = 1
@@ -1990,7 +2007,7 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
        mTaskViewsSecondaryTranslation = translation;
        for (int i = 0; i < getTaskViewCount(); i++) {
            TaskView task = getTaskViewAt(i);
            mOrientationHandler.getSecondaryViewTranslate().set(task, translation / getScaleY());
            task.getTaskResistanceTranslationProperty().set(task, translation / getScaleY());
        }
        mLiveTileTaskViewSimulator.recentsViewSecondaryTranslation.value = translation;
    }
@@ -2358,6 +2375,52 @@ public abstract class RecentsView<T extends StatefulActivity> extends PagedView
        return super.computeMinScroll();
    }

    @Override
    protected boolean getPageScrolls(int[] outPageScrolls, boolean layoutChildren,
            ComputePageScrollsLogic scrollLogic) {
        boolean pageScrollChanged = super.getPageScrolls(outPageScrolls, layoutChildren,
                scrollLogic);

        final int taskCount = getTaskViewCount();
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            if (childCount < mTaskViewStartIndex) {
                continue;
            }

            final TaskView taskView = getTaskViewAt(
                    Utilities.boundToRange(i, mTaskViewStartIndex, taskCount - 1));
            float scrollDiff =
                    taskView.getFullscreenTranslationX() + taskView.getAccumulatedTranslationX();
            if (scrollDiff != 0) {
                outPageScrolls[i] += scrollDiff;
                pageScrollChanged = true;
            }
        }
        return pageScrollChanged;
    }

    @Override
    protected int getChildOffset(int index) {
        if (index < mTaskViewStartIndex) {
            return super.getChildOffset(index);
        }

        final TaskView taskView = getTaskViewAt(
                Utilities.boundToRange(index, mTaskViewStartIndex, getTaskViewCount() - 1));
        return super.getChildOffset(index) + (int) taskView.getFullscreenTranslationX()
                + (int) taskView.getAccumulatedTranslationX();
    }

    @Override
    protected int getChildVisibleSize(int index) {
        final TaskView taskView = getTaskViewAtByAbsoluteIndex(index);
        if (taskView == null) {
            return super.getChildVisibleSize(index);
        }
        return super.getChildVisibleSize(index) - (int) taskView.getFullscreenTranslationX();
    }

    @Override
    protected int computeMaxScroll() {
        if (getTaskViewCount() > 0) {
+33 −2
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.SystemUiController;
@@ -110,6 +111,9 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
    private boolean mOverlayEnabled;
    private OverviewScreenshotActions mOverviewScreenshotActionsPlugin;

    // TODO(b/179466077): Remove when proper API is ready.
    private Float mThumbnailRatio = null;

    public TaskThumbnailView(Context context) {
        this(context, null);
    }
@@ -450,6 +454,31 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
        return mThumbnailData.isRealSnapshot;
    }

    // TODO(b/179466077): Remove when proper API is ready.
    public float getThumbnailRatio() {
        // API is ready.
        if (mThumbnailRatio != null) {
            return mThumbnailRatio;
        }

        if (mThumbnailData == null || mThumbnailData.thumbnail == null) {
            final float[] thumbnailRatios =
                    new float[]{0.8882452f, 1.2834098f, 0.5558415f, 2.15625f};
            // Use key's hash code to return a deterministic thumbnail ratio.
            mThumbnailRatio = thumbnailRatios[mTask.key.hashCode() % thumbnailRatios.length];
            return mThumbnailRatio;
        }

        float surfaceWidth = mThumbnailData.thumbnail.getWidth() / mThumbnailData.scale;
        float surfaceHeight = mThumbnailData.thumbnail.getHeight() / mThumbnailData.scale;
        float availableWidth = surfaceWidth
                - (mThumbnailData.insets.left + mThumbnailData.insets.right);
        float availableHeight = surfaceHeight
                - (mThumbnailData.insets.top + mThumbnailData.insets.bottom);
        mThumbnailRatio = availableWidth / availableHeight;
        return mThumbnailRatio;
    }

    /**
     * Utility class to position the thumbnail in the TaskView
     */
@@ -480,9 +509,11 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
            float scale = thumbnailData.scale;
            final float thumbnailScale;

            // Landscape vs portrait change
            // Landscape vs portrait change.
            // Note: Disable rotation in grid layout.
            boolean windowingModeSupportsRotation = !dp.isMultiWindowMode
                    && thumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN;
                    && thumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN
                    && !(dp.isTablet && FeatureFlags.ENABLE_OVERVIEW_GRID.get());
            isOrientationDifferent = isOrientationChange(deltaRotate)
                    && windowingModeSupportsRotation;
            if (canvasWidth == 0 || canvasHeight == 0 || scale == 0) {
Loading