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

Commit 1d75081a authored by Alex Chau's avatar Alex Chau Committed by Android (Google) Code Review
Browse files

Merge "Apply PreviewPositionHelper matrix to TTV and Overlay" into main

parents 8c983e8d 893f4c6a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:importantForAccessibility="no"
        android:scaleType="matrix"
        android:visibility="gone"/>

    <com.android.quickstep.task.thumbnail.LiveTileView
+5 −1
Original line number Diff line number Diff line
@@ -184,6 +184,10 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
            return mTaskContainer.getTaskView();
        }

        public View getSnapshotView() {
            return mTaskContainer.getSnapshotView();
        }

        /**
         * Called when the current task is interactive for the user
         */
@@ -312,7 +316,7 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
            // the difference between the bitmap bounds and the projected view bounds.
            Matrix boundsToBitmapSpace = new Matrix();
            Matrix thumbnailMatrix = enableRefactorTaskThumbnail()
                    ? mHelper.getEnabledState().getThumbnailMatrix()
                    ? mHelper.getThumbnailMatrix()
                    : mTaskContainer.getThumbnailViewDeprecated().getThumbnailMatrix();
            thumbnailMatrix.invert(boundsToBitmapSpace);
            RectF boundsInBitmapSpace = new RectF();
+54 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.quickstep.recents.usecase

import android.graphics.Matrix
import android.graphics.Rect
import com.android.quickstep.recents.data.RecentTasksRepository
import com.android.quickstep.recents.data.RecentsDeviceProfileRepository
import com.android.quickstep.recents.data.RecentsRotationStateRepository
import com.android.quickstep.recents.usecase.ThumbnailPositionState.MatrixScaling
import com.android.quickstep.recents.usecase.ThumbnailPositionState.MissingThumbnail
import com.android.systemui.shared.recents.utilities.PreviewPositionHelper
import kotlinx.coroutines.flow.firstOrNull

/** Use case for retrieving [Matrix] for positioning Thumbnail in a View */
class GetThumbnailPositionUseCase(
    private val deviceProfileRepository: RecentsDeviceProfileRepository,
    private val rotationStateRepository: RecentsRotationStateRepository,
    private val tasksRepository: RecentTasksRepository,
    private val previewPositionHelper: PreviewPositionHelper = PreviewPositionHelper()
) {
    suspend fun run(taskId: Int, width: Int, height: Int, isRtl: Boolean): ThumbnailPositionState {
        val thumbnailData =
            tasksRepository.getThumbnailById(taskId).firstOrNull() ?: return MissingThumbnail
        val thumbnail = thumbnailData.thumbnail ?: return MissingThumbnail
        previewPositionHelper.updateThumbnailMatrix(
            Rect(0, 0, thumbnail.width, thumbnail.height),
            thumbnailData,
            width,
            height,
            deviceProfileRepository.getRecentsDeviceProfile().isLargeScreen,
            rotationStateRepository.getRecentsRotationState().activityRotation,
            isRtl
        )
        return MatrixScaling(
            previewPositionHelper.matrix,
            previewPositionHelper.isOrientationChanged
        )
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.quickstep.task.util
package com.android.quickstep.recents.usecase

import android.graphics.Bitmap
import com.android.quickstep.recents.data.RecentTasksRepository
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.quickstep.recents.usecase

import android.graphics.Matrix

/** State on how a task Thumbnail can fit on given canvas */
sealed class ThumbnailPositionState {
    data object MissingThumbnail : ThumbnailPositionState()

    data class MatrixScaling(val matrix: Matrix, val isRotated: Boolean) : ThumbnailPositionState()
}
Loading