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 package com.android.launcher3.taskbar; 17 18 import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_NOTIFICATIONS; 19 import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_QUICK_SETTINGS; 20 21 import android.view.LayoutInflater; 22 import android.view.View; 23 import android.view.ViewGroup; 24 import android.widget.FrameLayout; 25 26 import com.android.launcher3.R; 27 28 /** 29 * Controller for managing buttons and status icons in taskbar in a desktop environment. 30 */ 31 public class DesktopNavbarButtonsViewController extends NavbarButtonsViewController { 32 33 private final TaskbarActivityContext mContext; 34 private final FrameLayout mNavButtonsView; 35 private final ViewGroup mNavButtonContainer; 36 private final ViewGroup mStartContextualContainer; 37 private final View mAllAppsButton; 38 39 private TaskbarControllers mControllers; 40 DesktopNavbarButtonsViewController(TaskbarActivityContext context, FrameLayout navButtonsView)41 public DesktopNavbarButtonsViewController(TaskbarActivityContext context, 42 FrameLayout navButtonsView) { 43 super(context, navButtonsView); 44 mContext = context; 45 mNavButtonsView = navButtonsView; 46 mNavButtonContainer = mNavButtonsView.findViewById(R.id.end_nav_buttons); 47 mStartContextualContainer = mNavButtonsView.findViewById(R.id.start_contextual_buttons); 48 mAllAppsButton = LayoutInflater.from(context) 49 .inflate(R.layout.taskbar_all_apps_button, mStartContextualContainer, false); 50 mAllAppsButton.setOnClickListener((View v) -> { 51 mControllers.taskbarAllAppsController.show(); 52 }); 53 } 54 55 /** 56 * Initializes the controller 57 */ 58 @Override init(TaskbarControllers controllers)59 public void init(TaskbarControllers controllers) { 60 mControllers = controllers; 61 mNavButtonsView.getLayoutParams().height = mContext.getDeviceProfile().taskbarHeight; 62 63 // Quick settings and notifications buttons 64 addButton(R.drawable.ic_sysbar_quick_settings, BUTTON_QUICK_SETTINGS, 65 mNavButtonContainer, mControllers.navButtonController, 66 R.id.quick_settings_button); 67 addButton(R.drawable.ic_sysbar_notifications, BUTTON_NOTIFICATIONS, 68 mNavButtonContainer, mControllers.navButtonController, 69 R.id.notifications_button); 70 // All apps button 71 mStartContextualContainer.addView(mAllAppsButton); 72 } 73 74 /** Cleans up on destroy */ 75 @Override onDestroy()76 public void onDestroy() { } 77 } 78