Updating the widget tray

-> adding dark panel / associated visual updates
-> cleaning up the sizing / padding / to match all apps
-> fixing a couple things from previous CL
-> (removed Context#getDrawable() calls, L-only)

Change-Id: Ia65a6eb704b35f74e7305be9334c27971b22235a
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 75ba8fd..ebf3cc2 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3205,6 +3205,12 @@
             final View page = content.getPageAt(content.getCurrentPage());
             final View revealView = toView.findViewById(R.id.fake_page);
 
+            if (contentType == AppsCustomizePagedView.ContentType.Widgets) {
+                revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark));
+            } else {
+                revealView.setBackground(res.getDrawable(R.drawable.quantum_panel));
+            }
+
             // Hide the real page background, and swap in the fake one
             revealView.setVisibility(View.VISIBLE);
             content.setPageBackgroundsVisible(false);
@@ -3227,24 +3233,27 @@
 
             mStateAnimation.play(panelAlphaAndDrift);
 
-            page.setVisibility(View.VISIBLE);
-            page.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+            if (page != null) {
+                page.setVisibility(View.VISIBLE);
+                page.setLayerType(View.LAYER_TYPE_HARDWARE, null);
 
-            ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", yDrift, 0);
-            pageDrift.setDuration(revealDuration);
-            pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));
-            mStateAnimation.play(pageDrift);
+                ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", yDrift, 0);
+                pageDrift.setDuration(revealDuration);
+                pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));
+                mStateAnimation.play(pageDrift);
 
-            // TODO (adamcohen): remove this 0.01f hack once fw is fixed
-            // it's there to work around a framework bug (16918357)
-            page.setAlpha(0.01f);
-            ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, "alpha", 0.01f, 1f);
-            itemsAlpha.setDuration(revealDuration);
-            itemsAlpha.setInterpolator(new AccelerateInterpolator(1.5f));
-            itemsAlpha.setStartDelay(itemsAlphaStagger);
-            mStateAnimation.play(itemsAlpha);
+                // TODO (adamcohen): remove this 0.01f hack once fw is fixed
+                // it's there to work around a framework bug (16918357)
+                page.setAlpha(0.01f);
+                ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, "alpha", 0.01f, 1f);
+                itemsAlpha.setDuration(revealDuration);
+                itemsAlpha.setInterpolator(new AccelerateInterpolator(1.5f));
+                itemsAlpha.setStartDelay(itemsAlphaStagger);
+                mStateAnimation.play(itemsAlpha);
+            }
 
-            View pageIndicators = fromView.findViewById(R.id.apps_customize_page_indicator);
+            View pageIndicators = toView.findViewById(R.id.apps_customize_page_indicator);
+            pageIndicators.setAlpha(0.01f);
             ObjectAnimator indicatorsAlpha =
                     ObjectAnimator.ofFloat(pageIndicators, "alpha", 1f);
             indicatorsAlpha.setDuration(revealDuration);
@@ -3267,7 +3276,9 @@
 
                     revealView.setVisibility(View.INVISIBLE);
                     revealView.setLayerType(View.LAYER_TYPE_NONE, null);
-                    page.setLayerType(View.LAYER_TYPE_NONE, null);
+                    if (page != null) {
+                        page.setLayerType(View.LAYER_TYPE_NONE, null);
+                    }
                     content.setPageBackgroundsVisible(true);
 
                     // Hide the search bar
@@ -3396,6 +3407,13 @@
             final View page = content.getPageAt(content.getNextPage());
             final View revealView = fromView.findViewById(R.id.fake_page);
 
+            AppsCustomizePagedView.ContentType contentType = content.getContentType();
+            if (contentType == AppsCustomizePagedView.ContentType.Widgets) {
+                revealView.setBackground(res.getDrawable(R.drawable.quantum_panel_dark));
+            } else {
+                revealView.setBackground(res.getDrawable(R.drawable.quantum_panel));
+            }
+
             int width = revealView.getMeasuredWidth();
             int height = revealView.getMeasuredHeight();
             float revealRadius = (float) Math.sqrt((width * width) / 4 + (height * height) / 4);
@@ -3410,7 +3428,7 @@
 
             PropertyValuesHolder panelAlpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1f, 0f);
             PropertyValuesHolder panelDrift =
-                    PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0, yDrift);
+                    PropertyValuesHolder.ofFloat("translationY", 0, yDrift);
             ObjectAnimator panelAlphaAndDrift =
                     ObjectAnimator.ofPropertyValuesHolder(revealView, panelAlpha, panelDrift);
             panelAlphaAndDrift.setDuration(revealDuration);
@@ -3420,23 +3438,26 @@
 
             mStateAnimation.play(panelAlphaAndDrift);
 
-            page.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+            if (page != null) {
+                page.setLayerType(View.LAYER_TYPE_HARDWARE, null);
 
-            ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, View.TRANSLATION_Y, 0, yDrift);
-            pageDrift.setDuration(revealDuration);
-            pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));
-            pageDrift.setStartDelay(itemsAlphaStagger);
-            mStateAnimation.play(pageDrift);
+                ObjectAnimator pageDrift = ObjectAnimator.ofFloat(page, "translationY", 0, yDrift);
+                pageDrift.setDuration(revealDuration);
+                pageDrift.setInterpolator(new LogDecelerateInterpolator(100, 0));
+                pageDrift.setStartDelay(itemsAlphaStagger);
+                mStateAnimation.play(pageDrift);
 
-            page.setAlpha(1f);
-            ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, View.ALPHA, 1f, 0f);
-            itemsAlpha.setDuration(revealDuration);
-            itemsAlpha.setInterpolator(new LogDecelerateInterpolator(100, 0));
-            mStateAnimation.play(itemsAlpha);
+                page.setAlpha(1f);
+                ObjectAnimator itemsAlpha = ObjectAnimator.ofFloat(page, View.ALPHA, 1f, 0f);
+                itemsAlpha.setDuration(revealDuration);
+                itemsAlpha.setInterpolator(new LogDecelerateInterpolator(100, 0));
+                mStateAnimation.play(itemsAlpha);
+            }
 
             View pageIndicators = fromView.findViewById(R.id.apps_customize_page_indicator);
+            pageIndicators.setAlpha(1f);
             ObjectAnimator indicatorsAlpha =
-                    ObjectAnimator.ofFloat(pageIndicators, View.ALPHA, 0f);
+                    ObjectAnimator.ofFloat(pageIndicators, "alpha", 0f);
             indicatorsAlpha.setDuration(revealDuration);
             indicatorsAlpha.setInterpolator(new DecelerateInterpolator(1.5f));
             mStateAnimation.play(indicatorsAlpha);
@@ -3479,7 +3500,9 @@
                     }
 
                     revealView.setLayerType(View.LAYER_TYPE_NONE, null);
-                    page.setLayerType(View.LAYER_TYPE_NONE, null);
+                    if (page != null) {
+                        page.setLayerType(View.LAYER_TYPE_NONE, null);
+                    }
                     content.setPageBackgroundsVisible(true);
                     mAppsCustomizeContent.updateCurrentPageScroll();
                 }