Merge "Add Repository for RecentOrientedState and DeviceProfile" into main

This commit is contained in:
Treehugger Robot
2024-07-17 12:25:09 +00:00
committed by Android (Google) Code Review
6 changed files with 174 additions and 9 deletions
@@ -0,0 +1,36 @@
/*
* 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.data
import com.android.quickstep.views.RecentsViewContainer
/**
* Repository for shrink down version of [com.android.launcher3.DeviceProfile] that only contains
* data related to Recents.
*/
class RecentsDeviceProfileRepository(private val container: RecentsViewContainer) {
fun getRecentsDeviceProfile() =
with(container.deviceProfile) { RecentsDeviceProfile(isLargeScreen = isTablet) }
/**
* Container to hold [com.android.launcher3.DeviceProfile] related to Recents.
*
* @property isLargeScreen whether the current device posture has a large screen
*/
data class RecentsDeviceProfile(val isLargeScreen: Boolean)
}
@@ -0,0 +1,35 @@
/*
* 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.data
import com.android.quickstep.util.RecentsOrientedState
/**
* Repository for [RecentsRotationState] which holds orientation/rotation related information
* related to Recents
*/
class RecentsRotationStateRepository(private val state: RecentsOrientedState) {
fun getRecentsRotationState() =
with(state) { RecentsRotationState(activityRotation = recentsActivityRotation) }
/**
* Container to hold orientation/rotation related information related to Recents.
*
* @property activityRotation rotation of the activity hosting RecentsView
*/
data class RecentsRotationState(val activityRotation: Int)
}
@@ -191,6 +191,8 @@ import com.android.quickstep.TaskViewUtils;
import com.android.quickstep.TopTaskTracker;
import com.android.quickstep.ViewUtils;
import com.android.quickstep.orientation.RecentsPagedOrientationHandler;
import com.android.quickstep.recents.data.RecentsDeviceProfileRepository;
import com.android.quickstep.recents.data.RecentsRotationStateRepository;
import com.android.quickstep.recents.data.TasksRepository;
import com.android.quickstep.recents.viewmodel.RecentsViewData;
import com.android.quickstep.util.ActiveGestureErrorDetector;
@@ -465,6 +467,10 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
public final RecentsViewData mRecentsViewData = new RecentsViewData();
@Nullable
public final TasksRepository mTasksRepository;
@Nullable
public final RecentsRotationStateRepository mOrientedStateRepository;
@Nullable
public final RecentsDeviceProfileRepository mDeviceProfileRepository;
protected final RecentsOrientedState mOrientationState;
protected final BaseContainerInterface<STATE_TYPE, CONTAINER_TYPE> mSizeStrategy;
@@ -822,8 +828,12 @@ public abstract class RecentsView<CONTAINER_TYPE extends Context & RecentsViewCo
if (enableRefactorTaskThumbnail()) {
mTasksRepository = new TasksRepository(
mModel, mModel.getThumbnailCache(), mModel.getIconCache());
mOrientedStateRepository = new RecentsRotationStateRepository(mOrientationState);
mDeviceProfileRepository = new RecentsDeviceProfileRepository(mContainer);
} else {
mTasksRepository = null;
mOrientedStateRepository = null;
mDeviceProfileRepository = null;
}
mClearAllButton = (ClearAllButton) LayoutInflater.from(context)