From fa6011fcdf73ad1cee81bc2fdc2bacb246688daf Mon Sep 17 00:00:00 2001 From: Brandon Dayauon Date: Fri, 9 Sep 2022 15:04:42 -0700 Subject: [PATCH] Work toggle button staying at the top when moving keyboard down - Same fix from implementation when implementing extendedFAB. ag/19223926 - Essentiall remove isEnabled() check since it is not needed bug: 235873194 test: Manual - before: https://drive.google.com/file/d/1JjDSudWS56fiDyMnP8Btvy0pWFyUIXND/view?usp=sharing after: https://drive.google.com/file/d/1Ja-OVpXKK1yUrixpU_V6WsLV0Ryw152w/view?usp=sharing Change-Id: Ibca405deccfcd61845dd4f5952ad196af1ab3fe2 --- .../android/launcher3/allapps/WorkModeSwitch.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java index fedc91fb05..a5894484ee 100644 --- a/src/com/android/launcher3/allapps/WorkModeSwitch.java +++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java @@ -170,12 +170,14 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi @Override public WindowInsets onApplyWindowInsets(WindowInsets insets) { - if (Utilities.ATLEAST_R && isEnabled()) { + if (!Utilities.ATLEAST_R) { + return insets; + } + if (insets.isVisible(WindowInsets.Type.ime())) { + Insets keyboardInsets = insets.getInsets(WindowInsets.Type.ime()); + setTranslationY(mInsets.bottom - keyboardInsets.bottom); + } else { setTranslationY(0); - if (insets.isVisible(WindowInsets.Type.ime())) { - Insets keyboardInsets = insets.getInsets(WindowInsets.Type.ime()); - setTranslationY(mInsets.bottom - keyboardInsets.bottom); - } } return insets; }