Merge "Fix <group> tag for NfcProvisioning sample" into lmp-docs
diff --git a/connectivity/wifidirect/DirectP2P/Application/tests/AndroidManifest.xml b/connectivity/wifidirect/DirectP2P/Application/tests/AndroidManifest.xml
index a636d3d..504c724 100644
--- a/connectivity/wifidirect/DirectP2P/Application/tests/AndroidManifest.xml
+++ b/connectivity/wifidirect/DirectP2P/Application/tests/AndroidManifest.xml
@@ -14,22 +14,6 @@
  See the License for the specific language governing permissions and
  limitations under the License.
 -->
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2013 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.
-  -->
 <!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
           package="com.example.android.wifidirectp2p.tests"
@@ -55,4 +39,4 @@
             android:targetPackage="com.example.android.wifidirectp2p"
             android:label="Tests for com.example.android.wifidirectp2p" />
 
-</manifest>
\ No newline at end of file
+</manifest>
diff --git a/connectivity/wifidirect/DirectP2P/Application/tests/src/com/example/android/wifidirectp2p/tests/SampleTests.java b/connectivity/wifidirect/DirectP2P/Application/tests/src/com/example/android/wifidirectp2p/tests/SampleTests.java
index 895f2c1..31a0170 100644
--- a/connectivity/wifidirect/DirectP2P/Application/tests/src/com/example/android/wifidirectp2p/tests/SampleTests.java
+++ b/connectivity/wifidirect/DirectP2P/Application/tests/src/com/example/android/wifidirectp2p/tests/SampleTests.java
@@ -13,21 +13,6 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-/*
-* Copyright (C) 2013 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.
-*/
 package com.example.android.wifidirectp2p.tests;
 
 import com.example.android.wifidirectp2p.*;
@@ -40,7 +25,6 @@
 public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
 
     private MainActivity mTestActivity;
-    private DirectP2PFragment mTestFragment;
 
     public SampleTests() {
         super(MainActivity.class);
@@ -55,8 +39,6 @@
         // flags = {@link Intent#FLAG_ACTIVITY_NEW_TASK}
         // All other fields are null or empty.
         mTestActivity = getActivity();
-        mTestFragment = (DirectP2PFragment)
-            mTestActivity.getSupportFragmentManager().getFragments().get(1);
     }
 
     /**
@@ -66,11 +48,10 @@
         //Try to add a message to add context to your assertions. These messages will be shown if
         //a tests fails and make it easy to understand why a test failed
         assertNotNull("mTestActivity is null", mTestActivity);
-        assertNotNull("mTestFragment is null", mTestFragment);
     }
 
     /**
     * Add more tests below.
     */
 
-}
\ No newline at end of file
+}
diff --git a/content/documentsUi/StorageClient/Application/src/main/java/com/example/android/storageclient/StorageClientFragment.java b/content/documentsUi/StorageClient/Application/src/main/java/com/example/android/storageclient/StorageClientFragment.java
index 7f9f73e..97733b0 100644
--- a/content/documentsUi/StorageClient/Application/src/main/java/com/example/android/storageclient/StorageClientFragment.java
+++ b/content/documentsUi/StorageClient/Application/src/main/java/com/example/android/storageclient/StorageClientFragment.java
@@ -117,69 +117,27 @@
             // Since the URI is to an image, create and show a DialogFragment to display the
             // image to the user.
             FragmentManager fm = getActivity().getSupportFragmentManager();
-            ImageDialogFragment imageDialog = new ImageDialogFragment(uri);
+            ImageDialogFragment imageDialog = new ImageDialogFragment();
+            Bundle fragmentArguments = new Bundle();
+            fragmentArguments.putParcelable("URI", uri);
+            imageDialog.setArguments(fragmentArguments);
             imageDialog.show(fm, "image_dialog");
         }
         // END_INCLUDE (create_show_image_dialog)
     }
 
-    /**
-     * Grabs metadata for a document specified by URI, logs it to the screen.
-     *
-     * @param uri The uri for the document whose metadata should be printed.
-     */
-    public void dumpImageMetaData(Uri uri) {
-        // BEGIN_INCLUDE (dump_metadata)
-
-        // The query, since it only applies to a single document, will only return one row.
-        // no need to filter, sort, or select fields, since we want all fields for one
-        // document.
-        Cursor cursor = getActivity().getContentResolver()
-                .query(uri, null, null, null, null, null);
-
-        try {
-        // moveToFirst() returns false if the cursor has 0 rows.  Very handy for
-        // "if there's anything to look at, look at it" conditionals.
-            if (cursor != null && cursor.moveToFirst()) {
-
-                // Note it's called "Display Name".  This is provider-specific, and
-                // might not necessarily be the file name.
-                String displayName = cursor.getString(
-                        cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
-                Log.i(TAG, "Display Name: " + displayName);
-
-                int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);
-                // If the size is unknown, the value stored is null.  But since an int can't be
-                // null in java, the behavior is implementation-specific, which is just a fancy
-                // term for "unpredictable".  So as a rule, check if it's null before assigning
-                // to an int.  This will happen often:  The storage API allows for remote
-                // files, whose size might not be locally known.
-                String size = null;
-                if (!cursor.isNull(sizeIndex)) {
-                    // Technically the column stores an int, but cursor.getString will do the
-                    // conversion automatically.
-                    size = cursor.getString(sizeIndex);
-                } else {
-                    size = "Unknown";
-                }
-                Log.i(TAG, "Size: " + size);
-            }
-        } finally {
-            cursor.close();
-        }
-        // END_INCLUDE (dump_metadata)
-    }
 
     /**
      * DialogFragment which displays an image, given a URI.
      */
-    private class ImageDialogFragment extends DialogFragment {
+    public static class ImageDialogFragment extends DialogFragment {
         private Dialog mDialog;
         private Uri mUri;
 
-        public ImageDialogFragment(Uri uri) {
-            super();
-            mUri = uri;
+        @Override
+        public void onCreate(Bundle savedInstanceState) {
+            super.onCreate(savedInstanceState);
+            mUri = getArguments().getParcelable("URI");
         }
 
         /** Create a Bitmap from the URI for that image and return it.
@@ -251,5 +209,54 @@
                 getDialog().dismiss();
             }
         }
+
+        /**
+         * Grabs metadata for a document specified by URI, logs it to the screen.
+         *
+         * @param uri The uri for the document whose metadata should be printed.
+         */
+        public void dumpImageMetaData(Uri uri) {
+            // BEGIN_INCLUDE (dump_metadata)
+
+            // The query, since it only applies to a single document, will only return one row.
+            // no need to filter, sort, or select fields, since we want all fields for one
+            // document.
+            Cursor cursor = getActivity().getContentResolver()
+                    .query(uri, null, null, null, null, null);
+
+            try {
+                // moveToFirst() returns false if the cursor has 0 rows.  Very handy for
+                // "if there's anything to look at, look at it" conditionals.
+                if (cursor != null && cursor.moveToFirst()) {
+
+                    // Note it's called "Display Name".  This is provider-specific, and
+                    // might not necessarily be the file name.
+                    String displayName = cursor.getString(
+                            cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
+                    Log.i(TAG, "Display Name: " + displayName);
+
+                    int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);
+                    // If the size is unknown, the value stored is null.  But since an int can't be
+                    // null in java, the behavior is implementation-specific, which is just a fancy
+                    // term for "unpredictable".  So as a rule, check if it's null before assigning
+                    // to an int.  This will happen often:  The storage API allows for remote
+                    // files, whose size might not be locally known.
+                    String size = null;
+                    if (!cursor.isNull(sizeIndex)) {
+                        // Technically the column stores an int, but cursor.getString will do the
+                        // conversion automatically.
+                        size = cursor.getString(sizeIndex);
+                    } else {
+                        size = "Unknown";
+                    }
+                    Log.i(TAG, "Size: " + size);
+                }
+            } finally {
+                if (cursor != null) {
+                    cursor.close();
+                }
+            }
+            // END_INCLUDE (dump_metadata)
+        }
     }
 }
diff --git a/content/documentsUi/StorageClient/Application/tests/src/com/example/android/storageclient/tests/SampleTests.java b/content/documentsUi/StorageClient/Application/tests/src/com/example/android/storageclient/tests/SampleTests.java
index 5ed779a..198596d 100644
--- a/content/documentsUi/StorageClient/Application/tests/src/com/example/android/storageclient/tests/SampleTests.java
+++ b/content/documentsUi/StorageClient/Application/tests/src/com/example/android/storageclient/tests/SampleTests.java
@@ -30,12 +30,12 @@
 */
 package com.example.android.storageclient.tests;
 
-import com.example.android.storageclient.*;
-
 import android.net.Uri;
-import android.support.v4.app.FragmentManager;
 import android.test.ActivityInstrumentationTestCase2;
 
+import com.example.android.storageclient.MainActivity;
+import com.example.android.storageclient.StorageClientFragment;
+
 /**
 * Tests for StorageClient sample.
 */
@@ -76,6 +76,6 @@
      */
     public void testDumpMetadataInvalidUri() {
         Uri uri = Uri.parse("content://HAHADOESNTEXIST");
-        mTestFragment.dumpImageMetaData(uri);
+        StorageClientFragment.ImageDialogFragment.dumpImageMetaData(mTestActivity, uri);
     }
 }
\ No newline at end of file
diff --git a/content/documentsUi/StorageClient/README.md b/content/documentsUi/StorageClient/README.md
index bb6c434..e7ce5fa 100644
--- a/content/documentsUi/StorageClient/README.md
+++ b/content/documentsUi/StorageClient/README.md
@@ -1,5 +1,5 @@
 Android StorageClient Sample
-==============================
+===================================
 
 Using the OPEN_DOCUMENT intent, a client app can access a list of Document Providers
 on the device, and choose a file from any of them.
@@ -10,8 +10,8 @@
 Pre-requisites
 --------------
 
-- Android SDK v20
-- Android Build Tools v20
+- Android SDK v21
+- Android Build Tools v21.1.1
 - Android Support Repository
 
 Getting Started
@@ -44,7 +44,7 @@
 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
+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
diff --git a/content/documentsUi/StorageClient/template-params.xml b/content/documentsUi/StorageClient/template-params.xml
index d1ac386..01c57c6 100644
--- a/content/documentsUi/StorageClient/template-params.xml
+++ b/content/documentsUi/StorageClient/template-params.xml
@@ -19,7 +19,7 @@
     <group>Content</group>
     <package>com.example.android.storageclient</package>
     <!-- change minSdk if needed-->
-    <minSdk>4</minSdk>
+    <minSdk>16</minSdk>
 
     <strings>
         <intro>