• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.systemui.accessibility.hearingaid;
18 
19 import com.android.settingslib.bluetooth.HearingAidDeviceManager.ConnectionStatus;
20 
21 /**
22  * A utility class to get the hearing device status drawable and its description for the
23  * given connection status. Hearing device status drawable combine with base and indicator
24  * drawable.
25  */
26 public final class HearingDeviceStatusDrawableInfo {
27 
28     private static final StatusDrawableInfo DRAWABLE_DEFAULT_INFO = new StatusDrawableInfo(
29             com.android.internal.R.drawable.ic_accessibility_hearing_aid,
30             0,
31             0);
32     private static final StatusDrawableInfo DRAWABLE_DISCONNECTED_INFO = new StatusDrawableInfo(
33             com.android.internal.R.drawable.ic_accessibility_hearing_aid_disconnected,
34             0,
35             com.android.internal.R.string.hearing_device_status_disconnected);
36     private static final StatusDrawableInfo DRAWABLE_CONNECTED_INFO = new StatusDrawableInfo(
37             com.android.internal.R.drawable.ic_accessibility_hearing_aid,
38             com.android.internal.R.drawable.ic_accessibility_hearing_aid_blue_dot,
39             com.android.internal.R.string.hearing_device_status_connected);
40     private static final StatusDrawableInfo DRAWABLE_ACTIVE_INFO = new StatusDrawableInfo(
41             com.android.internal.R.drawable.ic_accessibility_hearing_aid,
42             com.android.internal.R.drawable.ic_accessibility_hearing_aid_green_dot,
43             com.android.internal.R.string.hearing_device_status_active);
44 
HearingDeviceStatusDrawableInfo()45     private HearingDeviceStatusDrawableInfo() {}
46 
47     /**
48      * Returns the corresponding {@link StatusDrawableInfo} for the given {@link ConnectionStatus}.
49      */
get(@onnectionStatus int status)50     public static StatusDrawableInfo get(@ConnectionStatus int status) {
51         return switch (status) {
52             case ConnectionStatus.DISCONNECTED -> DRAWABLE_DISCONNECTED_INFO;
53             case ConnectionStatus.CONNECTED -> DRAWABLE_CONNECTED_INFO;
54             case ConnectionStatus.ACTIVE -> DRAWABLE_ACTIVE_INFO;
55             // TODO: b/357882387 - Handle to show connecting or disconnecting status drawable
56             case ConnectionStatus.CONNECTING_OR_DISCONNECTING, ConnectionStatus.NO_DEVICE_BONDED ->
57                     DRAWABLE_DEFAULT_INFO;
58             default -> DRAWABLE_DEFAULT_INFO;
59         };
60     }
61 
62     /**
63      * A data class that holds the base drawable, indicator drawable and state description to
64      * represent hearing device connection status.
65      *
66      * @param baseDrawableId the base drawable id for the hearing device status
67      * @param indicatorDrawableId the indicator drawable id for the hearing device status
68      * @param stateDescriptionId the description for the hearing device status
69      */
StatusDrawableInfo(int baseDrawableId, int indicatorDrawableId, int stateDescriptionId)70     public record StatusDrawableInfo(int baseDrawableId, int indicatorDrawableId,
71                                      int stateDescriptionId) {
72     }
73 }
74