• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.statusbar.pipeline.wifi.ui.model
18 
19 import android.annotation.DrawableRes
20 import com.android.systemui.common.shared.model.ContentDescription
21 import com.android.systemui.common.shared.model.Icon
22 import com.android.systemui.log.table.Diffable
23 import com.android.systemui.log.table.TableRowLogger
24 
25 /** Represents the various states of the wifi icon. */
26 sealed interface WifiIcon : Diffable<WifiIcon> {
27     /** Represents a wifi icon that should be hidden (not visible). */
28     object Hidden : WifiIcon {
toStringnull29         override fun toString() = "hidden"
30     }
31 
32     /**
33      * Represents a visible wifi icon that uses [res] as its image and [contentDescription] as its
34      * description.
35      */
36     class Visible(
37         @DrawableRes res: Int,
38         val contentDescription: ContentDescription.Loaded,
39     ) : WifiIcon {
40         val icon = Icon.Resource(res, contentDescription)
41 
42         override fun toString() = contentDescription.description.toString()
43     }
44 
logDiffsnull45     override fun logDiffs(prevVal: WifiIcon, row: TableRowLogger) {
46         if (prevVal.toString() != toString()) {
47             row.logChange(COL_ICON, toString())
48         }
49     }
50 
logFullnull51     override fun logFull(row: TableRowLogger) {
52         row.logChange(COL_ICON, toString())
53     }
54 }
55 
56 private const val COL_ICON = "icon"
57