Merge "Small asset tweeks for folders"
diff --git a/print_db.py b/print_db.py
index ebcba6c..4f90f94 100755
--- a/print_db.py
+++ b/print_db.py
@@ -9,6 +9,7 @@
 SCREENS = 5
 COLUMNS = 4
 ROWS = 4
+HOTSEAT_SIZE = 5
 CELL_SIZE = 110
 
 DIR = "db_files"
@@ -70,6 +71,52 @@
   "icon": print_icon
 }
 
+def render_cell_info(out, cell, occupied):
+  if cell is None:
+    out.write("    <td width=%d height=%d></td>\n" %
+        (CELL_SIZE, CELL_SIZE))
+  elif cell == occupied:
+    pass
+  else:
+    cellX = cell["cellX"]
+    cellY = cell["cellY"]
+    spanX = cell["spanX"]
+    spanY = cell["spanY"]
+    intent = cell["intent"]
+    if intent:
+      title = "title=\"%s\"" % cgi.escape(cell["intent"], True)
+    else:
+      title = ""
+    out.write(("    <td colspan=%d rowspan=%d width=%d height=%d"
+        + " bgcolor=#dddddd align=center valign=middle %s>") % (
+          spanX, spanY,
+          (CELL_SIZE*spanX), (CELL_SIZE*spanY),
+          title))
+    itemType = cell["itemType"]
+    if itemType == 0:
+      out.write("""<img src="icon_%d.png">\n""" % ( cell["_id"] ))
+      out.write("<br/>\n")
+      out.write(cgi.escape(cell["title"]) + " <br/><i>(app)</i>")
+    elif itemType == 1:
+      out.write("""<img src="icon_%d.png">\n""" % ( cell["_id"] ))
+      out.write("<br/>\n")
+      out.write(cgi.escape(cell["title"]) + " <br/><i>(shortcut)</i>")
+    elif itemType == 2:
+      out.write("""<i>folder</i>""")
+    elif itemType == 3:
+      out.write("""<i>live folder</i>""")
+    elif itemType == 4:
+      out.write("<i>widget %d</i><br/>\n" % cell["appWidgetId"])
+    elif itemType == 1000:
+      out.write("""<i>clock</i>""")
+    elif itemType == 1001:
+      out.write("""<i>search</i>""")
+    elif itemType == 1002:
+      out.write("""<i>photo frame</i>""")
+    else:
+      out.write("<b>unknown type: %d</b>" % itemType)
+    out.write("</td>\n")
+
 def process_file(fn):
   print "process_file: " + fn
   conn = sqlite3.connect(fn)
@@ -119,6 +166,21 @@
   out.write("""</table>
 """)
 
+  # Hotseat
+  hotseat = []
+  for i in range(0, HOTSEAT_SIZE):
+    hotseat.append(None)
+  for row in data:
+    if row["container"] != -101:
+      continue
+    screen = row["screen"]
+    hotseat[screen] = row
+  out.write("<br/><b>Hotseat</b><br/>\n")
+  out.write("<table class=layout border=1 cellspacing=0 cellpadding=4>\n")
+  for cell in hotseat:
+    render_cell_info(out, cell, None)
+  out.write("</table>\n")
+
   # Pages
   screens = []
   for i in range(0,SCREENS):
@@ -150,50 +212,7 @@
     for m in screen:
       out.write("  <tr>\n")
       for cell in m:
-        if cell is None:
-          out.write("    <td width=%d height=%d></td>\n" %
-              (CELL_SIZE, CELL_SIZE))
-        elif cell == occupied:
-          pass
-        else:
-          cellX = cell["cellX"]
-          cellY = cell["cellY"]
-          spanX = cell["spanX"]
-          spanY = cell["spanY"]
-          intent = cell["intent"]
-          if intent:
-            title = "title=\"%s\"" % cgi.escape(cell["intent"], True)
-          else:
-            title = ""
-          out.write(("    <td colspan=%d rowspan=%d width=%d height=%d"
-              + " bgcolor=#dddddd align=center valign=middle %s>") % (
-                spanX, spanY,
-                (CELL_SIZE*spanX), (CELL_SIZE*spanY),
-                title))
-          itemType = cell["itemType"]
-          if itemType == 0:
-            out.write("""<img src="icon_%d.png">\n""" % ( cell["_id"] ))
-            out.write("<br/>\n")
-            out.write(cgi.escape(cell["title"]) + " <br/><i>(app)</i>")
-          elif itemType == 1:
-            out.write("""<img src="icon_%d.png">\n""" % ( cell["_id"] ))
-            out.write("<br/>\n")
-            out.write(cgi.escape(cell["title"]) + " <br/><i>(shortcut)</i>")
-          elif itemType == 2:
-            out.write("""<i>folder</i>""")
-          elif itemType == 3:
-            out.write("""<i>live folder</i>""")
-          elif itemType == 4:
-            out.write("<i>widget %d</i><br/>\n" % cell["appWidgetId"])
-          elif itemType == 1000:
-            out.write("""<i>clock</i>""")
-          elif itemType == 1001:
-            out.write("""<i>search</i>""")
-          elif itemType == 1002:
-            out.write("""<i>photo frame</i>""")
-          else:
-            out.write("<b>unknown type: %d</b>" % itemType)
-          out.write("</td>\n")
+        render_cell_info(out, cell, occupied)
       out.write("</tr>\n")
     out.write("</table>\n")
     i=i+1
diff --git a/res/layout-port/search_bar.xml b/res/layout-port/search_bar.xml
index b65da0b..d548453 100644
--- a/res/layout-port/search_bar.xml
+++ b/res/layout-port/search_bar.xml
@@ -22,7 +22,7 @@
    <!-- Global search icon -->
    <LinearLayout
         style="@style/SearchButton"
-        android:layout_width="wrap_content"
+        android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 949d872..0e442ea 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -315,7 +315,11 @@
     private boolean testDataReady() {
         // We only do this test once, and we default to the Applications page, so we only really
         // have to wait for there to be apps.
-        return !mApps.isEmpty();
+        if (mContentType == AppsCustomizePagedView.ContentType.Widgets) {
+            return !mApps.isEmpty() && !mWidgets.isEmpty();
+        } else {
+            return !mApps.isEmpty();
+        }
     }
 
     /** Restores the page for an item at the specified index */
@@ -574,7 +578,7 @@
 
     public void setContentType(ContentType type) {
         mContentType = type;
-        invalidatePageData(0, true);
+        invalidatePageData(0, (type != ContentType.Applications));
     }
 
     public boolean isContentType(ContentType type) {
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 2fade8f..22a34e6 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1061,6 +1061,8 @@
     void closeSystemDialogs() {
         getWindow().closeAllPanels();
 
+        /**
+         * We should remove this code when we remove all the dialog code.
         try {
             dismissDialog(DIALOG_CREATE_SHORTCUT);
             // Unlock the workspace if the dialog was showing
@@ -1074,6 +1076,7 @@
         } catch (Exception e) {
             // An exception is thrown if the dialog is not visible, which is fine
         }
+         */
 
         // Whatever we were doing is hereby canceled.
         mWaitingForResult = false;
@@ -2487,6 +2490,7 @@
     private void updateGlobalSearchIcon() {
         final ImageView searchButton = (ImageView) findViewById(R.id.search_button);
         final View searchDivider = findViewById(R.id.search_divider);
+        final View voiceButton = findViewById(R.id.voice_button);
 
         final SearchManager searchManager =
                 (SearchManager) getSystemService(Context.SEARCH_SERVICE);
@@ -2497,8 +2501,10 @@
             searchButton.setVisibility(View.VISIBLE);
             if (searchDivider != null) searchDivider.setVisibility(View.VISIBLE);
         } else {
+            // We disable both search and voice search when there is no global search provider
             searchButton.setVisibility(View.GONE);
             if (searchDivider != null) searchDivider.setVisibility(View.GONE);
+            voiceButton.setVisibility(View.GONE);
         }
     }
 
diff --git a/src/com/android/launcher2/LauncherApplication.java b/src/com/android/launcher2/LauncherApplication.java
index 9b24587..ba028ef 100644
--- a/src/com/android/launcher2/LauncherApplication.java
+++ b/src/com/android/launcher2/LauncherApplication.java
@@ -62,6 +62,9 @@
         filter = new IntentFilter();
         filter.addAction(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED);
         registerReceiver(mModel, filter);
+        filter = new IntentFilter();
+        filter.addAction(SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED);
+        registerReceiver(mModel, filter);
 
         // Register for changes to the favorites
         ContentResolver resolver = getContentResolver();
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index f14140c..21c34bb 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -585,7 +585,8 @@
             mAllAppsLoaded = false;
             mWorkspaceLoaded = false;
             startLoaderFromBackground();
-        } else if (SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED.equals(action)) {
+        } else if (SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED.equals(action) ||
+                   SearchManager.INTENT_ACTION_SEARCHABLES_CHANGED.equals(action)) {
             Callbacks callbacks = mCallbacks.get();
             callbacks.bindSearchablesChanged();
         }