1 /* 2 * Copyright (C) 2021 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 androidx.annotation.IntDef; 19 20 import com.android.quickstep.SystemUiProxy; 21 22 import java.lang.annotation.Retention; 23 import java.lang.annotation.RetentionPolicy; 24 25 /** 26 * Normally Taskbar will auto-hide when entering immersive (fullscreen) apps. This controller allows 27 * us to suspend that behavior in certain cases (e.g. opening a Folder or dragging an icon). 28 */ 29 public class TaskbarAutohideSuspendController { 30 31 public static final int FLAG_AUTOHIDE_SUSPEND_FULLSCREEN = 1 << 0; 32 public static final int FLAG_AUTOHIDE_SUSPEND_DRAGGING = 1 << 1; 33 @IntDef(flag = true, value = { 34 FLAG_AUTOHIDE_SUSPEND_FULLSCREEN, 35 FLAG_AUTOHIDE_SUSPEND_DRAGGING, 36 }) 37 @Retention(RetentionPolicy.SOURCE) 38 public @interface AutohideSuspendFlag {} 39 40 private final SystemUiProxy mSystemUiProxy; 41 42 private @AutohideSuspendFlag int mAutohideSuspendFlags = 0; 43 TaskbarAutohideSuspendController(TaskbarActivityContext activity)44 public TaskbarAutohideSuspendController(TaskbarActivityContext activity) { 45 mSystemUiProxy = SystemUiProxy.INSTANCE.get(activity); 46 } 47 onDestroy()48 public void onDestroy() { 49 mSystemUiProxy.notifyTaskbarAutohideSuspend(false); 50 } 51 52 /** 53 * Adds or removes the given flag, then notifies system UI proxy whether to suspend auto-hide. 54 */ updateFlag(@utohideSuspendFlag int flag, boolean enabled)55 public void updateFlag(@AutohideSuspendFlag int flag, boolean enabled) { 56 if (enabled) { 57 mAutohideSuspendFlags |= flag; 58 } else { 59 mAutohideSuspendFlags &= ~flag; 60 } 61 mSystemUiProxy.notifyTaskbarAutohideSuspend(mAutohideSuspendFlags != 0); 62 } 63 } 64