Fixing drop target area, and adding bg color indicators.

- Merging wallpaper fix and PagedViewIconCache key fix

Change-Id: I2a65bc4b642f020dfc4d2223a36d3ebcf41de5f5
diff --git a/res/layout-large/qsb_bar.xml b/res/layout-large/qsb_bar.xml
index 57e4eeb..421ace2 100644
--- a/res/layout-large/qsb_bar.xml
+++ b/res/layout-large/qsb_bar.xml
@@ -104,32 +104,28 @@
         android:layout_height="match_parent"
         android:alpha="0">
 
-        <FrameLayout
+        <com.android.launcher2.DeleteDropTarget
             style="@style/DropTargetButtonContainer"
+            android:id="@+id/delete_target"
             android:layout_weight="1">
             <!-- Delete target -->
-            <com.android.launcher2.DeleteDropTarget
+            <TextView
                 style="@style/DropTargetButton"
-                android:id="@+id/delete_target"
+                android:id="@+id/delete_target_text"
                 android:text="@string/delete_zone_label_workspace"
-                android:drawableLeft="@drawable/delete_zone_selector"
-                launcher:strokeColor="#991e3157"
-                launcher:strokeTextColor="#DDFFFFFF"
-                launcher:strokeWidth="2.5" />
-        </FrameLayout>
+                android:drawableLeft="@drawable/delete_zone_selector" />
+        </com.android.launcher2.DeleteDropTarget>
 
-        <FrameLayout
+        <com.android.launcher2.InfoDropTarget
             style="@style/DropTargetButtonContainer"
+            android:id="@+id/info_target"
             android:layout_weight="1">
             <!-- Info target -->
-            <com.android.launcher2.InfoDropTarget
+            <TextView
                 style="@style/DropTargetButton"
-                android:id="@+id/info_target"
+                android:id="@+id/info_target_text"
                 android:text="@string/info_target_label"
-                android:drawableLeft="@drawable/ic_home_info_holo_dark"
-                launcher:strokeColor="#991e3157"
-                launcher:strokeTextColor="#DDFFFFFF"
-                launcher:strokeWidth="2.5" />
-        </FrameLayout>
+                android:drawableLeft="@drawable/ic_home_info_holo_dark" />
+        </com.android.launcher2.InfoDropTarget>
     </LinearLayout>
 </com.android.launcher2.SearchDropTargetBar>
diff --git a/res/layout/qsb_bar.xml b/res/layout/qsb_bar.xml
index 6e1d98c..68ee8b6 100644
--- a/res/layout/qsb_bar.xml
+++ b/res/layout/qsb_bar.xml
@@ -67,32 +67,28 @@
         android:layout_height="match_parent"
         android:alpha="0">
 
-        <FrameLayout
+        <com.android.launcher2.DeleteDropTarget
             style="@style/DropTargetButtonContainer"
+            android:id="@+id/delete_target"
             android:layout_weight="1">
             <!-- Delete target -->
-            <com.android.launcher2.DeleteDropTarget
+            <TextView
                 style="@style/DropTargetButton"
-                android:id="@+id/delete_target"
+                android:id="@+id/delete_target_text"
                 android:text="@string/delete_zone_label_workspace"
-                android:drawableLeft="@drawable/delete_zone_selector"
-                launcher:strokeColor="#991e3157"
-                launcher:strokeTextColor="#DDFFFFFF"
-                launcher:strokeWidth="2.5" />
-        </FrameLayout>
+                android:drawableLeft="@drawable/delete_zone_selector" />
+        </com.android.launcher2.DeleteDropTarget>
 
-        <FrameLayout
+        <com.android.launcher2.InfoDropTarget
             style="@style/DropTargetButtonContainer"
+            android:id="@+id/info_target"
             android:layout_weight="1">
             <!-- Info target -->
-            <com.android.launcher2.InfoDropTarget
+            <TextView
                 style="@style/DropTargetButton"
-                android:id="@+id/info_target"
+                android:id="@+id/info_target_text"
                 android:text="@string/info_target_label"
-                android:drawableLeft="@drawable/ic_home_info_holo_dark"
-                launcher:strokeColor="#991e3157"
-                launcher:strokeTextColor="#DDFFFFFF"
-                launcher:strokeWidth="2.5" />
-        </FrameLayout>
+                android:drawableLeft="@drawable/ic_home_info_holo_dark" />
+        </com.android.launcher2.InfoDropTarget>
     </LinearLayout>
 </com.android.launcher2.SearchDropTargetBar>
diff --git a/res/values-large/styles.xml b/res/values-large/styles.xml
index 42b85f6..9c1532a 100644
--- a/res/values-large/styles.xml
+++ b/res/values-large/styles.xml
@@ -80,12 +80,12 @@
     </style>
     <style name="DropTargetButton">
         <item name="android:layout_width">wrap_content</item>
-        <item name="android:layout_height">match_parent</item>
-        <item name="android:layout_gravity">center_horizontal</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:layout_gravity">center</item>
         <item name="android:gravity">center_vertical</item>
         <item name="android:drawablePadding">7.5dp</item>
-        <item name="android:paddingTop">@dimen/toolbar_button_vertical_padding</item>
-        <item name="android:paddingBottom">@dimen/toolbar_button_vertical_padding</item>
+        <item name="android:textColor">#FFFFFFFF</item>
+        <item name="android:textSize">16sp</item>
     </style>
 
     <style name="config_orientation">
diff --git a/res/values/colors.xml b/res/values/colors.xml
index e14fbfe..fd7b21c 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -20,8 +20,8 @@
 <resources>
     <!-- The color tints to apply to the text and drag view when hovering
          over the delete target or the info target -->
-    <color name="delete_target_hover_tint">#A5FF0000</color>
-    <color name="info_target_hover_tint">#A50000FE</color>
+    <color name="delete_target_hover_tint">#D4FF3600</color>
+    <color name="info_target_hover_tint">#D40078FF</color>
 
     <color name="window_background">#FF191919</color>
     <color name="grid_dark_background">#EB191919</color>     
diff --git a/res/values/config.xml b/res/values/config.xml
index 394ff8a..06e8fda 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -43,6 +43,9 @@
     <integer name="config_allAppsBatchSize">0</integer>
 
 <!-- Workspace -->
+    <!-- The transition duration for the background of the drop targets -->
+    <integer name="config_dropTargetBgTransitionDuration">100</integer>
+
     <integer name="config_crosshairsFadeInTime">600</integer>
 
     <!--  When dragging an item on the workspace, how much bigger (in pixels) the dragged view
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 176bab5..5c458b4 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -93,12 +93,12 @@
     </style>
     <style name="DropTargetButton">
         <item name="android:layout_width">wrap_content</item>
-        <item name="android:layout_height">match_parent</item>
-        <item name="android:layout_gravity">center_horizontal</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:layout_gravity">center</item>
         <item name="android:gravity">center_vertical</item>
         <item name="android:drawablePadding">7.5dp</item>
-        <item name="android:paddingTop">@dimen/toolbar_button_vertical_padding</item>
-        <item name="android:paddingBottom">@dimen/toolbar_button_vertical_padding</item>
+        <item name="android:textColor">#FFFFFFFF</item>
+        <item name="android:textSize">16sp</item>
     </style>
 
     <style name="TabIndicator">
diff --git a/src/com/android/launcher2/ButtonDropTarget.java b/src/com/android/launcher2/ButtonDropTarget.java
new file mode 100644
index 0000000..e3da860
--- /dev/null
+++ b/src/com/android/launcher2/ButtonDropTarget.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package com.android.launcher2;
+
+import android.content.Context;
+import android.graphics.Paint;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+
+import com.android.launcher.R;
+
+
+/**
+ * Implements a DropTarget.
+ */
+public class ButtonDropTarget extends FrameLayout implements DropTarget, DragController.DragListener {
+
+    protected final int mTransitionDuration;
+
+    protected Launcher mLauncher;
+
+    /** Whether this drop target is active for the current drag */
+    protected boolean mActive;
+
+    /** The paint applied to the drag view on hover */
+    protected final Paint mHoverPaint = new Paint();
+
+    public ButtonDropTarget(Context context, AttributeSet attrs) {
+        this(context, attrs, 0);
+    }
+
+    public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) {
+        super(context, attrs, defStyle);
+
+        mTransitionDuration =
+            context.getResources().getInteger(R.integer.config_dropTargetBgTransitionDuration);
+    }
+
+    void setLauncher(Launcher launcher) {
+        mLauncher = launcher;
+    }
+
+    public boolean acceptDrop(DragObject d) {
+        return false;
+    }
+
+    public void onDrop(DragObject d) {
+        // Do nothing
+    }
+
+    public void onDragEnter(DragObject d) {
+        d.dragView.setPaint(mHoverPaint);
+    }
+
+    public void onDragOver(DragObject d) {
+        // Do nothing
+    }
+
+    public void onDragExit(DragObject d) {
+        d.dragView.setPaint(null);
+    }
+
+    public void onDragStart(DragSource source, Object info, int dragAction) {
+        // Do nothing
+    }
+
+    public boolean isDropEnabled() {
+        return mActive;
+    }
+
+    public void onDragEnd() {
+        // Do nothing
+    }
+
+    @Override
+    public DropTarget getDropTargetDelegate(DragObject d) {
+        return null;
+    }
+}
diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java
index a474c27..5b3fd1e 100644
--- a/src/com/android/launcher2/DeleteDropTarget.java
+++ b/src/com/android/launcher2/DeleteDropTarget.java
@@ -16,23 +16,22 @@
 
 package com.android.launcher2;
 
+import android.animation.ObjectAnimator;
 import android.content.Context;
 import android.content.res.Resources;
+import android.graphics.Color;
 import android.graphics.PorterDuff;
 import android.graphics.PorterDuffColorFilter;
-import android.graphics.drawable.TransitionDrawable;
 import android.util.AttributeSet;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.TextView;
 
 import com.android.launcher.R;
 
-public class DeleteDropTarget extends IconDropTarget {
+public class DeleteDropTarget extends ButtonDropTarget {
 
-    private static final int sTransitionDuration = 0;
-
-    private TransitionDrawable mIcon;
-    private int mDefaultTextColor;
+    private TextView mText;
     private int mHoverColor = 0xFFFF0000;
 
     public DeleteDropTarget(Context context, AttributeSet attrs) {
@@ -48,14 +47,15 @@
         super.onFinishInflate();
 
         // Get the drawable
-        mIcon = (TransitionDrawable) getCompoundDrawables()[0];
+        mText = (TextView) findViewById(R.id.delete_target_text);
 
         // Get the hover color
         Resources r = getResources();
-        mDefaultTextColor = getTextColors().getDefaultColor();
         mHoverColor = r.getColor(R.color.delete_target_hover_tint);
         mHoverPaint.setColorFilter(new PorterDuffColorFilter(
                 mHoverColor, PorterDuff.Mode.SRC_ATOP));
+        setBackgroundColor(mHoverColor);
+        getBackground().setAlpha(0);
     }
 
     private boolean isAllAppsApplication(DragSource source, Object info) {
@@ -82,7 +82,6 @@
 
     @Override
     public void onDragStart(DragSource source, Object info, int dragAction) {
-        ItemInfo item = (ItemInfo) info;
         boolean isVisible = true;
         boolean isUninstall = false;
 
@@ -103,9 +102,9 @@
         }
 
         mActive = isVisible;
-        ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE);
-        if (getText().length() > 0) {
-            setText(isUninstall ? R.string.delete_target_uninstall_label
+        setVisibility(isVisible ? View.VISIBLE : View.GONE);
+        if (mText.getText().length() > 0) {
+            mText.setText(isUninstall ? R.string.delete_target_uninstall_label
                 : R.string.delete_target_label);
         }
     }
@@ -119,15 +118,18 @@
     public void onDragEnter(DragObject d) {
         super.onDragEnter(d);
 
-        mIcon.startTransition(sTransitionDuration);
-        setTextColor(mHoverColor);
+        ObjectAnimator anim = ObjectAnimator.ofInt(getBackground(), "alpha",
+                Color.alpha(mHoverColor));
+        anim.setDuration(mTransitionDuration);
+        anim.start();
     }
 
     public void onDragExit(DragObject d) {
         super.onDragExit(d);
 
-        mIcon.resetTransition();
-        setTextColor(mDefaultTextColor);
+        ObjectAnimator anim = ObjectAnimator.ofInt(getBackground(), "alpha", 0);
+        anim.setDuration(mTransitionDuration);
+        anim.start();
     }
 
     public void onDrop(DragObject d) {
diff --git a/src/com/android/launcher2/InfoDropTarget.java b/src/com/android/launcher2/InfoDropTarget.java
index bbde2b8..7e6b700 100644
--- a/src/com/android/launcher2/InfoDropTarget.java
+++ b/src/com/android/launcher2/InfoDropTarget.java
@@ -16,20 +16,20 @@
 
 package com.android.launcher2;
 
+import android.animation.ObjectAnimator;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.res.Resources;
+import android.graphics.Color;
 import android.graphics.PorterDuff;
 import android.graphics.PorterDuffColorFilter;
 import android.util.AttributeSet;
 import android.view.View;
-import android.view.ViewGroup;
 
 import com.android.launcher.R;
 
-public class InfoDropTarget extends IconDropTarget {
+public class InfoDropTarget extends ButtonDropTarget {
 
-    private int mDefaultTextColor;
     private int mHoverColor = 0xFF0000FF;
 
     public InfoDropTarget(Context context, AttributeSet attrs) {
@@ -46,10 +46,11 @@
 
         // Get the hover color
         Resources r = getResources();
-        mDefaultTextColor = getTextColors().getDefaultColor();
         mHoverColor = r.getColor(R.color.info_target_hover_tint);
         mHoverPaint.setColorFilter(new PorterDuffColorFilter(
                 mHoverColor, PorterDuff.Mode.SRC_ATOP));
+        setBackgroundColor(mHoverColor);
+        getBackground().setAlpha(0);
     }
 
     private boolean isApplication(Object info) {
@@ -85,7 +86,7 @@
         }
 
         mActive = isVisible;
-        ((ViewGroup) getParent()).setVisibility(isVisible ? View.VISIBLE : View.GONE);
+        setVisibility(isVisible ? View.VISIBLE : View.GONE);
     }
 
     @Override
@@ -97,12 +98,17 @@
     public void onDragEnter(DragObject d) {
         super.onDragEnter(d);
 
-        setTextColor(mHoverColor);
+        ObjectAnimator anim = ObjectAnimator.ofInt(getBackground(), "alpha",
+                Color.alpha(mHoverColor));
+        anim.setDuration(mTransitionDuration);
+        anim.start();
     }
 
     public void onDragExit(DragObject d) {
         super.onDragExit(d);
 
-        setTextColor(mDefaultTextColor);
+        ObjectAnimator anim = ObjectAnimator.ofInt(getBackground(), "alpha", 0);
+        anim.setDuration(mTransitionDuration);
+        anim.start();
     }
 }
diff --git a/src/com/android/launcher2/PagedViewIconCache.java b/src/com/android/launcher2/PagedViewIconCache.java
index de05ff1..d65f68b 100644
--- a/src/com/android/launcher2/PagedViewIconCache.java
+++ b/src/com/android/launcher2/PagedViewIconCache.java
@@ -48,11 +48,11 @@
             final ComponentInfo ci = info.activityInfo != null ? info.activityInfo :
                 info.serviceInfo;
             mComponentName = new ComponentName(ci.packageName, ci.name);
-            mType = Type.AppWidgetProviderInfoKey;
+            mType = Type.ResolveInfoKey;
         }
         public Key(AppWidgetProviderInfo info) {
             mComponentName = info.provider;
-            mType = Type.ResolveInfoKey;
+            mType = Type.AppWidgetProviderInfoKey;
         }
 
         private ComponentName getComponentName() {
diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java
index 5ab28ea..d00e210 100644
--- a/src/com/android/launcher2/SearchDropTargetBar.java
+++ b/src/com/android/launcher2/SearchDropTargetBar.java
@@ -17,9 +17,6 @@
 package com.android.launcher2;
 
 import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
 import android.util.AttributeSet;
 import android.view.View;
 import android.widget.FrameLayout;
@@ -38,8 +35,8 @@
     private boolean mIsSearchBarHidden;
     private View mQSBSearchBar;
     private View mDropTargetBar;
-    private IconDropTarget mInfoDropTarget;
-    private IconDropTarget mDeleteDropTarget;
+    private ButtonDropTarget mInfoDropTarget;
+    private ButtonDropTarget mDeleteDropTarget;
 
     public SearchDropTargetBar(Context context, AttributeSet attrs) {
         this(context, attrs, 0);
@@ -57,6 +54,7 @@
         dragController.addDropTarget(mDeleteDropTarget);
         mInfoDropTarget.setLauncher(launcher);
         mDeleteDropTarget.setLauncher(launcher);
+        mDropTargetBar.setBackgroundColor(0x33000000);
     }
 
     @Override
@@ -66,8 +64,8 @@
         // Get the individual components
         mQSBSearchBar = findViewById(R.id.qsb_search_bar);
         mDropTargetBar = findViewById(R.id.drag_target_bar);
-        mInfoDropTarget = (IconDropTarget) mDropTargetBar.findViewById(R.id.info_target);
-        mDeleteDropTarget = (IconDropTarget) mDropTargetBar.findViewById(R.id.delete_target);
+        mInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target);
+        mDeleteDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.delete_target);
     }
 
     /*
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index b6e4f56..ff2dede 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -45,6 +45,7 @@
 import android.graphics.Canvas;
 import android.graphics.Matrix;
 import android.graphics.Paint;
+import android.graphics.Point;
 import android.graphics.Rect;
 import android.graphics.RectF;
 import android.graphics.Region.Op;
@@ -61,8 +62,6 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.DecelerateInterpolator;
-import android.widget.TabHost;
-import android.widget.TabWidget;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -720,8 +719,13 @@
 
     protected void setWallpaperDimension() {
         Display display = mLauncher.getWindowManager().getDefaultDisplay();
-        final int maxDim = Math.max(display.getWidth(), display.getHeight());
-        final int minDim = Math.min(display.getWidth(), display.getHeight());
+        Point displaySize = new Point();
+        display.getSize(displaySize);
+        if (LauncherApplication.isScreenLarge()) {
+            displaySize.y += (int) getResources().getDimension(R.dimen.status_bar_height);
+        }
+        final int maxDim = Math.max(displaySize.x, displaySize.y);
+        final int minDim = Math.min(displaySize.x, displaySize.y);
 
         // We need to ensure that there is enough extra space in the wallpaper for the intended
         // parallax effects