Revert^2 "Moving taskbar lifecycle to TouchInteractionService"

430465a3d5ff0dcdd0c2e263d862049d93075a07
Bug: 187353581
Change-Id: I7b2280d16adfafd3e85ffc1d22e32d0c00d12b67
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 3d044d6..322c6ee 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -447,10 +447,6 @@
      * @param canvas The canvas to draw to.
      */
     protected void drawDotIfNecessary(Canvas canvas) {
-        if (mActivity instanceof Launcher && ((Launcher) mActivity).isViewInTaskbar(this)) {
-            // TODO: support notification dots in Taskbar
-            return;
-        }
         if (!mForceHideDot && (hasDot() || mDotParams.scale > 0)) {
             getIconBounds(mDotParams.iconBounds);
             Utilities.scaleRectAboutCenter(mDotParams.iconBounds,
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index b2a9e75..ff380ce 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -49,7 +49,6 @@
     private final View mQsb;
     private final int mQsbHeight;
 
-    private final View mTaskbarView;
     private final int mTaskbarViewHeight;
 
     public Hotseat(Context context) {
@@ -67,10 +66,7 @@
         mQsbHeight = mQsb.getLayoutParams().height;
         addView(mQsb);
 
-        mTaskbarView = LayoutInflater.from(context).inflate(R.layout.taskbar_view, this, false);
-        mTaskbarViewHeight = mTaskbarView.getLayoutParams().height;
-        // We want taskbar in the back so its background applies to Hotseat as well.
-        addView(mTaskbarView, 0);
+        mTaskbarViewHeight = context.getResources().getDimensionPixelSize(R.dimen.taskbar_size);
     }
 
     /**
@@ -187,8 +183,6 @@
         int width = getShortcutsAndWidgets().getMeasuredWidth();
         mQsb.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
                 MeasureSpec.makeMeasureSpec(mQsbHeight, MeasureSpec.EXACTLY));
-        mTaskbarView.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
-                MeasureSpec.makeMeasureSpec(mTaskbarViewHeight, MeasureSpec.EXACTLY));
     }
 
     @Override
@@ -202,13 +196,6 @@
         int bottom = b - t - getQsbOffsetY();
         int top = bottom - mQsbHeight;
         mQsb.layout(left, top, right, bottom);
-
-        int taskbarWidth = mTaskbarView.getMeasuredWidth();
-        left = (r - l - taskbarWidth) / 2;
-        right = left + taskbarWidth;
-        bottom = b - t - getTaskbarOffsetY();
-        top = bottom - mTaskbarViewHeight;
-        mTaskbarView.layout(left, top, right, bottom);
     }
 
     /**
@@ -244,10 +231,4 @@
         return mQsb;
     }
 
-    /**
-     * Returns the Taskbar inside hotseat
-     */
-    public View getTaskbarView() {
-        return mTaskbarView;
-    }
 }
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index cf90216..8889e60 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1942,13 +1942,6 @@
 
     @Override
     public boolean startActivitySafely(View v, Intent intent, ItemInfo item) {
-        if (isViewInTaskbar(v)) {
-            // Start the activity without the hacky workarounds below, which assume the View was
-            // clicked when Launcher was resumed and will be hidden until Launcher is re-resumed
-            // (this isn't the case for Taskbar).
-            return super.startActivitySafely(v, intent, item);
-        }
-
         if (!hasBeenResumed()) {
             // Workaround an issue where the WM launch animation is clobbered when finishing the
             // recents animation into launcher. Defer launching the activity until Launcher is
@@ -2860,13 +2853,6 @@
                 .start();
     }
 
-    /**
-     * @return Whether the View is in the same window as the Taskbar window.
-     */
-    public boolean isViewInTaskbar(View v) {
-        return false;
-    }
-
     public boolean supportsAdaptiveIconAnimation(View clickedView) {
         return false;
     }
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 7ae729a..2884fba 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -324,15 +324,17 @@
     }
 
     public static void scaleRectFAboutCenter(RectF r, float scale) {
+        scaleRectFAboutPivot(r, scale, r.centerX(), r.centerY());
+    }
+
+    public static void scaleRectFAboutPivot(RectF r, float scale, float px, float py) {
         if (scale != 1.0f) {
-            float cx = r.centerX();
-            float cy = r.centerY();
-            r.offset(-cx, -cy);
+            r.offset(-px, -py);
             r.left = r.left * scale;
             r.top = r.top * scale ;
             r.right = r.right * scale;
             r.bottom = r.bottom * scale;
-            r.offset(cx, cy);
+            r.offset(px, py);
         }
     }
 
diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java
index ce7dc07..b5dcd3a 100644
--- a/src/com/android/launcher3/touch/ItemClickHandler.java
+++ b/src/com/android/launcher3/touch/ItemClickHandler.java
@@ -27,6 +27,7 @@
 
 import android.app.AlertDialog;
 import android.app.PendingIntent;
+import android.content.Context;
 import android.content.Intent;
 import android.content.IntentSender;
 import android.content.pm.LauncherApps;
@@ -194,36 +195,43 @@
     }
 
     /**
+     * Handles clicking on a disabled shortcut
+     */
+    public static void handleDisabledItemClicked(WorkspaceItemInfo shortcut, Context context) {
+        final int disabledFlags = shortcut.runtimeStatusFlags
+                & WorkspaceItemInfo.FLAG_DISABLED_MASK;
+        if ((disabledFlags
+                & ~FLAG_DISABLED_SUSPENDED
+                & ~FLAG_DISABLED_QUIET_USER) == 0) {
+            // If the app is only disabled because of the above flags, launch activity anyway.
+            // Framework will tell the user why the app is suspended.
+        } else {
+            if (!TextUtils.isEmpty(shortcut.disabledMessage)) {
+                // Use a message specific to this shortcut, if it has one.
+                Toast.makeText(context, shortcut.disabledMessage, Toast.LENGTH_SHORT).show();
+                return;
+            }
+            // Otherwise just use a generic error message.
+            int error = R.string.activity_not_available;
+            if ((shortcut.runtimeStatusFlags & FLAG_DISABLED_SAFEMODE) != 0) {
+                error = R.string.safemode_shortcut_error;
+            } else if ((shortcut.runtimeStatusFlags & FLAG_DISABLED_BY_PUBLISHER) != 0
+                    || (shortcut.runtimeStatusFlags & FLAG_DISABLED_LOCKED_USER) != 0) {
+                error = R.string.shortcut_not_available;
+            }
+            Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
+        }
+    }
+
+    /**
      * Event handler for an app shortcut click.
      *
      * @param v The view that was clicked. Must be a tagged with a {@link WorkspaceItemInfo}.
      */
     public static void onClickAppShortcut(View v, WorkspaceItemInfo shortcut, Launcher launcher) {
         if (shortcut.isDisabled()) {
-            final int disabledFlags = shortcut.runtimeStatusFlags
-                    & WorkspaceItemInfo.FLAG_DISABLED_MASK;
-            if ((disabledFlags &
-                    ~FLAG_DISABLED_SUSPENDED &
-                    ~FLAG_DISABLED_QUIET_USER) == 0) {
-                // If the app is only disabled because of the above flags, launch activity anyway.
-                // Framework will tell the user why the app is suspended.
-            } else {
-                if (!TextUtils.isEmpty(shortcut.disabledMessage)) {
-                    // Use a message specific to this shortcut, if it has one.
-                    Toast.makeText(launcher, shortcut.disabledMessage, Toast.LENGTH_SHORT).show();
-                    return;
-                }
-                // Otherwise just use a generic error message.
-                int error = R.string.activity_not_available;
-                if ((shortcut.runtimeStatusFlags & FLAG_DISABLED_SAFEMODE) != 0) {
-                    error = R.string.safemode_shortcut_error;
-                } else if ((shortcut.runtimeStatusFlags & FLAG_DISABLED_BY_PUBLISHER) != 0 ||
-                        (shortcut.runtimeStatusFlags & FLAG_DISABLED_LOCKED_USER) != 0) {
-                    error = R.string.shortcut_not_available;
-                }
-                Toast.makeText(launcher, error, Toast.LENGTH_SHORT).show();
-                return;
-            }
+            handleDisabledItemClicked(shortcut, launcher);
+            return;
         }
 
         // Check for abandoned promise