• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.wm.shell.draganddrop.anim
18 
19 import android.content.res.Resources
20 import android.graphics.Insets
21 import com.android.wm.shell.common.DisplayLayout
22 import com.android.wm.shell.draganddrop.SplitDragPolicy
23 
24 /**
25  * When the user is dragging an icon from Taskbar to add an app into split
26  * screen, we have a set of rules by which we draw and move colored drop
27  * targets around the screen. The rules are provided through this interface.
28  *
29  * Each possible screen layout should have an implementation of this interface.
30  * E.g.
31  * - 50:50 two-app split
32  * - 10:45:45 three-app split
33  * - single app, no split
34  *     = three implementations of this interface.
35  */
36 interface DropTargetAnimSupplier {
37     /**
38      * Returns a Pair of lists.
39      * First list (length n): Where to draw the n colored drop zones.
40      * Second list (length n): How to animate the drop zones as user hovers around.
41      *
42      * Ex: First list => [A, B, C] // 3 views will be created representing these 3 targets
43      * Second list => [
44      *      [A (scaleX=4), B (translateX=20), C (translateX=20)], // hovering over A
45      *      [A (translateX=20), B (scaleX=4), C (translateX=20)], // hovering over B
46      *      [A (translateX=20), B (translateX=20), C (scaleX=4)], // hovering over C
47      *  ]
48      *
49      *  All indexes assume 0 to N => left to right when [isLeftRightSplit] is true and top to bottom
50      *  when [isLeftRightSplit] is false. Indexing is left to right even in RtL mode.
51      *
52      *  All lists should have the SAME number of elements, even if no animations are to be run for
53      *  a given target while in a hover state.
54      *  It's not that we don't trust you, but we _really_ don't trust you, so this will throw an
55      *  exception if lengths are different. Don't ruin it for everyone else...
56      *  or do. Idk, you're an adult.
57      */
getTargetsnull58     fun getTargets(displayLayout: DisplayLayout, insets: Insets, isLeftRightSplit: Boolean,
59                    resources: Resources) :
60             Pair<List<SplitDragPolicy.Target>, List<List<HoverAnimProps>>>
61 }