1 /* 2 * Copyright (C) 2021 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.systemui.shared.system.smartspace 18 19 import android.graphics.Rect 20 import android.os.Parcel 21 import android.os.Parcelable 22 23 /** 24 * Represents the state of a SmartSpace, including its location on screen and the index of the 25 * currently selected page. This object contains all of the information needed to synchronize two 26 * SmartSpace instances so that we can perform shared-element transitions between them. 27 */ 28 class SmartspaceState() : Parcelable { 29 var boundsOnScreen: Rect = Rect() 30 var selectedPage = 0 31 32 constructor(parcel: Parcel) : this() { 33 this.boundsOnScreen = parcel.readParcelable(Rect::javaClass.javaClass.classLoader) 34 this.selectedPage = parcel.readInt() 35 } 36 37 override fun writeToParcel(dest: Parcel?, flags: Int) { 38 dest?.writeParcelable(boundsOnScreen, 0) 39 dest?.writeInt(selectedPage) 40 } 41 42 override fun describeContents(): Int { 43 return 0 44 } 45 46 override fun toString(): String { 47 return "boundsOnScreen: $boundsOnScreen, selectedPage: $selectedPage" 48 } 49 50 companion object CREATOR : Parcelable.Creator<SmartspaceState> { 51 override fun createFromParcel(parcel: Parcel): SmartspaceState { 52 return SmartspaceState(parcel) 53 } 54 55 override fun newArray(size: Int): Array<SmartspaceState?> { 56 return arrayOfNulls(size) 57 } 58 } 59 }