Merge changes I36f6cfb8,I7c784765

* changes:
  Create new window for Taskbar Nav Buttons when taskbar is focusable
  Make taskbar focusable when folder is open to get IME input
This commit is contained in:
Tony Wickham
2022-01-14 17:12:08 +00:00
committed by Android (Google) Code Review
7 changed files with 204 additions and 58 deletions

View File

@@ -16,6 +16,7 @@
package com.android.launcher3.taskbar;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
@@ -189,21 +190,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
public void init(TaskbarSharedState sharedState) {
mLastRequestedNonFullscreenHeight = getDefaultTaskbarWindowHeight();
mWindowLayoutParams = new WindowManager.LayoutParams(
MATCH_PARENT,
mLastRequestedNonFullscreenHeight,
TYPE_NAVIGATION_BAR_PANEL,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_SLIPPERY,
PixelFormat.TRANSLUCENT);
mWindowLayoutParams.setTitle(WINDOW_TITLE);
mWindowLayoutParams.packageName = getPackageName();
mWindowLayoutParams.gravity = Gravity.BOTTOM;
mWindowLayoutParams.setFitInsetsTypes(0);
mWindowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
mWindowLayoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
mWindowLayoutParams.privateFlags =
WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
mWindowLayoutParams = createDefaultWindowLayoutParams();
WindowManagerWrapper wmWrapper = WindowManagerWrapper.getInstance();
wmWrapper.setProvidesInsetsTypes(
@@ -224,6 +211,27 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
mWindowManager.addView(mDragLayer, mWindowLayoutParams);
}
/** Creates LayoutParams for adding a view directly to WindowManager as a new window */
public WindowManager.LayoutParams createDefaultWindowLayoutParams() {
WindowManager.LayoutParams windowLayoutParams = new WindowManager.LayoutParams(
MATCH_PARENT,
mLastRequestedNonFullscreenHeight,
TYPE_NAVIGATION_BAR_PANEL,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_SLIPPERY,
PixelFormat.TRANSLUCENT);
windowLayoutParams.setTitle(WINDOW_TITLE);
windowLayoutParams.packageName = getPackageName();
windowLayoutParams.gravity = Gravity.BOTTOM;
windowLayoutParams.setFitInsetsTypes(0);
windowLayoutParams.receiveInsetsIgnoringZOrder = true;
windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
windowLayoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
windowLayoutParams.privateFlags =
WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
return windowLayoutParams;
}
public void onConfigurationChanged(@Config int configChanges) {
mControllers.onConfigurationChanged(configChanges);
}
@@ -270,14 +278,6 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
return mViewCache;
}
@Override
public boolean supportsIme() {
// Currently we don't support IME because we have FLAG_NOT_FOCUSABLE. We can remove that
// flag when opening a floating view that needs IME (such as Folder), but then that means
// Taskbar will be below IME and thus users can't click the back button.
return false;
}
@Override
public View.OnClickListener getItemOnClickListener() {
return this::onTaskbarIconClicked;
@@ -505,6 +505,31 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
return mTaskbarHeightForIme;
}
/**
* Either adds or removes {@link WindowManager.LayoutParams#FLAG_NOT_FOCUSABLE} on the taskbar
* window. If we're now focusable, also move nav buttons to a separate window above IME.
*/
public void setTaskbarWindowFocusableForIme(boolean focusable) {
if (focusable) {
mWindowLayoutParams.flags &= ~FLAG_NOT_FOCUSABLE;
mControllers.navbarButtonsViewController.moveNavButtonsToNewWindow();
} else {
mWindowLayoutParams.flags |= FLAG_NOT_FOCUSABLE;
mControllers.navbarButtonsViewController.moveNavButtonsBackToTaskbarWindow();
}
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
}
/** Adds the given view to WindowManager with the provided LayoutParams (creates new window). */
public void addWindowView(View view, WindowManager.LayoutParams windowLayoutParams) {
mWindowManager.addView(view, windowLayoutParams);
}
/** Removes the given view from WindowManager. See {@link #addWindowView}. */
public void removeWindowView(View view) {
mWindowManager.removeViewImmediate(view);
}
protected void onTaskbarIconClicked(View view) {
Object tag = view.getTag();
if (tag instanceof Task) {
@@ -514,6 +539,17 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
} else if (tag instanceof FolderInfo) {
FolderIcon folderIcon = (FolderIcon) view;
Folder folder = folderIcon.getFolder();
folder.setOnFolderStateChangedListener(newState -> {
if (newState == Folder.STATE_OPEN) {
setTaskbarWindowFocusableForIme(true);
} else if (newState == Folder.STATE_CLOSED) {
// Defer by a frame to ensure we're no longer fullscreen and thus won't jump.
getDragLayer().post(() -> setTaskbarWindowFocusableForIme(false));
folder.setOnFolderStateChangedListener(null);
}
});
setTaskbarWindowFullscreen(true);
getDragLayer().post(() -> {