refreshed apps/configure button, added search button

- configure button now has a pressed state (as
  do the other two)
- also added a cast to getX() from float->int
  because of changes in the view property code

Change-Id: I57dc6e44838f4f4354f8977a3b542e93384b3d7d
diff --git a/res/drawable-xlarge/all_apps_button.xml b/res/drawable-xlarge/all_apps_button.xml
new file mode 100644
index 0000000..1e654f0
--- /dev/null
+++ b/res/drawable-xlarge/all_apps_button.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true" android:drawable="@drawable/all_apps_button_pressed" />
+    <item android:drawable="@drawable/all_apps_button_normal" />
+</selector>
diff --git a/res/drawable-xlarge/all_apps_button_normal.png b/res/drawable-xlarge/all_apps_button_normal.png
new file mode 100644
index 0000000..095ce63
--- /dev/null
+++ b/res/drawable-xlarge/all_apps_button_normal.png
Binary files differ
diff --git a/res/drawable-xlarge/all_apps_button_pressed.png b/res/drawable-xlarge/all_apps_button_pressed.png
new file mode 100644
index 0000000..50e4735
--- /dev/null
+++ b/res/drawable-xlarge/all_apps_button_pressed.png
Binary files differ
diff --git a/res/drawable-xlarge/configure_button.xml b/res/drawable-xlarge/configure_button.xml
new file mode 100644
index 0000000..b292652
--- /dev/null
+++ b/res/drawable-xlarge/configure_button.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true" android:drawable="@drawable/configure_button_pressed" />
+    <item android:drawable="@drawable/configure_button_normal" />
+</selector>
diff --git a/res/drawable-xlarge/configure_button_normal.png b/res/drawable-xlarge/configure_button_normal.png
new file mode 100644
index 0000000..066f492
--- /dev/null
+++ b/res/drawable-xlarge/configure_button_normal.png
Binary files differ
diff --git a/res/drawable-xlarge/configure_button_pressed.png b/res/drawable-xlarge/configure_button_pressed.png
new file mode 100644
index 0000000..536ed7c
--- /dev/null
+++ b/res/drawable-xlarge/configure_button_pressed.png
Binary files differ
diff --git a/res/drawable-xlarge/search_button.xml b/res/drawable-xlarge/search_button.xml
new file mode 100644
index 0000000..6d5d949
--- /dev/null
+++ b/res/drawable-xlarge/search_button.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_pressed="true" android:drawable="@drawable/search_button_pressed" />
+    <item android:drawable="@drawable/search_button_normal" />
+</selector>
diff --git a/res/drawable-xlarge/search_button_normal.png b/res/drawable-xlarge/search_button_normal.png
new file mode 100644
index 0000000..3a3045a
--- /dev/null
+++ b/res/drawable-xlarge/search_button_normal.png
Binary files differ
diff --git a/res/drawable-xlarge/search_button_pressed.png b/res/drawable-xlarge/search_button_pressed.png
new file mode 100644
index 0000000..8ae6b16
--- /dev/null
+++ b/res/drawable-xlarge/search_button_pressed.png
Binary files differ
diff --git a/res/drawable/add_button.png b/res/drawable/add_button.png
deleted file mode 100644
index 0edcfa3..0000000
--- a/res/drawable/add_button.png
+++ /dev/null
Binary files differ
diff --git a/res/layout-xlarge/launcher.xml b/res/layout-xlarge/launcher.xml
index f0564ca..fa323fd 100644
--- a/res/layout-xlarge/launcher.xml
+++ b/res/layout-xlarge/launcher.xml
@@ -45,30 +45,38 @@
         <include android:id="@+id/cell5" layout="@layout/workspace_screen" />
     </com.android.launcher2.Workspace>
 
+    <ImageView
+        android:id="@+id/search_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:src="@drawable/search_button"
+
+        android:onClick="onClickSearchButton"
+        android:focusable="true"
+        android:clickable="true"
+        android:layout_gravity="top|left"/>
     <RelativeLayout
         android:id="@+id/all_apps_button_cluster"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="top|right">
-        <com.android.launcher2.HandleView
-            style="@style/HotseatButton"
-            android:id="@+id/all_apps_button"
-            android:layout_height="@dimen/button_bar_height"
-            android:layout_width="@dimen/button_bar_height"
-
-            android:src="@drawable/all_apps_button"
-            launcher:direction="horizontal"  />
         <ImageView
-            android:id="@+id/add_button"
+            android:id="@+id/configure_button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_toRightOf="@id/all_apps_button"
+            android:src="@drawable/configure_button"
 
-            android:layout_centerVertical="true"
-            android:scaleType="center"
-            android:src="@drawable/add_button"
+            android:onClick="onClickConfigureButton"
+            android:focusable="true"
+            android:clickable="true" />
+        <ImageView
+            android:id="@+id/all_apps_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_toRightOf="@id/configure_button"
+            android:src="@drawable/all_apps_button"
 
-            android:onClick="onClickAddButton"
+            android:onClick="onClickAllAppsButton"
             android:focusable="true"
             android:clickable="true" />
         <com.android.launcher2.DeleteZone
@@ -76,7 +84,7 @@
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:paddingTop="@dimen/delete_zone_padding"
-            android:layout_toRightOf="@id/all_apps_button"
+            android:layout_toRightOf="@id/configure_button"
 
             android:scaleType="center"
             android:src="@drawable/delete_zone_selector"
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 1a085a3..b20edbe 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -34,8 +34,8 @@
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
-import android.content.Intent.ShortcutIconResource;
 import android.content.IntentFilter;
+import android.content.Intent.ShortcutIconResource;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
@@ -68,12 +68,12 @@
 import android.view.MenuItem;
 import android.view.MotionEvent;
 import android.view.View;
-import android.view.View.OnLongClickListener;
 import android.view.ViewGroup;
 import android.view.WindowManager;
+import android.view.View.OnLongClickListener;
 import android.view.animation.Animation;
-import android.view.animation.Animation.AnimationListener;
 import android.view.animation.AnimationUtils;
+import android.view.animation.Animation.AnimationListener;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.EditText;
 import android.widget.ImageView;
@@ -765,10 +765,13 @@
         DeleteZone deleteZone = (DeleteZone) dragLayer.findViewById(R.id.delete_zone);
         mDeleteZone = deleteZone;
 
-        mHandleView = (HandleView) findViewById(R.id.all_apps_button);
-        mHandleView.setLauncher(this);
-        mHandleView.setOnClickListener(this);
-        mHandleView.setOnLongClickListener(this);
+        View handleView = findViewById(R.id.all_apps_button);
+        if (handleView != null && handleView instanceof HandleView) {
+            // we don't use handle view in xlarge mode
+            mHandleView.setLauncher(this);
+            mHandleView.setOnClickListener(this);
+            mHandleView.setOnLongClickListener(this);
+        }
 
         WidgetChooser widgetChooser = (WidgetChooser) findViewById(R.id.widget_chooser);
         if (widgetChooser != null) {
@@ -817,7 +820,7 @@
         deleteZone.setDragController(dragController);
         int deleteZoneHandleId;
         if (LauncherApplication.isScreenXLarge()) {
-            deleteZoneHandleId = R.id.add_button;
+            deleteZoneHandleId = R.id.configure_button;
         } else {
             deleteZoneHandleId = R.id.all_apps_button_cluster;
         }
@@ -1593,15 +1596,38 @@
     }
 
     /**
-     * Event handler for the "plus" button that appears on the home screen, which
+     * Event handler for the search button
+     *
+     * @param v The view that was clicked.
+     */
+    public void onClickSearchButton(View v) {
+        Intent i = new Intent(SearchManager.INTENT_ACTION_GLOBAL_SEARCH);
+        View button = findViewById(R.id.search_button);
+        i.setSourceBounds(
+                new Rect(button.getLeft(), button.getTop(), button.getRight(), button.getBottom()));
+        startActivity(i);
+    }
+
+    /**
+     * Event handler for the "gear" button that appears on the home screen, which
      * enters home screen customization mode.
      *
      * @param v The view that was clicked.
      */
-    public void onClickAddButton(View v) {
+    public void onClickConfigureButton(View v) {
         addItems();
     }
 
+    /**
+     * Event handler for the "grid" button that appears on the home screen, which
+     * enters all apps mode.
+     *
+     * @param v The view that was clicked.
+     */
+    public void onClickAllAppsButton(View v) {
+        showAllApps(true);
+    }
+
     void startActivitySafely(Intent intent, Object tag) {
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         try {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 536eba8..cb37b92 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -720,8 +720,8 @@
         for (int i = 0; i < screenCount; i++) {
             final View child = getChildAt(i);
             if (child.getVisibility() != View.GONE) {
-                final int childX = child.getX();
-                final int childY = child.getY();
+                final int childX = (int)child.getX();
+                final int childY = (int)child.getY();
                 child.layout(childX, childY,
                         childX + child.getMeasuredWidth(), childY + child.getMeasuredHeight());
             }