From 8143b69cec7c84a034bd9fe15fd63447bac5e93e Mon Sep 17 00:00:00 2001 From: Brandon Dayauon Date: Thu, 5 Dec 2024 10:46:11 -0800 Subject: [PATCH] Fix workUtilityView receiving touch for pause work apps button. bug: 382501851 Test manually video: before: https://drive.google.com/file/d/1I6av4cFoYex6QhzYAdlzJWCBwd2ilgzT/view?usp=sharing after: https://drive.google.com/file/d/1hMDELNTqUvoI7oI-lw0sLifcGyIalbS_/view?usp=sharing Flag: com.android.launcher3.work_scheduler_in_work_profile Change-Id: I9dfead6deac7f3dbcb66c961bea4a1828f20478d --- src/com/android/launcher3/allapps/WorkProfileManager.java | 2 +- src/com/android/launcher3/allapps/WorkUtilityView.java | 7 +++++++ tests/src/com/android/launcher3/ui/WorkProfileTest.java | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/allapps/WorkProfileManager.java b/src/com/android/launcher3/allapps/WorkProfileManager.java index 6ebab5a82d..6d7d1930fd 100644 --- a/src/com/android/launcher3/allapps/WorkProfileManager.java +++ b/src/com/android/launcher3/allapps/WorkProfileManager.java @@ -148,7 +148,7 @@ public class WorkProfileManager extends UserProfileManager if (getAH() != null) { getAH().applyPadding(); } - mWorkUtilityView.setOnClickListener(this::onWorkFabClicked); + mWorkUtilityView.getWorkFAB().setOnClickListener(this::onWorkFabClicked); return true; } /** diff --git a/src/com/android/launcher3/allapps/WorkUtilityView.java b/src/com/android/launcher3/allapps/WorkUtilityView.java index 4b58ab06dc..bfd96636e8 100644 --- a/src/com/android/launcher3/allapps/WorkUtilityView.java +++ b/src/com/android/launcher3/allapps/WorkUtilityView.java @@ -25,6 +25,7 @@ import android.content.Intent; import android.graphics.Rect; import android.text.TextUtils; import android.util.AttributeSet; +import android.view.View; import android.view.ViewGroup; import android.view.WindowInsets; import android.widget.ImageButton; @@ -82,6 +83,7 @@ public class WorkUtilityView extends LinearLayout implements Insettable, // Threshold when user scrolls up/down to determine when should button extend/collapse private final int mScrollThreshold; private ValueAnimator mPauseFABAnim; + private View mWorkFAB; private TextView mPauseText; private ImageView mWorkIcon; private ImageButton mSchedulerButton; @@ -116,6 +118,7 @@ public class WorkUtilityView extends LinearLayout implements Insettable, mPauseText = findViewById(R.id.pause_text); mWorkIcon = findViewById(R.id.work_icon); + mWorkFAB = findViewById(R.id.work_mode_toggle); mSchedulerButton = findViewById(R.id.work_scheduler); setSelected(true); KeyboardInsetAnimationCallback keyboardInsetAnimationCallback = @@ -386,6 +389,10 @@ public class WorkUtilityView extends LinearLayout implements Insettable, return mScrollThreshold; } + public View getWorkFAB() { + return mWorkFAB; + } + public void updateStringFromCache(){ StringCache cache = mActivityContext.getStringCache(); if (cache != null) { diff --git a/tests/src/com/android/launcher3/ui/WorkProfileTest.java b/tests/src/com/android/launcher3/ui/WorkProfileTest.java index d866a9f935..4dba78a899 100644 --- a/tests/src/com/android/launcher3/ui/WorkProfileTest.java +++ b/tests/src/com/android/launcher3/ui/WorkProfileTest.java @@ -146,7 +146,7 @@ public class WorkProfileTest extends BaseLauncherActivityTest { executeOnLauncher(l -> { // Ensure updates are not deferred so notification happens when apps pause. l.getAppsView().getAppsStore().disableDeferUpdates(DEFER_UPDATES_TEST); - l.getAppsView().getWorkManager().getWorkUtilityView().performClick(); + l.getAppsView().getWorkManager().getWorkUtilityView().getWorkFAB().performClick(); }); waitForLauncherCondition("Work profile toggle OFF failed", launcher -> {