2021-06-08 20:03:43 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2021 The Android Open Source Project
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
package com.android.launcher3.taskbar;
|
|
|
|
|
|
|
|
|
|
import android.content.res.Resources;
|
2022-08-11 17:33:35 -07:00
|
|
|
import android.graphics.Point;
|
2021-06-08 20:03:43 -07:00
|
|
|
import android.graphics.Rect;
|
2022-09-09 23:23:35 +00:00
|
|
|
import android.view.ViewTreeObserver;
|
2021-06-08 20:03:43 -07:00
|
|
|
|
2022-08-05 10:43:29 -07:00
|
|
|
import com.android.launcher3.DeviceProfile;
|
2021-06-08 20:03:43 -07:00
|
|
|
import com.android.launcher3.R;
|
2022-08-11 17:33:35 -07:00
|
|
|
import com.android.launcher3.util.DimensionUtils;
|
2021-12-01 14:51:51 +00:00
|
|
|
import com.android.launcher3.util.TouchController;
|
2021-06-08 20:03:43 -07:00
|
|
|
import com.android.quickstep.AnimatedFloat;
|
|
|
|
|
|
2021-12-15 13:09:39 -08:00
|
|
|
import java.io.PrintWriter;
|
|
|
|
|
|
2021-06-08 20:03:43 -07:00
|
|
|
/**
|
|
|
|
|
* Handles properties/data collection, then passes the results to TaskbarDragLayer to render.
|
|
|
|
|
*/
|
2021-12-15 13:09:39 -08:00
|
|
|
public class TaskbarDragLayerController implements TaskbarControllers.LoggableTaskbarController {
|
2021-06-08 20:03:43 -07:00
|
|
|
|
|
|
|
|
private final TaskbarActivityContext mActivity;
|
|
|
|
|
private final TaskbarDragLayer mTaskbarDragLayer;
|
|
|
|
|
private final int mFolderMargin;
|
2021-07-22 14:28:04 -10:00
|
|
|
|
2021-06-08 20:03:43 -07:00
|
|
|
// Alpha properties for taskbar background.
|
|
|
|
|
private final AnimatedFloat mBgTaskbar = new AnimatedFloat(this::updateBackgroundAlpha);
|
|
|
|
|
private final AnimatedFloat mBgNavbar = new AnimatedFloat(this::updateBackgroundAlpha);
|
2021-07-12 14:33:54 -07:00
|
|
|
private final AnimatedFloat mKeyguardBgTaskbar = new AnimatedFloat(this::updateBackgroundAlpha);
|
2021-10-21 10:45:20 -07:00
|
|
|
private final AnimatedFloat mNotificationShadeBgTaskbar = new AnimatedFloat(
|
|
|
|
|
this::updateBackgroundAlpha);
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
private final AnimatedFloat mImeBgTaskbar = new AnimatedFloat(this::updateBackgroundAlpha);
|
2021-07-22 14:28:04 -10:00
|
|
|
// Used to hide our background color when someone else (e.g. ScrimView) is handling it.
|
|
|
|
|
private final AnimatedFloat mBgOverride = new AnimatedFloat(this::updateBackgroundAlpha);
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
// Translation property for taskbar background.
|
|
|
|
|
private final AnimatedFloat mBgOffset = new AnimatedFloat(this::updateBackgroundOffset);
|
2021-06-08 20:03:43 -07:00
|
|
|
|
|
|
|
|
// Initialized in init.
|
|
|
|
|
private TaskbarControllers mControllers;
|
2021-11-04 16:53:59 -07:00
|
|
|
private AnimatedFloat mNavButtonDarkIntensityMultiplier;
|
|
|
|
|
|
|
|
|
|
private float mLastSetBackgroundAlpha;
|
2021-06-08 20:03:43 -07:00
|
|
|
|
|
|
|
|
public TaskbarDragLayerController(TaskbarActivityContext activity,
|
|
|
|
|
TaskbarDragLayer taskbarDragLayer) {
|
|
|
|
|
mActivity = activity;
|
|
|
|
|
mTaskbarDragLayer = taskbarDragLayer;
|
|
|
|
|
final Resources resources = mTaskbarDragLayer.getResources();
|
|
|
|
|
mFolderMargin = resources.getDimensionPixelSize(R.dimen.taskbar_folder_margin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void init(TaskbarControllers controllers) {
|
|
|
|
|
mControllers = controllers;
|
|
|
|
|
mTaskbarDragLayer.init(new TaskbarDragLayerCallbacks());
|
2021-10-19 14:48:09 -07:00
|
|
|
|
2021-11-04 16:53:59 -07:00
|
|
|
mNavButtonDarkIntensityMultiplier = mControllers.navbarButtonsViewController
|
|
|
|
|
.getNavButtonDarkIntensityMultiplier();
|
|
|
|
|
|
2021-10-19 14:48:09 -07:00
|
|
|
mBgTaskbar.value = 1;
|
2021-07-12 14:33:54 -07:00
|
|
|
mKeyguardBgTaskbar.value = 1;
|
2021-10-21 10:45:20 -07:00
|
|
|
mNotificationShadeBgTaskbar.value = 1;
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
mImeBgTaskbar.value = 1;
|
2021-07-22 14:28:04 -10:00
|
|
|
mBgOverride.value = 1;
|
2021-10-19 14:48:09 -07:00
|
|
|
updateBackgroundAlpha();
|
2021-06-08 20:03:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onDestroy() {
|
|
|
|
|
mTaskbarDragLayer.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Bounds (in TaskbarDragLayer coordinates) where an opened Folder can display.
|
|
|
|
|
*/
|
|
|
|
|
public Rect getFolderBoundingBox() {
|
|
|
|
|
Rect boundingBox = new Rect(0, 0, mTaskbarDragLayer.getWidth(),
|
|
|
|
|
mTaskbarDragLayer.getHeight() - mActivity.getDeviceProfile().taskbarSize);
|
|
|
|
|
boundingBox.inset(mFolderMargin, mFolderMargin);
|
|
|
|
|
return boundingBox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AnimatedFloat getTaskbarBackgroundAlpha() {
|
|
|
|
|
return mBgTaskbar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AnimatedFloat getNavbarBackgroundAlpha() {
|
|
|
|
|
return mBgNavbar;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 14:33:54 -07:00
|
|
|
public AnimatedFloat getKeyguardBgTaskbar() {
|
|
|
|
|
return mKeyguardBgTaskbar;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 10:45:20 -07:00
|
|
|
public AnimatedFloat getNotificationShadeBgTaskbar() {
|
|
|
|
|
return mNotificationShadeBgTaskbar;
|
|
|
|
|
}
|
|
|
|
|
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
public AnimatedFloat getImeBgTaskbar() {
|
|
|
|
|
return mImeBgTaskbar;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-22 14:28:04 -10:00
|
|
|
public AnimatedFloat getOverrideBackgroundAlpha() {
|
|
|
|
|
return mBgOverride;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
public AnimatedFloat getTaskbarBackgroundOffset() {
|
|
|
|
|
return mBgOffset;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-08 20:03:43 -07:00
|
|
|
private void updateBackgroundAlpha() {
|
2021-07-22 14:28:04 -10:00
|
|
|
final float bgNavbar = mBgNavbar.value;
|
2021-10-21 10:45:20 -07:00
|
|
|
final float bgTaskbar = mBgTaskbar.value * mKeyguardBgTaskbar.value
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
* mNotificationShadeBgTaskbar.value * mImeBgTaskbar.value;
|
2021-11-04 16:53:59 -07:00
|
|
|
mLastSetBackgroundAlpha = mBgOverride.value * Math.max(bgNavbar, bgTaskbar);
|
|
|
|
|
mTaskbarDragLayer.setTaskbarBackgroundAlpha(mLastSetBackgroundAlpha);
|
|
|
|
|
|
|
|
|
|
updateNavBarDarkIntensityMultiplier();
|
2021-06-08 20:03:43 -07:00
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
private void updateBackgroundOffset() {
|
|
|
|
|
mTaskbarDragLayer.setTaskbarBackgroundOffset(mBgOffset.value);
|
2021-11-04 16:53:59 -07:00
|
|
|
|
|
|
|
|
updateNavBarDarkIntensityMultiplier();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateNavBarDarkIntensityMultiplier() {
|
|
|
|
|
// Zero out the app-requested dark intensity when we're drawing our own background.
|
|
|
|
|
float effectiveBgAlpha = mLastSetBackgroundAlpha * (1 - mBgOffset.value);
|
|
|
|
|
mNavButtonDarkIntensityMultiplier.updateValue(1 - effectiveBgAlpha);
|
2021-06-01 16:54:07 -07:00
|
|
|
}
|
|
|
|
|
|
2021-12-15 13:09:39 -08:00
|
|
|
@Override
|
|
|
|
|
public void dumpLogs(String prefix, PrintWriter pw) {
|
|
|
|
|
pw.println(prefix + "TaskbarDragLayerController:");
|
|
|
|
|
|
2022-06-23 11:25:10 -07:00
|
|
|
pw.println(prefix + "\tmBgOffset=" + mBgOffset.value);
|
|
|
|
|
pw.println(prefix + "\tmFolderMargin=" + mFolderMargin);
|
|
|
|
|
pw.println(prefix + "\tmLastSetBackgroundAlpha=" + mLastSetBackgroundAlpha);
|
2021-12-15 13:09:39 -08:00
|
|
|
}
|
|
|
|
|
|
2021-06-08 20:03:43 -07:00
|
|
|
/**
|
|
|
|
|
* Callbacks for {@link TaskbarDragLayer} to interact with its controller.
|
|
|
|
|
*/
|
|
|
|
|
public class TaskbarDragLayerCallbacks {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called to update the touchable insets.
|
2022-09-09 23:23:35 +00:00
|
|
|
* @see ViewTreeObserver.InternalInsetsInfo#setTouchableInsets(int)
|
2021-06-08 20:03:43 -07:00
|
|
|
*/
|
2022-09-09 23:23:35 +00:00
|
|
|
public void updateInsetsTouchability(ViewTreeObserver.InternalInsetsInfo insetsInfo) {
|
2022-04-14 16:15:58 -07:00
|
|
|
mControllers.taskbarInsetsController.updateInsetsTouchability(insetsInfo);
|
2021-06-08 20:03:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when a child is removed from TaskbarDragLayer.
|
|
|
|
|
*/
|
|
|
|
|
public void onDragLayerViewRemoved() {
|
2022-02-24 18:57:59 -08:00
|
|
|
mActivity.maybeSetTaskbarWindowNotFullscreen();
|
2021-06-08 20:03:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns how tall the background should be drawn at the bottom of the screen.
|
|
|
|
|
*/
|
|
|
|
|
public int getTaskbarBackgroundHeight() {
|
2022-08-05 10:43:29 -07:00
|
|
|
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
|
|
|
|
|
if (TaskbarManager.isPhoneMode(deviceProfile)) {
|
|
|
|
|
Resources resources = mActivity.getResources();
|
2022-08-11 17:33:35 -07:00
|
|
|
Point taskbarDimensions =
|
|
|
|
|
DimensionUtils.getTaskbarPhoneDimensions(deviceProfile, resources,
|
|
|
|
|
TaskbarManager.isPhoneMode(deviceProfile));
|
|
|
|
|
return taskbarDimensions.y == -1 ?
|
|
|
|
|
deviceProfile.getDisplayInfo().currentSize.y :
|
|
|
|
|
taskbarDimensions.y;
|
2022-08-05 10:43:29 -07:00
|
|
|
} else {
|
|
|
|
|
return deviceProfile.taskbarSize;
|
|
|
|
|
}
|
2021-06-08 20:03:43 -07:00
|
|
|
}
|
2021-12-01 14:51:51 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns touch controllers.
|
|
|
|
|
*/
|
|
|
|
|
public TouchController[] getTouchControllers() {
|
|
|
|
|
return new TouchController[]{mActivity.getDragController(),
|
2022-05-02 11:51:01 -07:00
|
|
|
mControllers.taskbarForceVisibleImmersiveController,
|
|
|
|
|
mControllers.navbarButtonsViewController.getTouchController()};
|
2021-12-01 14:51:51 +00:00
|
|
|
}
|
2021-06-08 20:03:43 -07:00
|
|
|
}
|
|
|
|
|
}
|