OSDN Git Service

Hiding search bar buttons when qsb is disabled. (5187969, 5201453)
authorWinson Chung <winsonc@google.com>
Tue, 23 Aug 2011 18:58:54 +0000 (11:58 -0700)
committerWinson Chung <winsonc@google.com>
Tue, 23 Aug 2011 21:58:00 +0000 (14:58 -0700)
Change-Id: I23cbfac5c1a8f96eb8158fd30a1fb335b044d49c

res/layout-port/search_bar.xml
src/com/android/launcher2/Launcher.java
src/com/android/launcher2/LauncherApplication.java
src/com/android/launcher2/LauncherModel.java

index b65da0b..d548453 100644 (file)
@@ -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"
index 44dbc15..b42a6f7 100644 (file)
@@ -2486,6 +2486,7 @@ public final class Launcher extends Activity
     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);
@@ -2496,8 +2497,10 @@ public final class Launcher extends Activity
             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);
         }
     }
 
index 9b24587..ba028ef 100644 (file)
@@ -62,6 +62,9 @@ public class LauncherApplication extends Application {
         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();
index f14140c..21c34bb 100644 (file)
@@ -585,7 +585,8 @@ public class LauncherModel extends BroadcastReceiver {
             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();
         }