Update to follow clipboard APIs.

Change-Id: I905a499f2697bea218b6d4c3f8ec339fbe52c916
diff --git a/samples/NotePad/Android.mk b/samples/NotePad/Android.mk
new file mode 100644
index 0000000..7939212
--- /dev/null
+++ b/samples/NotePad/Android.mk
@@ -0,0 +1,16 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := samples
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := NotePad
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
+
+# Use the following include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/samples/NotePad/src/com/example/android/notepad/NoteEditor.java b/samples/NotePad/src/com/example/android/notepad/NoteEditor.java
index 78a9721..da85974 100644
--- a/samples/NotePad/src/com/example/android/notepad/NoteEditor.java
+++ b/samples/NotePad/src/com/example/android/notepad/NoteEditor.java
@@ -20,7 +20,7 @@
 
 import android.app.Activity;
 import android.content.ClipboardManager;
-import android.content.ClippedData;
+import android.content.ClipData;
 import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.ContentValues;
@@ -510,14 +510,14 @@
         ContentResolver cr = getContentResolver();
 
         // Gets the clipboard data from the clipboard
-        ClippedData clip = clipboard.getPrimaryClip();
+        ClipData clip = clipboard.getPrimaryClip();
         if (clip != null) {
 
             String text=null;
             String title=null;
 
             // Gets the first item from the clipboard data
-            ClippedData.Item item = clip.getItem(0);
+            ClipData.Item item = clip.getItem(0);
 
             // Tries to get the item's contents as a URI pointing to a note
             Uri uri = item.getUri();
diff --git a/samples/NotePad/src/com/example/android/notepad/NotePadProvider.java b/samples/NotePad/src/com/example/android/notepad/NotePadProvider.java
index f121553..1131356 100644
--- a/samples/NotePad/src/com/example/android/notepad/NotePadProvider.java
+++ b/samples/NotePad/src/com/example/android/notepad/NotePadProvider.java
@@ -18,6 +18,7 @@
 
 import com.example.android.notepad.NotePad;
 
+import android.content.ClipDescription;
 import android.content.ContentProvider;
 import android.content.ContentUris;
 import android.content.ContentValues;
@@ -349,10 +350,17 @@
            default:
                throw new IllegalArgumentException("Unknown URI " + uri);
        }
-   }
+    }
 
 //BEGIN_INCLUDE(stream)
     /**
+     * This describes the MIME types that are supported for opening a note
+     * URI as a stream.
+     */
+    static ClipDescription NOTE_STREAM_TYPES = new ClipDescription(null,
+            new String[] { ClipDescription.MIMETYPE_TEXT_PLAIN });
+
+    /**
      * Returns the types of available data streams.  URIs to specific notes are supported.
      * The application can convert such a note to a plain text stream.
      *
@@ -378,12 +386,7 @@
             // If the pattern is for note IDs and the MIME filter is text/plain, then return
             // text/plain
             case NOTE_ID:
-                if (compareMimeTypes("text/plain", mimeTypeFilter)) {
-                    return new String[] { "text/plain" };
-                }
-
-                // If the URI is for a note id, but the MIME filter isn't text/plain, return null.
-                return null;
+                return NOTE_STREAM_TYPES.filterMimeTypes(mimeTypeFilter);
 
                 // If the URI pattern doesn't match any permitted patterns, throws an exception.
             default:
@@ -394,16 +397,15 @@
 
     /**
      * Returns a stream of data for each supported stream type. This method does a query on the
-     * incomding URI, then uses
+     * incoming URI, then uses
      * {@link android.content.ContentProvider#openPipeHelper(Uri, String, Bundle, Object,
      * PipeDataWriter)} to start another thread in which to convert the data into a stream.
      *
      * @param uri The URI pattern that points to the data stream
      * @param mimeTypeFilter A String containing a MIME type. This method tries to get a stream of
      * data with this MIME type.
-     * @param opts The access mode for the data stream. This may be "r" for read-only, "w" for write
-     * with overwrite, "wa" for write with append, "rw" for read and write access for existing data,
-     * and "rwt" that truncates the existing file if the new data is smaller.
+     * @param opts Additional options supplied by the caller.  Can be interpreted as
+     * desired by the content provider.
      * @return AssetFileDescriptor A handle to the file.
      * @throws FileNotFoundException if there is no file associated with the incoming URI.
      */
diff --git a/samples/NotePad/src/com/example/android/notepad/NotesList.java b/samples/NotePad/src/com/example/android/notepad/NotesList.java
index 39be81c..6229dd2 100644
--- a/samples/NotePad/src/com/example/android/notepad/NotesList.java
+++ b/samples/NotePad/src/com/example/android/notepad/NotesList.java
@@ -20,7 +20,7 @@
 
 import android.app.ListActivity;
 import android.content.ClipboardManager;
-import android.content.ClippedData;
+import android.content.ClipData;
 import android.content.ComponentName;
 import android.content.ContentUris;
 import android.content.Context;
@@ -485,7 +485,6 @@
             }
 
 //BEGIN_INCLUDE(copy)
-
             // Copies the selected note to the clipboard
             case MENU_ITEM_COPY: {
 
@@ -497,12 +496,11 @@
                 Uri noteUri = ContentUris.withAppendedId(getIntent().getData(), info.id);
 
                 // Copies the notes URI to the clipboard. In effect, this copies the note itself
-                clipboard.setPrimaryClip(
-                        new ClippedData(                       // creates a new clipboard item
-                                null,                          // no visible label
-                                null,                          // no visible icon
-                                new ClippedData.Item(noteUri)  // A clipboard Item that is a URI.
-                        )
+                clipboard.setPrimaryClip(ClipData.newUri(   // new clipboard item holding a URI
+                        getContentResolver(),               // resolver to retrieve URI info
+                        "Note",                             // label for the clip
+                        null,                               // icon for the clip
+                        noteUri)                            // the URI
                 );
 
                 // Returns to the caller and skips further processing.