• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
<lambda>null2  * 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.systemui.media.controls.ui.viewmodel
18 
19 import com.android.systemui.animation.Expandable
20 import com.android.systemui.common.shared.model.Icon
21 
22 /** Models UI state for media player. */
23 data class MediaPlayerViewModel(
24     val contentDescription: (Boolean) -> CharSequence,
25     val backgroundCover: android.graphics.drawable.Icon?,
26     val appIcon: android.graphics.drawable.Icon?,
27     val launcherIcon: Icon,
28     val useGrayColorFilter: Boolean,
29     val artistName: CharSequence,
30     val titleName: CharSequence,
31     val isExplicitVisible: Boolean,
32     val canShowTime: Boolean,
33     val playTurbulenceNoise: Boolean,
34     val useSemanticActions: Boolean,
35     val actionButtons: List<MediaActionViewModel>,
36     val outputSwitcher: MediaOutputSwitcherViewModel,
37     val gutsMenu: GutsViewModel,
38     val onClicked: (Expandable) -> Unit,
39     val onLongClicked: () -> Unit,
40     val onSeek: () -> Unit,
41     val onBindSeekbar: (SeekBarViewModel) -> Unit,
42     val onLocationChanged: (Int) -> Unit,
43 ) {
44     fun contentEquals(other: MediaPlayerViewModel?): Boolean {
45         return other?.let {
46             other.backgroundCover == backgroundCover &&
47                 appIcon == other.appIcon &&
48                 useGrayColorFilter == other.useGrayColorFilter &&
49                 artistName == other.artistName &&
50                 titleName == other.titleName &&
51                 isExplicitVisible == other.isExplicitVisible &&
52                 canShowTime == other.canShowTime &&
53                 playTurbulenceNoise == other.playTurbulenceNoise &&
54                 useSemanticActions == other.useSemanticActions &&
55                 areActionsEqual(other.actionButtons) &&
56                 outputSwitcher.contentEquals(other.outputSwitcher)
57         } ?: false
58     }
59 
60     private fun areActionsEqual(other: List<MediaActionViewModel>): Boolean {
61         actionButtons.forEachIndexed { index, mediaActionViewModel ->
62             if (!mediaActionViewModel.contentEquals(other[index])) {
63                 return false
64             }
65         }
66         return true
67     }
68 }
69