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.systemui.dagger.qualifiers.DisplayId; 25 import com.android.systemui.navigationbar.NavigationBarComponent.NavigationBarScope; 26 import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler; 27 import com.android.systemui.res.R; 28 29 import dagger.Module; 30 import dagger.Provides; 31 32 /** Module for {@link com.android.systemui.navigationbar.NavigationBarComponent}. */ 33 @Module 34 public interface NavigationBarModule { 35 /** A Layout inflater specific to the display's context. */ 36 @Provides 37 @NavigationBarScope 38 @DisplayId provideLayoutInflater(@isplayId Context context)39 static LayoutInflater provideLayoutInflater(@DisplayId Context context) { 40 return LayoutInflater.from(context); 41 } 42 43 /** */ 44 @Provides 45 @NavigationBarScope provideNavigationBarFrame(@isplayId LayoutInflater layoutInflater)46 static NavigationBarFrame provideNavigationBarFrame(@DisplayId LayoutInflater layoutInflater) { 47 return (NavigationBarFrame) layoutInflater.inflate(R.layout.navigation_bar_window, null); 48 } 49 50 /** */ 51 @Provides 52 @NavigationBarScope provideNavigationBarview( @isplayId LayoutInflater layoutInflater, NavigationBarFrame frame)53 static NavigationBarView provideNavigationBarview( 54 @DisplayId LayoutInflater layoutInflater, NavigationBarFrame frame) { 55 View barView = layoutInflater.inflate(R.layout.navigation_bar, frame); 56 return barView.findViewById(R.id.navigation_bar_view); 57 } 58 59 /** */ 60 @Provides 61 @NavigationBarScope provideEdgeBackGestureHandler( EdgeBackGestureHandler.Factory factory, @DisplayId Context context)62 static EdgeBackGestureHandler provideEdgeBackGestureHandler( 63 EdgeBackGestureHandler.Factory factory, @DisplayId Context context) { 64 return factory.create(context); 65 } 66 67 /** A WindowManager specific to the display's context. */ 68 @Provides 69 @NavigationBarScope 70 @DisplayId provideWindowManager(@isplayId Context context)71 static WindowManager provideWindowManager(@DisplayId Context context) { 72 return context.getSystemService(WindowManager.class); 73 } 74 } 75