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 com.android.systemui.battery.BatteryMeterViewController; 20 import com.android.systemui.dagger.qualifiers.RootView; 21 import com.android.systemui.statusbar.phone.HeadsUpAppearanceController; 22 import com.android.systemui.statusbar.phone.PhoneStatusBarView; 23 import com.android.systemui.statusbar.phone.PhoneStatusBarViewController; 24 import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment; 25 26 import dagger.BindsInstance; 27 import dagger.Subcomponent; 28 29 /** 30 * A subcomponent that gets re-created each time we create a new {@link CollapsedStatusBarFragment}. 31 * 32 * This component will also re-create all classes that depend on {@link CollapsedStatusBarFragment} 33 * and friends. Specifically, the fragment creates a new {@link PhoneStatusBarView} and multiple 34 * controllers need access to that view, so those controllers will be re-created whenever the 35 * fragment is recreated. 36 * 37 * Note that this is completely separate from 38 * {@link com.android.systemui.statusbar.phone.dagger.StatusBarComponent}. This component gets 39 * re-created on each new fragment creation, whereas 40 * {@link com.android.systemui.statusbar.phone.dagger.StatusBarComponent} is only created once in 41 * {@link com.android.systemui.statusbar.phone.StatusBar} and never re-created. 42 */ 43 44 @Subcomponent(modules = {StatusBarFragmentModule.class}) 45 @StatusBarFragmentScope 46 public interface StatusBarFragmentComponent { 47 /** Simple factory. */ 48 @Subcomponent.Factory 49 interface Factory { create( @indsInstance CollapsedStatusBarFragment collapsedStatusBarFragment)50 StatusBarFragmentComponent create( 51 @BindsInstance CollapsedStatusBarFragment collapsedStatusBarFragment); 52 } 53 54 /** 55 * Initialize anything extra for the component. Must be called after the component is created. 56 */ init()57 default void init() { 58 // No one accesses this controller, so we need to make sure we reference it here so it does 59 // get initialized. 60 getBatteryMeterViewController().init(); 61 getHeadsUpAppearanceController().init(); 62 getPhoneStatusBarViewController().init(); 63 } 64 65 /** */ 66 @StatusBarFragmentScope getBatteryMeterViewController()67 BatteryMeterViewController getBatteryMeterViewController(); 68 69 /** */ 70 @StatusBarFragmentScope 71 @RootView getPhoneStatusBarView()72 PhoneStatusBarView getPhoneStatusBarView(); 73 74 /** */ 75 @StatusBarFragmentScope getPhoneStatusBarViewController()76 PhoneStatusBarViewController getPhoneStatusBarViewController(); 77 78 /** */ 79 @StatusBarFragmentScope getHeadsUpAppearanceController()80 HeadsUpAppearanceController getHeadsUpAppearanceController(); 81 } 82