1 /* 2 * Copyright (C) 2021 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.phone.fragment.dagger; 18 19 import android.view.View; 20 21 import com.android.systemui.R; 22 import com.android.systemui.battery.BatteryMeterView; 23 import com.android.systemui.dagger.qualifiers.RootView; 24 import com.android.systemui.statusbar.HeadsUpStatusBarView; 25 import com.android.systemui.statusbar.phone.PhoneStatusBarTransitions; 26 import com.android.systemui.statusbar.phone.PhoneStatusBarView; 27 import com.android.systemui.statusbar.phone.PhoneStatusBarViewController; 28 import com.android.systemui.statusbar.phone.StatusBarBoundsProvider; 29 import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment; 30 import com.android.systemui.statusbar.phone.userswitcher.StatusBarUserSwitcherContainer; 31 import com.android.systemui.statusbar.policy.Clock; 32 import com.android.systemui.statusbar.window.StatusBarWindowController; 33 34 import java.util.Optional; 35 import java.util.Set; 36 37 import javax.inject.Named; 38 39 import dagger.Module; 40 import dagger.Provides; 41 import dagger.multibindings.Multibinds; 42 43 /** Dagger module for {@link StatusBarFragmentComponent}. */ 44 @Module 45 public interface StatusBarFragmentModule { 46 47 String LIGHTS_OUT_NOTIF_VIEW = "lights_out_notif_view"; 48 String OPERATOR_NAME_VIEW = "operator_name_view"; 49 String OPERATOR_NAME_FRAME_VIEW = "operator_name_frame_view"; 50 String START_SIDE_CONTENT = "start_side_content"; 51 String END_SIDE_CONTENT = "end_side_content"; 52 53 /** */ 54 @Provides 55 @RootView 56 @StatusBarFragmentScope providePhoneStatusBarView( CollapsedStatusBarFragment collapsedStatusBarFragment)57 static PhoneStatusBarView providePhoneStatusBarView( 58 CollapsedStatusBarFragment collapsedStatusBarFragment) { 59 return (PhoneStatusBarView) collapsedStatusBarFragment.getView(); 60 } 61 62 /** */ 63 @Provides 64 @StatusBarFragmentScope provideBatteryMeterView(@ootView PhoneStatusBarView view)65 static BatteryMeterView provideBatteryMeterView(@RootView PhoneStatusBarView view) { 66 return view.findViewById(R.id.battery); 67 } 68 69 /** */ 70 @Provides 71 @StatusBarFragmentScope 72 @Named(START_SIDE_CONTENT) startSideContent(@ootView PhoneStatusBarView view)73 static View startSideContent(@RootView PhoneStatusBarView view) { 74 return view.findViewById(R.id.status_bar_start_side_content); 75 } 76 77 /** */ 78 @Provides 79 @StatusBarFragmentScope 80 @Named(END_SIDE_CONTENT) endSideContent(@ootView PhoneStatusBarView view)81 static View endSideContent(@RootView PhoneStatusBarView view) { 82 return view.findViewById(R.id.status_bar_end_side_content); 83 } 84 85 /** */ 86 @Provides 87 @StatusBarFragmentScope 88 @Named(LIGHTS_OUT_NOTIF_VIEW) provideLightsOutNotifView(@ootView PhoneStatusBarView view)89 static View provideLightsOutNotifView(@RootView PhoneStatusBarView view) { 90 return view.findViewById(R.id.notification_lights_out); 91 } 92 93 /** */ 94 @Provides 95 @StatusBarFragmentScope 96 @Named(OPERATOR_NAME_VIEW) provideOperatorNameView(@ootView PhoneStatusBarView view)97 static View provideOperatorNameView(@RootView PhoneStatusBarView view) { 98 return view.findViewById(R.id.operator_name); 99 } 100 101 /** */ 102 @Provides 103 @StatusBarFragmentScope 104 @Named(OPERATOR_NAME_FRAME_VIEW) provideOperatorFrameNameView(@ootView PhoneStatusBarView view)105 static Optional<View> provideOperatorFrameNameView(@RootView PhoneStatusBarView view) { 106 return Optional.ofNullable(view.findViewById(R.id.operator_name_frame)); 107 } 108 109 /** */ 110 @Provides 111 @StatusBarFragmentScope provideClock(@ootView PhoneStatusBarView view)112 static Clock provideClock(@RootView PhoneStatusBarView view) { 113 return view.findViewById(R.id.clock); 114 } 115 116 /** */ 117 @Provides 118 @StatusBarFragmentScope provideStatusBarUserSwitcherContainer( @ootView PhoneStatusBarView view)119 static StatusBarUserSwitcherContainer provideStatusBarUserSwitcherContainer( 120 @RootView PhoneStatusBarView view) { 121 return view.findViewById(R.id.user_switcher_container); 122 } 123 124 /** */ 125 @Provides 126 @StatusBarFragmentScope providePhoneStatusBarViewController( PhoneStatusBarViewController.Factory phoneStatusBarViewControllerFactory, @RootView PhoneStatusBarView phoneStatusBarView)127 static PhoneStatusBarViewController providePhoneStatusBarViewController( 128 PhoneStatusBarViewController.Factory phoneStatusBarViewControllerFactory, 129 @RootView PhoneStatusBarView phoneStatusBarView) { 130 return phoneStatusBarViewControllerFactory.create( 131 phoneStatusBarView); 132 } 133 134 /** */ 135 @Provides 136 @StatusBarFragmentScope providePhoneStatusBarTransitions( @ootView PhoneStatusBarView view, StatusBarWindowController statusBarWindowController )137 static PhoneStatusBarTransitions providePhoneStatusBarTransitions( 138 @RootView PhoneStatusBarView view, 139 StatusBarWindowController statusBarWindowController 140 ) { 141 return new PhoneStatusBarTransitions(view, statusBarWindowController.getBackgroundView()); 142 } 143 144 /** */ 145 @Provides 146 @StatusBarFragmentScope providesHeasdUpStatusBarView(@ootView PhoneStatusBarView view)147 static HeadsUpStatusBarView providesHeasdUpStatusBarView(@RootView PhoneStatusBarView view) { 148 return view.findViewById(R.id.heads_up_status_bar_view); 149 } 150 151 /** */ 152 @Multibinds boundsChangeListeners()153 Set<StatusBarBoundsProvider.BoundsChangeListener> boundsChangeListeners(); 154 } 155