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 17 package com.android.settingslib.bluetooth.devicesettings 18 19 import android.os.Bundle 20 import android.os.Parcel 21 import android.os.Parcelable 22 23 /** 24 * A data class representing a bluetooth device details config. 25 * 26 * @property mainContentItems The setting items to be shown in main page. 27 * @property moreSettingsItems The setting items to be shown in more settings page. 28 * @property moreSettingsHelpItem The help item displayed on the top right corner of the page. 29 * @property extras Extra bundle 30 */ 31 data class DeviceSettingsConfig( 32 val mainContentItems: List<DeviceSettingItem>, 33 val moreSettingsItems: List<DeviceSettingItem>, 34 val moreSettingsHelpItem: DeviceSettingItem?, 35 val extras: Bundle = Bundle.EMPTY, 36 ) : Parcelable { 37 describeContentsnull38 override fun describeContents(): Int = 0 39 40 override fun writeToParcel(parcel: Parcel, flags: Int) { 41 parcel.run { 42 writeTypedList(mainContentItems) 43 writeTypedList(moreSettingsItems) 44 writeParcelable(moreSettingsHelpItem, flags) 45 writeBundle(extras) 46 } 47 } 48 49 companion object { 50 @JvmField 51 val CREATOR: Parcelable.Creator<DeviceSettingsConfig> = 52 object : Parcelable.Creator<DeviceSettingsConfig> { createFromParcelnull53 override fun createFromParcel(parcel: Parcel): DeviceSettingsConfig = 54 parcel.run { 55 DeviceSettingsConfig( 56 mainContentItems = 57 arrayListOf<DeviceSettingItem>().also { 58 readTypedList(it, DeviceSettingItem.CREATOR) 59 }, 60 moreSettingsItems = 61 arrayListOf<DeviceSettingItem>().also { 62 readTypedList(it, DeviceSettingItem.CREATOR) 63 }, 64 moreSettingsHelpItem = readParcelable( 65 DeviceSettingItem::class.java.classLoader 66 ), 67 extras = readBundle((Bundle::class.java.classLoader)) ?: Bundle.EMPTY, 68 ) 69 } 70 newArraynull71 override fun newArray(size: Int): Array<DeviceSettingsConfig?> { 72 return arrayOfNulls(size) 73 } 74 } 75 } 76 } 77