• 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 package com.android.wm.shell.shared.bubbles
17 
18 import android.annotation.IntDef
19 import android.os.Parcel
20 import android.os.Parcelable
21 
22 /**
23  * The location of the bubble bar.
24  */
25 enum class BubbleBarLocation : Parcelable {
26     /**
27      * Place bubble bar at the default location for the chosen system language.
28      * If an RTL language is used, it is on the left. Otherwise on the right.
29      */
30     DEFAULT,
31     /** Default bubble bar location is overridden. Place bubble bar on the left. */
32     LEFT,
33     /** Default bubble bar location is overridden. Place bubble bar on the right. */
34     RIGHT;
35 
36     /**
37      * Returns whether bubble bar is pinned to the left edge or right edge.
38      */
isOnLeftnull39     fun isOnLeft(isRtl: Boolean): Boolean {
40         if (this == DEFAULT) {
41             return isRtl
42         }
43         return this == LEFT
44     }
45 
describeContentsnull46     override fun describeContents(): Int {
47         return 0
48     }
49 
writeToParcelnull50     override fun writeToParcel(dest: Parcel, flags: Int) {
51         dest.writeString(name)
52     }
53 
54     companion object {
55         @JvmField
56         val CREATOR = object : Parcelable.Creator<BubbleBarLocation> {
createFromParcelnull57             override fun createFromParcel(parcel: Parcel): BubbleBarLocation {
58                 return parcel.readString()?.let { valueOf(it) } ?: DEFAULT
59             }
60 
newArraynull61             override fun newArray(size: Int) = arrayOfNulls<BubbleBarLocation>(size)
62         }
63     }
64 
65     /** Define set of constants that allow to determine why location changed. */
66     @IntDef(
67         UpdateSource.DRAG_BAR,
68         UpdateSource.DRAG_BUBBLE,
69         UpdateSource.DRAG_EXP_VIEW,
70         UpdateSource.A11Y_ACTION_BAR,
71         UpdateSource.A11Y_ACTION_BUBBLE,
72         UpdateSource.A11Y_ACTION_EXP_VIEW,
73         UpdateSource.APP_ICON_DRAG,
74         UpdateSource.DRAG_TASK,
75     )
76     @Retention(AnnotationRetention.SOURCE)
77     annotation class UpdateSource {
78         companion object {
79             /** Location changed from dragging the bar */
80             const val DRAG_BAR = 1
81 
82             /** Location changed from dragging the bubble */
83             const val DRAG_BUBBLE = 2
84 
85             /** Location changed from dragging the expanded view */
86             const val DRAG_EXP_VIEW = 3
87 
88             /** Location changed via a11y action on the bar */
89             const val A11Y_ACTION_BAR = 4
90 
91             /** Location changed via a11y action on the bubble */
92             const val A11Y_ACTION_BUBBLE = 5
93 
94             /** Location changed via a11y action on the expanded view */
95             const val A11Y_ACTION_EXP_VIEW = 6
96 
97             /** Location changed from dragging the application icon to the bubble bar */
98             const val APP_ICON_DRAG = 7
99 
100             /** Location changed from dragging a running task to the bubble bar */
101             const val DRAG_TASK = 8
102         }
103     }
104 }
105