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.rotationlock 18 19 import com.android.systemui.camera.CameraRotationModule 20 import com.android.systemui.qs.QsEventLogger 21 import com.android.systemui.qs.pipeline.shared.TileSpec 22 import com.android.systemui.qs.shared.model.TileCategory 23 import com.android.systemui.qs.tiles.base.domain.interactor.QSTileAvailabilityInteractor 24 import com.android.systemui.qs.tiles.base.shared.model.QSTileConfig 25 import com.android.systemui.qs.tiles.base.shared.model.QSTileUIConfig 26 import com.android.systemui.qs.tiles.base.ui.viewmodel.QSTileViewModel 27 import com.android.systemui.qs.tiles.base.ui.viewmodel.QSTileViewModelFactory 28 import com.android.systemui.qs.tiles.impl.rotation.domain.interactor.RotationLockTileDataInteractor 29 import com.android.systemui.qs.tiles.impl.rotation.domain.interactor.RotationLockTileUserActionInteractor 30 import com.android.systemui.qs.tiles.impl.rotation.domain.model.RotationLockTileModel 31 import com.android.systemui.qs.tiles.impl.rotation.ui.mapper.RotationLockTileMapper 32 import com.android.systemui.res.R 33 import dagger.Binds 34 import dagger.Module 35 import dagger.Provides 36 import dagger.multibindings.IntoMap 37 import dagger.multibindings.StringKey 38 39 @Module(includes = [CameraRotationModule::class]) 40 interface RotationLockNewModule { 41 42 @Binds 43 @IntoMap 44 @StringKey(ROTATION_TILE_SPEC) provideRotationAvailabilityInteractornull45 fun provideRotationAvailabilityInteractor( 46 impl: RotationLockTileDataInteractor 47 ): QSTileAvailabilityInteractor 48 49 companion object { 50 private const val ROTATION_TILE_SPEC = "rotation" 51 52 /** Inject rotation tile config */ 53 @Provides 54 @IntoMap 55 @StringKey(ROTATION_TILE_SPEC) 56 fun provideRotationTileConfig(uiEventLogger: QsEventLogger): QSTileConfig = 57 QSTileConfig( 58 tileSpec = TileSpec.create(ROTATION_TILE_SPEC), 59 uiConfig = 60 QSTileUIConfig.Resource( 61 iconRes = R.drawable.qs_auto_rotate_icon_off, 62 labelRes = R.string.quick_settings_rotation_unlocked_label, 63 ), 64 instanceId = uiEventLogger.getNewInstanceId(), 65 category = TileCategory.DISPLAY, 66 ) 67 68 /** Inject Rotation tile into tileViewModelMap in QSModule */ 69 @Provides 70 @IntoMap 71 @StringKey(ROTATION_TILE_SPEC) 72 fun provideRotationTileViewModel( 73 factory: QSTileViewModelFactory.Static<RotationLockTileModel>, 74 mapper: RotationLockTileMapper, 75 stateInteractor: RotationLockTileDataInteractor, 76 userActionInteractor: RotationLockTileUserActionInteractor, 77 ): QSTileViewModel = 78 factory.create( 79 TileSpec.create(ROTATION_TILE_SPEC), 80 userActionInteractor, 81 stateInteractor, 82 mapper, 83 ) 84 } 85 } 86