Prevent hotseat updates if it is visible to the user.

Test: manual

Fixes: 168653219

Changing app icons under the user's finger could be disruptive. Added a checks for whether the hotseatand all apps predictions are visible and callbacks to update them when they become hidden.

Change-Id: Ib9e6e904e9f662ecfaeea6a2fe21d1d81ba39b96
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 6547b53..e4bdb39 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -25,6 +25,10 @@
 import android.view.ViewGroup;
 import android.widget.FrameLayout;
 
+import androidx.annotation.Nullable;
+
+import java.util.function.Consumer;
+
 /**
  * View class that represents the bottom row of the home screen.
  */
@@ -34,6 +38,7 @@
     private boolean mHasVerticalHotseat;
     private Workspace mWorkspace;
     private boolean mSendTouchToWorkspace;
+    @Nullable private Consumer<Boolean> mOnVisibilityAggregatedCallback;
 
     public Hotseat(Context context) {
         this(context, null);
@@ -129,4 +134,18 @@
         }
         return event.getY() > getCellHeight();
     }
+
+    @Override
+    public void onVisibilityAggregated(boolean isVisible) {
+        super.onVisibilityAggregated(isVisible);
+
+        if (mOnVisibilityAggregatedCallback != null) {
+            mOnVisibilityAggregatedCallback.accept(isVisible);
+        }
+    }
+
+    /** Sets a callback to be called onVisibilityAggregated */
+    public void setOnVisibilityAggregatedCallback(@Nullable Consumer<Boolean> callback) {
+        mOnVisibilityAggregatedCallback = callback;
+    }
 }