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.statusbar.pipeline.satellite.ui.model
18 
19 import com.android.systemui.common.shared.model.ContentDescription
20 import com.android.systemui.common.shared.model.Icon
21 import com.android.systemui.res.R
22 import com.android.systemui.statusbar.pipeline.satellite.shared.model.SatelliteConnectionState
23 
24 /**
25  * Define the [Icon] that relates to a given satellite connection state + level. Note that for now
26  * We don't need any data class box, so we can just use a simple mapping function.
27  */
28 object SatelliteIconModel {
fromConnectionStatenull29     fun fromConnectionState(
30         connectionState: SatelliteConnectionState,
31         signalStrength: Int,
32     ): Icon.Resource? =
33         when (connectionState) {
34             // TODO(b/316635648): check if this should be null
35             SatelliteConnectionState.Unknown,
36             SatelliteConnectionState.Off,
37             SatelliteConnectionState.On ->
38                 Icon.Resource(
39                     res = R.drawable.ic_satellite_not_connected,
40                     contentDescription =
41                         ContentDescription.Resource(
42                             R.string.accessibility_status_bar_satellite_available
43                         ),
44                 )
45             SatelliteConnectionState.Connected -> fromSignalStrength(signalStrength)
46         }
47 
48     /**
49      * Satellite icon appropriate for when we are connected. Use [fromConnectionState] for a more
50      * generally correct representation.
51      */
fromSignalStrengthnull52     fun fromSignalStrength(
53         signalStrength: Int,
54     ): Icon.Resource? =
55         // TODO(b/316634365): these need content descriptions
56         when (signalStrength) {
57             // No signal
58             0 ->
59                 Icon.Resource(
60                     res = R.drawable.ic_satellite_connected_0,
61                     contentDescription =
62                         ContentDescription.Resource(
63                             R.string.accessibility_status_bar_satellite_no_connection
64                         )
65                 )
66 
67             // Poor -> Moderate
68             1,
69             2 ->
70                 Icon.Resource(
71                     res = R.drawable.ic_satellite_connected_1,
72                     contentDescription =
73                         ContentDescription.Resource(
74                             R.string.accessibility_status_bar_satellite_poor_connection
75                         )
76                 )
77 
78             // Good -> Great
79             3,
80             4 ->
81                 Icon.Resource(
82                     res = R.drawable.ic_satellite_connected_2,
83                     contentDescription =
84                         ContentDescription.Resource(
85                             R.string.accessibility_status_bar_satellite_good_connection
86                         )
87                 )
88             else -> null
89         }
90 }
91