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.common.bubbles 17 18 import android.os.Parcel 19 import android.os.Parcelable 20 21 /** 22 * The location of the bubble bar. 23 */ 24 enum class BubbleBarLocation : Parcelable { 25 /** 26 * Place bubble bar at the default location for the chosen system language. 27 * If an RTL language is used, it is on the left. Otherwise on the right. 28 */ 29 DEFAULT, 30 /** Default bubble bar location is overridden. Place bubble bar on the left. */ 31 LEFT, 32 /** Default bubble bar location is overridden. Place bubble bar on the right. */ 33 RIGHT; 34 35 /** 36 * Returns whether bubble bar is pinned to the left edge or right edge. 37 */ isOnLeftnull38 fun isOnLeft(isRtl: Boolean): Boolean { 39 if (this == DEFAULT) { 40 return isRtl 41 } 42 return this == LEFT 43 } 44 describeContentsnull45 override fun describeContents(): Int { 46 return 0 47 } 48 writeToParcelnull49 override fun writeToParcel(dest: Parcel, flags: Int) { 50 dest.writeString(name) 51 } 52 53 companion object { 54 @JvmField 55 val CREATOR = object : Parcelable.Creator<BubbleBarLocation> { createFromParcelnull56 override fun createFromParcel(parcel: Parcel): BubbleBarLocation { 57 return parcel.readString()?.let { valueOf(it) } ?: DEFAULT 58 } 59 newArraynull60 override fun newArray(size: Int) = arrayOfNulls<BubbleBarLocation>(size) 61 } 62 } 63 } 64