Stash taskbar when software keyboard is docked

Stash taskbar when
1) Software keybaord is docked
2) Input toolbar is placed at the taskbar area (stash so toolbar and taskbar would not overlap)

Testing result:
https://drive.google.com/file/d/1NMDexHl0FgyHFaOUh_GSEEUU2k08STJH/view?usp=sharing

Bug: 317251202
Test: TaplTestsQuickstep#testQuickSwitchToPreviousAppForTablet
Flag: N/A

Change-Id: I90662bc6e68f644e919f5c702059476b02519ed6
This commit is contained in:
helencheuk
2024-02-09 15:36:44 +00:00
parent a6def81654
commit 00ddb5e3a9
11 changed files with 81 additions and 7 deletions
@@ -72,6 +72,8 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.graphics.Insets;
import androidx.core.view.WindowInsetsCompat;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BubbleTextView;
@@ -417,6 +419,28 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
return isPhoneMode() && !isThreeButtonNav();
}
/**
* Returns if software keyboard is docked or input toolbar is placed at the taskbar area
*/
public boolean isImeDocked() {
View dragLayer = getDragLayer();
WindowInsets insets = dragLayer.getRootWindowInsets();
if (insets == null) {
return false;
}
WindowInsetsCompat insetsCompat =
WindowInsetsCompat.toWindowInsetsCompat(insets, dragLayer.getRootView());
if (insetsCompat.isVisible(WindowInsetsCompat.Type.ime())) {
Insets imeInsets = insetsCompat.getInsets(WindowInsetsCompat.Type.ime());
return imeInsets.bottom >= getResources().getDimensionPixelSize(
R.dimen.floating_ime_inset_height);
} else {
return false;
}
}
/**
* Show Taskbar upon receiving broadcast
*/
@@ -30,9 +30,12 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.Insets;
import androidx.core.view.WindowInsetsCompat;
import com.android.app.viewcapture.SettingsAwareViewCapture;
import com.android.launcher3.AbstractFloatingView;
@@ -110,6 +113,18 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
recreateControllers();
}
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
if (insets != null) {
WindowInsetsCompat insetsCompat = WindowInsetsCompat.toWindowInsetsCompat(insets, this);
Insets imeInsets = insetsCompat.getInsets(WindowInsetsCompat.Type.ime());
if (imeInsets != null) {
mControllerCallbacks.onImeInsetChanged();
}
}
return insets;
}
@Override
public void recreateControllers() {
mControllers = mControllerCallbacks.getTouchControllers();
@@ -275,6 +275,13 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
mControllers.taskbarInsetsController.updateInsetsTouchability(insetsInfo);
}
/**
* Called when an IME inset is changed.
*/
public void onImeInsetChanged() {
mControllers.taskbarStashController.onImeInsetChanged();
}
/**
* Called when a child is removed from TaskbarDragLayer.
*/
@@ -891,6 +891,10 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
}
// Only update the following flags when system gesture is not in progress.
setStashedImeState();
}
private void setStashedImeState() {
boolean shouldStashForIme = shouldStashForIme();
updateStateForFlag(FLAG_STASHED_IN_TASKBAR_ALL_APPS, false);
if (hasAnyFlag(FLAG_STASHED_IN_APP_IME) != shouldStashForIme) {
@@ -901,6 +905,13 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
}
}
/**
* Should be called when Ime inset is changed to determine if taskbar should be stashed
*/
public void onImeInsetChanged() {
setStashedImeState();
}
/**
* When hiding the IME, delay the unstash animation to align with the end of the transition.
*/
@@ -950,7 +961,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
*
* <p>Do not stash if in small screen, with 3 button nav, and in landscape (or seascape).
* <p>Do not stash if taskbar is transient.
* <p>Do not stash if hardware keyboard is attached and taskbar is pinned.
* <p>Do not stash if hardware keyboard is attached and taskbar is pinned and IME is docked
*/
private boolean shouldStashForIme() {
if (DisplayController.isTransientTaskbar(mActivity)) {
@@ -961,8 +972,10 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
&& mActivity.getDeviceProfile().isLandscape) {
return false;
}
// Do not stash if pinned taskbar and hardware keyboard is attached.
if (mActivity.isHardwareKeyboard() && DisplayController.isPinnedTaskbar(mActivity)) {
// Do not stash if pinned taskbar, hardware keyboard is attached and no IME is docked
if (mActivity.isHardwareKeyboard() && DisplayController.isPinnedTaskbar(mActivity)
&& !mActivity.isImeDocked()) {
return false;
}
@@ -187,7 +187,10 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
// Allow null-pointer to catch illegal states.
runOnTISBinder(tisBinder -> tisBinder.getTaskbarManager().recreateTaskbar());
return response;
case TestProtocol.REQUEST_TASKBAR_IME_DOCKED:
return getTISBinderUIProperty(Bundle::putBoolean, tisBinder ->
tisBinder.getTaskbarManager()
.getCurrentActivityContext().isImeDocked());
case TestProtocol.REQUEST_UNSTASH_BUBBLE_BAR_IF_STASHED:
runOnTISBinder(tisBinder -> {
// Allow null-pointer to catch illegal states.