From 1502c673d022ced571382e23302eb4a0aba72f9c Mon Sep 17 00:00:00 2001 From: arangelov Date: Mon, 16 Jul 2018 17:47:39 +0100 Subject: [PATCH] Prevent the work mode switch thumb from being dragged. When we normally press the work mode switch, it waits for the profile to receive the ACTION_MANAGED_PROFILE_AVAILABLE broadcast before the button UI actually toggles. The user never interacts directly with that switch. However, dragging the switch thumb used to bypass that logic. This CL makes sure dragging the switch thumb cannot happen in the first place. Change-Id: Ib3b4ae7591136c35e6d02783387d752e246cfb5b Fixes: 111211805 Test: Manual --- src/com/android/launcher3/allapps/WorkModeSwitch.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java index e7cf092093..d529f6fb59 100644 --- a/src/com/android/launcher3/allapps/WorkModeSwitch.java +++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java @@ -20,6 +20,7 @@ import android.os.AsyncTask; import android.os.Process; import android.os.UserHandle; import android.util.AttributeSet; +import android.view.MotionEvent; import android.widget.Switch; import com.android.launcher3.compat.UserManagerCompat; @@ -60,6 +61,11 @@ public class WorkModeSwitch extends Switch { setEnabled(true); } + @Override + public boolean onTouchEvent(MotionEvent ev) { + return ev.getActionMasked() == MotionEvent.ACTION_MOVE || super.onTouchEvent(ev); + } + private void trySetQuietModeEnabledToAllProfilesAsync(boolean enabled) { new AsyncTask() {