From 44424572b4bb378995e138e2e5f89c6fcc3a1ca7 Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Wed, 14 Jul 2021 11:39:43 -0700 Subject: [PATCH] Fix work profile disable button falsing Bug: 191996677 Test: before this CL: when tapping on immediately above keyboard when keyboard is translating or when onApplyWindowInset is called, the hidden (GONE) view handles touch and triggers work profile to be disabled. After the CL, the button view is not attached to the parent container when on personal tab. Also, the onApplyWindowInsets method translations can only be called when work tab is selected. Change-Id: Ib3e9a5c4b3280052f9ccb62a199ed256ae4e094f --- .../launcher3/allapps/AllAppsContainerView.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 516af59d75..d2c71b2afe 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -477,10 +477,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo } else { mAH[AdapterHolder.MAIN].setup(findViewById(R.id.apps_list_view), null); mAH[AdapterHolder.WORK].recyclerView = null; - if (mWorkModeSwitch != null) { - ((ViewGroup) mWorkModeSwitch.getParent()).removeView(mWorkModeSwitch); - mWorkModeSwitch = null; - } } setupHeader(); @@ -532,7 +528,7 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo @Override public void onActivePageChanged(int currentActivePage) { - mHeader.setMainActive(currentActivePage == 0); + mHeader.setMainActive(currentActivePage == AdapterHolder.MAIN); if (mAH[currentActivePage].recyclerView != null) { mAH[currentActivePage].recyclerView.bindFastScrollbar(); } @@ -541,6 +537,14 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo mWorkModeSwitch.setWorkTabVisible(currentActivePage == AdapterHolder.WORK && mAllAppsStore.hasModelFlag( FLAG_HAS_SHORTCUT_PERMISSION | FLAG_QUIET_MODE_CHANGE_PERMISSION)); + + if (currentActivePage == AdapterHolder.WORK) { + if (mWorkModeSwitch.getParent() == null) { + addView(mWorkModeSwitch); + } + } else { + removeView(mWorkModeSwitch); + } } }