• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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.shared.bubbles
18 
19 import android.graphics.Rect
20 
21 /**
22  * Represents an invisible area on the screen that determines what happens to a dragged object if it
23  * is released in that area.
24  *
25  * [bounds] are the bounds of the drag zone. Drag zones have an associated drop target that serves
26  * as visual feedback hinting what would happen if the object is released. When a dragged object is
27  * dragged into a drag zone, the associated drop target will be displayed. Not all drag zones have
28  * drop targets; only those that are made visible by Bubbles do.
29  */
30 sealed interface DragZone {
31 
32     /** The bounds of this drag zone. */
33     val bounds: Rect
34     /** The bounds of the drop target associated with this drag zone. */
35     val dropTarget: Rect?
36 
containsnull37     fun contains(x: Int, y: Int) = bounds.contains(x, y)
38 
39     /** Represents the bubble drag area on the screen. */
40     sealed class Bubble(override val bounds: Rect, override val dropTarget: Rect) : DragZone {
41         data class Left(override val bounds: Rect, override val dropTarget: Rect) :
42             Bubble(bounds, dropTarget)
43 
44         data class Right(override val bounds: Rect, override val dropTarget: Rect) :
45             Bubble(bounds, dropTarget)
46     }
47 
48     /** Represents dragging to Desktop Window. */
49     data class DesktopWindow(override val bounds: Rect, override val dropTarget: Rect) : DragZone
50 
51     /** Represents dragging to Full Screen. */
52     data class FullScreen(override val bounds: Rect, override val dropTarget: Rect) : DragZone
53 
54     /** Represents dragging to dismiss. */
55     data class Dismiss(override val bounds: Rect) : DragZone {
56         override val dropTarget: Rect? = null
57     }
58 
59     /** Represents dragging to enter Split or replace a Split app. */
60     sealed class Split(override val bounds: Rect) : DragZone {
61         override val dropTarget: Rect? = null
62 
63         data class Left(override val bounds: Rect) : Split(bounds)
64 
65         data class Right(override val bounds: Rect) : Split(bounds)
66 
67         data class Top(override val bounds: Rect) : Split(bounds)
68 
69         data class Bottom(override val bounds: Rect) : Split(bounds)
70     }
71 }
72