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 ) 74 @Retention(AnnotationRetention.SOURCE) 75 annotation class UpdateSource { 76 companion object { 77 /** Location changed from dragging the bar */ 78 const val DRAG_BAR = 1 79 80 /** Location changed from dragging the bubble */ 81 const val DRAG_BUBBLE = 2 82 83 /** Location changed from dragging the expanded view */ 84 const val DRAG_EXP_VIEW = 3 85 86 /** Location changed via a11y action on the bar */ 87 const val A11Y_ACTION_BAR = 4 88 89 /** Location changed via a11y action on the bubble */ 90 const val A11Y_ACTION_BUBBLE = 5 91 92 /** Location changed via a11y action on the expanded view */ 93 const val A11Y_ACTION_EXP_VIEW = 6 94 } 95 } 96 } 97