Merge "Add Repository for RecentOrientedState and DeviceProfile" into main
This commit is contained in:
commit
c2a36a6fcd
6 files changed
+174
-9
No files matched your search
@@ -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)
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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 androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.android.launcher3.FakeInvariantDeviceProfileTest
|
||||
import com.android.quickstep.views.RecentsViewContainer
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
/** Test for [RecentsDeviceProfileRepository] */
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class RecentsDeviceProfileRepositoryTest : FakeInvariantDeviceProfileTest() {
|
||||
private val recentsViewContainer = mock<RecentsViewContainer>()
|
||||
|
||||
private val systemUnderTest = RecentsDeviceProfileRepository(recentsViewContainer)
|
||||
|
||||
@Test
|
||||
fun deviceProfileMappedCorrectly() {
|
||||
initializeVarsForTablet()
|
||||
val tabletDeviceProfile = newDP()
|
||||
whenever(recentsViewContainer.deviceProfile).thenReturn(tabletDeviceProfile)
|
||||
|
||||
assertThat(systemUnderTest.getRecentsDeviceProfile())
|
||||
.isEqualTo(RecentsDeviceProfileRepository.RecentsDeviceProfile(isLargeScreen = true))
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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 android.view.Surface.ROTATION_90
|
||||
import com.android.quickstep.util.RecentsOrientedState
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Test
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.whenever
|
||||
|
||||
/** Test for [RecentsRotationStateRepository] */
|
||||
class RecentsRotationStateRepositoryTest {
|
||||
private val recentsOrientedState = mock<RecentsOrientedState>()
|
||||
|
||||
private val systemUnderTest = RecentsRotationStateRepository(recentsOrientedState)
|
||||
|
||||
@Test
|
||||
fun orientedStateMappedCorrectly() {
|
||||
whenever(recentsOrientedState.recentsActivityRotation).thenReturn(ROTATION_90)
|
||||
|
||||
assertThat(systemUnderTest.getRecentsRotationState())
|
||||
.isEqualTo(
|
||||
RecentsRotationStateRepository.RecentsRotationState(activityRotation = ROTATION_90)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -47,14 +47,13 @@ import org.mockito.kotlin.whenever
|
||||
abstract class FakeInvariantDeviceProfileTest {
|
||||
|
||||
protected lateinit var context: Context
|
||||
protected var inv: InvariantDeviceProfile? = null
|
||||
protected val info: Info = mock()
|
||||
protected var windowBounds: WindowBounds? = null
|
||||
protected var isMultiWindowMode: Boolean = false
|
||||
protected var transposeLayoutWithOrientation: Boolean = false
|
||||
protected var useTwoPanels: Boolean = false
|
||||
protected var isGestureMode: Boolean = true
|
||||
protected var isTransientTaskbar: Boolean = true
|
||||
protected lateinit var inv: InvariantDeviceProfile
|
||||
protected val info = mock<Info>()
|
||||
protected lateinit var windowBounds: WindowBounds
|
||||
private var transposeLayoutWithOrientation = false
|
||||
private var useTwoPanels = false
|
||||
private var isGestureMode = true
|
||||
private var isTransientTaskbar = true
|
||||
|
||||
@Rule @JvmField val limitDevicesRule = LimitDevicesRule()
|
||||
|
||||
@@ -73,7 +72,7 @@ abstract class FakeInvariantDeviceProfileTest {
|
||||
info,
|
||||
windowBounds,
|
||||
SparseArray(),
|
||||
isMultiWindowMode,
|
||||
/*isMultiWindowMode=*/ false,
|
||||
transposeLayoutWithOrientation,
|
||||
useTwoPanels,
|
||||
isGestureMode,
|
||||
|
||||
Reference in new issue
Block a user