• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.navigationbar;
18 
19 import android.content.Context;
20 import android.view.LayoutInflater;
21 import android.view.View;
22 import android.view.WindowManager;
23 
24 import com.android.app.displaylib.PerDisplayRepository;
25 import com.android.systemui.dagger.qualifiers.DisplayId;
26 import com.android.systemui.model.SysUiState;
27 import com.android.systemui.navigationbar.NavigationBarComponent.NavigationBarScope;
28 import com.android.systemui.navigationbar.views.NavigationBarFrame;
29 import com.android.systemui.navigationbar.views.NavigationBarView;
30 import com.android.systemui.res.R;
31 import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround;
32 import com.android.systemui.utils.windowmanager.WindowManagerProvider;
33 
34 import dagger.Module;
35 import dagger.Provides;
36 
37 /** Module for {@link com.android.systemui.navigationbar.NavigationBarComponent}. */
38 @Module
39 public interface NavigationBarModule {
40     /** A Layout inflater specific to the display's context. */
41     @Provides
42     @NavigationBarScope
43     @DisplayId
provideLayoutInflater(@isplayId Context context)44     static LayoutInflater provideLayoutInflater(@DisplayId Context context) {
45         return LayoutInflater.from(context);
46     }
47 
48     /** */
49     @Provides
50     @NavigationBarScope
provideNavigationBarFrame(@isplayId LayoutInflater layoutInflater)51     static NavigationBarFrame provideNavigationBarFrame(@DisplayId LayoutInflater layoutInflater) {
52         return (NavigationBarFrame) layoutInflater.inflate(R.layout.navigation_bar_window, null);
53     }
54 
55     /** */
56     @Provides
57     @NavigationBarScope
provideNavigationBarview( @isplayId LayoutInflater layoutInflater, NavigationBarFrame frame)58     static NavigationBarView provideNavigationBarview(
59             @DisplayId LayoutInflater layoutInflater, NavigationBarFrame frame) {
60         View barView = layoutInflater.inflate(R.layout.navigation_bar, frame);
61         return barView.findViewById(R.id.navigation_bar_view);
62     }
63 
64     /** A WindowManager specific to the display's context. */
65     @Provides
66     @NavigationBarScope
67     @DisplayId
provideWindowManager(@isplayId Context context, WindowManagerProvider windowManagerProvider)68     static WindowManager provideWindowManager(@DisplayId Context context,
69             WindowManagerProvider windowManagerProvider) {
70         return windowManagerProvider.getWindowManager(context);
71     }
72 
73     /** A SysUiState for the navigation bar display. */
74     @Provides
75     @NavigationBarScope
76     @DisplayId
provideSysUiState(@isplayId Context context, SysUiState defaultState, PerDisplayRepository<SysUiState> repository)77     static SysUiState provideSysUiState(@DisplayId Context context,
78             SysUiState defaultState,
79             PerDisplayRepository<SysUiState> repository) {
80         if (ShadeWindowGoesAround.isEnabled()) {
81             return repository.get(context.getDisplayId());
82         } else {
83             return defaultState;
84         }
85     }
86 }
87