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 17 package com.android.systemui.qs.tiles.impl.custom.commons 18 19 import android.service.quicksettings.Tile 20 Tilenull21fun Tile.copy(): Tile = 22 Tile().also { 23 it.icon = icon 24 it.label = label 25 it.subtitle = subtitle 26 it.contentDescription = contentDescription 27 it.stateDescription = stateDescription 28 it.activityLaunchForClick = activityLaunchForClick 29 it.state = state 30 } 31 setFromnull32fun Tile.setFrom(otherTile: Tile) { 33 if (otherTile.icon != null) { 34 icon = otherTile.icon 35 } 36 if (otherTile.customLabel != null) { 37 label = otherTile.customLabel 38 } 39 if (otherTile.subtitle != null) { 40 subtitle = otherTile.subtitle 41 } 42 if (otherTile.contentDescription != null) { 43 contentDescription = otherTile.contentDescription 44 } 45 if (otherTile.stateDescription != null) { 46 stateDescription = otherTile.stateDescription 47 } 48 activityLaunchForClick = otherTile.activityLaunchForClick 49 state = otherTile.state 50 } 51