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.complication.dagger; 18 19 import static java.lang.annotation.RetentionPolicy.RUNTIME; 20 21 import android.view.LayoutInflater; 22 import android.view.View; 23 24 import com.android.systemui.complication.DreamMediaEntryComplication; 25 import com.android.systemui.res.R; 26 27 import dagger.Module; 28 import dagger.Provides; 29 import dagger.Subcomponent; 30 31 import java.lang.annotation.Documented; 32 import java.lang.annotation.Retention; 33 34 import javax.inject.Named; 35 import javax.inject.Scope; 36 37 /** 38 * Responsible for generating dependencies for the {@link DreamMediaEntryComplication}. 39 */ 40 @Subcomponent(modules = DreamMediaEntryComplicationComponent.DreamMediaEntryModule.class) 41 @DreamMediaEntryComplicationComponent.DreamMediaEntryComplicationScope 42 public interface DreamMediaEntryComplicationComponent { 43 /** 44 * Creates a view holder for the media entry complication. 45 */ getViewHolder()46 DreamMediaEntryComplication.DreamMediaEntryViewHolder getViewHolder(); 47 48 /** 49 * Scope of the media entry complication. 50 */ 51 @Documented 52 @Retention(RUNTIME) 53 @Scope 54 @interface DreamMediaEntryComplicationScope {} 55 56 /** 57 * Factory that generates a {@link DreamMediaEntryComplicationComponent}. 58 */ 59 @Subcomponent.Factory 60 interface Factory { create()61 DreamMediaEntryComplicationComponent create(); 62 } 63 64 /** 65 * Scoped injected values for the {@link DreamMediaEntryComplicationComponent}. 66 */ 67 @Module 68 interface DreamMediaEntryModule { 69 String DREAM_MEDIA_ENTRY_VIEW = "dream_media_entry_view"; 70 71 /** 72 * Provides the dream media entry view. 73 */ 74 @Provides 75 @DreamMediaEntryComplicationScope 76 @Named(DREAM_MEDIA_ENTRY_VIEW) provideMediaEntryView(LayoutInflater layoutInflater)77 static View provideMediaEntryView(LayoutInflater layoutInflater) { 78 return (View) layoutInflater.inflate(R.layout.dream_overlay_media_entry_chip, null); 79 } 80 } 81 } 82