1 /* 2 * Copyright (C) 2023 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.wallpaper.model 17 18 import android.net.Uri 19 import android.os.Parcel 20 import android.os.Parcelable 21 22 data class WallpaperAction( 23 val label: String?, 24 val applyActionUri: Uri?, 25 val effectId: String?, 26 var toggled: Boolean 27 ) : Parcelable { 28 constructor( 29 parcel: Parcel 30 ) : this( 31 parcel.readString(), 32 parcel.readParcelable(Uri::class.java.classLoader, Uri::class.java), 33 parcel.readString(), 34 parcel.readByte() != 0.toByte() 35 ) {} 36 writeToParcelnull37 override fun writeToParcel(parcel: Parcel, flags: Int) { 38 parcel.writeString(label) 39 parcel.writeParcelable(applyActionUri, flags) 40 parcel.writeString(effectId) 41 parcel.writeByte(if (toggled) 1 else 0) 42 } 43 describeContentsnull44 override fun describeContents(): Int { 45 return 0 46 } 47 48 companion object CREATOR : Parcelable.Creator<WallpaperAction> { createFromParcelnull49 override fun createFromParcel(parcel: Parcel): WallpaperAction { 50 return WallpaperAction(parcel) 51 } 52 newArraynull53 override fun newArray(size: Int): Array<WallpaperAction?> { 54 return arrayOfNulls(size) 55 } 56 } 57 } 58