1 /* 2 * Copyright (C) 2020 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.notification.row; 18 19 import com.android.systemui.dagger.SysUISingleton; 20 import com.android.systemui.flags.FeatureFlags; 21 import com.android.systemui.flags.Flags; 22 23 import dagger.Binds; 24 import dagger.Module; 25 import dagger.Provides; 26 import dagger.multibindings.ElementsIntoSet; 27 28 import java.util.HashSet; 29 import java.util.Set; 30 31 import javax.inject.Named; 32 33 /** 34 * Dagger Module containing notification row and view inflation implementations. 35 */ 36 @Module 37 public abstract class NotificationRowModule { 38 public static final String NOTIF_REMOTEVIEWS_FACTORIES = 39 "notif_remoteviews_factories"; 40 41 /** 42 * Provides notification row content binder instance. 43 */ 44 @Binds 45 @SysUISingleton provideNotificationRowContentBinder( NotificationContentInflater contentBinderImpl)46 public abstract NotificationRowContentBinder provideNotificationRowContentBinder( 47 NotificationContentInflater contentBinderImpl); 48 49 /** 50 * Provides notification remote view cache instance. 51 */ 52 @Binds 53 @SysUISingleton provideNotifRemoteViewCache( NotifRemoteViewCacheImpl cacheImpl)54 public abstract NotifRemoteViewCache provideNotifRemoteViewCache( 55 NotifRemoteViewCacheImpl cacheImpl); 56 57 /** Provides view factories to be inflated in notification content. */ 58 @Provides 59 @ElementsIntoSet 60 @Named(NOTIF_REMOTEVIEWS_FACTORIES) provideNotifRemoteViewsFactories( FeatureFlags featureFlags, PrecomputedTextViewFactory precomputedTextViewFactory )61 static Set<NotifRemoteViewsFactory> provideNotifRemoteViewsFactories( 62 FeatureFlags featureFlags, 63 PrecomputedTextViewFactory precomputedTextViewFactory 64 ) { 65 final Set<NotifRemoteViewsFactory> replacementFactories = new HashSet<>(); 66 if (featureFlags.isEnabled(Flags.PRECOMPUTED_TEXT)) { 67 replacementFactories.add(precomputedTextViewFactory); 68 } 69 return replacementFactories; 70 } 71 } 72