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.volume.panel.component.captioning 18 19 import com.android.systemui.volume.panel.component.button.ui.composable.ToggleButtonComponent 20 import com.android.systemui.volume.panel.component.captioning.domain.CaptioningAvailabilityCriteria 21 import com.android.systemui.volume.panel.component.captioning.ui.viewmodel.CaptioningViewModel 22 import com.android.systemui.volume.panel.component.shared.model.VolumePanelComponents 23 import com.android.systemui.volume.panel.domain.ComponentAvailabilityCriteria 24 import com.android.systemui.volume.panel.shared.model.VolumePanelUiComponent 25 import dagger.Binds 26 import dagger.Module 27 import dagger.Provides 28 import dagger.multibindings.IntoMap 29 import dagger.multibindings.StringKey 30 31 /** Dagger module, that provides Captioning Volume Panel UI functionality. */ 32 @Module 33 interface CaptioningModule { 34 35 @Binds 36 @IntoMap 37 @StringKey(VolumePanelComponents.CAPTIONING) bindComponentAvailabilityCriterianull38 fun bindComponentAvailabilityCriteria( 39 criteria: CaptioningAvailabilityCriteria 40 ): ComponentAvailabilityCriteria 41 42 companion object { 43 44 @Provides 45 @IntoMap 46 @StringKey(VolumePanelComponents.CAPTIONING) 47 fun provideVolumePanelUiComponent(viewModel: CaptioningViewModel): VolumePanelUiComponent = 48 ToggleButtonComponent( 49 viewModel.buttonViewModel, 50 viewModel::setIsSystemAudioCaptioningEnabled, 51 ) 52 } 53 } 54