From 64b3fcc9f7bd951530bf9b78339882d7b104b50e Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 4 Mar 2015 13:54:52 -0800 Subject: Ensuring setQsbSearchBar is called whenever the QSB is created > On launcher3 when the QSB is created for the first time after a widget drop, it is not set in searchDropTarget and as a result the "Remove" and "App Info" drop targets are not visible until Launcher3 restarts and rebinds QSB Change-Id: I599a9a18cc5d46af790b3145dae2eb385b32b20e --- src/com/android/launcher3/Launcher.java | 12 +++++++----- src/com/android/launcher3/Workspace.java | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 1ad8b274d..e3a2d7c5f 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -116,7 +116,6 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; -import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.text.DateFormat; @@ -147,7 +146,6 @@ public class Launcher extends Activity private static final int REQUEST_CREATE_SHORTCUT = 1; private static final int REQUEST_CREATE_APPWIDGET = 5; - private static final int REQUEST_PICK_SHORTCUT = 7; private static final int REQUEST_PICK_APPWIDGET = 9; private static final int REQUEST_PICK_WALLPAPER = 10; @@ -1444,7 +1442,10 @@ public class Launcher extends Activity dragController.addDropTarget(mWorkspace); if (mSearchDropTargetBar != null) { mSearchDropTargetBar.setup(this, dragController); - mSearchDropTargetBar.setQsbSearchBar(getQsbBar()); + if (getOrCreateQsbBar() == null) { + // Explicitly set it to null during initialization. + mSearchDropTargetBar.setQsbSearchBar(null); + } } if (getResources().getBoolean(R.bool.debug_memory_enabled)) { @@ -3952,7 +3953,7 @@ public class Launcher extends Activity // NO-OP } - public View getQsbBar() { + public View getOrCreateQsbBar() { if (mLauncherCallbacks != null && mLauncherCallbacks.providesSearch()) { return mLauncherCallbacks.getQsbBar(); } @@ -4001,6 +4002,7 @@ public class Launcher extends Activity mQsb.updateAppWidgetOptions(opts); mQsb.setPadding(0, 0, 0, 0); mSearchDropTargetBar.addView(mQsb); + mSearchDropTargetBar.setQsbSearchBar(mQsb); } } return mQsb; @@ -4602,7 +4604,7 @@ public class Launcher extends Activity mSearchDropTargetBar.removeView(mQsb); mQsb = null; } - mSearchDropTargetBar.setQsbSearchBar(getQsbBar()); + getOrCreateQsbBar(); } /** diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index b9c1f4d3d..da893b6ee 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2305,7 +2305,7 @@ public class Workspace extends SmoothPagedView } } - final View searchBar = mLauncher.getQsbBar(); + final View searchBar = mLauncher.getOrCreateQsbBar(); final View overviewPanel = mLauncher.getOverviewPanel(); final View hotseat = mLauncher.getHotseat(); final View pageIndicator = getPageIndicator(); -- cgit v1.2.3