mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
Format files with the upcoming version of ktfmt
This CL was generated automatically from the following command: $ external/ktfmt/prepare_upgrade.py --repo=packages/apps/Launcher3/ --build_id=9645412 --bug_id=266197805 This CL formats all files already correctly formatted with the upcoming version of ktfmt. Bug: 266197805 Test: Presubmits Change-Id: Ide7d63a75fed98aabe348821355356c77f00a9ec Merged-In: Ide7d63a75fed98aabe348821355356c77f00a9ec
This commit is contained in:
@@ -32,8 +32,8 @@ import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource
|
||||
import com.android.launcher3.views.ActivityContext
|
||||
|
||||
/**
|
||||
* Shortcut to allow starting split. Default interaction for [onClick] is to launch
|
||||
* split selection mode
|
||||
* Shortcut to allow starting split. Default interaction for [onClick] is to launch split selection
|
||||
* mode
|
||||
*/
|
||||
abstract class SplitShortcut<T>(
|
||||
iconResId: Int,
|
||||
|
||||
@@ -79,6 +79,7 @@ class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
|
||||
|
||||
/**
|
||||
* Sets the roundness of the round corner above Taskbar. No effect on transient Taskkbar.
|
||||
*
|
||||
* @param cornerRoundness 0 has no round corner, 1 has complete round corner.
|
||||
*/
|
||||
fun setCornerRoundness(cornerRoundness: Float) {
|
||||
|
||||
@@ -51,8 +51,11 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
||||
onTaskbarWindowHeightOrInsetsChanged()
|
||||
}
|
||||
private val gestureNavSettingsObserver =
|
||||
GestureNavigationSettingsObserver(context.mainThreadHandler, context,
|
||||
this::onTaskbarWindowHeightOrInsetsChanged)
|
||||
GestureNavigationSettingsObserver(
|
||||
context.mainThreadHandler,
|
||||
context,
|
||||
this::onTaskbarWindowHeightOrInsetsChanged
|
||||
)
|
||||
|
||||
// Initialized in init.
|
||||
private lateinit var controllers: TaskbarControllers
|
||||
@@ -71,13 +74,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
||||
ITYPE_LEFT_GESTURES,
|
||||
ITYPE_RIGHT_GESTURES,
|
||||
),
|
||||
intArrayOf(
|
||||
SOURCE_FRAME,
|
||||
SOURCE_FRAME,
|
||||
SOURCE_FRAME,
|
||||
SOURCE_DISPLAY,
|
||||
SOURCE_DISPLAY
|
||||
)
|
||||
intArrayOf(SOURCE_FRAME, SOURCE_FRAME, SOURCE_FRAME, SOURCE_DISPLAY, SOURCE_DISPLAY)
|
||||
)
|
||||
|
||||
onTaskbarWindowHeightOrInsetsChanged()
|
||||
@@ -102,7 +99,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
||||
)
|
||||
val contentHeight = controllers.taskbarStashController.contentHeightToReportToApps
|
||||
val tappableHeight = controllers.taskbarStashController.tappableHeightToReportToApps
|
||||
val res = context.resources;
|
||||
val res = context.resources
|
||||
for (provider in windowLayoutParams.providedInsets) {
|
||||
if (
|
||||
provider.type == ITYPE_EXTRA_NAVIGATION_BAR ||
|
||||
@@ -157,6 +154,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
||||
|
||||
/**
|
||||
* @return [Insets] where the [bottomInset] is either used as a bottom inset or
|
||||
*
|
||||
* ```
|
||||
* right/left inset if using 3 button nav
|
||||
* ```
|
||||
@@ -174,20 +172,25 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
||||
|
||||
/**
|
||||
* Sets {@param providesInsetsTypes} as the inset types provided by {@param params}.
|
||||
*
|
||||
* @param params The window layout params.
|
||||
* @param providesInsetsTypes The inset types we would like this layout params to provide.
|
||||
*/
|
||||
fun setProvidesInsetsTypes(params: WindowManager.LayoutParams, providesInsetsTypes: IntArray,
|
||||
providesInsetsSources: IntArray) {
|
||||
fun setProvidesInsetsTypes(
|
||||
params: WindowManager.LayoutParams,
|
||||
providesInsetsTypes: IntArray,
|
||||
providesInsetsSources: IntArray
|
||||
) {
|
||||
params.providedInsets = arrayOfNulls<InsetsFrameProvider>(providesInsetsTypes.size)
|
||||
for (i in providesInsetsTypes.indices) {
|
||||
params.providedInsets[i] = InsetsFrameProvider(providesInsetsTypes[i],
|
||||
providesInsetsSources[i], null, null)
|
||||
params.providedInsets[i] =
|
||||
InsetsFrameProvider(providesInsetsTypes[i], providesInsetsSources[i], null, null)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to update the touchable insets.
|
||||
*
|
||||
* @see InternalInsetsInfo.setTouchableInsets
|
||||
*/
|
||||
fun updateInsetsTouchability(insetsInfo: ViewTreeObserver.InternalInsetsInfo) {
|
||||
|
||||
@@ -35,7 +35,7 @@ private const val TEMP_BACKGROUND_WINDOW_TITLE = "VoiceInteractionTaskbarBackgro
|
||||
* Controls Taskbar behavior while Voice Interaction Window (assistant) is showing. Specifically:
|
||||
* - We always hide the taskbar icons or stashed handle, whichever is currently showing.
|
||||
* - For persistent taskbar, we also move the taskbar background to a new window/layer
|
||||
* (TYPE_APPLICATION_OVERLAY) which is behind the assistant.
|
||||
* (TYPE_APPLICATION_OVERLAY) which is behind the assistant.
|
||||
* - For transient taskbar, we hide the real taskbar background (if it's showing).
|
||||
*/
|
||||
class VoiceInteractionWindowController(val context: TaskbarActivityContext) :
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonL
|
||||
*
|
||||
* @property navButtonContainer ViewGroup that holds the 3 navigation buttons.
|
||||
* @property endContextualContainer ViewGroup that holds the end contextual button (ex, IME
|
||||
* dismiss).
|
||||
* dismiss).
|
||||
* @property startContextualContainer ViewGroup that holds the start contextual button (ex, A11y).
|
||||
*/
|
||||
abstract class AbstractNavButtonLayoutter(
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.android.launcher3.logging.InstanceId
|
||||
object LogUtils {
|
||||
/**
|
||||
* @return a [Pair] of two InstanceIds but with different types, one that can be used by
|
||||
* framework (if needing to pass through an intent or such) and one used in Launcher
|
||||
* framework (if needing to pass through an intent or such) and one used in Launcher
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getShellShareableInstanceId(): Pair<com.android.internal.logging.InstanceId, InstanceId> {
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.mockito.ArgumentCaptor
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.times
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations.initMocks
|
||||
import org.mockito.Mockito.`when` as whenever
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@@ -37,10 +36,8 @@ class FallbackTaskbarUIControllerTest : TaskbarBaseTestCase() {
|
||||
lateinit var fallbackTaskbarUIController: FallbackTaskbarUIController
|
||||
lateinit var stateListener: StateManager.StateListener<RecentsState>
|
||||
|
||||
@Mock
|
||||
lateinit var recentsActivity: RecentsActivity
|
||||
@Mock
|
||||
lateinit var stateManager: StateManager<RecentsState>
|
||||
@Mock lateinit var recentsActivity: RecentsActivity
|
||||
@Mock lateinit var stateManager: StateManager<RecentsState>
|
||||
|
||||
@Before
|
||||
override fun setup() {
|
||||
@@ -80,4 +77,4 @@ class FallbackTaskbarUIControllerTest : TaskbarBaseTestCase() {
|
||||
// verify split selection enabled
|
||||
verify(taskbarPopupController, times(1)).setAllowInitialSplitSelection(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ import com.android.launcher3.util.withArgCaptor
|
||||
import com.android.quickstep.RecentsModel
|
||||
import com.android.quickstep.SystemUiProxy
|
||||
import com.android.systemui.shared.recents.model.Task
|
||||
import java.util.ArrayList
|
||||
import java.util.function.Consumer
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
@@ -44,9 +46,6 @@ import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
import java.util.ArrayList
|
||||
import java.util.function.Consumer
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class SplitSelectStateControllerTest {
|
||||
@@ -64,34 +63,48 @@ class SplitSelectStateControllerTest {
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
splitSelectStateController = SplitSelectStateController(context, handler,
|
||||
stateManager, depthController, statsLogManager, systemUiProxy, recentsModel)
|
||||
splitSelectStateController =
|
||||
SplitSelectStateController(
|
||||
context,
|
||||
handler,
|
||||
stateManager,
|
||||
depthController,
|
||||
statsLogManager,
|
||||
systemUiProxy,
|
||||
recentsModel
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun activeTasks_noMatchingTasks() {
|
||||
val groupTask1 = generateGroupTask(
|
||||
val groupTask1 =
|
||||
generateGroupTask(
|
||||
ComponentName("pomegranate", "juice"),
|
||||
ComponentName("pumpkin", "pie"))
|
||||
val groupTask2 = generateGroupTask(
|
||||
ComponentName("pumpkin", "pie")
|
||||
)
|
||||
val groupTask2 =
|
||||
generateGroupTask(
|
||||
ComponentName("hotdog", "juice"),
|
||||
ComponentName("personal", "computer"))
|
||||
ComponentName("personal", "computer")
|
||||
)
|
||||
val tasks: ArrayList<GroupTask> = ArrayList()
|
||||
tasks.add(groupTask1)
|
||||
tasks.add(groupTask2)
|
||||
|
||||
// Assertions happen in the callback we get from what we pass into
|
||||
// #findLastActiveTaskAndRunCallback
|
||||
val taskConsumer = Consumer<Task> {
|
||||
assertNull("No tasks should have matched", it /*task*/)
|
||||
}
|
||||
val taskConsumer =
|
||||
Consumer<Task> { assertNull("No tasks should have matched", it /*task*/) }
|
||||
|
||||
// Capture callback from recentsModel#getTasks()
|
||||
val consumer = withArgCaptor<Consumer<ArrayList<GroupTask>>> {
|
||||
splitSelectStateController.findLastActiveTaskAndRunCallback(
|
||||
ComponentName("no", "match"), taskConsumer)
|
||||
verify(recentsModel).getTasks(capture())
|
||||
}
|
||||
val consumer =
|
||||
withArgCaptor<Consumer<ArrayList<GroupTask>>> {
|
||||
splitSelectStateController.findLastActiveTaskAndRunCallback(
|
||||
ComponentName("no", "match"),
|
||||
taskConsumer
|
||||
)
|
||||
verify(recentsModel).getTasks(capture())
|
||||
}
|
||||
|
||||
// Send our mocked tasks
|
||||
consumer.accept(tasks)
|
||||
@@ -101,32 +114,46 @@ class SplitSelectStateControllerTest {
|
||||
fun activeTasks_singleMatchingTask() {
|
||||
val matchingPackage = "hotdog"
|
||||
val matchingClass = "juice"
|
||||
val groupTask1 = generateGroupTask(
|
||||
val groupTask1 =
|
||||
generateGroupTask(
|
||||
ComponentName(matchingPackage, matchingClass),
|
||||
ComponentName("pomegranate", "juice"))
|
||||
val groupTask2 = generateGroupTask(
|
||||
ComponentName("pomegranate", "juice")
|
||||
)
|
||||
val groupTask2 =
|
||||
generateGroupTask(
|
||||
ComponentName("pumpkin", "pie"),
|
||||
ComponentName("personal", "computer"))
|
||||
ComponentName("personal", "computer")
|
||||
)
|
||||
val tasks: ArrayList<GroupTask> = ArrayList()
|
||||
tasks.add(groupTask1)
|
||||
tasks.add(groupTask2)
|
||||
|
||||
// Assertions happen in the callback we get from what we pass into
|
||||
// #findLastActiveTaskAndRunCallback
|
||||
val taskConsumer = Consumer<Task> {
|
||||
assertEquals("ComponentName package mismatched",
|
||||
it.key.baseIntent.component.packageName, matchingPackage)
|
||||
assertEquals("ComponentName class mismatched",
|
||||
it.key.baseIntent.component.className, matchingClass)
|
||||
assertEquals(it, groupTask1.task1)
|
||||
}
|
||||
val taskConsumer =
|
||||
Consumer<Task> {
|
||||
assertEquals(
|
||||
"ComponentName package mismatched",
|
||||
it.key.baseIntent.component.packageName,
|
||||
matchingPackage
|
||||
)
|
||||
assertEquals(
|
||||
"ComponentName class mismatched",
|
||||
it.key.baseIntent.component.className,
|
||||
matchingClass
|
||||
)
|
||||
assertEquals(it, groupTask1.task1)
|
||||
}
|
||||
|
||||
// Capture callback from recentsModel#getTasks()
|
||||
val consumer = withArgCaptor<Consumer<ArrayList<GroupTask>>> {
|
||||
splitSelectStateController.findLastActiveTaskAndRunCallback(
|
||||
ComponentName(matchingPackage, matchingClass), taskConsumer)
|
||||
verify(recentsModel).getTasks(capture())
|
||||
}
|
||||
val consumer =
|
||||
withArgCaptor<Consumer<ArrayList<GroupTask>>> {
|
||||
splitSelectStateController.findLastActiveTaskAndRunCallback(
|
||||
ComponentName(matchingPackage, matchingClass),
|
||||
taskConsumer
|
||||
)
|
||||
verify(recentsModel).getTasks(capture())
|
||||
}
|
||||
|
||||
// Send our mocked tasks
|
||||
consumer.accept(tasks)
|
||||
@@ -136,32 +163,46 @@ class SplitSelectStateControllerTest {
|
||||
fun activeTasks_multipleMatchMostRecentTask() {
|
||||
val matchingPackage = "hotdog"
|
||||
val matchingClass = "juice"
|
||||
val groupTask1 = generateGroupTask(
|
||||
val groupTask1 =
|
||||
generateGroupTask(
|
||||
ComponentName(matchingPackage, matchingClass),
|
||||
ComponentName("pumpkin", "pie"))
|
||||
val groupTask2 = generateGroupTask(
|
||||
ComponentName("pumpkin", "pie")
|
||||
)
|
||||
val groupTask2 =
|
||||
generateGroupTask(
|
||||
ComponentName("pomegranate", "juice"),
|
||||
ComponentName(matchingPackage, matchingClass))
|
||||
ComponentName(matchingPackage, matchingClass)
|
||||
)
|
||||
val tasks: ArrayList<GroupTask> = ArrayList()
|
||||
tasks.add(groupTask2)
|
||||
tasks.add(groupTask1)
|
||||
|
||||
// Assertions happen in the callback we get from what we pass into
|
||||
// #findLastActiveTaskAndRunCallback
|
||||
val taskConsumer = Consumer<Task> {
|
||||
assertEquals("ComponentName package mismatched",
|
||||
it.key.baseIntent.component.packageName, matchingPackage)
|
||||
assertEquals("ComponentName class mismatched",
|
||||
it.key.baseIntent.component.className, matchingClass)
|
||||
assertEquals(it, groupTask2.task2)
|
||||
}
|
||||
val taskConsumer =
|
||||
Consumer<Task> {
|
||||
assertEquals(
|
||||
"ComponentName package mismatched",
|
||||
it.key.baseIntent.component.packageName,
|
||||
matchingPackage
|
||||
)
|
||||
assertEquals(
|
||||
"ComponentName class mismatched",
|
||||
it.key.baseIntent.component.className,
|
||||
matchingClass
|
||||
)
|
||||
assertEquals(it, groupTask2.task2)
|
||||
}
|
||||
|
||||
// Capture callback from recentsModel#getTasks()
|
||||
val consumer = withArgCaptor<Consumer<ArrayList<GroupTask>>> {
|
||||
splitSelectStateController.findLastActiveTaskAndRunCallback(
|
||||
ComponentName(matchingPackage, matchingClass), taskConsumer)
|
||||
verify(recentsModel).getTasks(capture())
|
||||
}
|
||||
val consumer =
|
||||
withArgCaptor<Consumer<ArrayList<GroupTask>>> {
|
||||
splitSelectStateController.findLastActiveTaskAndRunCallback(
|
||||
ComponentName(matchingPackage, matchingClass),
|
||||
taskConsumer
|
||||
)
|
||||
verify(recentsModel).getTasks(capture())
|
||||
}
|
||||
|
||||
// Send our mocked tasks
|
||||
consumer.accept(tasks)
|
||||
@@ -169,29 +210,45 @@ class SplitSelectStateControllerTest {
|
||||
|
||||
@Test
|
||||
fun setInitialApp_withTaskId() {
|
||||
splitSelectStateController.setInitialTaskSelect(null /*intent*/,
|
||||
-1 /*stagePosition*/, ItemInfo(), null /*splitEvent*/, 10 /*alreadyRunningTask*/)
|
||||
splitSelectStateController.setInitialTaskSelect(
|
||||
null /*intent*/,
|
||||
-1 /*stagePosition*/,
|
||||
ItemInfo(),
|
||||
null /*splitEvent*/,
|
||||
10 /*alreadyRunningTask*/
|
||||
)
|
||||
assertTrue(splitSelectStateController.isSplitSelectActive)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun setInitialApp_withIntent() {
|
||||
splitSelectStateController.setInitialTaskSelect(Intent() /*intent*/,
|
||||
-1 /*stagePosition*/, ItemInfo(), null /*splitEvent*/, -1 /*alreadyRunningTask*/)
|
||||
splitSelectStateController.setInitialTaskSelect(
|
||||
Intent() /*intent*/,
|
||||
-1 /*stagePosition*/,
|
||||
ItemInfo(),
|
||||
null /*splitEvent*/,
|
||||
-1 /*alreadyRunningTask*/
|
||||
)
|
||||
assertTrue(splitSelectStateController.isSplitSelectActive)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resetAfterInitial() {
|
||||
splitSelectStateController.setInitialTaskSelect(Intent() /*intent*/,
|
||||
-1 /*stagePosition*/, ItemInfo(), null /*splitEvent*/,
|
||||
-1)
|
||||
splitSelectStateController.setInitialTaskSelect(
|
||||
Intent() /*intent*/,
|
||||
-1 /*stagePosition*/,
|
||||
ItemInfo(),
|
||||
null /*splitEvent*/,
|
||||
-1
|
||||
)
|
||||
splitSelectStateController.resetState()
|
||||
assertFalse(splitSelectStateController.isSplitSelectActive)
|
||||
}
|
||||
|
||||
private fun generateGroupTask(task1ComponentName: ComponentName,
|
||||
task2ComponentName: ComponentName): GroupTask {
|
||||
private fun generateGroupTask(
|
||||
task1ComponentName: ComponentName,
|
||||
task2ComponentName: ComponentName
|
||||
): GroupTask {
|
||||
val task1 = Task()
|
||||
var taskInfo = ActivityManager.RunningTaskInfo()
|
||||
var intent = Intent()
|
||||
@@ -205,8 +262,10 @@ class SplitSelectStateControllerTest {
|
||||
intent.component = task2ComponentName
|
||||
taskInfo.baseIntent = intent
|
||||
task2.key = Task.TaskKey(taskInfo)
|
||||
return GroupTask(task1, task2, SplitConfigurationOptions.SplitBounds(
|
||||
Rect(), Rect(), -1, -1
|
||||
))
|
||||
return GroupTask(
|
||||
task1,
|
||||
task2,
|
||||
SplitConfigurationOptions.SplitBounds(Rect(), Rect(), -1, -1)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.android.launcher3.util.Themes
|
||||
|
||||
/**
|
||||
* Use same context for shared preferences, so that we use a single cached instance
|
||||
*
|
||||
* TODO(b/262721340): Replace all direct SharedPreference refs with LauncherPrefs / Item methods.
|
||||
*/
|
||||
class LauncherPrefs(private val context: Context) {
|
||||
@@ -90,7 +91,7 @@ class LauncherPrefs(private val context: Context) {
|
||||
* optimized to avoid retrieving the same shared preference file multiple times.
|
||||
*
|
||||
* @return `List<SharedPreferences.Editor>` 1 for each distinct shared preference file among the
|
||||
* items given as part of the itemsToValues parameter
|
||||
* items given as part of the itemsToValues parameter
|
||||
*/
|
||||
private fun prepareToPutValues(
|
||||
itemsToValues: Array<out Pair<Item, Any>>
|
||||
|
||||
@@ -77,8 +77,7 @@ class WorkspaceSpecs(resourceHelper: ResourceHelper) {
|
||||
attrs.getInt(
|
||||
R.styleable.WorkspaceSpec_specType,
|
||||
WorkspaceSpec.SpecType.HEIGHT.ordinal
|
||||
)
|
||||
]
|
||||
)]
|
||||
attrs.recycle()
|
||||
|
||||
var startPadding: SizeSpec? = null
|
||||
|
||||
@@ -101,15 +101,18 @@ inline fun <reified T : Any> kotlinArgumentCaptor(): KotlinArgumentCaptor<T> =
|
||||
|
||||
/**
|
||||
* Helper function for creating and using a single-use ArgumentCaptor in kotlin.
|
||||
*
|
||||
* ```
|
||||
* val captor = argumentCaptor<Foo>()
|
||||
* verify(...).someMethod(captor.capture())
|
||||
* val captured = captor.value
|
||||
* ```
|
||||
*
|
||||
* becomes:
|
||||
* ```
|
||||
* val captured = withArgCaptor<Foo> { verify(...).someMethod(capture()) }
|
||||
* ```
|
||||
*
|
||||
* NOTE: this uses the KotlinArgumentCaptor to avoid the NullPointerException.
|
||||
*/
|
||||
inline fun <reified T : Any> withArgCaptor(block: KotlinArgumentCaptor<T>.() -> Unit): T =
|
||||
|
||||
Reference in New Issue
Block a user