• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.qs.dagger;
18 
19 import static com.android.systemui.util.Utils.useCollapsedMediaInLandscape;
20 import static com.android.systemui.util.Utils.useQsMediaPlayer;
21 
22 import android.content.Context;
23 import android.view.LayoutInflater;
24 import android.view.View;
25 
26 import com.android.systemui.R;
27 import com.android.systemui.dagger.qualifiers.RootView;
28 import com.android.systemui.plugins.qs.QS;
29 import com.android.systemui.qs.QSContainerImpl;
30 import com.android.systemui.qs.QSFooter;
31 import com.android.systemui.qs.QSFooterView;
32 import com.android.systemui.qs.QSFooterViewController;
33 import com.android.systemui.qs.QSFragment;
34 import com.android.systemui.qs.QSPanel;
35 import com.android.systemui.qs.QuickQSPanel;
36 import com.android.systemui.qs.QuickStatusBarHeader;
37 import com.android.systemui.qs.customize.QSCustomizer;
38 
39 import javax.inject.Named;
40 
41 import dagger.Binds;
42 import dagger.Module;
43 import dagger.Provides;
44 
45 /**
46  * Dagger Module for {@link QSFragmentComponent}.
47  */
48 @Module
49 public interface QSFragmentModule {
50     String QS_USING_MEDIA_PLAYER = "qs_using_media_player";
51     String QS_USING_COLLAPSED_LANDSCAPE_MEDIA = "qs_using_collapsed_landscape_media";
52 
53     /**
54      * Provide a context themed using the QS theme
55      */
56     @Provides
57     @QSThemedContext
provideThemedContext(@ootView View view)58     static Context provideThemedContext(@RootView View view) {
59         return view.getContext();
60     }
61 
62     /** */
63     @Provides
64     @QSThemedContext
provideThemedLayoutInflater(@SThemedContext Context context)65     static LayoutInflater provideThemedLayoutInflater(@QSThemedContext Context context) {
66         return LayoutInflater.from(context);
67     }
68 
69     /** */
70     @Provides
71     @RootView
provideRootView(QSFragment qsFragment)72     static View provideRootView(QSFragment qsFragment) {
73         return qsFragment.getView();
74     }
75 
76     /** */
77     @Provides
provideQSPanel(@ootView View view)78     static QSPanel provideQSPanel(@RootView View view) {
79         return view.findViewById(R.id.quick_settings_panel);
80     }
81 
82     /** */
83     @Provides
providesQSContainerImpl(@ootView View view)84     static QSContainerImpl providesQSContainerImpl(@RootView View view) {
85         return view.findViewById(R.id.quick_settings_container);
86     }
87 
88     /** */
89     @Binds
bindQS(QSFragment qsFragment)90     QS bindQS(QSFragment qsFragment);
91 
92     /** */
93     @Provides
providesQuickStatusBarHeader(@ootView View view)94     static QuickStatusBarHeader providesQuickStatusBarHeader(@RootView View view) {
95         return view.findViewById(R.id.header);
96     }
97 
98     /** */
99     @Provides
providesQuickQSPanel(QuickStatusBarHeader quickStatusBarHeader)100     static QuickQSPanel providesQuickQSPanel(QuickStatusBarHeader quickStatusBarHeader) {
101         return quickStatusBarHeader.findViewById(R.id.quick_qs_panel);
102     }
103 
104     /** */
105     @Provides
providesQSFooterView(@ootView View view)106     static QSFooterView providesQSFooterView(@RootView View view) {
107         return view.findViewById(R.id.qs_footer);
108     }
109 
110     /** */
111     @Provides
112     @QSScope
providesQSFooter(QSFooterViewController qsFooterViewController)113     static QSFooter providesQSFooter(QSFooterViewController qsFooterViewController) {
114         qsFooterViewController.init();
115         return qsFooterViewController;
116     }
117 
118     /** */
119     @Provides
120     @QSScope
providesQSCutomizer(@ootView View view)121     static QSCustomizer providesQSCutomizer(@RootView View view) {
122         return view.findViewById(R.id.qs_customize);
123     }
124 
125     /** */
126     @Provides
127     @Named(QS_USING_MEDIA_PLAYER)
providesQSUsingMediaPlayer(Context context)128     static boolean providesQSUsingMediaPlayer(Context context) {
129         return useQsMediaPlayer(context);
130     }
131 
132     /** */
133     @Provides
134     @Named(QS_USING_COLLAPSED_LANDSCAPE_MEDIA)
providesQSUsingCollapsedLandscapeMedia(Context context)135     static boolean providesQSUsingCollapsedLandscapeMedia(Context context) {
136         return useCollapsedMediaInLandscape(context.getResources());
137     }
138 }