Fix back button not showing in all floating views

We only show the back button when adding the floating view to the
drag layer if it is already "open". A couple of floating items
(folder and options popup) added first then set mIsOpen, causing
the back button to not appear. (We have to check that it is open,
and not just on the drag layer, because we want to get rid of the
back button when changing to some states such as spring-loaded. If
we only checked if the view was present, it wouldn't hide if one of
the floating views such as folder or shortcuts was animated closed.)

Bug: 76169527
Change-Id: I0dff6d2e3424eab72d47dccc42cc703a0fb0141b
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 1bdd554..12d7dc7 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -481,6 +481,8 @@
             openFolder.close(true);
         }
 
+        mIsOpen = true;
+
         DragLayer dragLayer = mLauncher.getDragLayer();
         // Just verify that the folder hasn't already been added to the DragLayer.
         // There was a one-off crash where the folder had a parent already.
@@ -494,8 +496,6 @@
             }
         }
 
-        mIsOpen = true;
-
         mContent.completePendingPageChanges();
         if (!mDragInProgress) {
             // Open on the first page.
diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java
index 21b6773..dc86aec 100644
--- a/src/com/android/launcher3/views/OptionsPopupView.java
+++ b/src/com/android/launcher3/views/OptionsPopupView.java
@@ -288,8 +288,8 @@
         lp.y = Utilities.boundToRange((int) (y - height / 2), insets.top + margin,
                 maxHeight - insets.bottom - height - margin);
 
-        launcher.getDragLayer().addView(view);
         view.animateOpen();
+        launcher.getDragLayer().addView(view);
     }
 
     public static boolean onWidgetsClicked(Launcher launcher) {