Merge "Address some insets issues in Taskbar All Apps" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-03-04 00:08:34 +00:00
committed by Android (Google) Code Review
3 changed files with 48 additions and 5 deletions
@@ -60,10 +60,10 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
// If any of these flags are enabled, inset apps by our stashed height instead of our unstashed
// height. This way the reported insets are consistent even during transitions out of the app.
// Currently any flag that causes us to stash in an app is included, except for IME since that
// covers the underlying app anyway and thus the app shouldn't change insets.
// Currently any flag that causes us to stash in an app is included, except for IME or All Apps
// since those cover the underlying app anyway and thus the app shouldn't change insets.
private static final int FLAGS_REPORT_STASHED_INSETS_TO_APP = FLAGS_STASHED_IN_APP
& ~FLAG_STASHED_IN_APP_IME;
& ~FLAG_STASHED_IN_APP_IME & ~FLAG_STASHED_IN_APP_ALL_APPS;
/**
* How long to stash/unstash when manually invoked via long press.
@@ -187,7 +187,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
* Returns whether the taskbar can visually stash into a handle based on the current device
* state.
*/
private boolean supportsVisualStashing() {
public boolean supportsVisualStashing() {
return !mActivity.isThreeButtonNav();
}
@@ -254,7 +254,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
* Returns the height that taskbar will inset when inside apps.
*/
public int getContentHeightToReportToApps() {
if (hasAnyFlag(FLAGS_REPORT_STASHED_INSETS_TO_APP)) {
if (supportsVisualStashing() && hasAnyFlag(FLAGS_REPORT_STASHED_INSETS_TO_APP)) {
boolean isAnimating = mAnimator != null && mAnimator.isStarted();
return mControllers.stashedHandleViewController.isStashedHandleVisible() || isAnimating
? mStashedHeight : 0;
@@ -22,8 +22,10 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION;
import android.content.Context;
import android.graphics.Insets;
import android.view.KeyEvent;
import android.view.View;
import android.view.WindowInsets;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
@@ -59,6 +61,10 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
private final TaskbarAllAppsDragLayer mDragLayer;
private final TaskbarAllAppsContainerView mAppsView;
// We automatically stash taskbar when all apps is opened in gesture navigation mode.
private final boolean mWillTaskbarBeVisuallyStashed;
private final int mStashedTaskbarHeight;
TaskbarAllAppsContext(
TaskbarActivityContext taskbarContext,
TaskbarAllAppsController windowController,
@@ -79,6 +85,9 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
windowController,
taskbarStashController);
mAppsView = slideInView.getAppsView();
mWillTaskbarBeVisuallyStashed = taskbarStashController.supportsVisualStashing();
mStashedTaskbarHeight = taskbarStashController.getStashedHeight();
}
TaskbarAllAppsViewController getAllAppsViewController() {
@@ -189,5 +198,37 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
inoutInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION);
}
}
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
return updateInsetsDueToStashing(insets);
}
/**
* Taskbar automatically stashes when opening all apps, but we don't report the insets as
* changing to avoid moving the underlying app. But internally, the apps view should still
* layout according to the stashed insets rather than the unstashed insets. So this method
* does two things:
* 1) Sets navigationBars bottom inset to stashedHeight.
* 2) Sets tappableInsets bottom inset to 0.
*/
private WindowInsets updateInsetsDueToStashing(WindowInsets oldInsets) {
if (!mActivity.mWillTaskbarBeVisuallyStashed) {
return oldInsets;
}
WindowInsets.Builder updatedInsetsBuilder = new WindowInsets.Builder(oldInsets);
Insets oldNavInsets = oldInsets.getInsets(WindowInsets.Type.navigationBars());
Insets newNavInsets = Insets.of(oldNavInsets.left, oldNavInsets.top, oldNavInsets.right,
mActivity.mStashedTaskbarHeight);
updatedInsetsBuilder.setInsets(WindowInsets.Type.navigationBars(), newNavInsets);
Insets oldTappableInsets = oldInsets.getInsets(WindowInsets.Type.tappableElement());
Insets newTappableInsets = Insets.of(oldTappableInsets.left, oldTappableInsets.top,
oldTappableInsets.right, 0);
updatedInsetsBuilder.setInsets(WindowInsets.Type.tappableElement(), newTappableInsets);
return updatedInsetsBuilder.build();
}
}
}
@@ -15,6 +15,7 @@
*/
package com.android.launcher3.taskbar.allapps;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
@@ -158,6 +159,7 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
layoutParams.gravity = Gravity.BOTTOM;
layoutParams.packageName = mTaskbarContext.getPackageName();
layoutParams.setFitInsetsTypes(0); // Handled by container view.
layoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
layoutParams.setSystemApplicationOverlay(true);
return layoutParams;
}