mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 19:38:21 +00:00
Merge "Revert "Ensure taskbar insets for camera cutout only apply on the needed sides"" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
50ae58df57
@@ -529,26 +529,52 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
|
||||
/**
|
||||
* Creates {@link WindowManager.LayoutParams} for Taskbar, and also sets LP.paramsForRotation
|
||||
* for taskbar
|
||||
* for taskbar showing as navigation bar
|
||||
*/
|
||||
private WindowManager.LayoutParams createAllWindowParams() {
|
||||
final int windowType =
|
||||
ENABLE_TASKBAR_NAVBAR_UNIFICATION ? TYPE_NAVIGATION_BAR : TYPE_NAVIGATION_BAR_PANEL;
|
||||
WindowManager.LayoutParams windowLayoutParams =
|
||||
createDefaultWindowLayoutParams(windowType, TaskbarActivityContext.WINDOW_TITLE);
|
||||
if (!isPhoneButtonNavMode()) {
|
||||
return windowLayoutParams;
|
||||
}
|
||||
|
||||
// Provide WM layout params for all rotations to cache, see NavigationBar#getBarLayoutParams
|
||||
int width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
int height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
int gravity = Gravity.BOTTOM;
|
||||
windowLayoutParams.paramsForRotation = new WindowManager.LayoutParams[4];
|
||||
for (int rot = Surface.ROTATION_0; rot <= Surface.ROTATION_270; rot++) {
|
||||
WindowManager.LayoutParams lp =
|
||||
createDefaultWindowLayoutParams(windowType,
|
||||
TaskbarActivityContext.WINDOW_TITLE);
|
||||
if (isPhoneButtonNavMode()) {
|
||||
populatePhoneButtonNavModeWindowLayoutParams(rot, lp);
|
||||
switch (rot) {
|
||||
case Surface.ROTATION_0, Surface.ROTATION_180 -> {
|
||||
// Defaults are fine
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
height = mLastRequestedNonFullscreenSize;
|
||||
gravity = Gravity.BOTTOM;
|
||||
}
|
||||
case Surface.ROTATION_90 -> {
|
||||
width = mLastRequestedNonFullscreenSize;
|
||||
height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
gravity = Gravity.END;
|
||||
}
|
||||
case Surface.ROTATION_270 -> {
|
||||
width = mLastRequestedNonFullscreenSize;
|
||||
height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
gravity = Gravity.START;
|
||||
}
|
||||
|
||||
}
|
||||
lp.width = width;
|
||||
lp.height = height;
|
||||
lp.gravity = gravity;
|
||||
windowLayoutParams.paramsForRotation[rot] = lp;
|
||||
}
|
||||
|
||||
// Override with current layout params
|
||||
// Override current layout params
|
||||
WindowManager.LayoutParams currentParams =
|
||||
windowLayoutParams.paramsForRotation[getDisplay().getRotation()];
|
||||
windowLayoutParams.width = currentParams.width;
|
||||
@@ -558,32 +584,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
return windowLayoutParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update {@link WindowManager.LayoutParams} with values specific to phone and 3 button
|
||||
* navigation users
|
||||
*/
|
||||
private void populatePhoneButtonNavModeWindowLayoutParams(int rot,
|
||||
WindowManager.LayoutParams lp) {
|
||||
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
lp.gravity = Gravity.BOTTOM;
|
||||
|
||||
// Override with per-rotation specific values
|
||||
switch (rot) {
|
||||
case Surface.ROTATION_0, Surface.ROTATION_180 -> {
|
||||
lp.height = mLastRequestedNonFullscreenSize;
|
||||
}
|
||||
case Surface.ROTATION_90 -> {
|
||||
lp.width = mLastRequestedNonFullscreenSize;
|
||||
lp.gravity = Gravity.END;
|
||||
}
|
||||
case Surface.ROTATION_270 -> {
|
||||
lp.width = mLastRequestedNonFullscreenSize;
|
||||
lp.gravity = Gravity.START;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(@Config int configChanges) {
|
||||
mControllers.onConfigurationChanged(configChanges);
|
||||
if (!mIsUserSetupComplete) {
|
||||
@@ -944,10 +944,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
}
|
||||
if (landscapePhoneButtonNav) {
|
||||
mWindowLayoutParams.width = size;
|
||||
mWindowLayoutParams.paramsForRotation[getDisplay().getRotation()].width = size;
|
||||
} else {
|
||||
mWindowLayoutParams.height = size;
|
||||
mWindowLayoutParams.paramsForRotation[getDisplay().getRotation()].height = size;
|
||||
}
|
||||
mControllers.taskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged();
|
||||
notifyUpdateLayoutParams();
|
||||
|
||||
@@ -118,9 +118,11 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
||||
getProvidedInsets(insetsRoundedCornerFlag)
|
||||
}
|
||||
|
||||
if (windowLayoutParams.paramsForRotation != null) {
|
||||
for (layoutParams in windowLayoutParams.paramsForRotation) {
|
||||
layoutParams.providedInsets = getProvidedInsets(insetsRoundedCornerFlag)
|
||||
if (!context.isGestureNav) {
|
||||
if (windowLayoutParams.paramsForRotation != null) {
|
||||
for (layoutParams in windowLayoutParams.paramsForRotation) {
|
||||
layoutParams.providedInsets = getProvidedInsets(insetsRoundedCornerFlag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,12 +156,19 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas
|
||||
)
|
||||
}
|
||||
|
||||
val gravity = windowLayoutParams.gravity
|
||||
|
||||
// Pre-calculate insets for different providers across different rotations for this gravity
|
||||
for (rotation in Surface.ROTATION_0..Surface.ROTATION_270) {
|
||||
// Add insets for navbar rotated params
|
||||
val layoutParams = windowLayoutParams.paramsForRotation[rotation]
|
||||
for (provider in layoutParams.providedInsets) {
|
||||
setProviderInsets(provider, layoutParams.gravity, rotation)
|
||||
if (windowLayoutParams.paramsForRotation != null) {
|
||||
val layoutParams = windowLayoutParams.paramsForRotation[rotation]
|
||||
for (provider in layoutParams.providedInsets) {
|
||||
setProviderInsets(provider, layoutParams.gravity, rotation)
|
||||
}
|
||||
}
|
||||
for (provider in windowLayoutParams.providedInsets) {
|
||||
setProviderInsets(provider, gravity, rotation)
|
||||
}
|
||||
}
|
||||
context.notifyUpdateLayoutParams()
|
||||
|
||||
Reference in New Issue
Block a user