Add a dynamically-revealed view to the drag demo

This is to show off and test the handling of views that become
visible after the primary ACTION_DRAG_STARTED broadcast happens.

Change-Id: I8bb575c2e055a9d60fc6ed8bc77457dec13a80b4
diff --git a/samples/ApiDemos/res/layout/drag_layout.xml b/samples/ApiDemos/res/layout/drag_layout.xml
index 4e509c4..909cef4 100644
--- a/samples/ApiDemos/res/layout/drag_layout.xml
+++ b/samples/ApiDemos/res/layout/drag_layout.xml
@@ -62,6 +62,18 @@
         dot:anr="drop"
         />
 
+    <com.example.android.apis.view.DraggableDot
+        android:id="@+id/drag_dot_hidden"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        dot:radius="64dp"
+        android:padding="15dp"
+        android:layout_toRightOf="@id/drag_dot_3"
+        android:layout_alignTop="@id/drag_dot_3"
+        android:visibility="invisible"
+        dot:legend="Surprise!"
+        />
+
     <TextView android:id="@+id/drag_result_text"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
diff --git a/samples/ApiDemos/src/com/example/android/apis/view/DragAndDropDemo.java b/samples/ApiDemos/src/com/example/android/apis/view/DragAndDropDemo.java
index f3a3521..1230933 100644
--- a/samples/ApiDemos/src/com/example/android/apis/view/DragAndDropDemo.java
+++ b/samples/ApiDemos/src/com/example/android/apis/view/DragAndDropDemo.java
@@ -26,6 +26,7 @@
 
 public class DragAndDropDemo extends Activity {
     TextView mResultText;
+    DraggableDot mHiddenDot;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -40,14 +41,30 @@
         dot = (DraggableDot) findViewById(R.id.drag_dot_3);
         dot.setReportView(text);
 
+        mHiddenDot = (DraggableDot) findViewById(R.id.drag_dot_hidden);
+        mHiddenDot.setReportView(text);
+
         mResultText = (TextView) findViewById(R.id.drag_result_text);
         mResultText.setOnDragListener(new View.OnDragListener() {
             @Override
             public boolean onDrag(View v, DragEvent event) {
                 final int action = event.getAction();
-                if (action == DragEvent.ACTION_DRAG_ENDED) {
-                    final boolean dropped = event.getResult();
-                    mResultText.setText(dropped ? "Dropped!" : "No drop");
+                switch (action) {
+                    case DragEvent.ACTION_DRAG_STARTED: {
+                        // Bring up a fourth draggable dot on the fly. Note that it
+                        // is properly notified about the ongoing drag, and lights up
+                        // to indicate that it can handle the current content.
+                        mHiddenDot.setVisibility(View.VISIBLE);
+                    } break;
+
+                    case DragEvent.ACTION_DRAG_ENDED: {
+                        // Hide the surprise again
+                        mHiddenDot.setVisibility(View.INVISIBLE);
+
+                        // Report the drop/no-drop result to the user
+                        final boolean dropped = event.getResult();
+                        mResultText.setText(dropped ? "Dropped!" : "No drop");
+                    } break;
                 }
                 return false;
             }