• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 android.platform.systemui_tapl.ui
18 
19 import android.graphics.Rect
20 
21 /**
22  * Represents dimensions and position of a visible view on the screen.
23  *
24  * Allows to compare it with other [sized] objects **without** disclosing the real position.
25  */
26 abstract class Sized internal constructor(private val rect: Rect) {
27     /** Returns whether this class intersects with [other]. */
intersectnull28     infix fun intersect(other: Sized): Boolean = rect.intersect(other.rect)
29 
30     override fun equals(other: Any?): Boolean =
31         if (other is Sized) {
32             rect == other.rect
33         } else {
34             super.equals(other)
35         }
36 
hashCodenull37     override fun hashCode(): Int = rect.hashCode()
38 
39     override fun toString(): String = "${this::class.simpleName}(bounds=$rect)"
40 }
41 
42 /**
43  * System UI test automation object representing the notification shelf.
44  *
45  * This is visible at the end of the [NotificationStack] only when there are notification that don't
46  * fit in the available space.
47  */
48 class NotificationShelf internal constructor(rect: Rect) : Sized(rect)
49 
50 /** System UI test automation object representing the lock icon visible on lockscreen. */
51 class LockscreenLockIcon internal constructor(rect: Rect) : Sized(rect)
52