Merge "Fix the build error for RecyclerView sample" into lmp-docs
diff --git a/content/documentsUi/DirectorySelection/Application/.gitignore b/content/documentsUi/DirectorySelection/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/.gitignore
@@ -0,0 +1,16 @@
+# Copyright 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.
+src/template/
+src/common/
+build.gradle
diff --git a/content/documentsUi/DirectorySelection/Application/proguard-project.txt b/content/documentsUi/DirectorySelection/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/proguard-project.txt
@@ -0,0 +1,20 @@
+ To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/AndroidManifest.xml b/content/documentsUi/DirectorySelection/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..46cddcf
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.example.android.directoryselection"
+    android:versionCode="1"
+    android:versionName="1.0">
+
+    <application android:allowBackup="true"
+        android:label="@string/app_name"
+        android:icon="@drawable/ic_launcher"
+        android:theme="@style/AppTheme">
+
+        <activity android:name=".DirectorySelectionActivity"
+                  android:label="@string/app_name">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+
+</manifest>
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntry.java b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntry.java
new file mode 100644
index 0000000..04c1c89
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntry.java
@@ -0,0 +1,25 @@
+/*
+* Copyright (C) 2014 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.directoryselection;
+
+/**
+ * Entity class that represents an directory entry.
+ */
+public class DirectoryEntry {
+    public String fileName;
+    public String mimeType;
+}
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntryAdapter.java b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntryAdapter.java
new file mode 100644
index 0000000..e92c71e
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntryAdapter.java
@@ -0,0 +1,100 @@
+/*
+* Copyright (C) 2014 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.directoryselection;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import java.util.List;
+
+/**
+ * Provide views to RecyclerView with the directory entries.
+ */
+public class DirectoryEntryAdapter extends RecyclerView.Adapter<DirectoryEntryAdapter.ViewHolder> {
+
+    static final String DIRECTORY_MIME_TYPE = "vnd.android.document/directory";
+    private List<DirectoryEntry> mDirectoryEntries;
+
+    /**
+     * Provide a reference to the type of views that you are using (custom ViewHolder)
+     */
+    public static class ViewHolder extends RecyclerView.ViewHolder {
+        private final TextView mFileName;
+        private final TextView mMimeType;
+        private final ImageView mImageView;
+
+        public ViewHolder(View v) {
+            super(v);
+            mFileName = (TextView) v.findViewById(R.id.textview_filename);
+            mMimeType = (TextView) v.findViewById(R.id.textview_mimetype);
+            mImageView = (ImageView) v.findViewById(R.id.entry_image);
+        }
+
+        public TextView getFileName() {
+            return mFileName;
+        }
+
+        public TextView getMimeType() {
+            return mMimeType;
+        }
+
+        public ImageView getImageView() {
+            return mImageView;
+        }
+    }
+
+    /**
+     * Initialize the directory entries of the Adapter.
+     *
+     * @param directoryEntries an array of {@link DirectoryEntry}.
+     */
+    public DirectoryEntryAdapter(List<DirectoryEntry> directoryEntries) {
+        mDirectoryEntries = directoryEntries;
+    }
+
+    @Override
+    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
+        View v = LayoutInflater.from(viewGroup.getContext())
+                .inflate(R.layout.directory_item, viewGroup, false);
+        return new ViewHolder(v);
+    }
+
+    @Override
+    public void onBindViewHolder(ViewHolder viewHolder, final int position) {
+        viewHolder.getFileName().setText(mDirectoryEntries.get(position).fileName);
+        viewHolder.getMimeType().setText(mDirectoryEntries.get(position).mimeType);
+
+        if (DIRECTORY_MIME_TYPE.equals(mDirectoryEntries.get(position).mimeType)) {
+            viewHolder.getImageView().setImageResource(R.drawable.ic_folder_grey600_36dp);
+        } else {
+            viewHolder.getImageView().setImageResource(R.drawable.ic_description_grey600_36dp);
+        }
+    }
+
+    @Override
+    public int getItemCount() {
+        return mDirectoryEntries.size();
+    }
+
+    public void setDirectoryEntries(List<DirectoryEntry> directoryEntries) {
+        mDirectoryEntries = directoryEntries;
+    }
+}
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionActivity.java b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionActivity.java
new file mode 100644
index 0000000..d27ba72
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionActivity.java
@@ -0,0 +1,37 @@
+/*
+* Copyright 2014 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.directoryselection;
+
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+
+/**
+ * Launcher Activity for the Directory Selection sample app.
+ */
+public class DirectorySelectionActivity extends FragmentActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_directory_selection);
+        if (savedInstanceState == null) {
+            getSupportFragmentManager().beginTransaction()
+                    .add(R.id.container, DirectorySelectionFragment.newInstance())
+                    .commit();
+        }
+    }
+}
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionFragment.java b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionFragment.java
new file mode 100644
index 0000000..4af55db
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionFragment.java
@@ -0,0 +1,231 @@
+/*
+* Copyright 2014 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.directoryselection;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.ContentResolver;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.provider.DocumentsContract;
+import android.provider.DocumentsContract.Document;
+import android.support.v4.app.Fragment;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Fragment that demonstrates how to use Directory Selection API.
+ */
+public class DirectorySelectionFragment extends Fragment {
+
+    private static final String TAG = DirectorySelectionFragment.class.getSimpleName();
+
+    public static final int REQUEST_CODE_OPEN_DIRECTORY = 1;
+
+    Uri mCurrentDirectoryUri;
+    TextView mCurrentDirectoryTextView;
+    Button mCreateDirectoryButton;
+    RecyclerView mRecyclerView;
+    DirectoryEntryAdapter mAdapter;
+    RecyclerView.LayoutManager mLayoutManager;
+
+    /**
+     * Use this factory method to create a new instance of
+     * this fragment using the provided parameters.
+     *
+     * @return A new instance of fragment {@link DirectorySelectionFragment}.
+     */
+    public static DirectorySelectionFragment newInstance() {
+        DirectorySelectionFragment fragment = new DirectorySelectionFragment();
+        return fragment;
+    }
+
+    public DirectorySelectionFragment() {
+        // Required empty public constructor
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        // Inflate the layout for this fragment
+        return inflater.inflate(R.layout.fragment_directory_selection, container, false);
+    }
+
+    @Override
+    public void onViewCreated(View rootView, Bundle savedInstanceState) {
+        super.onViewCreated(rootView, savedInstanceState);
+
+        rootView.findViewById(R.id.button_open_directory)
+                .setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
+                        startActivityForResult(intent, REQUEST_CODE_OPEN_DIRECTORY);
+                    }
+                });
+
+        mCurrentDirectoryTextView = (TextView) rootView
+                .findViewById(R.id.textview_current_directory);
+        mCreateDirectoryButton = (Button) rootView.findViewById(R.id.button_create_directory);
+        mCreateDirectoryButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                final EditText editView = new EditText(getActivity());
+                new AlertDialog.Builder(getActivity())
+                        .setTitle(R.string.create_directory)
+                        .setView(editView)
+                        .setPositiveButton(android.R.string.ok,
+                                new DialogInterface.OnClickListener() {
+                                    public void onClick(DialogInterface dialog, int whichButton) {
+                                        createDirectory(mCurrentDirectoryUri,
+                                                editView.getText().toString());
+                                        updateDirectoryEntries(mCurrentDirectoryUri);
+                                    }
+                                })
+                        .setNegativeButton(android.R.string.cancel,
+                                new DialogInterface.OnClickListener() {
+                                    public void onClick(DialogInterface dialog, int whichButton) {
+                                    }
+                                })
+                        .show();
+            }
+        });
+        mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview_directory_entries);
+        mLayoutManager = new LinearLayoutManager(getActivity());
+        mRecyclerView.setLayoutManager(mLayoutManager);
+        mRecyclerView.scrollToPosition(0);
+        mAdapter = new DirectoryEntryAdapter(new ArrayList<DirectoryEntry>());
+        mRecyclerView.setAdapter(mAdapter);
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (requestCode == REQUEST_CODE_OPEN_DIRECTORY && resultCode == Activity.RESULT_OK) {
+            Log.d(TAG, String.format("Open Directory result Uri : %s", data.getData()));
+            updateDirectoryEntries(data.getData());
+            mAdapter.notifyDataSetChanged();
+        }
+    }
+
+
+    /**
+     * Updates the current directory of the uri passed as an argument and its children directories.
+     * And updates the {@link #mRecyclerView} depending on the contents of the children.
+     *
+     * @param uri The uri of the current directory.
+     */
+    //VisibileForTesting
+    void updateDirectoryEntries(Uri uri) {
+        ContentResolver contentResolver = getActivity().getContentResolver();
+        Uri docUri = DocumentsContract.buildDocumentUriUsingTree(uri,
+                DocumentsContract.getTreeDocumentId(uri));
+        Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(uri,
+                DocumentsContract.getTreeDocumentId(uri));
+
+        Cursor docCursor = contentResolver.query(docUri, new String[]{
+                Document.COLUMN_DISPLAY_NAME, Document.COLUMN_MIME_TYPE}, null, null, null);
+        try {
+            while (docCursor.moveToNext()) {
+                Log.d(TAG, "found doc =" + docCursor.getString(0) + ", mime=" + docCursor
+                        .getString(1));
+                mCurrentDirectoryUri = uri;
+                mCurrentDirectoryTextView.setText(docCursor.getString(0));
+                mCreateDirectoryButton.setEnabled(true);
+            }
+        } finally {
+            closeQuietly(docCursor);
+        }
+
+        Cursor childCursor = contentResolver.query(childrenUri, new String[]{
+                Document.COLUMN_DISPLAY_NAME, Document.COLUMN_MIME_TYPE}, null, null, null);
+        try {
+            List<DirectoryEntry> directoryEntries = new ArrayList<>();
+            while (childCursor.moveToNext()) {
+                Log.d(TAG, "found child=" + childCursor.getString(0) + ", mime=" + childCursor
+                        .getString(1));
+                DirectoryEntry entry = new DirectoryEntry();
+                entry.fileName = childCursor.getString(0);
+                entry.mimeType = childCursor.getString(1);
+                directoryEntries.add(entry);
+            }
+            mAdapter.setDirectoryEntries(directoryEntries);
+            mAdapter.notifyDataSetChanged();
+        } finally {
+            closeQuietly(childCursor);
+        }
+    }
+
+    /**
+     * Creates a directory under the directory represented as the uri in the argument.
+     *
+     * @param uri The uri of the directory under which a new directory is created.
+     * @param directoryName The directory name of a new directory.
+     */
+    //VisibileForTesting
+    void createDirectory(Uri uri, String directoryName) {
+        ContentResolver contentResolver = getActivity().getContentResolver();
+        Uri docUri = DocumentsContract.buildDocumentUriUsingTree(uri,
+                DocumentsContract.getTreeDocumentId(uri));
+        Uri directoryUri = DocumentsContract
+                .createDocument(contentResolver, docUri, Document.MIME_TYPE_DIR, directoryName);
+        if (directoryUri != null) {
+            Log.i(TAG, String.format(
+                    "Created directory : %s, Document Uri : %s, Created directory Uri : %s",
+                    directoryName, docUri, directoryUri));
+            Toast.makeText(getActivity(), String.format("Created a directory [%s]",
+                    directoryName), Toast.LENGTH_SHORT).show();
+        } else {
+            Log.w(TAG, String.format("Failed to create a directory : %s, Uri %s", directoryName,
+                    docUri));
+            Toast.makeText(getActivity(), String.format("Failed to created a directory [%s] : ",
+                    directoryName), Toast.LENGTH_SHORT).show();
+        }
+
+    }
+
+    public void closeQuietly(AutoCloseable closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (RuntimeException rethrown) {
+                throw rethrown;
+            } catch (Exception ignored) {
+            }
+        }
+    }
+}
+
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_description_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_description_grey600_36dp.png
new file mode 100755
index 0000000..dd7d073
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_description_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_folder_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_folder_grey600_36dp.png
new file mode 100755
index 0000000..6c022d4
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_folder_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_launcher.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100755
index 0000000..49ee854
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_description_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_description_grey600_36dp.png
new file mode 100755
index 0000000..ac18b57
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_description_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_folder_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_folder_grey600_36dp.png
new file mode 100755
index 0000000..e3dccd2
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_folder_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_launcher.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100755
index 0000000..282a00c
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_description_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_description_grey600_36dp.png
new file mode 100755
index 0000000..50f854e
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_description_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_folder_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_folder_grey600_36dp.png
new file mode 100755
index 0000000..6fbc404
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_folder_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100755
index 0000000..7293ad6
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_description_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_description_grey600_36dp.png
new file mode 100755
index 0000000..33df5d9
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_description_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_folder_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_folder_grey600_36dp.png
new file mode 100755
index 0000000..ed2f08e
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_folder_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100755
index 0000000..7b618d4
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/layout/activity_directory_selection.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/activity_directory_selection.xml
new file mode 100644
index 0000000..db65583
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/activity_directory_selection.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 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.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+             xmlns:tools="http://schemas.android.com/tools"
+             android:id="@+id/container"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent"
+             tools:context="com.example.android.directoryselection.DirectorySelectionActivity"
+             tools:ignore="MergeRootFrame" />
\ No newline at end of file
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/layout/directory_item.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/directory_item.xml
new file mode 100644
index 0000000..0763cff
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/directory_item.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 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.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="@dimen/directory_item_height"
+        >
+
+    <LinearLayout android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:orientation="horizontal"
+                  android:layout_centerVertical="true"
+                  android:gravity="center_vertical"
+            >
+        <ImageView android:id="@+id/entry_image"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:src="@drawable/ic_folder_grey600_36dp"
+                />
+        <LinearLayout android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layout_marginLeft="@dimen/margin_medium"
+                      android:orientation="vertical"
+                >
+            <View android:id="@+id/divisor"
+                  android:layout_width="match_parent"
+                  android:layout_height="1dp"
+                  android:background="#aaaaaa"/>
+
+            <TextView
+                    android:id="@+id/textview_filename"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    style="@style/DirectoryEntryNameFont"
+                    />
+            <TextView
+                    android:id="@+id/textview_mimetype"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"/>
+
+        </LinearLayout>
+    </LinearLayout>
+</RelativeLayout>
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/layout/fragment_directory_selection.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/fragment_directory_selection.xml
new file mode 100644
index 0000000..d63219c
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/fragment_directory_selection.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:gravity="center_vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="vertical"
+              android:padding="@dimen/margin_medium">
+
+    <LinearLayout android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:orientation="horizontal"
+            >
+
+        <Button android:id="@+id/button_open_directory"
+                android:text="@string/open_directory"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"/>
+
+        <Button android:id="@+id/button_create_directory"
+                android:text="@string/create_directory"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:enabled="false"
+                />
+    </LinearLayout>
+
+    <LinearLayout android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:orientation="horizontal"
+                  android:layout_marginLeft="@dimen/margin_small"
+                  android:layout_marginRight="@dimen/margin_small"
+            >
+
+        <TextView android:id="@+id/label_current_directory"
+                  android:text="@string/selected_directory"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"/>
+
+        <TextView android:id="@+id/textview_current_directory"
+                  android:enabled="false"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  style="@style/DirectoryEntryNameFont"
+                />
+
+    </LinearLayout>
+
+    <android.support.v7.widget.RecyclerView
+            android:id="@+id/recyclerview_directory_entries"
+            android:layout_marginLeft="@dimen/margin_small"
+            android:layout_marginRight="@dimen/margin_small"
+            android:scrollbars="vertical"
+            android:drawSelectorOnTop="true"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"/>
+
+</LinearLayout>
+
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/menu/main.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/menu/main.xml
new file mode 100644
index 0000000..e9b5e0b
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/menu/main.xml
@@ -0,0 +1,16 @@
+<!--
+  Copyright 2014 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.
+  -->
+<menu xmlns:android="http://schemas.android.com/apk/res/android" />
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/values/dimens.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..53d0182
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/values/dimens.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 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>
+    <dimen name="directory_item_height">72dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/values/strings.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..24d59dd
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/values/strings.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 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>
+    <string name="open_directory">Open directory</string>
+    <string name="create_directory">Create Directory</string>
+    <string name="selected_directory">"Selected Directory : "</string>
+</resources>
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/values/styles.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/values/styles.xml
new file mode 100644
index 0000000..38441f3
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/values/styles.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 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="DirectoryEntryNameFont" parent="@android:style/TextAppearance.Medium">
+        <item name="android:textColor">#000000</item>
+    </style>
+</resources>
\ No newline at end of file
diff --git a/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectoryEntryAdapterTest.java b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectoryEntryAdapterTest.java
new file mode 100644
index 0000000..97b2629
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectoryEntryAdapterTest.java
@@ -0,0 +1,82 @@
+/*
+* Copyright 2014 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.
+*/
+/*
+* Copyright (C) 2014 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.directoryselection;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests for {@link DirectorySelectionFragment}.
+ */
+public class DirectoryEntryAdapterTest
+        extends ActivityInstrumentationTestCase2<DirectorySelectionActivity> {
+
+    private static final String FILE1 = "file1";
+    private static final String MIME_TYPE1 = "text/appliaction";
+    private static final String DIRECTORY1 = "directory1";
+
+    private DirectorySelectionActivity mTestActivity;
+    private DirectorySelectionFragment mTestFragment;
+    private DirectoryEntryAdapter mAdapter;
+    private List<DirectoryEntry> mDirectoryEntries;
+
+    public DirectoryEntryAdapterTest() {
+        super(DirectorySelectionActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        mTestActivity = getActivity();
+        mTestFragment = (DirectorySelectionFragment)
+                mTestActivity.getSupportFragmentManager().getFragments().get(0);
+        mDirectoryEntries = new ArrayList<>();
+
+        DirectoryEntry file = new DirectoryEntry();
+        file.fileName = FILE1;
+        file.mimeType = MIME_TYPE1;
+        mDirectoryEntries.add(file);
+
+        DirectoryEntry directory = new DirectoryEntry();
+        directory.fileName = DIRECTORY1;
+        directory.mimeType = DirectoryEntryAdapter.DIRECTORY_MIME_TYPE;
+        mDirectoryEntries.add(directory);
+    }
+
+    public void testGetItemCount() {
+        mTestFragment.mAdapter.setDirectoryEntries(mDirectoryEntries);
+
+        assertEquals(2, mTestFragment.mAdapter.getItemCount());
+    }
+}
diff --git a/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionActivityTest.java b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionActivityTest.java
new file mode 100644
index 0000000..8f767ae
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionActivityTest.java
@@ -0,0 +1,56 @@
+/*
+* Copyright 2014 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.directoryselection;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+ * Tests for {@link DirectorySelectionActivity}.
+ */
+public class DirectorySelectionActivityTest
+        extends ActivityInstrumentationTestCase2<DirectorySelectionActivity> {
+
+    private DirectorySelectionActivity mTestActivity;
+    private DirectorySelectionFragment mTestFragment;
+
+    public DirectorySelectionActivityTest() {
+        super(DirectorySelectionActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // Starts the activity under test using the default Intent with:
+        // action = {@link Intent#ACTION_MAIN}
+        // flags = {@link Intent#FLAG_ACTIVITY_NEW_TASK}
+        // All other fields are null or empty.
+        mTestActivity = getActivity();
+        mTestFragment = (DirectorySelectionFragment)
+                mTestActivity.getSupportFragmentManager().getFragments().get(0);
+    }
+
+    /**
+     * Test if the test fixture has been set up correctly.
+     */
+    public void testPreconditions() {
+        //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);
+    }
+}
diff --git a/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionFragmentTest.java b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionFragmentTest.java
new file mode 100644
index 0000000..90cd30f
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionFragmentTest.java
@@ -0,0 +1,68 @@
+/*
+* Copyright 2014 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.
+*/
+/*
+* Copyright (C) 2014 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.directoryselection;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+ * Tests for {@link com.example.android.directoryselection.DirectorySelectionFragment}.
+ */
+public class DirectorySelectionFragmentTest
+        extends ActivityInstrumentationTestCase2<DirectorySelectionActivity> {
+
+    private DirectorySelectionActivity mTestActivity;
+    private DirectorySelectionFragment mTestFragment;
+
+    public DirectorySelectionFragmentTest() {
+        super(DirectorySelectionActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // Starts the activity under test using the default Intent with:
+        // action = {@link Intent#ACTION_MAIN}
+        // flags = {@link Intent#FLAG_ACTIVITY_NEW_TASK}
+        // All other fields are null or empty.
+        mTestActivity = getActivity();
+        mTestFragment = (DirectorySelectionFragment)
+                mTestActivity.getSupportFragmentManager().getFragments().get(0);
+    }
+
+    public void testPreconditions() {
+        assertNotNull(mTestFragment.mCurrentDirectoryTextView);
+        assertNotNull(mTestFragment.mCreateDirectoryButton);
+        assertNotNull(mTestFragment.mRecyclerView);
+        assertNotNull(mTestFragment.mAdapter);
+        assertNotNull(mTestFragment.mLayoutManager);
+    }
+}
diff --git a/content/documentsUi/DirectorySelection/build.gradle b/content/documentsUi/DirectorySelection/build.gradle
new file mode 100644
index 0000000..18f393f
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/build.gradle
@@ -0,0 +1,11 @@
+
+// BEGIN_EXCLUDE
+import com.example.android.samples.build.SampleGenPlugin
+apply plugin: SampleGenPlugin
+
+samplegen {
+  pathToBuild "../../../../../build"
+  pathToSamplesCommon "../../../common"
+}
+apply from: "../../../../../build/build.gradle"
+// END_EXCLUDE
diff --git a/content/documentsUi/DirectorySelection/buildSrc/build.gradle b/content/documentsUi/DirectorySelection/buildSrc/build.gradle
new file mode 100644
index 0000000..7cebf71
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/buildSrc/build.gradle
@@ -0,0 +1,15 @@
+repositories {
+    mavenCentral()
+}
+dependencies {
+    compile 'org.freemarker:freemarker:2.3.20'
+}
+
+sourceSets {
+    main {
+        groovy {
+            srcDir new File(rootDir, "../../../../../../build/buildSrc/src/main/groovy")
+        }
+    }
+}
+
diff --git a/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.jar b/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.properties b/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..3e37868
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Dec 03 14:12:05 JST 2014
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
diff --git a/content/documentsUi/DirectorySelection/gradlew b/content/documentsUi/DirectorySelection/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/content/documentsUi/DirectorySelection/gradlew.bat b/content/documentsUi/DirectorySelection/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off

+@rem ##########################################################################

+@rem

+@rem  Gradle startup script for Windows

+@rem

+@rem ##########################################################################

+

+@rem Set local scope for the variables with windows NT shell

+if "%OS%"=="Windows_NT" setlocal

+

+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.

+set DEFAULT_JVM_OPTS=

+

+set DIRNAME=%~dp0

+if "%DIRNAME%" == "" set DIRNAME=.

+set APP_BASE_NAME=%~n0

+set APP_HOME=%DIRNAME%

+

+@rem Find java.exe

+if defined JAVA_HOME goto findJavaFromJavaHome

+

+set JAVA_EXE=java.exe

+%JAVA_EXE% -version >NUL 2>&1

+if "%ERRORLEVEL%" == "0" goto init

+

+echo.

+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

+echo.

+echo Please set the JAVA_HOME variable in your environment to match the

+echo location of your Java installation.

+

+goto fail

+

+:findJavaFromJavaHome

+set JAVA_HOME=%JAVA_HOME:"=%

+set JAVA_EXE=%JAVA_HOME%/bin/java.exe

+

+if exist "%JAVA_EXE%" goto init

+

+echo.

+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%

+echo.

+echo Please set the JAVA_HOME variable in your environment to match the

+echo location of your Java installation.

+

+goto fail

+

+:init

+@rem Get command-line arguments, handling Windowz variants

+

+if not "%OS%" == "Windows_NT" goto win9xME_args

+if "%@eval[2+2]" == "4" goto 4NT_args

+

+:win9xME_args

+@rem Slurp the command line arguments.

+set CMD_LINE_ARGS=

+set _SKIP=2

+

+:win9xME_args_slurp

+if "x%~1" == "x" goto execute

+

+set CMD_LINE_ARGS=%*

+goto execute

+

+:4NT_args

+@rem Get arguments from the 4NT Shell from JP Software

+set CMD_LINE_ARGS=%$

+

+:execute

+@rem Setup the command line

+

+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

+

+@rem Execute Gradle

+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

+

+:end

+@rem End local scope for the variables with windows NT shell

+if "%ERRORLEVEL%"=="0" goto mainEnd

+

+:fail

+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of

+rem the _cmd.exe /c_ return code!

+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1

+exit /b 1

+

+:mainEnd

+if "%OS%"=="Windows_NT" endlocal

+

+:omega

diff --git a/content/documentsUi/DirectorySelection/screenshots/screenshot-1.png b/content/documentsUi/DirectorySelection/screenshots/screenshot-1.png
new file mode 100644
index 0000000..a4310dc
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/screenshots/screenshot-1.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/screenshots/screenshot-2.png b/content/documentsUi/DirectorySelection/screenshots/screenshot-2.png
new file mode 100644
index 0000000..cd27507
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/screenshots/screenshot-2.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/screenshots/screenshot-3.png b/content/documentsUi/DirectorySelection/screenshots/screenshot-3.png
new file mode 100644
index 0000000..0795475
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/screenshots/screenshot-3.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/screenshots/web-icon.png b/content/documentsUi/DirectorySelection/screenshots/web-icon.png
new file mode 100755
index 0000000..f0a573f
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/screenshots/web-icon.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/settings.gradle b/content/documentsUi/DirectorySelection/settings.gradle
new file mode 100644
index 0000000..9464a35
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/settings.gradle
@@ -0,0 +1 @@
+include 'Application'
diff --git a/content/documentsUi/DirectorySelection/template-params.xml b/content/documentsUi/DirectorySelection/template-params.xml
new file mode 100644
index 0000000..c0172f6
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/template-params.xml
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2014 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.
+-->
+<sample>
+    <name>DirectorySelection</name>
+    <group>Content</group>
+    <package>com.example.android.directoryselection</package>
+
+    <dependency>com.android.support:recyclerview-v7:+</dependency>
+
+    <!-- change minSdk if needed-->
+    <minSdk>21</minSdk>
+
+    <strings>
+        <intro>
+            <![CDATA[
+            This sample explains how to use Directory selection API, which was introduced
+            in Android 5.0.
+            ]]>
+        </intro>
+    </strings>
+
+    <template src="base" />
+
+    <metadata>
+        <status>DRAFTED</status>
+        <categories>Content</categories>
+        <technologies>Android</technologies>
+        <languages>Java</languages>
+        <solutions>Mobile</solutions>
+        <level>INTERMEDIATE</level>
+        <icon>screenshots/web-icon.png</icon>
+        <screenshots>
+            <img>screenshots/screenshot-1.png</img>
+            <img>screenshots/screenshot-2.png</img>
+            <img>screenshots/screenshot-3.png</img>
+        </screenshots>
+        <api_refs>
+            <android>android.content.ContentResolver</android>
+            <android>android.provider.DocumentsContract</android>
+        </api_refs>
+
+        <description>
+<![CDATA[
+A basic app showing how to use Directory Selection API to let users
+select an entire directory subtree, which extends the Storage Access Framework
+introduced in Android 4.4 (API level 19).
+]]>
+        </description>
+
+        <intro>
+<![CDATA[
+The [Directory Selection][1] API, which was introduced in Android 5.0 (API level 21)
+extends the [Storage Access Framework][2] to let users select an entire directory subtree,
+giving apps read/write access to all contained documents without requiring user
+confirmation for each item.
+
+To select a directory subtree, build and send an [OPEN_DOCUMENT_TREE intent][3] like in the
+following code:
+
+```java
+Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
+startActivityForResult(intent, REQUEST_CODE_OPEN_DIRECTORY);
+```
+
+The system displays all [DocumentsProvider][4] instances that support subtree selection,
+ letting the user browse and select a directory.
+
+The returned URI represents access to the selected subtree. You can then use
+[buildChildDocumentsUriUsingTree()][5] to access to the child documents and
+[buildDocumentUriUsingTree()][6] to access to the selected directory itself along with [query()][7]
+to explore the subtree.
+
+This example explores the child documents and the selected document by following code:
+
+```java
+@Override
+public void onActivityResult(int requestCode, int resultCode, Intent data) {
+    super.onActivityResult(requestCode, resultCode, data);
+    if (requestCode == REQUEST_CODE_OPEN_DIRECTORY && resultCode == Activity.RESULT_OK) {
+        updateDirectoryEntries(data.getData());
+    }
+}
+
+void updateDirectoryEntries(Uri uri) {
+    ContentResolver contentResolver = getActivity().getContentResolver();
+    Uri docUri = DocumentsContract.buildDocumentUriUsingTree(uri,
+            DocumentsContract.getTreeDocumentId(uri));
+    Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(uri,
+            DocumentsContract.getTreeDocumentId(uri));
+
+    Cursor docCursor = contentResolver.query(docUri, new String[]{
+            Document.COLUMN_DISPLAY_NAME, Document.COLUMN_MIME_TYPE}, null, null, null);
+    try {
+        while (docCursor.moveToNext()) {
+            Log.d(TAG, "found doc =" + docCursor.getString(0) + ", mime=" + docCursor
+                    .getString(1));
+            mCurrentDirectoryUri = uri;
+            mCurrentDirectoryTextView.setText(docCursor.getString(0));
+            mCreateDirectoryButton.setEnabled(true);
+        }
+    } finally {
+        closeQuietly(docCursor);
+    }
+
+    Cursor childCursor = contentResolver.query(childrenUri, new String[]{
+            Document.COLUMN_DISPLAY_NAME, Document.COLUMN_MIME_TYPE}, null, null, null);
+    try {
+        List<DirectoryEntry> directoryEntries = new ArrayList<>();
+        while (childCursor.moveToNext()) {
+            Log.d(TAG, "found child=" + childCursor.getString(0) + ", mime=" + childCursor
+                    .getString(1));
+            DirectoryEntry entry = new DirectoryEntry();
+            entry.fileName = childCursor.getString(0);
+            entry.mimeType = childCursor.getString(1);
+            directoryEntries.add(entry);
+        }
+        mAdapter.setDirectoryEntries(directoryEntries);
+        mAdapter.notifyDataSetChanged();
+    } finally {
+        closeQuietly(childCursor);
+    }
+}
+```
+
+Also, the new [createDocument()][8] method lets you create new documents or directories
+anywhere under the subtree.
+
+This example creates a new directory by following code:
+
+```java
+ContentResolver contentResolver = getActivity().getContentResolver();
+Uri docUri = DocumentsContract.buildDocumentUriUsingTree(uri,
+        DocumentsContract.getTreeDocumentId(uri));
+Uri directoryUri = DocumentsContract
+        .createDocument(contentResolver, docUri, Document.MIME_TYPE_DIR, directoryName);
+```
+
+[1]: https://developer.android.com/about/versions/android-5.0.html#Storage
+[2]: https://developer.android.com/guide/topics/providers/document-provider.html
+[3]: https://developer.android.com/reference/android/content/Intent.html#ACTION_OPEN_DOCUMENT_TREE
+[4]: https://developer.android.com/reference/android/provider/DocumentsProvider.html
+[5]: https://developer.android.com/reference/android/provider/DocumentsContract.html#buildChildDocumentsUriUsingTree(android.net.Uri%2C%20java.lang.String)
+[6]: https://developer.android.com/reference/android/provider/DocumentsContract.html#buildDocumentUriUsingTree(android.net.Uri%2C%20java.lang.String)
+[7]: https://developer.android.com/reference/android/content/ContentResolver.html#query(android.net.Uri%2C%20java.lang.String%5B%5D%2C%20java.lang.String%2C%20java.lang.String%5B%5D%2C%20java.lang.String)
+[8]: https://developer.android.com/reference/android/provider/DocumentsContract.html#createDocument(android.content.ContentResolver%2C%20android.net.Uri%2C%20java.lang.String%2C%20java.lang.String)
+]]>
+        </intro>
+    </metadata>
+</sample>
diff --git a/wearable/wear/JumpingJack/screenshots/web-icon.png b/wearable/wear/JumpingJack/screenshots/web-icon.png
new file mode 100644
index 0000000..da3c00a
--- /dev/null
+++ b/wearable/wear/JumpingJack/screenshots/web-icon.png
Binary files differ
diff --git a/wearable/wear/JumpingJack/template-params.xml b/wearable/wear/JumpingJack/template-params.xml
index 7351c1d..7085d5c 100644
--- a/wearable/wear/JumpingJack/template-params.xml
+++ b/wearable/wear/JumpingJack/template-params.xml
@@ -41,4 +41,64 @@
     <common src="logger"/>
     <common src="activities"/>
 
+    <metadata>
+        <status>PUBLISHED</status>
+        <categories>Wearable</categories>
+        <technologies>Android</technologies>
+        <languages>Java</languages>
+        <solutions>Mobile</solutions>
+        <level>INTERMEDIATE</level>
+        <icon>screenshots/web-icon.png</icon>
+        <screenshots>
+            <img>screenshots/jumping_jack.gif</img>
+        </screenshots>
+        <api_refs>
+            <android>android.hardware.SensorEvent</android>
+            <android>android.hardware.SensorEventManager</android>
+        </api_refs>
+
+        <description>
+<![CDATA[
+A basic sample showing how to use the Gravity sensor on the wearable device
+by counting how many jumping jacks you have performed.
+]]>
+        </description>
+
+        <intro>
+<![CDATA[
+[SensorEventListener][1] offers you methods used for receiving notifications from the
+[SensorManager][2] when sensor values have changed.
+
+This example counts how many times Jumping Jakcs are performed by detecting the value
+of the Gravity sensor by the following code:
+
+```java
+@Override
+public void onSensorChanged(SensorEvent event) {
+    detectJump(event.values[0], event.timestamp);
+}
+
+private void detectJump(float xValue, long timestamp) {
+    if ((Math.abs(xValue) > GRAVITY_THRESHOLD)) {
+        if(timestamp - mLastTime < TIME_THRESHOLD_NS && mUp != (xValue > 0)) {
+            onJumpDetected(!mUp);
+        }
+        mUp = xValue > 0;
+        mLastTime = timestamp;
+    }
+}
+```
+
+The detectJump method above assumes that when a person is wearing the watch, the x-component of gravity
+as measured by the Gravity Sensor is +9.8 when the hand is downward and -9.8 when the hand
+is upward (signs are reversed if the watch is worn on the right hand). Since the upward or
+downward may not be completely accurate, we leave some room and instead of 9.8, we use
+GRAVITY_THRESHOLD (7.0f). We also consider the up <-> down movement successful if it takes less than
+TIME_THRESHOLD_NS (2000000000 nanoseconds).
+
+[1]: http://developer.android.com/reference/android/hardware/SensorEventListener.html
+[2]: http://developer.android.com/reference/android/hardware/SensorManager.html
+]]>
+        </intro>
+    </metadata>
 </sample>