Merge "Introduce IconProvider." into ub-launcher3-calgary
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 63e460e..3a361e2 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -52,11 +52,11 @@
 
         <include
             android:id="@+id/app_info_drop_target_bar"
-            layout="@layout/app_info_drop_target_bar" />
+            layout="@layout/drop_target_bar_vert_info" />
 
         <include
             android:id="@+id/search_drop_target_bar"
-            layout="@layout/search_drop_target_bar" />
+            layout="@layout/drop_target_bar_vert_search" />
 
         <include layout="@layout/overview_panel"
             android:id="@+id/overview_panel"
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index 39f5ac1..f711274 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -66,11 +66,11 @@
 
         <include
             android:id="@+id/app_info_drop_target_bar"
-            layout="@layout/app_info_drop_target_bar" />
+            layout="@layout/drop_target_bar_horz_info" />
 
         <include
             android:id="@+id/search_drop_target_bar"
-            layout="@layout/search_drop_target_bar" />
+            layout="@layout/drop_target_bar_horz_search" />
 
         <include layout="@layout/widgets_view"
             android:id="@+id/widgets_view"
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index b572444..780d645 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -52,11 +52,11 @@
 
         <include
             android:id="@+id/app_info_drop_target_bar"
-            layout="@layout/app_info_drop_target_bar" />
+            layout="@layout/drop_target_bar_horz_info" />
 
         <include
             android:id="@+id/search_drop_target_bar"
-            layout="@layout/search_drop_target_bar" />
+            layout="@layout/drop_target_bar_horz_search" />
 
         <include layout="@layout/overview_panel"
             android:id="@+id/overview_panel"
diff --git a/res/layout/app_info_drop_target_bar.xml b/res/layout/app_info_drop_target_bar.xml
deleted file mode 100644
index 5f19d43..0000000
--- a/res/layout/app_info_drop_target_bar.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2011 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.
--->
-<com.android.launcher3.AppInfoDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:focusable="false" >
-
-    <!-- Drag specific targets container -->
-    <LinearLayout
-        android:id="@+id/drag_target_bar"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_gravity="center|bottom" >
-
-        <FrameLayout
-            style="@style/DropTargetButtonContainer"
-            android:layout_weight="1" >
-
-            <!-- Info target -->
-
-            <com.android.launcher3.InfoDropTarget
-                android:id="@+id/info_target_text"
-                style="@style/DropTargetButton"
-                android:text="@string/app_info_drop_target_label" />
-        </FrameLayout>
-    </LinearLayout>
-
-</com.android.launcher3.AppInfoDropTargetBar>
\ No newline at end of file
diff --git a/res/layout/drop_target_bar_horz_info.xml b/res/layout/drop_target_bar_horz_info.xml
new file mode 100644
index 0000000..92a9b22
--- /dev/null
+++ b/res/layout/drop_target_bar_horz_info.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2016 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.
+-->
+<com.android.launcher3.AppInfoDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="48dp"
+    android:layout_gravity="center_horizontal|bottom"
+    android:focusable="false" >
+
+    <FrameLayout
+        android:id="@+id/drag_target_bar"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <!-- Info target -->
+
+        <com.android.launcher3.InfoDropTarget
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_gravity="center"
+            android:gravity="center"
+            android:id="@+id/info_target_text"
+            style="@style/DropTargetButton"
+            android:text="@string/app_info_drop_target_label" />
+    </FrameLayout>
+</com.android.launcher3.AppInfoDropTargetBar>
\ No newline at end of file
diff --git a/res/layout/search_drop_target_bar.xml b/res/layout/drop_target_bar_horz_search.xml
similarity index 67%
rename from res/layout/search_drop_target_bar.xml
rename to res/layout/drop_target_bar_horz_search.xml
index 50f9679..7997801 100644
--- a/res/layout/search_drop_target_bar.xml
+++ b/res/layout/drop_target_bar_horz_search.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-     Copyright (C) 2011 The Android Open Source Project
+     Copyright (C) 2015 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.
@@ -15,9 +15,11 @@
      limitations under the License.
 -->
 <com.android.launcher3.SearchDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:launcher="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:focusable="false" >
+    android:layout_gravity="center_horizontal|top"
+    android:focusable="false">
 
     <!-- Drag specific targets container -->
 
@@ -28,24 +30,36 @@
         android:layout_gravity="center" >
 
         <FrameLayout
-            style="@style/DropTargetButtonContainer"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
             android:layout_weight="1" >
 
             <!-- Delete target -->
 
             <com.android.launcher3.DeleteDropTarget
+                launcher:hideParentOnDisable="true"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:layout_gravity="center"
+                android:gravity="center"
                 android:id="@+id/delete_target_text"
                 style="@style/DropTargetButton"
                 android:text="@string/remove_drop_target_label" />
         </FrameLayout>
 
         <FrameLayout
-            style="@style/DropTargetButtonContainer"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
             android:layout_weight="1" >
 
             <!-- Uninstall target -->
 
             <com.android.launcher3.UninstallDropTarget
+                launcher:hideParentOnDisable="true"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:layout_gravity="center"
+                android:gravity="center"
                 android:id="@+id/uninstall_target_text"
                 style="@style/DropTargetButton"
                 android:text="@string/uninstall_drop_target_label" />
diff --git a/res/layout/drop_target_bar_vert_info.xml b/res/layout/drop_target_bar_vert_info.xml
new file mode 100644
index 0000000..da33d1a
--- /dev/null
+++ b/res/layout/drop_target_bar_vert_info.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2016 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.
+-->
+<com.android.launcher3.AppInfoDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="48dp"
+    android:layout_height="match_parent"
+    android:focusable="false" >
+
+    <FrameLayout
+        android:id="@+id/drag_target_bar"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <!-- Info target -->
+        <com.android.launcher3.InfoDropTarget
+            android:layout_width="48dp"
+            android:layout_height="48dp"
+            android:layout_gravity="center_horizontal|bottom"
+            android:gravity="center"
+            android:paddingLeft="14dp"
+            android:paddingRight="14dp"
+            android:textColor="@android:color/white"
+            android:id="@+id/info_target_text" />
+    </FrameLayout>
+
+</com.android.launcher3.AppInfoDropTargetBar>
\ No newline at end of file
diff --git a/res/layout/drop_target_bar_vert_search.xml b/res/layout/drop_target_bar_vert_search.xml
new file mode 100644
index 0000000..d5e41df
--- /dev/null
+++ b/res/layout/drop_target_bar_vert_search.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2015 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.
+-->
+<com.android.launcher3.SearchDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="48dp"
+    android:layout_height="match_parent"
+    android:focusable="false">
+
+    <!-- Drag specific targets container -->
+
+    <LinearLayout
+        android:id="@+id/drag_target_bar"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical"
+        android:layout_gravity="center"
+        android:paddingTop="20dp">
+
+        <!-- Delete target -->
+        <com.android.launcher3.DeleteDropTarget
+            android:layout_width="48dp"
+            android:layout_height="48dp"
+            android:gravity="center"
+            android:paddingLeft="14dp"
+            android:paddingRight="14dp"
+            android:id="@+id/delete_target_text"
+            android:textColor="@android:color/white"
+            android:layout_marginBottom="10dp" />
+
+        <!-- Uninstall target -->
+        <com.android.launcher3.UninstallDropTarget
+            android:layout_width="48dp"
+            android:layout_height="48dp"
+            android:layout_gravity="center"
+            android:gravity="center"
+            android:paddingLeft="14dp"
+            android:paddingRight="14dp"
+            android:id="@+id/uninstall_target_text"
+            android:textColor="@android:color/white"
+            android:layout_marginTop="10dp"/>
+    </LinearLayout>
+
+</com.android.launcher3.SearchDropTargetBar>
\ No newline at end of file
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index 2be9391..3915759 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -15,10 +15,6 @@
 -->
 
 <resources>
-<!-- QSB -->
-    <dimen name="toolbar_button_vertical_padding">8dip</dimen>
-    <dimen name="toolbar_button_horizontal_padding">0dip</dimen>
-
 <!-- Container -->
      <item name="container_margin" format="fraction" type="fraction">12%</item>
 </resources>
diff --git a/res/values-land/styles.xml b/res/values-land/styles.xml
deleted file mode 100644
index 4092679..0000000
--- a/res/values-land/styles.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?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.
-*/
--->
-
-<resources>
-
-    <style name="DropTargetButtonContainer">
-        <item name="android:layout_width">match_parent</item>
-        <item name="android:layout_height">wrap_content</item>
-    </style>
-
-    <!-- This style applies to the drop target when it is shown in the sidebar -->
-    <style name="DropTargetButton" parent="DropTargetButtonBase">
-        <item name="android:layout_height">wrap_content</item>
-        <item name="android:gravity">center</item>
-        <item name="android:drawablePadding">0dp</item>
-        <item name="android:paddingTop">@dimen/toolbar_button_vertical_padding</item>
-        <item name="android:paddingBottom">@dimen/toolbar_button_vertical_padding</item>
-        <item name="android:paddingLeft">@dimen/toolbar_button_horizontal_padding</item>
-        <item name="android:paddingRight">@dimen/toolbar_button_horizontal_padding</item>
-        <item name="android:shadowColor">#DD000000</item>
-    </style>
-
-</resources>
\ No newline at end of file
diff --git a/res/values-sw720dp/styles.xml b/res/values-sw720dp/styles.xml
index 1fdb267..674edaa 100644
--- a/res/values-sw720dp/styles.xml
+++ b/res/values-sw720dp/styles.xml
@@ -28,11 +28,6 @@
     </style>
 
     <!-- Workspace -->
-    <style name="DropTargetButtonContainer">
-        <item name="android:layout_width">0dp</item>
-        <item name="android:layout_height">match_parent</item>
-    </style>
-
     <style name="DropTargetButton" parent="DropTargetButtonBase">
         <item name="android:paddingLeft">60dp</item>
         <item name="android:paddingRight">60dp</item>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 2224ac8..6d8efaa 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -83,4 +83,8 @@
     <declare-styleable name="InsettableFrameLayout_Layout">
         <attr name="layout_ignoreInsets" format="boolean" />
     </declare-styleable>
+
+    <declare-styleable name="ButtonDropTarget">
+        <attr name="hideParentOnDisable" format="boolean" />
+    </declare-styleable>
 </resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 92cbe04..1b7072d 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -71,16 +71,7 @@
     </style>
 
     <!-- Drop targets -->
-    <style name="DropTargetButtonContainer">
-        <item name="android:layout_width">0dp</item>
-        <item name="android:layout_height">match_parent</item>
-    </style>
-
     <style name="DropTargetButtonBase">
-        <item name="android:layout_width">wrap_content</item>
-        <item name="android:layout_height">match_parent</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:paddingLeft">25dp</item>
         <item name="android:paddingRight">25dp</item>
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index d882683..af1ebde 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -24,11 +24,13 @@
 import android.annotation.TargetApi;
 import android.content.Context;
 import android.content.res.ColorStateList;
+import android.content.res.TypedArray;
 import android.graphics.ColorMatrix;
 import android.graphics.ColorMatrixColorFilter;
 import android.graphics.PointF;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
+import android.graphics.drawable.InsetDrawable;
 import android.os.Build;
 import android.util.AttributeSet;
 import android.view.View;
@@ -52,6 +54,8 @@
 
     private static final int DRAG_VIEW_DROP_DURATION = 285;
 
+    private final boolean mHideParentOnDisable;
+
     protected Launcher mLauncher;
     private int mBottomDragPadding;
     protected BaseDropTargetBar mDropTargetBar;
@@ -65,12 +69,9 @@
     protected ColorStateList mOriginalTextColor;
     protected Drawable mDrawable;
 
-    protected DeviceProfile mDeviceProfile;
-
     private AnimatorSet mCurrentColorAnim;
     @Thunk ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter;
 
-
     public ButtonDropTarget(Context context, AttributeSet attrs) {
         this(context, attrs, 0);
     }
@@ -78,18 +79,17 @@
     public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         mBottomDragPadding = getResources().getDimensionPixelSize(R.dimen.drop_target_drag_padding);
+
+        TypedArray a = context.obtainStyledAttributes(attrs,
+                R.styleable.ButtonDropTarget, defStyle, 0);
+        mHideParentOnDisable = a.getBoolean(R.styleable.ButtonDropTarget_hideParentOnDisable, false);
+        a.recycle();
     }
 
     @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
         mOriginalTextColor = getTextColors();
-
-        // Remove the text in the Phone UI in landscape
-        mDeviceProfile = ((Launcher) getContext()).getDeviceProfile();
-        if (mDeviceProfile.isVerticalBarLayout()) {
-            setText("");
-        }
     }
 
     @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@@ -203,7 +203,8 @@
             mCurrentColorAnim = null;
         }
         setTextColor(mOriginalTextColor);
-        ((ViewGroup) getParent()).setVisibility(mActive ? View.VISIBLE : View.GONE);
+        (mHideParentOnDisable ? ((ViewGroup) getParent()) : this)
+                .setVisibility(mActive ? View.VISIBLE : View.GONE);
     }
 
     @Override
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index 997ded2..f24e00b 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -19,6 +19,7 @@
 import android.animation.TimeInterpolator;
 import android.content.Context;
 import android.graphics.PointF;
+import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.View;
 import android.view.animation.AnimationUtils;
@@ -69,7 +70,7 @@
      * Set the drop target's text to either "Remove" or "Cancel" depending on the drag source.
      */
     public void setTextBasedOnDragSource(DragSource dragSource) {
-        if (!mDeviceProfile.isVerticalBarLayout()) {
+        if (!TextUtils.isEmpty(getText())) {
             setText(dragSource.supportsDeleteDropTarget() ? R.string.remove_drop_target_label
                     : android.R.string.cancel);
         }
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 5bfa716..7c6f39e 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -31,7 +31,6 @@
 import android.view.ViewGroup.LayoutParams;
 import android.view.ViewGroup.MarginLayoutParams;
 import android.widget.FrameLayout;
-import android.widget.LinearLayout;
 
 import com.android.launcher3.config.FeatureFlags;
 
@@ -469,7 +468,7 @@
         // Layout the search bar space
         Rect searchBarBounds = getSearchBarBounds(isLayoutRtl);
         View searchBar = launcher.getSearchDropTargetBar();
-        lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, searchBar, Gravity.TOP);
+        lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams();
         lp.width = searchBarBounds.width();
         lp.height = searchBarBounds.height();
         lp.topMargin = searchBarTopExtraPaddingPx;
@@ -477,7 +476,7 @@
 
         // Layout the app info bar space
         View appInfoBar = launcher.getAppInfoDropTargetBar();
-        lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, appInfoBar, Gravity.BOTTOM);
+        lp = (FrameLayout.LayoutParams) appInfoBar.getLayoutParams();
         lp.bottomMargin = hotseatBarHeightPx;
         appInfoBar.setLayoutParams(lp);
 
@@ -584,28 +583,6 @@
         }
     }
 
-    private FrameLayout.LayoutParams getDropTargetBarLayoutParams(boolean hasVerticalBarLayout,
-            View dropTargetBar, int verticalGravity) {
-        FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) dropTargetBar.getLayoutParams();
-        if (hasVerticalBarLayout) {
-            // Vertical drop target bar space -- The drop target bar is fixed in the layout to be on
-            //                                   the left of the screen regardless of RTL
-            lp.gravity = Gravity.LEFT;
-            lp.width = normalSearchBarSpaceHeightPx;
-
-            LinearLayout targets = (LinearLayout) dropTargetBar.findViewById(R.id.drag_target_bar);
-            targets.setOrientation(LinearLayout.VERTICAL);
-            FrameLayout.LayoutParams targetsLp = (FrameLayout.LayoutParams) targets.getLayoutParams();
-            targetsLp.gravity = verticalGravity;
-            targetsLp.height = LayoutParams.WRAP_CONTENT;
-        } else {
-            // Horizontal drop target bar space
-            lp.gravity = verticalGravity | Gravity.CENTER_HORIZONTAL;
-            lp.height = searchBarSpaceHeightPx;
-        }
-        return lp;
-    }
-
     private int getCurrentWidth() {
         return isLandscape
                 ? Math.max(widthPx, heightPx)