Need to remove views and not just hide them after animations.

- Removing Manage Apps button from workspace and renaming it in AppsCustomize
- Fixing foolish string play in resources from initial change for search bar
- Using proper way to get full screen dims for wallpaper fix

Change-Id: I1319d225135436468f1feb3057cd9f28eda7c89c
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 5b4f150..c27e375 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -508,15 +508,17 @@
     }
     private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h,
             float scaleX, float scaleY) {
-        Canvas c = new Canvas();
-        if (bitmap != null) c.setBitmap(bitmap);
-        c.save();
-        c.scale(scaleX, scaleY);
-        Rect oldBounds = d.copyBounds();
-        d.setBounds(x, y, x + w, y + h);
-        d.draw(c);
-        d.setBounds(oldBounds); // Restore the bounds
-        c.restore();
+        if (bitmap != null) {
+            Canvas c = new Canvas();
+            c.setBitmap(bitmap);
+            c.save();
+            c.scale(scaleX, scaleY);
+            Rect oldBounds = d.copyBounds();
+            d.setBounds(x, y, x + w, y + h);
+            d.draw(c);
+            d.setBounds(oldBounds); // Restore the bounds
+            c.restore();
+        }
     }
     private FastBitmapDrawable getShortcutPreview(ResolveInfo info, int cellWidth, int cellHeight) {
         // Return the cached version if necessary
diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java
index 5b3fd1e..a30c03e 100644
--- a/src/com/android/launcher2/DeleteDropTarget.java
+++ b/src/com/android/launcher2/DeleteDropTarget.java
@@ -18,6 +18,7 @@
 
 import android.animation.ObjectAnimator;
 import android.content.Context;
+import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.graphics.Color;
 import android.graphics.PorterDuff;
@@ -56,6 +57,14 @@
                 mHoverColor, PorterDuff.Mode.SRC_ATOP));
         setBackgroundColor(mHoverColor);
         getBackground().setAlpha(0);
+
+        // Remove the text in the Phone UI in landscape
+        int orientation = getResources().getConfiguration().orientation;
+        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
+            if (!LauncherApplication.isScreenLarge()) {
+                mText.setText("");
+            }
+        }
     }
 
     private boolean isAllAppsApplication(DragSource source, Object info) {
diff --git a/src/com/android/launcher2/InfoDropTarget.java b/src/com/android/launcher2/InfoDropTarget.java
index 7e6b700..76a6bf9 100644
--- a/src/com/android/launcher2/InfoDropTarget.java
+++ b/src/com/android/launcher2/InfoDropTarget.java
@@ -19,17 +19,20 @@
 import android.animation.ObjectAnimator;
 import android.content.ComponentName;
 import android.content.Context;
+import android.content.res.Configuration;
 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.widget.TextView;
 
 import com.android.launcher.R;
 
 public class InfoDropTarget extends ButtonDropTarget {
 
+    private TextView mText;
     private int mHoverColor = 0xFF0000FF;
 
     public InfoDropTarget(Context context, AttributeSet attrs) {
@@ -44,6 +47,8 @@
     protected void onFinishInflate() {
         super.onFinishInflate();
 
+        mText = (TextView) findViewById(R.id.info_target_text);
+
         // Get the hover color
         Resources r = getResources();
         mHoverColor = r.getColor(R.color.info_target_hover_tint);
@@ -51,11 +56,18 @@
                 mHoverColor, PorterDuff.Mode.SRC_ATOP));
         setBackgroundColor(mHoverColor);
         getBackground().setAlpha(0);
+
+        // Remove the text in the Phone UI in landscape
+        int orientation = getResources().getConfiguration().orientation;
+        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
+            if (!LauncherApplication.isScreenLarge()) {
+                mText.setText("");
+            }
+        }
     }
 
-    private boolean isApplication(Object info) {
-        if (info instanceof ApplicationInfo) return true;
-        return (((ItemInfo) info).itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION);
+    private boolean isAllAppsApplication(DragSource source, Object info) {
+        return (source instanceof AppsCustomizePagedView) && (info instanceof ApplicationInfo);
     }
 
     @Override
@@ -77,11 +89,10 @@
 
     @Override
     public void onDragStart(DragSource source, Object info, int dragAction) {
-        ItemInfo item = (ItemInfo) info;
         boolean isVisible = true;
 
         // If we are dragging a widget or shortcut, hide the info target
-        if (!isApplication(info)) {
+        if (!isAllAppsApplication(source, info)) {
             isVisible = false;
         }
 
diff --git a/src/com/android/launcher2/SearchDropTargetBar.java b/src/com/android/launcher2/SearchDropTargetBar.java
index d00e210..943bd00 100644
--- a/src/com/android/launcher2/SearchDropTargetBar.java
+++ b/src/com/android/launcher2/SearchDropTargetBar.java
@@ -16,6 +16,9 @@
 
 package com.android.launcher2;
 
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ObjectAnimator;
 import android.content.Context;
 import android.util.AttributeSet;
 import android.view.View;
@@ -32,6 +35,11 @@
     private static final int sTransitionInDuration = 275;
     private static final int sTransitionOutDuration = 100;
 
+    private ObjectAnimator mDropTargetBarFadeInAnim;
+    private ObjectAnimator mDropTargetBarFadeOutAnim;
+    private ObjectAnimator mQSBSearchBarFadeInAnim;
+    private ObjectAnimator mQSBSearchBarFadeOutAnim;
+
     private boolean mIsSearchBarHidden;
     private View mQSBSearchBar;
     private View mDropTargetBar;
@@ -66,23 +74,68 @@
         mDropTargetBar = findViewById(R.id.drag_target_bar);
         mInfoDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.info_target);
         mDeleteDropTarget = (ButtonDropTarget) mDropTargetBar.findViewById(R.id.delete_target);
+
+        // Create the various fade animations
+        mDropTargetBarFadeInAnim = ObjectAnimator.ofFloat(mDropTargetBar, "alpha", 1f);
+        mDropTargetBarFadeInAnim.setDuration(sTransitionInDuration);
+        mDropTargetBarFadeInAnim.addListener(new AnimatorListenerAdapter() {
+            @Override
+            public void onAnimationStart(Animator animation) {
+                mDropTargetBar.setVisibility(View.VISIBLE);
+            }
+        });
+        mDropTargetBarFadeOutAnim = ObjectAnimator.ofFloat(mDropTargetBar, "alpha", 0f);
+        mDropTargetBarFadeOutAnim.setDuration(sTransitionOutDuration);
+        mDropTargetBarFadeOutAnim.addListener(new AnimatorListenerAdapter() {
+            @Override
+            public void onAnimationEnd(Animator animation) {
+                mDropTargetBar.setVisibility(View.GONE);
+            }
+        });
+        mQSBSearchBarFadeInAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "alpha", 1f);
+        mQSBSearchBarFadeInAnim.setDuration(sTransitionInDuration);
+        mQSBSearchBarFadeInAnim.addListener(new AnimatorListenerAdapter() {
+            @Override
+            public void onAnimationStart(Animator animation) {
+                mQSBSearchBar.setVisibility(View.VISIBLE);
+            }
+        });
+        mQSBSearchBarFadeOutAnim = ObjectAnimator.ofFloat(mQSBSearchBar, "alpha", 0f);
+        mQSBSearchBarFadeOutAnim.setDuration(sTransitionOutDuration);
+        mQSBSearchBarFadeOutAnim.addListener(new AnimatorListenerAdapter() {
+            @Override
+            public void onAnimationEnd(Animator animation) {
+                mQSBSearchBar.setVisibility(View.GONE);
+            }
+        });
+    }
+
+    private void cancelAnimations() {
+        mDropTargetBarFadeInAnim.cancel();
+        mDropTargetBarFadeOutAnim.cancel();
+        mQSBSearchBarFadeInAnim.cancel();
+        mQSBSearchBarFadeOutAnim.cancel();
     }
 
     /*
      * Shows and hides the search bar.
      */
     public void showSearchBar(boolean animated) {
+        cancelAnimations();
         if (animated) {
-            mQSBSearchBar.animate().alpha(1f).setDuration(sTransitionInDuration);
+            mQSBSearchBarFadeInAnim.start();
         } else {
+            mQSBSearchBar.setVisibility(View.VISIBLE);
             mQSBSearchBar.setAlpha(1f);
         }
         mIsSearchBarHidden = false;
     }
     public void hideSearchBar(boolean animated) {
+        cancelAnimations();
         if (animated) {
-            mQSBSearchBar.animate().alpha(0f).setDuration(sTransitionOutDuration);
+            mQSBSearchBarFadeOutAnim.start();
         } else {
+            mQSBSearchBar.setVisibility(View.GONE);
             mQSBSearchBar.setAlpha(0f);
         }
         mIsSearchBarHidden = true;
@@ -104,18 +157,18 @@
     @Override
     public void onDragStart(DragSource source, Object info, int dragAction) {
         // Animate out the QSB search bar, and animate in the drop target bar
-        mDropTargetBar.animate().alpha(1f).setDuration(sTransitionInDuration);
+        mDropTargetBarFadeInAnim.start();
         if (!mIsSearchBarHidden) {
-            mQSBSearchBar.animate().alpha(0f).setDuration(sTransitionOutDuration);
+            mQSBSearchBarFadeOutAnim.start();
         }
     }
 
     @Override
     public void onDragEnd() {
         // Restore the QSB search bar, and animate out the drop target bar
-        mDropTargetBar.animate().alpha(0f).setDuration(sTransitionOutDuration);
+        mDropTargetBarFadeOutAnim.start();
         if (!mIsSearchBarHidden) {
-            mQSBSearchBar.animate().alpha(1f).setDuration(sTransitionInDuration);
+            mQSBSearchBarFadeInAnim.start();
         }
     }
 }
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 1048fd5..7165865 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -735,13 +735,10 @@
 
     protected void setWallpaperDimension() {
         Display display = mLauncher.getWindowManager().getDefaultDisplay();
-        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);
+        DisplayMetrics displayMetrics = new DisplayMetrics();
+        display.getRealMetrics(displayMetrics);
+        final int maxDim = Math.max(displayMetrics.widthPixels, displayMetrics.heightPixels);
+        final int minDim = Math.min(displayMetrics.widthPixels, displayMetrics.heightPixels);
 
         // We need to ensure that there is enough extra space in the wallpaper for the intended
         // parallax effects