• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.window
18 
19 import android.content.Context
20 import android.view.View
21 import android.view.ViewGroup
22 import android.view.WindowManager
23 import com.android.systemui.animation.ActivityTransitionAnimator
24 import com.android.systemui.fragments.FragmentHostManager
25 import com.android.systemui.statusbar.data.repository.StatusBarConfigurationController
26 import com.android.systemui.statusbar.layout.StatusBarContentInsetsProvider
27 import java.util.Optional
28 
29 /** Encapsulates all logic for the status bar window state management. */
30 interface StatusBarWindowController {
31     val statusBarHeight: Int
32 
33     /** Rereads the status bar height and reapplies the current state if the height is different. */
refreshStatusBarHeightnull34     fun refreshStatusBarHeight()
35 
36     /** Adds the status bar view to the window manager. */
37     fun attach()
38 
39     /** Called when work should stop and resources should be released. */
40     fun stop()
41 
42     /** Adds the given view to the status bar window view. */
43     fun addViewToWindow(view: View, layoutParams: ViewGroup.LayoutParams)
44 
45     /** Returns the status bar window's background view. */
46     val backgroundView: View
47 
48     /** Returns a fragment host manager for the status bar window view. */
49     val fragmentHostManager: FragmentHostManager
50 
51     /**
52      * Provides an updated animation controller if we're animating a view in the status bar.
53      *
54      * This is needed because we have to make sure that the status bar window matches the full
55      * screen during the animation and that we are expanding the view below the other status bar
56      * text.
57      *
58      * @param rootView the root view of the animation
59      * @param animationController the default animation controller to use
60      * @return If the animation is on a view in the status bar, returns an Optional containing an
61      *   updated animation controller that handles status-bar-related animation details. Returns an
62      *   empty optional if the animation is *not* on a view in the status bar.
63      */
64     fun wrapAnimationControllerIfInStatusBar(
65         rootView: View,
66         animationController: ActivityTransitionAnimator.Controller,
67     ): Optional<ActivityTransitionAnimator.Controller>
68 
69     /** Set force status bar visible. */
70     fun setForceStatusBarVisible(forceStatusBarVisible: Boolean)
71 
72     /**
73      * Sets whether an ongoing process requires the status bar to be forced visible.
74      *
75      * This method is separate from {@link this#setForceStatusBarVisible} because the ongoing
76      * process **takes priority**. For example, if {@link this#setForceStatusBarVisible} is set to
77      * false but this method is set to true, then the status bar **will** be visible.
78      *
79      * TODO(b/195839150): We should likely merge this method and {@link
80      *   this#setForceStatusBarVisible} together and use some sort of ranking system instead.
81      */
82     fun setOngoingProcessRequiresStatusBarVisible(visible: Boolean)
83 
84     fun interface Factory {
85         fun create(
86             context: Context,
87             windowManager: WindowManager,
88             statusBarConfigurationController: StatusBarConfigurationController,
89             contentInsetsProvider: StatusBarContentInsetsProvider,
90         ): StatusBarWindowController
91     }
92 }
93