am 6d0fbc00: am e60501b0: Merge "Migrate changes for wear samples in development/samples/wearable" into klp-modular-docs
* commit '6d0fbc00aa92ea17e828d803256a7d17f1e28195':
Migrate changes for wear samples in development/samples/wearable
diff --git a/admin/BasicManagedProfile/Application/.gitignore b/admin/BasicManagedProfile/Application/.gitignore
new file mode 100644
index 0000000..8fd2e1c
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/.gitignore
@@ -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.
+src/template/
+src/common/
+build.gradle
diff --git a/admin/BasicManagedProfile/Application/proguard-project.txt b/admin/BasicManagedProfile/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/admin/BasicManagedProfile/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/admin/BasicManagedProfile/Application/src/main/AndroidManifest.xml b/admin/BasicManagedProfile/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..ed41452
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,58 @@
+<?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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.basicmanagedprofile"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L" />
+
+ <application
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher">
+
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+
+ <activity
+ android:name=".EnableProfileActivity"
+ android:label="@string/app_name"/>
+
+ <receiver
+ android:name=".BasicDeviceAdminReceiver"
+ android:description="@string/app_name"
+ android:label="@string/app_name"
+ android:permission="android.permission.BIND_DEVICE_ADMIN">
+ <meta-data
+ android:name="android.app.device_admin"
+ android:resource="@xml/basic_device_admin_receiver"/>
+ <intent-filter>
+ <action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/>
+ </intent-filter>
+ </receiver>
+
+ </application>
+
+
+</manifest>
diff --git a/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/BasicDeviceAdminReceiver.java b/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/BasicDeviceAdminReceiver.java
new file mode 100644
index 0000000..54eee84
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/BasicDeviceAdminReceiver.java
@@ -0,0 +1,51 @@
+/*
+ * 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.basicmanagedprofile;
+
+import android.app.admin.DeviceAdminReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+
+/**
+ * Handles events related to managed profile.
+ */
+public class BasicDeviceAdminReceiver extends DeviceAdminReceiver {
+
+ /**
+ * Called on the new profile when managed profile provisioning has completed. Managed profile
+ * provisioning is the process of setting up the device so that it has a separate profile which
+ * is managed by the mobile device management(mdm) application that triggered the provisioning.
+ * Note that the managed profile is not fully visible until it is enabled.
+ */
+ @Override
+ public void onProfileProvisioningComplete(Context context, Intent intent) {
+ // EnableProfileActivity is launched with the newly set up profile.
+ Intent launch = new Intent(context, EnableProfileActivity.class);
+ launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(launch);
+ }
+
+ /**
+ * Generates a {@link ComponentName} that is used throughout the app.
+ * @return a {@link ComponentName}
+ */
+ public static ComponentName getComponentName(Context context) {
+ return new ComponentName(context.getApplicationContext(), BasicDeviceAdminReceiver.class);
+ }
+
+}
diff --git a/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/BasicManagedProfileFragment.java b/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/BasicManagedProfileFragment.java
new file mode 100644
index 0000000..bb3f239
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/BasicManagedProfileFragment.java
@@ -0,0 +1,360 @@
+/*
+ * 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.basicmanagedprofile;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Fragment;
+import android.app.admin.DevicePolicyManager;
+import android.content.ActivityNotFoundException;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.CompoundButton;
+import android.widget.ScrollView;
+import android.widget.Switch;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import static android.app.admin.DevicePolicyManager.FLAG_MANAGED_CAN_ACCESS_PARENT;
+import static android.app.admin.DevicePolicyManager.FLAG_PARENT_CAN_ACCESS_MANAGED;
+
+/**
+ * Provides several functions that are available in a managed profile. This includes
+ * enabling/disabling other apps, setting app restrictions, enabling/disabling intent forwarding,
+ * and wiping out all the data in the profile.
+ */
+public class BasicManagedProfileFragment extends Fragment
+ implements View.OnClickListener,
+ CompoundButton.OnCheckedChangeListener {
+
+ /**
+ * Tag for logging.
+ */
+ private static final String TAG = "BasicManagedProfileFragment";
+
+ /**
+ * Package name of calculator
+ */
+ private static final String PACKAGE_NAME_CALCULATOR = "com.android.calculator2";
+
+ /**
+ * Package name of Chrome
+ */
+ private static final String PACKAGE_NAME_CHROME = "com.android.chrome";
+
+ /**
+ * {@link Button} to remove this managed profile.
+ */
+ private Button mButtonRemoveProfile;
+
+ /**
+ * Whether the calculator app is enabled in this profile
+ */
+ private boolean mCalculatorEnabled;
+
+ /**
+ * Whether Chrome is enabled in this profile
+ */
+ private boolean mChromeEnabled;
+
+ public BasicManagedProfileFragment() {
+ }
+
+ public static BasicManagedProfileFragment newInstance() {
+ return new BasicManagedProfileFragment();
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_main, container, false);
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ // Retrieves whether the calculator app is enabled in this profile
+ mCalculatorEnabled = isApplicationEnabled(PACKAGE_NAME_CALCULATOR);
+ // Retrieves whether Chrome is enabled in this profile
+ mChromeEnabled = isApplicationEnabled(PACKAGE_NAME_CHROME);
+ }
+
+ /**
+ * Checks if the application is available in this profile.
+ *
+ * @param packageName The package name
+ * @return True if the application is available in this profile.
+ */
+ private boolean isApplicationEnabled(String packageName) {
+ Activity activity = getActivity();
+ PackageManager packageManager = activity.getPackageManager();
+ try {
+ ApplicationInfo applicationInfo = packageManager.getApplicationInfo(
+ packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
+ // Return false if the app is not installed in this profile
+ if (0 == (applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED)) {
+ return false;
+ }
+ // Check if the app is not hidden in this profile
+ DevicePolicyManager devicePolicyManager =
+ (DevicePolicyManager) activity.getSystemService(Activity.DEVICE_POLICY_SERVICE);
+ return !devicePolicyManager.isApplicationHidden(
+ BasicDeviceAdminReceiver.getComponentName(activity), packageName);
+ } catch (PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ // Bind event listeners and initial states
+ view.findViewById(R.id.set_chrome_restrictions).setOnClickListener(this);
+ view.findViewById(R.id.enable_forwarding).setOnClickListener(this);
+ view.findViewById(R.id.disable_forwarding).setOnClickListener(this);
+ view.findViewById(R.id.send_intent).setOnClickListener(this);
+ mButtonRemoveProfile = (Button) view.findViewById(R.id.remove_profile);
+ mButtonRemoveProfile.setOnClickListener(this);
+ Switch toggleCalculator = (Switch) view.findViewById(R.id.toggle_calculator);
+ toggleCalculator.setChecked(mCalculatorEnabled);
+ toggleCalculator.setOnCheckedChangeListener(this);
+ Switch toggleChrome = (Switch) view.findViewById(R.id.toggle_chrome);
+ toggleChrome.setChecked(mChromeEnabled);
+ toggleChrome.setOnCheckedChangeListener(this);
+ }
+
+ @Override
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.set_chrome_restrictions: {
+ setChromeRestrictions();
+ break;
+ }
+ case R.id.enable_forwarding: {
+ enableForwarding();
+ break;
+ }
+ case R.id.disable_forwarding: {
+ disableForwarding();
+ break;
+ }
+ case R.id.send_intent: {
+ sendIntent();
+ break;
+ }
+ case R.id.remove_profile: {
+ mButtonRemoveProfile.setEnabled(false);
+ removeProfile();
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ switch (compoundButton.getId()) {
+ case R.id.toggle_calculator: {
+ setAppEnabled(PACKAGE_NAME_CALCULATOR, checked);
+ mCalculatorEnabled = checked;
+ break;
+ }
+ case R.id.toggle_chrome: {
+ setAppEnabled(PACKAGE_NAME_CHROME, checked);
+ mChromeEnabled = checked;
+ break;
+ }
+ }
+ }
+
+ /**
+ * Enables or disables the specified app in this profile.
+ *
+ * @param packageName The package name of the target app.
+ * @param enabled Pass true to enable the app.
+ */
+ private void setAppEnabled(String packageName, boolean enabled) {
+ Activity activity = getActivity();
+ if (null == activity) {
+ return;
+ }
+ PackageManager packageManager = activity.getPackageManager();
+ DevicePolicyManager devicePolicyManager =
+ (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
+ try {
+ ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName,
+ PackageManager.GET_UNINSTALLED_PACKAGES);
+ // Here, we check the ApplicationInfo of the target app, and see if the flags have
+ // ApplicationInfo.FLAG_INSTALLED turned on using bitwise operation.
+ if (0 == (applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED)) {
+ // If the app is not installed in this profile, we can enable it by
+ // DPM.enableSystemApp
+ if (enabled) {
+ devicePolicyManager.enableSystemApp(
+ BasicDeviceAdminReceiver.getComponentName(activity), packageName);
+ } else {
+ // But we cannot disable the app since it is already disabled
+ Log.e(TAG, "Cannot disable this app: " + packageName);
+ return;
+ }
+ } else {
+ // If the app is already installed, we can enable or disable it by
+ // DPM.setApplicationHidden
+ devicePolicyManager.setApplicationHidden(
+ BasicDeviceAdminReceiver.getComponentName(activity), packageName, !enabled);
+ }
+ Toast.makeText(activity, enabled ? R.string.enabled : R.string.disabled,
+ Toast.LENGTH_SHORT).show();
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "The app cannot be found: " + packageName, e);
+ }
+ }
+
+ /**
+ * Sets restrictions to Chrome
+ */
+ private void setChromeRestrictions() {
+ final Activity activity = getActivity();
+ if (null == activity) {
+ return;
+ }
+ final DevicePolicyManager manager =
+ (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
+ final Bundle settings = new Bundle();
+ settings.putString("EditBookmarksEnabled", "false");
+ settings.putString("IncognitoModeAvailability", "1");
+ settings.putString("ManagedBookmarks",
+ "[{\"name\": \"Chromium\", \"url\": \"http://chromium.org\"}, " +
+ "{\"name\": \"Google\", \"url\": \"https://www.google.com\"}]");
+ settings.putString("DefaultSearchProviderEnabled", "true");
+ settings.putString("DefaultSearchProviderName", "\"LMGTFY\"");
+ settings.putString("DefaultSearchProviderSearchURL",
+ "\"http://lmgtfy.com/?q={searchTerms}\"");
+ settings.putString("URLBlacklist", "[\"example.com\", \"example.org\"]");
+ StringBuilder message = new StringBuilder("Setting Chrome restrictions:");
+ for (String key : settings.keySet()) {
+ message.append("\n");
+ message.append(key);
+ message.append(": ");
+ message.append(settings.getString(key));
+ }
+ ScrollView view = new ScrollView(activity);
+ TextView text = new TextView(activity);
+ text.setText(message);
+ int size = (int) activity.getResources().getDimension(R.dimen.activity_horizontal_margin);
+ view.setPadding(size, size, size, size);
+ view.addView(text);
+ new AlertDialog.Builder(activity)
+ .setView(view)
+ .setNegativeButton(android.R.string.cancel, null)
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ // This is how you can set restrictions to an app.
+ // The format for settings in Bundle differs from app to app.
+ manager.setApplicationRestrictions
+ (BasicDeviceAdminReceiver.getComponentName(activity),
+ PACKAGE_NAME_CHROME, settings);
+ Toast.makeText(activity, R.string.restrictions_set,
+ Toast.LENGTH_SHORT).show();
+ }
+ })
+ .show();
+ }
+
+ /**
+ * Enables forwarding of share intent between private account and managed profile.
+ */
+ private void enableForwarding() {
+ Activity activity = getActivity();
+ if (null == activity || activity.isFinishing()) {
+ return;
+ }
+ DevicePolicyManager manager =
+ (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
+ try {
+ IntentFilter filter = new IntentFilter(Intent.ACTION_SEND);
+ filter.addDataType("text/plain");
+ filter.addDataType("image/jpeg");
+ // This is how you can register an IntentFilter as allowed pattern of Intent forwarding
+ manager.addCrossProfileIntentFilter(BasicDeviceAdminReceiver.getComponentName(activity),
+ filter, FLAG_MANAGED_CAN_ACCESS_PARENT | FLAG_PARENT_CAN_ACCESS_MANAGED);
+ } catch (IntentFilter.MalformedMimeTypeException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Disables forwarding of all intents.
+ */
+ private void disableForwarding() {
+ Activity activity = getActivity();
+ if (null == activity || activity.isFinishing()) {
+ return;
+ }
+ DevicePolicyManager manager =
+ (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
+ manager.clearCrossProfileIntentFilters(BasicDeviceAdminReceiver.getComponentName(activity));
+ }
+
+ /**
+ * Sends a sample intent of a plain text message. This is just a utility function to see how
+ * the intent forwarding works.
+ */
+ private void sendIntent() {
+ Activity activity = getActivity();
+ if (null == activity || activity.isFinishing()) {
+ return;
+ }
+ DevicePolicyManager manager =
+ (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType("text/plain");
+ intent.putExtra(Intent.EXTRA_TEXT,
+ manager.isProfileOwnerApp(activity.getApplicationContext().getPackageName())
+ ? "From the managed account" : "From the primary account");
+ try {
+ startActivity(intent);
+ Log.d(TAG, "A sample intent was sent.");
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(activity, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ /**
+ * Wipes out all the data related to this managed profile.
+ */
+ private void removeProfile() {
+ Activity activity = getActivity();
+ if (null == activity || activity.isFinishing()) {
+ return;
+ }
+ DevicePolicyManager manager =
+ (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
+ manager.wipeData(0);
+ // The screen turns off here
+ }
+
+}
diff --git a/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/EnableProfileActivity.java b/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/EnableProfileActivity.java
new file mode 100644
index 0000000..deed2f6
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/EnableProfileActivity.java
@@ -0,0 +1,68 @@
+/*
+ * 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.basicmanagedprofile;
+
+import android.app.Activity;
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+
+/**
+ * This activity is started after the provisioning is complete in {@link BasicDeviceAdminReceiver}.
+ */
+public class EnableProfileActivity extends Activity implements View.OnClickListener {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (null == savedInstanceState) {
+ // Important: After the profile has been created, the MDM must enable it for corporate
+ // apps to become visible in the launcher.
+ enableProfile();
+ }
+ // This is just a friendly shortcut to the main screen.
+ setContentView(R.layout.activity_setup);
+ findViewById(R.id.icon).setOnClickListener(this);
+ }
+
+ private void enableProfile() {
+ DevicePolicyManager manager =
+ (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
+ ComponentName componentName = BasicDeviceAdminReceiver.getComponentName(this);
+ // This is the name for the newly created managed profile.
+ manager.setProfileName(componentName, getString(R.string.profile_name));
+ // We enable the profile here.
+ manager.setProfileEnabled(componentName);
+ }
+
+ @Override
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.icon: {
+ // Opens up the main screen
+ startActivity(new Intent(this, MainActivity.class));
+ finish();
+ break;
+ }
+ }
+ }
+
+}
diff --git a/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/MainActivity.java b/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/MainActivity.java
new file mode 100644
index 0000000..3847fee
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/MainActivity.java
@@ -0,0 +1,55 @@
+/*
+ * 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.basicmanagedprofile;
+
+import android.app.Activity;
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.os.Bundle;
+
+public class MainActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main_real);
+ if (savedInstanceState == null) {
+ DevicePolicyManager manager = (DevicePolicyManager)
+ getSystemService(Context.DEVICE_POLICY_SERVICE);
+ if (manager.isProfileOwnerApp(getApplicationContext().getPackageName())) {
+ // If the managed profile is already set up, we show the main screen.
+ showMainFragment();
+ } else {
+ // If not, we show the set up screen.
+ showSetupProfile();
+ }
+ }
+ }
+
+ private void showSetupProfile() {
+ getFragmentManager().beginTransaction()
+ .replace(R.id.container, SetupProfileFragment.newInstance())
+ .commit();
+ }
+
+ private void showMainFragment() {
+ getFragmentManager().beginTransaction()
+ .add(R.id.container, BasicManagedProfileFragment.newInstance())
+ .commit();
+ }
+
+}
diff --git a/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/SetupProfileFragment.java b/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/SetupProfileFragment.java
new file mode 100644
index 0000000..7da6e02
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/java/com/example/android/basicmanagedprofile/SetupProfileFragment.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.basicmanagedprofile;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Toast;
+
+import static android.app.admin.DevicePolicyManager.ACTION_PROVISION_MANAGED_PROFILE;
+import static android.app.admin.DevicePolicyManager.EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME;
+
+/**
+ * This {@link Fragment} handles initiation of managed profile provisioning.
+ */
+public class SetupProfileFragment extends Fragment implements View.OnClickListener {
+
+ private static final int REQUEST_PROVISION_MANAGED_PROFILE = 1;
+
+ public static SetupProfileFragment newInstance() {
+ return new SetupProfileFragment();
+ }
+
+ public SetupProfileFragment() {
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_setup_profile, container, false);
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ view.findViewById(R.id.set_up_profile).setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.set_up_profile: {
+ provisionManagedProfile();
+ break;
+ }
+ }
+ }
+
+ /**
+ * Initiates the managed profile provisioning. If we already have a managed profile set up on
+ * this device, we will get an error dialog in the following provisioning phase.
+ */
+ private void provisionManagedProfile() {
+ Activity activity = getActivity();
+ if (null == activity) {
+ return;
+ }
+ Intent intent = new Intent(ACTION_PROVISION_MANAGED_PROFILE);
+ intent.putExtra(EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_NAME,
+ activity.getApplicationContext().getPackageName());
+ if (intent.resolveActivity(activity.getPackageManager()) != null) {
+ startActivityForResult(intent, REQUEST_PROVISION_MANAGED_PROFILE);
+ activity.finish();
+ } else {
+ Toast.makeText(activity, "Device provisioning is not enabled. Stopping.",
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_PROVISION_MANAGED_PROFILE) {
+ if (resultCode == Activity.RESULT_OK) {
+ Toast.makeText(getActivity(), "Provisioning done.", Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(getActivity(), "Provisioning failed.", Toast.LENGTH_SHORT).show();
+ }
+ return;
+ }
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
+}
diff --git a/admin/BasicManagedProfile/Application/src/main/res/drawable-hdpi/ic_launcher.png b/admin/BasicManagedProfile/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..c8feb76
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/admin/BasicManagedProfile/Application/src/main/res/drawable-mdpi/ic_launcher.png b/admin/BasicManagedProfile/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..4bf549e
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/admin/BasicManagedProfile/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/admin/BasicManagedProfile/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..33afaaa
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/admin/BasicManagedProfile/Application/src/main/res/drawable-xxhdpi/badge.png b/admin/BasicManagedProfile/Application/src/main/res/drawable-xxhdpi/badge.png
new file mode 100644
index 0000000..77a88cf
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/drawable-xxhdpi/badge.png
Binary files differ
diff --git a/admin/BasicManagedProfile/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/admin/BasicManagedProfile/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..d6f927a
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/admin/BasicManagedProfile/Application/src/main/res/drawable/ic_launcher_badged.xml b/admin/BasicManagedProfile/Application/src/main/res/drawable/ic_launcher_badged.xml
new file mode 100644
index 0000000..b91b9bd
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/drawable/ic_launcher_badged.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@drawable/ic_launcher"/>
+ <item
+ android:top="56dp"
+ android:left="56dp"
+ android:right="8dp"
+ android:bottom="8dp"
+ android:drawable="@drawable/badge"/>
+</layer-list>
diff --git a/admin/BasicManagedProfile/Application/src/main/res/layout/activity_main_real.xml b/admin/BasicManagedProfile/Application/src/main/res/layout/activity_main_real.xml
new file mode 100644
index 0000000..e09df9e
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/layout/activity_main_real.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.basicmanagedprofile.MainActivity"
+ tools:ignore="MergeRootFrame" />
diff --git a/admin/BasicManagedProfile/Application/src/main/res/layout/activity_setup.xml b/admin/BasicManagedProfile/Application/src/main/res/layout/activity_setup.xml
new file mode 100644
index 0000000..c52f15d
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/layout/activity_setup.xml
@@ -0,0 +1,45 @@
+<?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:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:paddingTop="@dimen/activity_vertical_margin"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin">
+
+ <TextView
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/all_done"/>
+
+ <TextView
+ android:padding="8dp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/all_done_explanation"/>
+
+ <ImageButton
+ android:id="@+id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/ic_launcher_badged"
+ android:contentDescription="@string/icon"/>
+
+</LinearLayout>
diff --git a/admin/BasicManagedProfile/Application/src/main/res/layout/fragment_main.xml b/admin/BasicManagedProfile/Application/src/main/res/layout/fragment_main.xml
new file mode 100644
index 0000000..7dcb9f2
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/layout/fragment_main.xml
@@ -0,0 +1,96 @@
+<?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.
+-->
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.example.android.basicmanagedprofile.MainActivity.MainFragment">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/activity_vertical_margin"
+ android:text="@string/main_message" />
+
+ <!-- Calculator -->
+
+ <Switch
+ android:id="@+id/toggle_calculator"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="8dp"
+ android:text="@string/toggle_calculator" />
+
+ <!-- Chrome (App restrictions) -->
+
+ <Switch
+ android:id="@+id/toggle_chrome"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="24dp"
+ android:padding="8dp"
+ android:text="@string/toggle_chrome" />
+
+ <Button
+ android:id="@+id/set_chrome_restrictions"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/set_chrome_restrictions" />
+
+ <!-- Intent Forwarding -->
+
+ <Button
+ android:id="@+id/enable_forwarding"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="24dp"
+ android:text="@string/enable_forwarding" />
+
+ <Button
+ android:id="@+id/disable_forwarding"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/disable_forwarding" />
+
+ <Button
+ android:id="@+id/send_intent"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/send_intent_text" />
+
+ <!-- Remove profile -->
+
+ <Button
+ android:id="@+id/remove_profile"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="24dp"
+ android:text="@string/remove_profile" />
+
+ </LinearLayout>
+
+</ScrollView>
+
diff --git a/admin/BasicManagedProfile/Application/src/main/res/layout/fragment_setup_profile.xml b/admin/BasicManagedProfile/Application/src/main/res/layout/fragment_setup_profile.xml
new file mode 100644
index 0000000..2aaaa93
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/layout/fragment_setup_profile.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="com.example.android.basicmanagedprofile.MainActivity.MainFragment">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingBottom="@dimen/activity_vertical_margin"
+ android:paddingLeft="@dimen/activity_horizontal_margin"
+ android:paddingRight="@dimen/activity_horizontal_margin"
+ android:paddingTop="@dimen/activity_vertical_margin">
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/setup_profile_message" />
+
+ <Button
+ android:id="@+id/set_up_profile"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/set_up_profile" />
+
+ </LinearLayout>
+
+</ScrollView>
diff --git a/admin/BasicManagedProfile/Application/src/main/res/values-w820dp/dimens.xml b/admin/BasicManagedProfile/Application/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..146c0e1
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,3 @@
+<resources>
+ <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
diff --git a/admin/BasicManagedProfile/Application/src/main/res/values/dimens.xml b/admin/BasicManagedProfile/Application/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..71c0df5
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/values/dimens.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>
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
diff --git a/admin/BasicManagedProfile/Application/src/main/res/values/strings.xml b/admin/BasicManagedProfile/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..3e9f8fa
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/values/strings.xml
@@ -0,0 +1,38 @@
+<?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="set_up_profile">Set up profile</string>
+ <string name="enable_forwarding">Enable forwarding of Share Intent</string>
+ <string name="send_intent_text">Send a sample share Intent</string>
+ <string name="disable_forwarding">Disable forwarding</string>
+ <string name="setup_profile_message">This app is currently not a profile owner.</string>
+ <string name="main_message">The app is ready to control the managed profile.</string>
+ <string name="remove_profile">Remove managed profile</string>
+ <string name="all_done">Setup all done</string>
+ <string name="all_done_explanation">To manage the configuration in your managed profile, visit the badged version of this application.</string>
+ <string name="toggle_calculator">Calculator in this profile: </string>
+ <string name="toggle_chrome">Chrome in this profile:</string>
+ <string name="set_chrome_restrictions">Set Chrome restrictions</string>
+ <string name="icon">Icon</string>
+ <string name="profile_name">Sample Managed Profile</string>
+ <string name="enabled">Enabled</string>
+ <string name="disabled">Disabled</string>
+ <string name="restrictions_set">Restrictions set.</string>
+ <string name="activity_not_found">No app can handle this intent.</string>
+
+</resources>
diff --git a/admin/BasicManagedProfile/Application/src/main/res/xml/basic_device_admin_receiver.xml b/admin/BasicManagedProfile/Application/src/main/res/xml/basic_device_admin_receiver.xml
new file mode 100644
index 0000000..5b876dd
--- /dev/null
+++ b/admin/BasicManagedProfile/Application/src/main/res/xml/basic_device_admin_receiver.xml
@@ -0,0 +1,29 @@
+<?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.
+-->
+<device-admin>
+ <uses-policies>
+ <limit-password/>
+ <watch-login/>
+ <reset-password/>
+ <force-lock/>
+ <wipe-data/>
+ <expire-password/>
+ <encrypted-storage/>
+ <disable-camera/>
+ <disable-keyguard-features/>
+ </uses-policies>
+</device-admin>
diff --git a/admin/BasicManagedProfile/CONTRIB.md b/admin/BasicManagedProfile/CONTRIB.md
new file mode 100644
index 0000000..14a4fcf
--- /dev/null
+++ b/admin/BasicManagedProfile/CONTRIB.md
@@ -0,0 +1,35 @@
+# How to become a contributor and submit your own code
+
+## Contributor License Agreements
+
+We'd love to accept your sample apps and patches! Before we can take them, we
+have to jump a couple of legal hurdles.
+
+Please fill out either the individual or corporate Contributor License Agreement (CLA).
+
+ * If you are an individual writing original source code and you're sure you
+ own the intellectual property, then you'll need to sign an [individual CLA]
+ (https://developers.google.com/open-source/cla/individual).
+ * If you work for a company that wants to allow you to contribute your work,
+ then you'll need to sign a [corporate CLA]
+ (https://developers.google.com/open-source/cla/corporate).
+
+Follow either of the two links above to access the appropriate CLA and
+instructions for how to sign and return it. Once we receive it, we'll be able to
+accept your pull requests.
+
+## Contributing A Patch
+
+1. Submit an issue describing your proposed change to the repo in question.
+1. The repo owner will respond to your issue promptly.
+1. If your proposed change is accepted, and you haven't already done so, sign a
+ Contributor License Agreement (see details above).
+1. Fork the desired repo, develop and test your code changes.
+1. Ensure that your code adheres to the existing style in the sample to which
+ you are contributing. Refer to the
+ [Android Code Style Guide]
+ (https://source.android.com/source/code-style.html) for the
+ recommended coding standards for this organization.
+1. Ensure that your code has an appropriate set of unit tests which all pass.
+1. Submit a pull request.
+
diff --git a/admin/BasicManagedProfile/LICENSE b/admin/BasicManagedProfile/LICENSE
new file mode 100644
index 0000000..1af981f
--- /dev/null
+++ b/admin/BasicManagedProfile/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ 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.
diff --git a/admin/BasicManagedProfile/build.gradle b/admin/BasicManagedProfile/build.gradle
new file mode 100644
index 0000000..f9f6f65
--- /dev/null
+++ b/admin/BasicManagedProfile/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+// 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/admin/BasicManagedProfile/buildSrc/build.gradle b/admin/BasicManagedProfile/buildSrc/build.gradle
new file mode 100644
index 0000000..29282af
--- /dev/null
+++ b/admin/BasicManagedProfile/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/admin/BasicManagedProfile/gradle/wrapper/gradle-wrapper.jar b/admin/BasicManagedProfile/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/admin/BasicManagedProfile/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/admin/BasicManagedProfile/gradle/wrapper/gradle-wrapper.properties b/admin/BasicManagedProfile/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..d7f03cf
--- /dev/null
+++ b/admin/BasicManagedProfile/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
diff --git a/admin/BasicManagedProfile/gradlew b/admin/BasicManagedProfile/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/admin/BasicManagedProfile/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/admin/BasicManagedProfile/gradlew.bat b/admin/BasicManagedProfile/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/admin/BasicManagedProfile/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/admin/BasicManagedProfile/settings.gradle b/admin/BasicManagedProfile/settings.gradle
new file mode 100644
index 0000000..68c02fb
--- /dev/null
+++ b/admin/BasicManagedProfile/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'Application'
diff --git a/admin/BasicManagedProfile/template-params.xml b/admin/BasicManagedProfile/template-params.xml
new file mode 100644
index 0000000..456716c
--- /dev/null
+++ b/admin/BasicManagedProfile/template-params.xml
@@ -0,0 +1,45 @@
+<?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>BasicManagedProfile</name>
+ <group>Admin</group>
+ <package>com.example.android.basicmanagedprofile</package>
+
+
+
+ <!-- change minSdk if needed-->
+ <minSdk>21</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+
+
+ <strings>
+ <intro>
+ <![CDATA[
+ This sample demonstrates how to create a managed profile. You can also learn how to
+ enable or disable other apps and how to set restrictions to them. Intents can be
+ configured to be forwarded between primary account and managed profile. Finally, you can
+ wipe all the data associated with the profile.
+ Note that there can only be one managed profile on a device.
+ ]]>
+ </intro>
+ </strings>
+ <template src="base"/>
+
+</sample>
diff --git a/background/JobScheduler/Application/.gitignore b/background/JobScheduler/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/background/JobScheduler/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/background/JobScheduler/Application/proguard-project.txt b/background/JobScheduler/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/background/JobScheduler/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/background/JobScheduler/Application/src/main/AndroidManifest.xml b/background/JobScheduler/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..369bb57
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,48 @@
+<?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.jobscheduler" >
+
+ <uses-sdk
+ android:minSdkVersion="18"
+ android:targetSdkVersion="L" />
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/app_name"
+ android:windowSoftInputMode="stateHidden" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <service
+ android:name=".service.TestJobService"
+ android:permission="android.permission.BIND_JOB_SERVICE"
+ android:exported="true"/>
+ </application>
+
+</manifest>
\ No newline at end of file
diff --git a/background/JobScheduler/Application/src/main/java/com/example/android/jobscheduler/MainActivity.java b/background/JobScheduler/Application/src/main/java/com/example/android/jobscheduler/MainActivity.java
new file mode 100644
index 0000000..f495bf1
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/java/com/example/android/jobscheduler/MainActivity.java
@@ -0,0 +1,195 @@
+/*
+ * 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.
+ */
+
+package com.example.android.jobscheduler;
+
+import android.app.Activity;
+import android.app.job.JobInfo;
+import android.app.job.JobParameters;
+import android.app.job.JobScheduler;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.Messenger;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.example.android.jobscheduler.service.TestJobService;
+
+public class MainActivity extends Activity {
+
+ private static final String TAG = "MainActivity";
+
+ public static final int MSG_UNCOLOUR_START = 0;
+ public static final int MSG_UNCOLOUR_STOP = 1;
+ public static final int MSG_SERVICE_OBJ = 2;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.sample_main);
+ Resources res = getResources();
+ defaultColor = res.getColor(R.color.none_received);
+ startJobColor = res.getColor(R.color.start_received);
+ stopJobColor = res.getColor(R.color.stop_received);
+
+ // Set up UI.
+ mShowStartView = (TextView) findViewById(R.id.onstart_textview);
+ mShowStopView = (TextView) findViewById(R.id.onstop_textview);
+ mParamsTextView = (TextView) findViewById(R.id.task_params);
+ mDelayEditText = (EditText) findViewById(R.id.delay_time);
+ mDeadlineEditText = (EditText) findViewById(R.id.deadline_time);
+ mWiFiConnectivityRadioButton = (RadioButton) findViewById(R.id.checkbox_unmetered);
+ mAnyConnectivityRadioButton = (RadioButton) findViewById(R.id.checkbox_any);
+ mRequiresChargingCheckBox = (CheckBox) findViewById(R.id.checkbox_charging);
+ mRequiresIdleCheckbox = (CheckBox) findViewById(R.id.checkbox_idle);
+ mServiceComponent = new ComponentName(this, TestJobService.class);
+ // Start service and provide it a way to communicate with us.
+ Intent startServiceIntent = new Intent(this, TestJobService.class);
+ startServiceIntent.putExtra("messenger", new Messenger(mHandler));
+ startService(startServiceIntent);
+ }
+ // UI fields.
+ int defaultColor;
+ int startJobColor;
+ int stopJobColor;
+
+ private TextView mShowStartView;
+ private TextView mShowStopView;
+ private TextView mParamsTextView;
+ private EditText mDelayEditText;
+ private EditText mDeadlineEditText;
+ private RadioButton mWiFiConnectivityRadioButton;
+ private RadioButton mAnyConnectivityRadioButton;
+ private CheckBox mRequiresChargingCheckBox;
+ private CheckBox mRequiresIdleCheckbox;
+
+ ComponentName mServiceComponent;
+ /** Service object to interact scheduled jobs. */
+ TestJobService mTestService;
+
+ private static int kJobId = 0;
+
+ Handler mHandler = new Handler(/* default looper */) {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_UNCOLOUR_START:
+ mShowStartView.setBackgroundColor(defaultColor);
+ break;
+ case MSG_UNCOLOUR_STOP:
+ mShowStopView.setBackgroundColor(defaultColor);
+ break;
+ case MSG_SERVICE_OBJ:
+ mTestService = (TestJobService) msg.obj;
+ mTestService.setUiCallback(MainActivity.this);
+ }
+ }
+ };
+
+ private boolean ensureTestService() {
+ if (mTestService == null) {
+ Toast.makeText(MainActivity.this, "Service null, never got callback?",
+ Toast.LENGTH_SHORT).show();
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * UI onclick listener to schedule a job. What this job is is defined in
+ * TestJobService#scheduleJob().
+ */
+ public void scheduleJob(View v) {
+ if (!ensureTestService()) {
+ return;
+ }
+
+ JobInfo.Builder builder = new JobInfo.Builder(kJobId++, mServiceComponent);
+
+ String delay = mDelayEditText.getText().toString();
+ if (delay != null && !TextUtils.isEmpty(delay)) {
+ builder.setMinimumLatency(Long.valueOf(delay) * 1000);
+ }
+ String deadline = mDeadlineEditText.getText().toString();
+ if (deadline != null && !TextUtils.isEmpty(deadline)) {
+ builder.setOverrideDeadline(Long.valueOf(deadline) * 1000);
+ }
+ boolean requiresUnmetered = mWiFiConnectivityRadioButton.isChecked();
+ boolean requiresAnyConnectivity = mAnyConnectivityRadioButton.isChecked();
+ if (requiresUnmetered) {
+ builder.setRequiredNetworkCapabilities(JobInfo.NetworkType.UNMETERED);
+ } else if (requiresAnyConnectivity) {
+ builder.setRequiredNetworkCapabilities(JobInfo.NetworkType.ANY);
+ }
+ builder.setRequiresDeviceIdle(mRequiresIdleCheckbox.isChecked());
+ builder.setRequiresCharging(mRequiresChargingCheckBox.isChecked());
+
+ mTestService.scheduleJob(builder.build());
+
+ }
+
+ public void cancelAllJobs(View v) {
+ JobScheduler tm =
+ (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
+ tm.cancelAll();
+ }
+
+ /**
+ * UI onclick listener to call jobFinished() in our service.
+ */
+ public void finishJob(View v) {
+ if (!ensureTestService()) {
+ return;
+ }
+ mTestService.callJobFinished();
+ mParamsTextView.setText("");
+ }
+
+ /**
+ * Receives callback from the service when a job has landed
+ * on the app. Colours the UI and post a message to
+ * uncolour it after a second.
+ */
+ public void onReceivedStartJob(JobParameters params) {
+ mShowStartView.setBackgroundColor(startJobColor);
+ Message m = Message.obtain(mHandler, MSG_UNCOLOUR_START);
+ mHandler.sendMessageDelayed(m, 1000L); // uncolour in 1 second.
+ mParamsTextView.setText("Executing: " + params.getJobId() + " " + params.getExtras());
+ }
+
+ /**
+ * Receives callback from the service when a job that
+ * previously landed on the app must stop executing.
+ * Colours the UI and post a message to uncolour it after a
+ * second.
+ */
+ public void onReceivedStopJob() {
+ mShowStopView.setBackgroundColor(stopJobColor);
+ Message m = Message.obtain(mHandler, MSG_UNCOLOUR_STOP);
+ mHandler.sendMessageDelayed(m, 2000L); // uncolour in 1 second.
+ mParamsTextView.setText("");
+ }
+}
diff --git a/background/JobScheduler/Application/src/main/java/com/example/android/jobscheduler/service/TestJobService.java b/background/JobScheduler/Application/src/main/java/com/example/android/jobscheduler/service/TestJobService.java
new file mode 100644
index 0000000..8608be5
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/java/com/example/android/jobscheduler/service/TestJobService.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * 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.jobscheduler.service;
+
+import android.app.job.JobInfo;
+import android.app.job.JobScheduler;
+import android.app.job.JobParameters;
+import android.app.job.JobService;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.util.Log;
+
+import com.example.android.jobscheduler.MainActivity;
+
+import java.util.LinkedList;
+
+
+/**
+ * Service to handle callbacks from the JobScheduler. Requests scheduled with the JobScheduler
+ * ultimately land on this service's "onStartJob" method. Currently all this does is post a message
+ * to the app's main activity to change the state of the UI.
+ */
+public class TestJobService extends JobService {
+ private static final String TAG = "SyncService";
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ Log.i(TAG, "Service created");
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ Log.i(TAG, "Service destroyed");
+ }
+
+ /**
+ * When the app's MainActivity is created, it starts this service. This is so that the
+ * activity and this service can communicate back and forth. See "setUiCalback()"
+ */
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ Messenger callback = intent.getParcelableExtra("messenger");
+ Message m = Message.obtain();
+ m.what = MainActivity.MSG_SERVICE_OBJ;
+ m.obj = this;
+ try {
+ callback.send(m);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error passing service object back to activity.");
+ }
+ return START_NOT_STICKY;
+ }
+
+ @Override
+ public boolean onStartJob(JobParameters params) {
+ // We don't do any real 'work' in this sample app. All we'll
+ // do is track which jobs have landed on our service, and
+ // update the UI accordingly.
+ jobParamsMap.add(params);
+ if (mActivity != null) {
+ mActivity.onReceivedStartJob(params);
+ }
+ Log.i(TAG, "on start job: " + params.getJobId());
+ return true;
+ }
+
+ @Override
+ public boolean onStopJob(JobParameters params) {
+ // Stop tracking these job parameters, as we've 'finished' executing.
+ jobParamsMap.remove(params);
+ if (mActivity != null) {
+ mActivity.onReceivedStopJob();
+ }
+ Log.i(TAG, "on stop job: " + params.getJobId());
+ return true;
+ }
+
+ MainActivity mActivity;
+ private final LinkedList<JobParameters> jobParamsMap = new LinkedList<JobParameters>();
+
+ public void setUiCallback(MainActivity activity) {
+ mActivity = activity;
+ }
+
+ /** Send job to the JobScheduler. */
+ public void scheduleJob(JobInfo t) {
+ Log.d(TAG, "Scheduling job");
+ JobScheduler tm =
+ (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
+ tm.schedule(t);
+ }
+
+ /**
+ * Not currently used, but as an exercise you can hook this
+ * up to a button in the UI to finish a job that has landed
+ * in onStartJob().
+ */
+ public boolean callJobFinished() {
+ JobParameters params = jobParamsMap.poll();
+ if (params == null) {
+ return false;
+ } else {
+ jobFinished(params, false);
+ return true;
+ }
+ }
+
+}
diff --git a/background/JobScheduler/Application/src/main/res/drawable-hdpi/ic_launcher.png b/background/JobScheduler/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..9cb5f74
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/background/JobScheduler/Application/src/main/res/drawable-mdpi/ic_launcher.png b/background/JobScheduler/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..869355b
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/background/JobScheduler/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/background/JobScheduler/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..679fc16
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/background/JobScheduler/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/background/JobScheduler/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..1734fd3
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/background/JobScheduler/Application/src/main/res/layout/sample_main.xml b/background/JobScheduler/Application/src/main/res/layout/sample_main.xml
new file mode 100644
index 0000000..94b1624
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/res/layout/sample_main.xml
@@ -0,0 +1,179 @@
+<?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.
+-->
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="100dp">
+ <TextView
+ android:id="@+id/onstart_textview"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@color/none_received"
+ android:gravity="center"
+ android:text="@string/onstarttask"/>
+ <TextView
+ android:id="@+id/onstop_textview"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@color/none_received"
+ android:gravity="center"
+ android:text="@string/onstoptask"/>
+ </LinearLayout>
+ <Button
+ android:id="@+id/finished_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="20dp"
+ android:layout_marginBottom="5dp"
+ android:onClick="finishJob"
+ android:text="@string/finish_job_button_text"/>
+
+ <TextView
+ android:id="@+id/task_params"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/defaultparamtext"
+ android:gravity="center"
+ android:textSize="20dp"
+
+ android:padding="15dp"
+ android:layout_marginBottom="10dp" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/constraints"
+ android:layout_margin="15dp"
+ android:textSize="18dp"/>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_marginLeft="10dp">
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/connectivity"
+ android:layout_marginRight="10dp"/>
+ <RadioGroup
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <RadioButton android:id="@+id/checkbox_any"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/any"/>
+ <RadioButton android:id="@+id/checkbox_unmetered"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/unmetered"/>
+ </RadioGroup>
+
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/timing"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="15dp"
+ android:textSize="17dp"
+ android:text="@string/delay"/>
+ <EditText
+ android:id="@+id/delay_time"
+ android:layout_width="60dp"
+ android:layout_height="wrap_content"
+ android:inputType="number"/>
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/deadline"
+ android:textSize="17dp"/>
+ <EditText
+ android:id="@+id/deadline_time"
+ android:layout_width="60dp"
+ android:layout_height="wrap_content"
+ android:inputType="number"/>
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/charging_caption"
+ android:layout_marginRight="15dp"/>
+ <CheckBox
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/checkbox_charging"
+ android:text="@string/charging_text"/>
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/idle_caption"
+ android:layout_marginRight="15dp"/>
+ <CheckBox
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/checkbox_idle"
+ android:text="@string/idle_mode_text"/>
+ </LinearLayout>
+
+ </LinearLayout>
+ <Button
+ android:id="@+id/schedule_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
+ android:layout_marginLeft="40dp"
+ android:layout_marginRight="40dp"
+ android:onClick="scheduleJob"
+ android:text="@string/schedule_job_button_text"/>
+ <Button
+ android:id="@+id/cancel_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="40dp"
+ android:layout_marginRight="40dp"
+ android:onClick="cancelAllJobs"
+ android:text="@string/cancel_all_jobs_button_text"/>
+ </LinearLayout>
+</ScrollView>
diff --git a/background/JobScheduler/Application/src/main/res/values-v11/styles.xml b/background/JobScheduler/Application/src/main/res/values-v11/styles.xml
new file mode 100644
index 0000000..a181ed0
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/res/values-v11/styles.xml
@@ -0,0 +1,28 @@
+<?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.
+-->
+
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/sample-styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources>
\ No newline at end of file
diff --git a/background/JobScheduler/Application/src/main/res/values-v14/styles.xml b/background/JobScheduler/Application/src/main/res/values-v14/styles.xml
new file mode 100644
index 0000000..53cc49d
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/res/values-v14/styles.xml
@@ -0,0 +1,29 @@
+<?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.
+-->
+
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/sample-styles.xml and
+ res/values-v11/sample-styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources>
\ No newline at end of file
diff --git a/background/JobScheduler/Application/src/main/res/values/color.xml b/background/JobScheduler/Application/src/main/res/values/color.xml
new file mode 100644
index 0000000..b1e5338
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/res/values/color.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>
+ <color name="none_received">#999999</color>
+ <color name="start_received">#00FF00</color>
+ <color name="stop_received">#FF0000</color>
+</resources>
\ No newline at end of file
diff --git a/background/JobScheduler/Application/src/main/res/values/strings.xml b/background/JobScheduler/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..89524b2
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/res/values/strings.xml
@@ -0,0 +1,36 @@
+<?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="onstoptask">onStopTask</string>
+ <string name="onstarttask">onStartTask</string>
+ <string name="defaultparamtext">task params will show up here.</string>
+ <string name="schedule_job_button_text">Schedule Job</string>
+ <string name="cancel_all_jobs_button_text">Cancel all</string>
+ <string name="finish_job_button_text">taskFinished</string>
+ <string name="idle_mode_text">Requires device in idle mode.</string>
+ <string name="charging_caption">Charging:</string>
+ <string name="charging_text">Requires device plugged in.</string>
+ <string name="idle_caption">Idle:</string>
+ <string name="constraints">Constraints</string>
+ <string name="connectivity">Connectivity:</string>
+ <string name="any">Any</string>
+ <string name="unmetered">WiFi</string>
+ <string name="timing">Timing:</string>
+ <string name="delay">Delay:</string>
+ <string name="deadline">Deadline:</string>
+</resources>
diff --git a/background/JobScheduler/Application/src/main/res/values/styles.xml b/background/JobScheduler/Application/src/main/res/values/styles.xml
new file mode 100644
index 0000000..b767e51
--- /dev/null
+++ b/background/JobScheduler/Application/src/main/res/values/styles.xml
@@ -0,0 +1,32 @@
+<?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>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+</resources>
\ No newline at end of file
diff --git a/background/JobScheduler/Application/tests/AndroidManifest.xml b/background/JobScheduler/Application/tests/AndroidManifest.xml
new file mode 100644
index 0000000..2a9d92d
--- /dev/null
+++ b/background/JobScheduler/Application/tests/AndroidManifest.xml
@@ -0,0 +1,61 @@
+<?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.
+-->
+
+
+
+<?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.jobscheduler.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="18"
+ android:targetSdkVersion="L" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.example.android.jobscheduler"
+ android:label="Tests for com.example.android.jobscheduler" />
+
+</manifest>
\ No newline at end of file
diff --git a/background/JobScheduler/Application/tests/src/com/example/android/jobscheduler/tests/SampleTests.java b/background/JobScheduler/Application/tests/src/com/example/android/jobscheduler/tests/SampleTests.java
new file mode 100644
index 0000000..d791b6e
--- /dev/null
+++ b/background/JobScheduler/Application/tests/src/com/example/android/jobscheduler/tests/SampleTests.java
@@ -0,0 +1,79 @@
+/*
+* 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.
+*/
+
+
+
+/*
+* 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.jobscheduler.tests;
+
+import com.example.android.jobscheduler.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+* Tests for JobScheduler sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+ private JobSchedulerFragment mTestFragment;
+
+ public SampleTests() {
+ super(MainActivity.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 = (JobSchedulerFragment)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Add more tests below.
+ */
+
+}
\ No newline at end of file
diff --git a/background/JobScheduler/README.txt b/background/JobScheduler/README.txt
new file mode 100644
index 0000000..015d2b3
--- /dev/null
+++ b/background/JobScheduler/README.txt
@@ -0,0 +1,18 @@
+Build Instructions
+-------------------
+
+This sample uses the Gradle build system. To build this project, use the
+"gradlew build" command or use "Import Project" in Android Studio.
+
+To see a list of all available commands, run "gradlew tasks".
+
+Dependencies
+-------------
+
+- Android SDK Build-tools v20.0.0
+- Android Support Repository v2
+
+Dependencies are available for download via the Android SDK Manager.
+
+Android Studio is available for download at:
+ http://developer.android.com/sdk/installing/studio.html
diff --git a/background/JobScheduler/build.gradle b/background/JobScheduler/build.gradle
new file mode 100644
index 0000000..f9f6f65
--- /dev/null
+++ b/background/JobScheduler/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+// 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/background/JobScheduler/buildSrc/build.gradle b/background/JobScheduler/buildSrc/build.gradle
new file mode 100644
index 0000000..29282af
--- /dev/null
+++ b/background/JobScheduler/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/background/JobScheduler/gradle/wrapper/gradle-wrapper.jar b/background/JobScheduler/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/background/JobScheduler/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/background/JobScheduler/gradle/wrapper/gradle-wrapper.properties b/background/JobScheduler/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..d7f03cf
--- /dev/null
+++ b/background/JobScheduler/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
diff --git a/background/JobScheduler/gradlew b/background/JobScheduler/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/background/JobScheduler/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/background/JobScheduler/gradlew.bat b/background/JobScheduler/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/background/JobScheduler/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/background/JobScheduler/settings.gradle b/background/JobScheduler/settings.gradle
new file mode 100644
index 0000000..77a2714
--- /dev/null
+++ b/background/JobScheduler/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'JobSchedulerSample'
diff --git a/background/JobScheduler/template-params.xml b/background/JobScheduler/template-params.xml
new file mode 100644
index 0000000..25667a5
--- /dev/null
+++ b/background/JobScheduler/template-params.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+
+
+
+<sample>
+ <name>JobScheduler</name>
+ <group>Background</group>
+ <package>com.example.android.jobscheduler</package>
+
+ <!-- change minSdk if needed-->
+ <minSdk>18</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+
+ <strings>
+ <intro>
+ <![CDATA[
+ Demonstration of the JobScheduler API, which provides an interface for scheduling
+ background tasks when certain tasks apply.
+ ]]>
+ </intro>
+ </strings>
+
+ <template src="base"/>
+ <common src="logger"/>
+
+</sample>
diff --git a/background/alarms/RepeatingAlarm/Application/build.gradle b/background/alarms/RepeatingAlarm/Application/build.gradle
new file mode 100644
index 0000000..4c19e8b
--- /dev/null
+++ b/background/alarms/RepeatingAlarm/Application/build.gradle
@@ -0,0 +1,64 @@
+
+
+
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.12.+'
+ }
+}
+
+apply plugin: 'com.android.application'
+
+
+dependencies {
+
+ compile "com.android.support:support-v4:20.+"
+ compile "com.android.support:support-v13:20.+"
+
+}
+
+// The sample build uses multiple directories to
+// keep boilerplate and common code separate from
+// the main sample code.
+List<String> dirs = [
+ 'main', // main sample code; look here for the interesting stuff.
+ 'common', // components that are reused by multiple samples
+ 'template'] // boilerplate code that is generated by the sample template process
+
+android {
+ compileSdkVersion "android-L"
+
+ buildToolsVersion "20.0.0"
+
+ sourceSets {
+ main {
+ dirs.each { dir ->
+ java.srcDirs "src/${dir}/java"
+ res.srcDirs "src/${dir}/res"
+ }
+ }
+ androidTest.setRoot('tests')
+ androidTest.java.srcDirs = ['tests/src']
+
+ }
+
+}
+// BEGIN_EXCLUDE
+// Tasks below this line will be hidden from release output
+
+task preflight (dependsOn: parent.preflight) {
+ project.afterEvaluate {
+ // Inject a preflight task into each variant so we have a place to hook tasks
+ // that need to run before any of the android build tasks.
+ //
+ android.applicationVariants.each { variant ->
+ tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight
+ }
+ }
+}
+
+// END_EXCLUDE
diff --git a/build.gradle b/build.gradle
index 58e1adc..dfc8cc7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -27,6 +27,7 @@
"ui/notifications/BasicNotifications",
"ui/notifications/CustomNotifications",
"ui/actionbar/DoneBar",
+"ui/graphics/PdfRendererBasic",
"ui/window/BasicImmersiveMode",
"ui/window/AdvancedImmersiveMode",
"ui/window/ImmersiveMode",
@@ -46,10 +47,19 @@
"ui/views/SwipeRefreshLayout/SwipeRefreshLayoutBasic",
"ui/views/SwipeRefreshLayout/SwipeRefreshListFragment",
"ui/views/SwipeRefreshLayout/SwipeRefreshMultipleViews",
-"wearable/wear/SynchronizedNotifications",
"media/MediaRouter",
-"media/MediaEffects",
-"connectivity/bluetooth/BluetoothChat",
+"admin/BasicManagedProfile",
+"media/Camera2Basic",
+"media/Camera2Video",
+"ui/activityscenetransition/ActivitySceneTransitionBasic",
+"ui/views/NavigationDrawer",
+"ui/views/Elevation/ElevationBasic",
+"ui/views/Elevation/ElevationDrag",
+"ui/views/Clipping/ClippingBasic",
+"ui/views/FloatingActionButton/FloatingActionButtonBasic",
+"ui/views/RevealEffect/RevealEffectBasic",
+"background/JobScheduler",
+"wearable/wear/SynchronizedNotifications"
]
List<String> taskNames = [
diff --git a/common/src/java/com/example/android/common/media/MediaCodecWrapper.java b/common/src/java/com/example/android/common/media/MediaCodecWrapper.java
index a511221..a483374 100644
--- a/common/src/java/com/example/android/common/media/MediaCodecWrapper.java
+++ b/common/src/java/com/example/android/common/media/MediaCodecWrapper.java
@@ -21,6 +21,7 @@
import android.os.Looper;
import android.view.Surface;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayDeque;
import java.util.Queue;
@@ -136,7 +137,7 @@
* @return
*/
public static MediaCodecWrapper fromVideoFormat(final MediaFormat trackFormat,
- Surface surface) {
+ Surface surface) throws IOException {
MediaCodecWrapper result = null;
MediaCodec videoCodec = null;
diff --git a/connectivity/nfc/CardReader/gradle/wrapper/gradle-wrapper.properties b/connectivity/nfc/CardReader/gradle/wrapper/gradle-wrapper.properties
index f040b45..a7bd4a7 100644
--- a/connectivity/nfc/CardReader/gradle/wrapper/gradle-wrapper.properties
+++ b/connectivity/nfc/CardReader/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
diff --git a/media/Camera2Basic/Application/.gitignore b/media/Camera2Basic/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/media/Camera2Basic/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/media/Camera2Basic/Application/proguard-project.txt b/media/Camera2Basic/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/media/Camera2Basic/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/media/Camera2Basic/Application/src/main/AndroidManifest.xml b/media/Camera2Basic/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..fd783c0
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?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.
+-->
+
+
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.camera2basic"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L" />
+ <uses-permission android:name="android.permission.CAMERA" />
+
+ <application android:allowBackup="true"
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher"
+ android:theme="@style/MaterialTheme">
+
+ <activity android:name=".CameraActivity"
+ 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/media/Camera2Basic/Application/src/main/java/com/example/android/camera2basic/AutoFitTextureView.java b/media/Camera2Basic/Application/src/main/java/com/example/android/camera2basic/AutoFitTextureView.java
new file mode 100644
index 0000000..f4903e1
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/java/com/example/android/camera2basic/AutoFitTextureView.java
@@ -0,0 +1,76 @@
+/*
+ * 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.camera2basic;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.TextureView;
+
+/**
+ * A {@link TextureView} that can be adjusted to a specified aspect ratio.
+ */
+public class AutoFitTextureView extends TextureView {
+
+ private int mRatioWidth = 0;
+ private int mRatioHeight = 0;
+
+ public AutoFitTextureView(Context context) {
+ this(context, null);
+ }
+
+ public AutoFitTextureView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public AutoFitTextureView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ /**
+ * Sets the aspect ratio for this view. The size of the view will be measured based on the ratio
+ * calculated from the parameters. Note that the actual sizes of parameters don't matter, that
+ * is, calling setAspectRatio(2, 3) and setAspectRatio(4, 6) make the same result.
+ *
+ * @param width Relative horizontal size
+ * @param height Relative vertical size
+ */
+ public void setAspectRatio(int width, int height) {
+ if (width < 0 || height < 0) {
+ throw new IllegalArgumentException("Size cannot be negative.");
+ }
+ mRatioWidth = width;
+ mRatioHeight = height;
+ requestLayout();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ int width = MeasureSpec.getSize(widthMeasureSpec);
+ int height = MeasureSpec.getSize(heightMeasureSpec);
+ if (0 == mRatioWidth || 0 == mRatioHeight) {
+ setMeasuredDimension(width, height);
+ } else {
+ if (width < height * mRatioWidth / mRatioHeight) {
+ setMeasuredDimension(width, width * mRatioHeight / mRatioWidth);
+ } else {
+ setMeasuredDimension(height * mRatioWidth / mRatioHeight, height);
+ }
+ }
+ }
+
+}
diff --git a/media/Camera2Basic/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java b/media/Camera2Basic/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java
new file mode 100644
index 0000000..19ec587
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/java/com/example/android/camera2basic/Camera2BasicFragment.java
@@ -0,0 +1,792 @@
+/*
+ * 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.camera2basic;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.app.Fragment;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.res.Configuration;
+import android.graphics.ImageFormat;
+import android.graphics.Matrix;
+import android.graphics.RectF;
+import android.graphics.SurfaceTexture;
+import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCaptureSession;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CameraManager;
+import android.hardware.camera2.CameraMetadata;
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.CaptureResult;
+import android.hardware.camera2.TotalCaptureResult;
+import android.hardware.camera2.params.StreamConfigurationMap;
+import android.media.Image;
+import android.media.ImageReader;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.util.Log;
+import android.util.Size;
+import android.util.SparseIntArray;
+import android.view.LayoutInflater;
+import android.view.Surface;
+import android.view.TextureView;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Toast;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+public class Camera2BasicFragment extends Fragment implements View.OnClickListener {
+
+ /**
+ * Conversion from screen rotation to JPEG orientation.
+ */
+ private static final SparseIntArray ORIENTATIONS = new SparseIntArray();
+
+ static {
+ ORIENTATIONS.append(Surface.ROTATION_0, 90);
+ ORIENTATIONS.append(Surface.ROTATION_90, 0);
+ ORIENTATIONS.append(Surface.ROTATION_180, 270);
+ ORIENTATIONS.append(Surface.ROTATION_270, 180);
+ }
+
+ /**
+ * Tag for the {@link Log}.
+ */
+ private static final String TAG = "Camera2BasicFragment";
+
+ /**
+ * Camera state: Showing camera preview.
+ */
+ private static final int STATE_PREVIEW = 0;
+
+ /**
+ * Camera state: Waiting for the focus to be locked.
+ */
+ private static final int STATE_WAITING_LOCK = 1;
+ /**
+ * Camera state: Waiting for the exposure to be precapture state.
+ */
+ private static final int STATE_WAITING_PRECAPTURE = 2;
+ /**
+ * Camera state: Waiting for the exposure state to be something other than precapture.
+ */
+ private static final int STATE_WAITING_NON_PRECAPTURE = 3;
+ /**
+ * Camera state: Picture was taken.
+ */
+ private static final int STATE_PICTURE_TAKEN = 4;
+
+ /**
+ * {@link TextureView.SurfaceTextureListener} handles several lifecycle events on a
+ * {@link TextureView}.
+ */
+ private final TextureView.SurfaceTextureListener mSurfaceTextureListener
+ = new TextureView.SurfaceTextureListener() {
+
+ @Override
+ public void onSurfaceTextureAvailable(SurfaceTexture texture, int width, int height) {
+ openCamera(width, height);
+ }
+
+ @Override
+ public void onSurfaceTextureSizeChanged(SurfaceTexture texture, int width, int height) {
+ configureTransform(width, height);
+ }
+
+ @Override
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture texture) {
+ return true;
+ }
+
+ @Override
+ public void onSurfaceTextureUpdated(SurfaceTexture texture) {
+ }
+
+ };
+
+ /**
+ * ID of the current {@link CameraDevice}.
+ */
+ private String mCameraId;
+
+ /**
+ * An {@link AutoFitTextureView} for camera preview.
+ */
+ private AutoFitTextureView mTextureView;
+
+ /**
+ * A {@link CameraCaptureSession } for camera preview.
+ */
+
+ private CameraCaptureSession mCaptureSession;
+ /**
+ * A reference to the opened {@link CameraDevice}.
+ */
+
+ private CameraDevice mCameraDevice;
+ /**
+ * The {@link android.util.Size} of camera preview.
+ */
+
+ private Size mPreviewSize;
+
+ /**
+ * {@link CameraDevice.StateListener} is called when {@link CameraDevice} changes its state.
+ */
+ private final CameraDevice.StateListener mStateListener = new CameraDevice.StateListener() {
+
+ @Override
+ public void onOpened(CameraDevice cameraDevice) {
+ // This method is called when the camera is opened. We start camera preview here.
+ mCameraDevice = cameraDevice;
+ createCameraPreviewSession();
+ }
+
+ @Override
+ public void onDisconnected(CameraDevice cameraDevice) {
+ cameraDevice.close();
+ mCameraDevice = null;
+ }
+
+ @Override
+ public void onError(CameraDevice cameraDevice, int error) {
+ cameraDevice.close();
+ mCameraDevice = null;
+ Activity activity = getActivity();
+ if (null != activity) {
+ activity.finish();
+ }
+ }
+
+ };
+
+ /**
+ * An additional thread for running tasks that shouldn't block the UI.
+ */
+ private HandlerThread mBackgroundThread;
+
+ /**
+ * A {@link Handler} for running tasks in the background.
+ */
+ private Handler mBackgroundHandler;
+
+ /**
+ * An {@link ImageReader} that handles still image capture.
+ */
+ private ImageReader mImageReader;
+
+ /**
+ * This is the output file for our picture.
+ */
+ private File mFile;
+
+ /**
+ * This a callback object for the {@link ImageReader}. "onImageAvailable" will be called when a
+ * still image is ready to be saved.
+ */
+ private final ImageReader.OnImageAvailableListener mOnImageAvailableListener
+ = new ImageReader.OnImageAvailableListener() {
+
+ @Override
+ public void onImageAvailable(ImageReader reader) {
+ mBackgroundHandler.post(new ImageSaver(reader.acquireNextImage(), mFile));
+ }
+
+ };
+
+ /**
+ * {@link CaptureRequest.Builder} for the camera preview
+ */
+ private CaptureRequest.Builder mPreviewRequestBuilder;
+
+ /**
+ * {@link CaptureRequest} generated by {@link #mPreviewRequestBuilder}
+ */
+ private CaptureRequest mPreviewRequest;
+
+ /**
+ * The current state of camera state for taking pictures.
+ *
+ * @see #mCaptureListener
+ */
+ private int mState = STATE_PREVIEW;
+
+ /**
+ * A {@link CameraCaptureSession.CaptureListener} that handles events related to JPEG capture.
+ */
+ private CameraCaptureSession.CaptureListener mCaptureListener
+ = new CameraCaptureSession.CaptureListener() {
+
+ private void process(CaptureResult result) {
+ switch (mState) {
+ case STATE_PREVIEW: {
+ // We have nothing to do when the camera preview is working normally.
+ break;
+ }
+ case STATE_WAITING_LOCK: {
+ int afState = result.get(CaptureResult.CONTROL_AF_STATE);
+ if (CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState ||
+ CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState) {
+ int aeState = result.get(CaptureResult.CONTROL_AE_STATE);
+ if (aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED) {
+ mState = STATE_WAITING_NON_PRECAPTURE;
+ captureStillPicture();
+ } else {
+ runPrecaptureSequence();
+ }
+ }
+ break;
+ }
+ case STATE_WAITING_PRECAPTURE: {
+ int aeState = result.get(CaptureResult.CONTROL_AE_STATE);
+ if (CaptureResult.CONTROL_AE_STATE_PRECAPTURE == aeState) {
+ mState = STATE_WAITING_NON_PRECAPTURE;
+ } else if (CaptureRequest.CONTROL_AE_STATE_FLASH_REQUIRED == aeState) {
+ mState = STATE_WAITING_NON_PRECAPTURE;
+ }
+ break;
+ }
+ case STATE_WAITING_NON_PRECAPTURE: {
+ int aeState = result.get(CaptureResult.CONTROL_AE_STATE);
+ if (CaptureResult.CONTROL_AE_STATE_PRECAPTURE != aeState) {
+ mState = STATE_PICTURE_TAKEN;
+ captureStillPicture();
+ }
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request,
+ CaptureResult partialResult) {
+ process(partialResult);
+ }
+
+ @Override
+ public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
+ TotalCaptureResult result) {
+ process(result);
+ }
+
+ };
+
+ /**
+ * Given {@code choices} of {@code Size}s supported by a camera, chooses the smallest one whose
+ * width and height are at least as large as the respective requested values, and whose aspect
+ * ratio matches with the specified value.
+ *
+ * @param choices The list of sizes that the camera supports for the intended output class
+ * @param width The minimum desired width
+ * @param height The minimum desired height
+ * @param aspectRatio The aspect ratio
+ * @return The optimal {@code Size}, or an arbitrary one if none were big enough
+ */
+ private static Size chooseOptimalSize(Size[] choices, int width, int height, Size aspectRatio) {
+ // Collect the supported resolutions that are at least as big as the preview Surface
+ List<Size> bigEnough = new ArrayList<Size>();
+ int w = aspectRatio.getWidth();
+ int h = aspectRatio.getHeight();
+ for (Size option : choices) {
+ if (option.getHeight() == option.getWidth() * h / w &&
+ option.getWidth() >= width && option.getHeight() >= height) {
+ bigEnough.add(option);
+ }
+ }
+
+ // Pick the smallest of those, assuming we found any
+ if (bigEnough.size() > 0) {
+ return Collections.min(bigEnough, new CompareSizesByArea());
+ } else {
+ Log.e(TAG, "Couldn't find any suitable preview size");
+ return choices[0];
+ }
+ }
+
+ public static Camera2BasicFragment newInstance() {
+ Camera2BasicFragment fragment = new Camera2BasicFragment();
+ fragment.setRetainInstance(true);
+ return fragment;
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_camera2_basic, container, false);
+ }
+
+ @Override
+ public void onViewCreated(final View view, Bundle savedInstanceState) {
+ view.findViewById(R.id.picture).setOnClickListener(this);
+ view.findViewById(R.id.info).setOnClickListener(this);
+ mTextureView = (AutoFitTextureView) view.findViewById(R.id.texture);
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ mFile = new File(getActivity().getExternalFilesDir(null), "pic.jpg");
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ startBackgroundThread();
+
+ // When the screen is turned off and turned back on, the SurfaceTexture is already
+ // available, and "onSurfaceTextureAvailable" will not be called. In that case, we can open
+ // a camera and start preview from here (otherwise, we wait until the surface is ready in
+ // the SurfaceTextureListener).
+ if (mTextureView.isAvailable()) {
+ openCamera(mTextureView.getWidth(), mTextureView.getHeight());
+ } else {
+ mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);
+ }
+ }
+
+ @Override
+ public void onPause() {
+ closeCamera();
+ stopBackgroundThread();
+ super.onPause();
+ }
+
+ /**
+ * Sets up member variables related to camera.
+ *
+ * @param width The width of available size for camera preview
+ * @param height The height of available size for camera preview
+ */
+ private void setUpCameraOutputs(int width, int height) {
+ Activity activity = getActivity();
+ CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
+ try {
+ for (String cameraId : manager.getCameraIdList()) {
+ CameraCharacteristics characteristics
+ = manager.getCameraCharacteristics(cameraId);
+
+ // We don't use a front facing camera in this sample.
+ if (characteristics.get(CameraCharacteristics.LENS_FACING)
+ == CameraCharacteristics.LENS_FACING_FRONT) {
+ continue;
+ }
+
+ StreamConfigurationMap map = characteristics.get(
+ CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+
+ // For still image captures, we use the largest available size.
+ Size largest = Collections.max(
+ Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)),
+ new CompareSizesByArea());
+ mImageReader = ImageReader.newInstance(largest.getWidth(), largest.getHeight(),
+ ImageFormat.JPEG, /*maxImages*/2);
+ mImageReader.setOnImageAvailableListener(
+ mOnImageAvailableListener, mBackgroundHandler);
+
+ // Danger, W.R.! Attempting to use too large a preview size could exceed the camera
+ // bus' bandwidth limitation, resulting in gorgeous previews but the storage of
+ // garbage capture data.
+ mPreviewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class),
+ width, height, largest);
+
+ // We fit the aspect ratio of TextureView to the size of preview we picked.
+ int orientation = getResources().getConfiguration().orientation;
+ if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ mTextureView.setAspectRatio(
+ mPreviewSize.getWidth(), mPreviewSize.getHeight());
+ } else {
+ mTextureView.setAspectRatio(
+ mPreviewSize.getHeight(), mPreviewSize.getWidth());
+ }
+
+ mCameraId = cameraId;
+ return;
+ }
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ // Currently an NPE is thrown when the Camera2API is used but not supported on the
+ // device this code runs.
+ new ErrorDialog().show(getFragmentManager(), "dialog");
+ }
+ }
+
+ /**
+ * Opens the camera specified by {@link Camera2BasicFragment#mCameraId}.
+ */
+ private void openCamera(int width, int height) {
+ setUpCameraOutputs(width, height);
+ configureTransform(width, height);
+ Activity activity = getActivity();
+ CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
+ try {
+ manager.openCamera(mCameraId, mStateListener, mBackgroundHandler);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Closes the current {@link CameraDevice}.
+ */
+ private void closeCamera() {
+ if (null != mCaptureSession) {
+ mCaptureSession.close();
+ mCaptureSession = null;
+ }
+ if (null != mCameraDevice) {
+ mCameraDevice.close();
+ mCameraDevice = null;
+ }
+ if (null != mImageReader) {
+ mImageReader.close();
+ mImageReader = null;
+ }
+ }
+
+ /**
+ * Starts a background thread and its {@link Handler}.
+ */
+ private void startBackgroundThread() {
+ mBackgroundThread = new HandlerThread("CameraBackground");
+ mBackgroundThread.start();
+ mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
+ }
+
+ /**
+ * Stops the background thread and its {@link Handler}.
+ */
+ private void stopBackgroundThread() {
+ mBackgroundThread.quitSafely();
+ try {
+ mBackgroundThread.join();
+ mBackgroundThread = null;
+ mBackgroundHandler = null;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Creates a new {@link CameraCaptureSession} for camera preview.
+ */
+ private void createCameraPreviewSession() {
+ try {
+ SurfaceTexture texture = mTextureView.getSurfaceTexture();
+ assert texture != null;
+
+ // We configure the size of default buffer to be the size of camera preview we want.
+ texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
+
+ // This is the output Surface we need to start preview.
+ Surface surface = new Surface(texture);
+
+ // We set up a CaptureRequest.Builder with the output Surface.
+ mPreviewRequestBuilder
+ = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
+ mPreviewRequestBuilder.addTarget(surface);
+
+ // Here, we create a CameraCaptureSession for camera preview.
+ mCameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()),
+ new CameraCaptureSession.StateListener() {
+
+ @Override
+ public void onConfigured(CameraCaptureSession cameraCaptureSession) {
+ // When the session is ready, we start displaying the preview.
+ mCaptureSession = cameraCaptureSession;
+ try {
+ // Auto focus should be continuous for camera preview.
+ mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
+ CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
+ // Flash is automatically enabled when necessary.
+ mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
+ CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
+
+ // Finally, we start displaying the camera preview.
+ mPreviewRequest = mPreviewRequestBuilder.build();
+ mCaptureSession.setRepeatingRequest(mPreviewRequest,
+ mCaptureListener, mBackgroundHandler);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
+ Activity activity = getActivity();
+ if (null != activity) {
+ Toast.makeText(activity, "Failed", Toast.LENGTH_SHORT).show();
+ }
+ }
+ }, null
+ );
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
+ * This method should be called after the camera preview size is determined in
+ * setUpCameraOutputs and also the size of `mTextureView` is fixed.
+ *
+ * @param viewWidth The width of `mTextureView`
+ * @param viewHeight The height of `mTextureView`
+ */
+ private void configureTransform(int viewWidth, int viewHeight) {
+ Activity activity = getActivity();
+ if (null == mTextureView || null == mPreviewSize || null == activity) {
+ return;
+ }
+ int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
+ Matrix matrix = new Matrix();
+ RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
+ RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
+ float centerX = viewRect.centerX();
+ float centerY = viewRect.centerY();
+ if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
+ bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
+ matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
+ float scale = Math.max(
+ (float) viewHeight / mPreviewSize.getHeight(),
+ (float) viewWidth / mPreviewSize.getWidth());
+ matrix.postScale(scale, scale, centerX, centerY);
+ matrix.postRotate(90 * (rotation - 2), centerX, centerY);
+ }
+ mTextureView.setTransform(matrix);
+ }
+
+ /**
+ * Initiate a still image capture.
+ */
+ private void takePicture() {
+ lockFocus();
+ }
+
+ /**
+ * Lock the focus as the first step for a still image capture.
+ */
+ private void lockFocus() {
+ try {
+ // This is how to tell the camera to lock focus.
+ mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
+ CameraMetadata.CONTROL_AF_TRIGGER_START);
+ // Tell #mCaptureListener to wait for the lock.
+ mState = STATE_WAITING_LOCK;
+ mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), mCaptureListener,
+ mBackgroundHandler);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Run the precapture sequence for capturing a still image. This method should be called when we
+ * get a response in {@link #mCaptureListener} from {@link #lockFocus()}.
+ */
+ private void runPrecaptureSequence() {
+ try {
+ // This is how to tell the camera to trigger.
+ mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
+ CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START);
+ // Tell #mCaptureListener to wait for the precapture sequence to be set.
+ mState = STATE_WAITING_PRECAPTURE;
+ mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureListener,
+ mBackgroundHandler);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Capture a still picture. This method should be called when we get a response in
+ * {@link #mCaptureListener} from both {@link #lockFocus()}.
+ */
+ private void captureStillPicture() {
+ try {
+ final Activity activity = getActivity();
+ if (null == activity || null == mCameraDevice) {
+ return;
+ }
+ // This is the CaptureRequest.Builder that we use to take a picture.
+ final CaptureRequest.Builder captureBuilder =
+ mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
+ captureBuilder.addTarget(mImageReader.getSurface());
+
+ // Use the same AE and AF modes as the preview.
+ captureBuilder.set(CaptureRequest.CONTROL_AF_MODE,
+ CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
+ captureBuilder.set(CaptureRequest.CONTROL_AE_MODE,
+ CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
+
+ // Orientation
+ int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
+ captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATIONS.get(rotation));
+
+ CameraCaptureSession.CaptureListener captureListener
+ = new CameraCaptureSession.CaptureListener() {
+
+ @Override
+ public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
+ TotalCaptureResult result) {
+ Toast.makeText(getActivity(), "Saved: " + mFile, Toast.LENGTH_SHORT).show();
+ unlockFocus();
+ }
+ };
+
+ mCaptureSession.stopRepeating();
+ mCaptureSession.capture(captureBuilder.build(), captureListener, null);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Unlock the focus. This method should be called when still image capture sequence is finished.
+ */
+ private void unlockFocus() {
+ try {
+ // Reset the autofucos trigger
+ mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER,
+ CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
+ mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
+ CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
+ mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureListener,
+ mBackgroundHandler);
+ // After this, the camera will go back to the normal state of preview.
+ mState = STATE_PREVIEW;
+ mCaptureSession.setRepeatingRequest(mPreviewRequest, mCaptureListener,
+ mBackgroundHandler);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.picture: {
+ takePicture();
+ break;
+ }
+ case R.id.info: {
+ Activity activity = getActivity();
+ if (null != activity) {
+ new AlertDialog.Builder(activity)
+ .setMessage(R.string.intro_message)
+ .setPositiveButton(android.R.string.ok, null)
+ .show();
+ }
+ break;
+ }
+ }
+ }
+
+ /**
+ * Saves a JPEG {@link Image} into the specified {@link File}.
+ */
+ private static class ImageSaver implements Runnable {
+
+ /**
+ * The JPEG image
+ */
+ private final Image mImage;
+ /**
+ * The file we save the image into.
+ */
+ private final File mFile;
+
+ public ImageSaver(Image image, File file) {
+ mImage = image;
+ mFile = file;
+ }
+
+ @Override
+ public void run() {
+ ByteBuffer buffer = mImage.getPlanes()[0].getBuffer();
+ byte[] bytes = new byte[buffer.remaining()];
+ buffer.get(bytes);
+ FileOutputStream output = null;
+ try {
+ output = new FileOutputStream(mFile);
+ output.write(bytes);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ mImage.close();
+ if (null != output) {
+ try {
+ output.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Compares two {@code Size}s based on their areas.
+ */
+ static class CompareSizesByArea implements Comparator<Size> {
+
+ @Override
+ public int compare(Size lhs, Size rhs) {
+ // We cast here to ensure the multiplications won't overflow
+ return Long.signum((long) lhs.getWidth() * lhs.getHeight() -
+ (long) rhs.getWidth() * rhs.getHeight());
+ }
+
+ }
+
+ public static class ErrorDialog extends DialogFragment {
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final Activity activity = getActivity();
+ return new AlertDialog.Builder(activity)
+ .setMessage("This device doesn't support Camera2 API.")
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ activity.finish();
+ }
+ })
+ .create();
+ }
+
+ }
+
+}
diff --git a/media/Camera2Basic/Application/src/main/java/com/example/android/camera2basic/CameraActivity.java b/media/Camera2Basic/Application/src/main/java/com/example/android/camera2basic/CameraActivity.java
new file mode 100644
index 0000000..eb7f834
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/java/com/example/android/camera2basic/CameraActivity.java
@@ -0,0 +1,35 @@
+/*
+ * 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.camera2basic;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class CameraActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_camera);
+ if (null == savedInstanceState) {
+ getFragmentManager().beginTransaction()
+ .replace(R.id.container, Camera2BasicFragment.newInstance())
+ .commit();
+ }
+ }
+
+}
diff --git a/media/Camera2Basic/Application/src/main/res/drawable-hdpi/ic_action_info.png b/media/Camera2Basic/Application/src/main/res/drawable-hdpi/ic_action_info.png
new file mode 100644
index 0000000..32bd1aa
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/drawable-hdpi/ic_action_info.png
Binary files differ
diff --git a/media/Camera2Basic/Application/src/main/res/drawable-hdpi/ic_launcher.png b/media/Camera2Basic/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..ac6cf27
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/media/Camera2Basic/Application/src/main/res/drawable-mdpi/ic_action_info.png b/media/Camera2Basic/Application/src/main/res/drawable-mdpi/ic_action_info.png
new file mode 100644
index 0000000..8efbbf8
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/drawable-mdpi/ic_action_info.png
Binary files differ
diff --git a/media/Camera2Basic/Application/src/main/res/drawable-mdpi/ic_launcher.png b/media/Camera2Basic/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..65f92a5
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/media/Camera2Basic/Application/src/main/res/drawable-xhdpi/ic_action_info.png b/media/Camera2Basic/Application/src/main/res/drawable-xhdpi/ic_action_info.png
new file mode 100644
index 0000000..ba143ea
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/drawable-xhdpi/ic_action_info.png
Binary files differ
diff --git a/media/Camera2Basic/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/media/Camera2Basic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..6fd1318
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/media/Camera2Basic/Application/src/main/res/drawable-xxhdpi/ic_action_info.png b/media/Camera2Basic/Application/src/main/res/drawable-xxhdpi/ic_action_info.png
new file mode 100644
index 0000000..394eb7e
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/drawable-xxhdpi/ic_action_info.png
Binary files differ
diff --git a/media/Camera2Basic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/media/Camera2Basic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..4513cf2
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/media/Camera2Basic/Application/src/main/res/layout-land/fragment_camera2_basic.xml b/media/Camera2Basic/Application/src/main/res/layout-land/fragment_camera2_basic.xml
new file mode 100644
index 0000000..3a3e2ff
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/layout-land/fragment_camera2_basic.xml
@@ -0,0 +1,59 @@
+<?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="match_parent">
+
+ <com.example.android.camera2basic.AutoFitTextureView
+ android:id="@+id/texture"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentTop="true" />
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentEnd="true"
+ android:layout_alignParentTop="true"
+ android:layout_below="@id/texture"
+ android:layout_toRightOf="@id/texture"
+ android:background="#4285f4"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/picture"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/picture" />
+
+ <ImageButton
+ android:id="@+id/info"
+ style="@android:style/Widget.Material.Light.Button.Borderless"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal|bottom"
+ android:contentDescription="@string/description_info"
+ android:padding="20dp"
+ android:src="@drawable/ic_action_info" />
+
+
+ </FrameLayout>
+
+</RelativeLayout>
diff --git a/media/Camera2Basic/Application/src/main/res/layout/activity_camera.xml b/media/Camera2Basic/Application/src/main/res/layout/activity_camera.xml
new file mode 100644
index 0000000..a86d220
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/layout/activity_camera.xml
@@ -0,0 +1,22 @@
+<?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"
+ android:background="#000"
+ tools:context="com.example.android.camera2basic.CameraActivity" />
diff --git a/media/Camera2Basic/Application/src/main/res/layout/fragment_camera2_basic.xml b/media/Camera2Basic/Application/src/main/res/layout/fragment_camera2_basic.xml
new file mode 100644
index 0000000..7d05ab3
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/layout/fragment_camera2_basic.xml
@@ -0,0 +1,54 @@
+<?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="match_parent">
+
+ <com.example.android.camera2basic.AutoFitTextureView
+ android:id="@+id/texture"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentTop="true" />
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentStart="true"
+ android:layout_below="@id/texture"
+ android:background="#4285f4">
+
+ <Button
+ android:id="@+id/picture"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/picture" />
+
+ <ImageButton
+ android:id="@+id/info"
+ android:contentDescription="@string/description_info"
+ style="@android:style/Widget.Material.Light.Button.Borderless"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|right"
+ android:padding="20dp"
+ android:src="@drawable/ic_action_info" />
+
+ </FrameLayout>
+
+</RelativeLayout>
diff --git a/media/Camera2Basic/Application/src/main/res/values/strings.xml b/media/Camera2Basic/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..66f1000
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/values/strings.xml
@@ -0,0 +1,19 @@
+<?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="picture">Picture</string>
+ <string name="description_info">Info</string>
+</resources>
diff --git a/media/Camera2Basic/Application/src/main/res/values/styles.xml b/media/Camera2Basic/Application/src/main/res/values/styles.xml
new file mode 100644
index 0000000..3f3bdfb
--- /dev/null
+++ b/media/Camera2Basic/Application/src/main/res/values/styles.xml
@@ -0,0 +1,18 @@
+<?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="MaterialTheme" parent="android:Theme.Material.Light.NoActionBar.Fullscreen" />
+</resources>
diff --git a/media/Camera2Basic/Application/tests/AndroidManifest.xml b/media/Camera2Basic/Application/tests/AndroidManifest.xml
new file mode 100644
index 0000000..7196a85
--- /dev/null
+++ b/media/Camera2Basic/Application/tests/AndroidManifest.xml
@@ -0,0 +1,61 @@
+<?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.
+-->
+
+
+
+<?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.camera2basic.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="18"
+ android:targetSdkVersion="19" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.example.android.camera2basic"
+ android:label="Tests for com.example.android.camera2basic" />
+
+</manifest>
\ No newline at end of file
diff --git a/media/Camera2Basic/Application/tests/src/com/example/android/camera2basic/tests/SampleTests.java b/media/Camera2Basic/Application/tests/src/com/example/android/camera2basic/tests/SampleTests.java
new file mode 100644
index 0000000..44cdfeb
--- /dev/null
+++ b/media/Camera2Basic/Application/tests/src/com/example/android/camera2basic/tests/SampleTests.java
@@ -0,0 +1,79 @@
+/*
+* 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.
+*/
+
+
+
+/*
+* 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.camera2basic.tests;
+
+import com.example.android.camera2basic.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+* Tests for Camera2Basic sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<CameraActivity> {
+
+ private CameraActivity mTestActivity;
+ private Camera2BasicFragment mTestFragment;
+
+ public SampleTests() {
+ super(CameraActivity.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 = (Camera2BasicFragment)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Add more tests below.
+ */
+
+}
\ No newline at end of file
diff --git a/media/Camera2Basic/build.gradle b/media/Camera2Basic/build.gradle
new file mode 100644
index 0000000..c7a137e
--- /dev/null
+++ b/media/Camera2Basic/build.gradle
@@ -0,0 +1,10 @@
+// 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/media/Camera2Basic/buildSrc/build.gradle b/media/Camera2Basic/buildSrc/build.gradle
new file mode 100644
index 0000000..29282af
--- /dev/null
+++ b/media/Camera2Basic/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/media/Camera2Basic/gradle/wrapper/gradle-wrapper.jar b/media/Camera2Basic/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/media/Camera2Basic/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/media/Camera2Basic/gradle/wrapper/gradle-wrapper.properties b/media/Camera2Basic/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..d7f03cf
--- /dev/null
+++ b/media/Camera2Basic/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
diff --git a/media/Camera2Basic/gradlew b/media/Camera2Basic/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/media/Camera2Basic/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/media/Camera2Basic/gradlew.bat b/media/Camera2Basic/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/media/Camera2Basic/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/media/Camera2Basic/settings.gradle b/media/Camera2Basic/settings.gradle
new file mode 100644
index 0000000..fcefe51
--- /dev/null
+++ b/media/Camera2Basic/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'Camera2BasicSample'
diff --git a/media/Camera2Basic/template-params.xml b/media/Camera2Basic/template-params.xml
new file mode 100644
index 0000000..b7c226b
--- /dev/null
+++ b/media/Camera2Basic/template-params.xml
@@ -0,0 +1,37 @@
+<?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>Camera2Basic</name>
+ <group>Media</group>
+ <package>com.example.android.camera2basic</package>
+ <minSdk>L</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+ <strings>
+ <intro>
+ <![CDATA[
+ This sample demonstrates the basic use of Camera2 API. Check the source code to see how
+ you can display camera preview and take pictures.
+ ]]>
+ </intro>
+ </strings>
+
+ <template src="base"/>
+
+</sample>
diff --git a/media/Camera2Video/Application/.gitignore b/media/Camera2Video/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/media/Camera2Video/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/media/Camera2Video/Application/proguard-project.txt b/media/Camera2Video/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/media/Camera2Video/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/media/Camera2Video/Application/src/main/AndroidManifest.xml b/media/Camera2Video/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..fef8ea3
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.camera2video"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L" />
+
+ <uses-permission android:name="android.permission.CAMERA"/>
+ <uses-permission android:name="android.permission.RECORD_AUDIO"/>
+
+ <application android:allowBackup="true"
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher"
+ android:theme="@style/MaterialTheme">
+
+ <activity android:name=".CameraActivity"
+ 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/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/AutoFitTextureView.java b/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/AutoFitTextureView.java
new file mode 100644
index 0000000..090f81c
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/AutoFitTextureView.java
@@ -0,0 +1,76 @@
+/*
+ * 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.camera2video;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.TextureView;
+
+/**
+ * A {@link TextureView} that can be adjusted to a specified aspect ratio.
+ */
+public class AutoFitTextureView extends TextureView {
+
+ private int mRatioWidth = 0;
+ private int mRatioHeight = 0;
+
+ public AutoFitTextureView(Context context) {
+ this(context, null);
+ }
+
+ public AutoFitTextureView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public AutoFitTextureView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ /**
+ * Sets the aspect ratio for this view. The size of the view will be measured based on the ratio
+ * calculated from the parameters. Note that the actual sizes of parameters don't matter, that
+ * is, calling setAspectRatio(2, 3) and setAspectRatio(4, 6) make the same result.
+ *
+ * @param width Relative horizontal size
+ * @param height Relative vertical size
+ */
+ public void setAspectRatio(int width, int height) {
+ if (width < 0 || height < 0) {
+ throw new IllegalArgumentException("Size cannot be negative.");
+ }
+ mRatioWidth = width;
+ mRatioHeight = height;
+ requestLayout();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ int width = MeasureSpec.getSize(widthMeasureSpec);
+ int height = MeasureSpec.getSize(heightMeasureSpec);
+ if (0 == mRatioWidth || 0 == mRatioHeight) {
+ setMeasuredDimension(width, height);
+ } else {
+ if (width < height * mRatioWidth / mRatioHeight) {
+ setMeasuredDimension(width, width * mRatioHeight / mRatioWidth);
+ } else {
+ setMeasuredDimension(height * mRatioWidth / mRatioHeight, height);
+ }
+ }
+ }
+
+}
diff --git a/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/Camera2VideoFragment.java b/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/Camera2VideoFragment.java
new file mode 100644
index 0000000..2f3fe91
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/Camera2VideoFragment.java
@@ -0,0 +1,462 @@
+/*
+ * 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.camera2video;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.app.Fragment;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.res.Configuration;
+import android.graphics.Matrix;
+import android.graphics.RectF;
+import android.graphics.SurfaceTexture;
+import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCaptureSession;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CameraManager;
+import android.hardware.camera2.CameraMetadata;
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.params.StreamConfigurationMap;
+import android.media.MediaRecorder;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.util.Size;
+import android.util.SparseIntArray;
+import android.view.LayoutInflater;
+import android.view.Surface;
+import android.view.TextureView;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.Toast;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class Camera2VideoFragment extends Fragment implements View.OnClickListener {
+
+ private static final SparseIntArray ORIENTATIONS = new SparseIntArray();
+
+ static {
+ ORIENTATIONS.append(Surface.ROTATION_0, 90);
+ ORIENTATIONS.append(Surface.ROTATION_90, 0);
+ ORIENTATIONS.append(Surface.ROTATION_180, 270);
+ ORIENTATIONS.append(Surface.ROTATION_270, 180);
+ }
+
+ /**
+ * An {@link AutoFitTextureView} for camera preview.
+ */
+ private AutoFitTextureView mTextureView;
+
+ /**
+ * Button to record video
+ */
+ private Button mButtonVideo;
+
+ /**
+ * A refernce to the opened {@link android.hardware.camera2.CameraDevice}.
+ */
+ private CameraDevice mCameraDevice;
+
+ /**
+ * A reference to the current {@link android.hardware.camera2.CameraCaptureSession} for preview.
+ */
+ private CameraCaptureSession mPreviewSession;
+
+ /**
+ * {@link TextureView.SurfaceTextureListener} handles several lifecycle events on a
+ * {@link TextureView}.
+ */
+ private TextureView.SurfaceTextureListener mSurfaceTextureListener
+ = new TextureView.SurfaceTextureListener() {
+
+ @Override
+ public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture,
+ int width, int height) {
+ configureTransform(width, height);
+ startPreview();
+ }
+
+ @Override
+ public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture,
+ int width, int height) {
+ configureTransform(width, height);
+ startPreview();
+ }
+
+ @Override
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
+ return true;
+ }
+
+ @Override
+ public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
+ }
+
+ };
+
+ /**
+ * The {@link android.util.Size} of camera preview.
+ */
+ private Size mPreviewSize;
+
+ /**
+ * Camera preview.
+ */
+ private CaptureRequest.Builder mPreviewBuilder;
+
+ /**
+ * MediaRecorder
+ */
+ private MediaRecorder mMediaRecorder;
+
+ /**
+ * Whether the app is recording video now
+ */
+ private boolean mIsRecordingVideo;
+
+ /**
+ * Whether the app is currently trying to open camera
+ */
+ private boolean mOpeningCamera;
+
+ /**
+ * {@link CameraDevice.StateListener} is called when {@link CameraDevice} changes its status.
+ */
+ private CameraDevice.StateListener mStateListener = new CameraDevice.StateListener() {
+
+ @Override
+ public void onOpened(CameraDevice cameraDevice) {
+ mCameraDevice = cameraDevice;
+ startPreview();
+ mOpeningCamera = false;
+ if (null != mTextureView) {
+ configureTransform(mTextureView.getWidth(), mTextureView.getHeight());
+ }
+ }
+
+ @Override
+ public void onDisconnected(CameraDevice cameraDevice) {
+ cameraDevice.close();
+ mCameraDevice = null;
+ mOpeningCamera = false;
+ }
+
+ @Override
+ public void onError(CameraDevice cameraDevice, int error) {
+ cameraDevice.close();
+ mCameraDevice = null;
+ Activity activity = getActivity();
+ if (null != activity) {
+ activity.finish();
+ }
+ mOpeningCamera = false;
+ }
+
+ };
+
+ public static Camera2VideoFragment newInstance() {
+ Camera2VideoFragment fragment = new Camera2VideoFragment();
+ fragment.setRetainInstance(true);
+ return fragment;
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_camera2_video, container, false);
+ }
+
+ @Override
+ public void onViewCreated(final View view, Bundle savedInstanceState) {
+ mTextureView = (AutoFitTextureView) view.findViewById(R.id.texture);
+ mTextureView.setSurfaceTextureListener(mSurfaceTextureListener);
+ mButtonVideo = (Button) view.findViewById(R.id.video);
+ mButtonVideo.setOnClickListener(this);
+ view.findViewById(R.id.info).setOnClickListener(this);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ openCamera();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ if (null != mCameraDevice) {
+ mCameraDevice.close();
+ mCameraDevice = null;
+ }
+ }
+
+ @Override
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.video: {
+ if (mIsRecordingVideo) {
+ stopRecordingVideo();
+ } else {
+ startRecordingVideo();
+ }
+ break;
+ }
+ case R.id.info: {
+ Activity activity = getActivity();
+ if (null != activity) {
+ new AlertDialog.Builder(activity)
+ .setMessage(R.string.intro_message)
+ .setPositiveButton(android.R.string.ok, null)
+ .show();
+ }
+ break;
+ }
+ }
+ }
+
+ /**
+ * Tries to open a {@link CameraDevice}. The result is listened by `mStateListener`.
+ */
+ private void openCamera() {
+ final Activity activity = getActivity();
+ if (null == activity || activity.isFinishing() || mOpeningCamera) {
+ return;
+ }
+ mOpeningCamera = true;
+ CameraManager manager = (CameraManager) activity.getSystemService(Context.CAMERA_SERVICE);
+ try {
+ String cameraId = manager.getCameraIdList()[0];
+ CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
+ StreamConfigurationMap map = characteristics
+ .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+ mPreviewSize = map.getOutputSizes(SurfaceTexture.class)[0];
+ int orientation = getResources().getConfiguration().orientation;
+ if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ mTextureView.setAspectRatio(mPreviewSize.getWidth(), mPreviewSize.getHeight());
+ } else {
+ mTextureView.setAspectRatio(mPreviewSize.getHeight(), mPreviewSize.getWidth());
+ }
+ manager.openCamera(cameraId, mStateListener, null);
+ } catch (CameraAccessException e) {
+ Toast.makeText(activity, "Cannot access the camera.", Toast.LENGTH_SHORT).show();
+ activity.finish();
+ } catch (NullPointerException e) {
+ // Currently an NPE is thrown when the Camera2API is used but not supported on the
+ // device this code runs.
+ new ErrorDialog().show(getFragmentManager(), "dialog");
+ }
+ }
+
+ /**
+ * Start the camera preview.
+ */
+ private void startPreview() {
+ if (null == mCameraDevice || !mTextureView.isAvailable() || null == mPreviewSize) {
+ return;
+ }
+ try {
+ SurfaceTexture texture = mTextureView.getSurfaceTexture();
+ assert texture != null;
+ texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
+ mPreviewBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
+ Surface surface = new Surface(texture);
+ List<Surface> surfaces = new ArrayList<Surface>();
+ surfaces.add(surface);
+ mPreviewBuilder.addTarget(surface);
+ mCameraDevice.createCaptureSession(surfaces, new CameraCaptureSession.StateListener() {
+
+ @Override
+ public void onConfigured(CameraCaptureSession cameraCaptureSession) {
+ mPreviewSession = cameraCaptureSession;
+ updatePreview();
+ }
+
+ @Override
+ public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
+ Activity activity = getActivity();
+ if (null != activity) {
+ Toast.makeText(activity, "Failed", Toast.LENGTH_SHORT).show();
+ }
+ }
+ }, null);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Update the camera preview. {@link #startPreview()} needs to be called in advance.
+ */
+ private void updatePreview() {
+ if (null == mCameraDevice) {
+ return;
+ }
+ try {
+ setUpCaptureRequestBuilder(mPreviewBuilder);
+ HandlerThread thread = new HandlerThread("CameraPreview");
+ thread.start();
+ Handler backgroundHandler = new Handler(thread.getLooper());
+ mPreviewSession.setRepeatingRequest(mPreviewBuilder.build(), null, backgroundHandler);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void setUpCaptureRequestBuilder(CaptureRequest.Builder builder) {
+ builder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
+ }
+
+ /**
+ * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
+ * This method should not to be called until the camera preview size is determined in
+ * openCamera, or until the size of `mTextureView` is fixed.
+ *
+ * @param viewWidth The width of `mTextureView`
+ * @param viewHeight The height of `mTextureView`
+ */
+ private void configureTransform(int viewWidth, int viewHeight) {
+ Activity activity = getActivity();
+ if (null == mTextureView || null == mPreviewSize || null == activity) {
+ return;
+ }
+ int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
+ Matrix matrix = new Matrix();
+ RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
+ RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
+ float centerX = viewRect.centerX();
+ float centerY = viewRect.centerY();
+ if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
+ bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
+ matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
+ float scale = Math.max(
+ (float) viewHeight / mPreviewSize.getHeight(),
+ (float) viewWidth / mPreviewSize.getWidth());
+ matrix.postScale(scale, scale, centerX, centerY);
+ matrix.postRotate(90 * (rotation - 2), centerX, centerY);
+ }
+ mTextureView.setTransform(matrix);
+ }
+
+ private void startRecordingVideo() {
+ final Activity activity = getActivity();
+ if (null == activity) {
+ return;
+ }
+ mMediaRecorder = new MediaRecorder();
+ final File file = getVideoFile(activity);
+ try {
+ // UI
+ mButtonVideo.setText(R.string.stop);
+ mIsRecordingVideo = true;
+ // Configure the MediaRecorder
+ mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
+ mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
+ mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
+ mMediaRecorder.setOutputFile(file.getAbsolutePath());
+ mMediaRecorder.setVideoEncodingBitRate(10000000);
+ mMediaRecorder.setVideoFrameRate(30);
+ mMediaRecorder.setVideoSize(1440, 1080);
+ mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
+ mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
+ int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
+ int orientation = ORIENTATIONS.get(rotation);
+ mMediaRecorder.setOrientationHint(orientation);
+ mMediaRecorder.prepare();
+ Surface surface = mMediaRecorder.getSurface();
+ // Set up the CaptureRequest
+ final CaptureRequest.Builder builder =
+ mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
+ builder.addTarget(surface);
+ Surface previewSurface = new Surface(mTextureView.getSurfaceTexture());
+ builder.addTarget(previewSurface);
+ mCameraDevice.createCaptureSession(Arrays.asList(surface, previewSurface),
+ new CameraCaptureSession.StateListener() {
+ @Override
+ public void onConfigured(CameraCaptureSession session) {
+ // Start recording
+ try {
+ session.setRepeatingRequest(builder.build(), null, null);
+ mMediaRecorder.start();
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onConfigureFailed(CameraCaptureSession session) {
+ Toast.makeText(activity, "Failed.", Toast.LENGTH_SHORT).show();
+ }
+ }, null
+ );
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private File getVideoFile(Context context) {
+ return new File(context.getExternalFilesDir(null), "video.mp4");
+ }
+
+ private void stopRecordingVideo() {
+ // UI
+ mIsRecordingVideo = false;
+ mButtonVideo.setText(R.string.record);
+ // Stop recording
+ mMediaRecorder.stop();
+ mMediaRecorder.release();
+ mMediaRecorder = null;
+ Activity activity = getActivity();
+ if (null != activity) {
+ Toast.makeText(activity, "Video saved: " + getVideoFile(activity),
+ Toast.LENGTH_SHORT).show();
+ }
+ startPreview();
+ }
+
+ public static class ErrorDialog extends DialogFragment {
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final Activity activity = getActivity();
+ return new AlertDialog.Builder(activity)
+ .setMessage("This device doesn't support Camera2 API.")
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ activity.finish();
+ }
+ })
+ .create();
+ }
+
+ }
+
+}
diff --git a/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/CameraActivity.java b/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/CameraActivity.java
new file mode 100644
index 0000000..d90f227
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/CameraActivity.java
@@ -0,0 +1,35 @@
+/*
+ * 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.camera2video;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class CameraActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_camera);
+ if (null == savedInstanceState) {
+ getFragmentManager().beginTransaction()
+ .replace(R.id.container, Camera2VideoFragment.newInstance())
+ .commit();
+ }
+ }
+
+}
diff --git a/media/Camera2Video/Application/src/main/res/drawable-hdpi/ic_action_info.png b/media/Camera2Video/Application/src/main/res/drawable-hdpi/ic_action_info.png
new file mode 100644
index 0000000..32bd1aa
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/drawable-hdpi/ic_action_info.png
Binary files differ
diff --git a/media/Camera2Video/Application/src/main/res/drawable-hdpi/ic_launcher.png b/media/Camera2Video/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..88bc107
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/media/Camera2Video/Application/src/main/res/drawable-mdpi/ic_action_info.png b/media/Camera2Video/Application/src/main/res/drawable-mdpi/ic_action_info.png
new file mode 100644
index 0000000..8efbbf8
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/drawable-mdpi/ic_action_info.png
Binary files differ
diff --git a/media/Camera2Video/Application/src/main/res/drawable-mdpi/ic_launcher.png b/media/Camera2Video/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..28a5a42
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/media/Camera2Video/Application/src/main/res/drawable-xhdpi/ic_action_info.png b/media/Camera2Video/Application/src/main/res/drawable-xhdpi/ic_action_info.png
new file mode 100644
index 0000000..ba143ea
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/drawable-xhdpi/ic_action_info.png
Binary files differ
diff --git a/media/Camera2Video/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/media/Camera2Video/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..2811666
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/media/Camera2Video/Application/src/main/res/drawable-xxhdpi/ic_action_info.png b/media/Camera2Video/Application/src/main/res/drawable-xxhdpi/ic_action_info.png
new file mode 100644
index 0000000..394eb7e
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/drawable-xxhdpi/ic_action_info.png
Binary files differ
diff --git a/media/Camera2Video/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/media/Camera2Video/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..0e8ab46
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/media/Camera2Video/Application/src/main/res/layout-land/fragment_camera2_video.xml b/media/Camera2Video/Application/src/main/res/layout-land/fragment_camera2_video.xml
new file mode 100644
index 0000000..aa139a9
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/layout-land/fragment_camera2_video.xml
@@ -0,0 +1,58 @@
+<?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="match_parent">
+
+ <com.example.android.camera2video.AutoFitTextureView
+ android:id="@+id/texture"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentTop="true" />
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentEnd="true"
+ android:layout_alignParentTop="true"
+ android:layout_below="@id/texture"
+ android:layout_toRightOf="@id/texture"
+ android:background="#4285f4"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/video"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/record" />
+
+ <ImageButton
+ android:id="@+id/info"
+ style="@android:style/Widget.Material.Light.Button.Borderless"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal|bottom"
+ android:contentDescription="@string/description_info"
+ android:padding="20dp"
+ android:src="@drawable/ic_action_info" />
+
+ </FrameLayout>
+
+</RelativeLayout>
diff --git a/media/Camera2Video/Application/src/main/res/layout/activity_camera.xml b/media/Camera2Video/Application/src/main/res/layout/activity_camera.xml
new file mode 100644
index 0000000..a86d220
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/layout/activity_camera.xml
@@ -0,0 +1,22 @@
+<?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"
+ android:background="#000"
+ tools:context="com.example.android.camera2basic.CameraActivity" />
diff --git a/media/Camera2Video/Application/src/main/res/layout/fragment_camera2_video.xml b/media/Camera2Video/Application/src/main/res/layout/fragment_camera2_video.xml
new file mode 100644
index 0000000..e30009d
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/layout/fragment_camera2_video.xml
@@ -0,0 +1,54 @@
+<?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="match_parent">
+
+ <com.example.android.camera2video.AutoFitTextureView
+ android:id="@+id/texture"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentTop="true" />
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentStart="true"
+ android:layout_below="@id/texture"
+ android:background="#4285f4">
+
+ <Button
+ android:id="@+id/video"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/record" />
+
+ <ImageButton
+ android:id="@+id/info"
+ android:contentDescription="@string/description_info"
+ style="@android:style/Widget.Material.Light.Button.Borderless"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|right"
+ android:padding="20dp"
+ android:src="@drawable/ic_action_info" />
+
+ </FrameLayout>
+
+</RelativeLayout>
diff --git a/media/Camera2Video/Application/src/main/res/values/strings.xml b/media/Camera2Video/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..bf5e439
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/values/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="record">Record</string>
+ <string name="stop">Stop</string>
+ <string name="description_info">Info</string>
+</resources>
\ No newline at end of file
diff --git a/media/Camera2Video/Application/src/main/res/values/styles.xml b/media/Camera2Video/Application/src/main/res/values/styles.xml
new file mode 100644
index 0000000..841d8ce
--- /dev/null
+++ b/media/Camera2Video/Application/src/main/res/values/styles.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>
+
+ <style name="MaterialTheme" parent="android:Theme.Material.Light.NoActionBar.Fullscreen" />
+
+</resources>
\ No newline at end of file
diff --git a/media/Camera2Video/build.gradle b/media/Camera2Video/build.gradle
new file mode 100644
index 0000000..f9f6f65
--- /dev/null
+++ b/media/Camera2Video/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+// 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/media/Camera2Video/buildSrc/build.gradle b/media/Camera2Video/buildSrc/build.gradle
new file mode 100644
index 0000000..29282af
--- /dev/null
+++ b/media/Camera2Video/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/media/Camera2Video/gradle/wrapper/gradle-wrapper.jar b/media/Camera2Video/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/media/Camera2Video/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/media/Camera2Video/gradle/wrapper/gradle-wrapper.properties b/media/Camera2Video/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..d7f03cf
--- /dev/null
+++ b/media/Camera2Video/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
diff --git a/media/Camera2Video/gradlew b/media/Camera2Video/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/media/Camera2Video/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/media/Camera2Video/gradlew.bat b/media/Camera2Video/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/media/Camera2Video/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/media/Camera2Video/settings.gradle b/media/Camera2Video/settings.gradle
new file mode 100644
index 0000000..890bae1
--- /dev/null
+++ b/media/Camera2Video/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'Camera2VideoSample'
diff --git a/media/Camera2Video/template-params.xml b/media/Camera2Video/template-params.xml
new file mode 100644
index 0000000..221b334
--- /dev/null
+++ b/media/Camera2Video/template-params.xml
@@ -0,0 +1,36 @@
+<?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>Camera2Video</name>
+ <group>Media</group>
+ <package>com.example.android.camera2video</package>
+
+ <minSdk>21</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+
+ <strings>
+ <intro>
+ <![CDATA[
+ This sample demonstrates how to record video using Camera2 API.
+ ]]>
+ </intro>
+ </strings>
+
+ <template src="base"/>
+
+</sample>
diff --git a/media/MediaRouter/gradle/wrapper/gradle-wrapper.properties b/media/MediaRouter/gradle/wrapper/gradle-wrapper.properties
index 5de946b..1e61d1f 100644
--- a/media/MediaRouter/gradle/wrapper/gradle-wrapper.properties
+++ b/media/MediaRouter/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
diff --git a/media/MediaRouter/template-params.xml b/media/MediaRouter/template-params.xml
index f43a126..d31b69f 100644
--- a/media/MediaRouter/template-params.xml
+++ b/media/MediaRouter/template-params.xml
@@ -19,16 +19,16 @@
<sample>
<name>MediaRouter</name>
- <group>NoGroup</group>
+ <group>Media</group>
<package>com.example.android.mediarouter</package>
<!-- change minSdk if needed-->
- <minSdk>4</minSdk>
+ <minSdk>13</minSdk>
- <dependency>com.android.support:appcompat-v7:+</dependency>
- <dependency>com.android.support:mediarouter-v7:+</dependency>
+ <dependency>com.android.support:appcompat-v7:20.+</dependency>
+ <dependency>com.android.support:mediarouter-v7:20.+</dependency>
<strings>
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/.gitignore b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/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/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/libs/volley.jar b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/libs/volley.jar
new file mode 100644
index 0000000..a38dac4
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/libs/volley.jar
Binary files differ
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/proguard-project.txt b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/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/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/AndroidManifest.xml b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..08aa0ca
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,46 @@
+<?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.activityscenetransitionbasic"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L" />
+
+ <application android:allowBackup="true"
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher"
+ android:theme="@style/AppTheme">
+
+ <activity android:name=".MainActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".DetailActivity" />
+
+ </application>
+
+ <uses-permission android:name="android.permission.INTERNET" />
+
+</manifest>
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/DetailActivity.java b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/DetailActivity.java
new file mode 100644
index 0000000..741cd26
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/DetailActivity.java
@@ -0,0 +1,95 @@
+/*
+ * 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.activityscenetransitionbasic;
+
+import com.android.volley.toolbox.ImageLoader;
+import com.android.volley.toolbox.NetworkImageView;
+import com.android.volley.toolbox.Volley;
+
+import android.app.Activity;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.widget.TextView;
+
+/**
+ * Our secondary Activity which is launched from {@link MainActivity}. Has a simple detail UI
+ * which has a large banner image, title and body text.
+ */
+public class DetailActivity extends Activity {
+
+ // Extra name for the ID parameter
+ public static final String EXTRA_PARAM_ID = "detail:_id";
+
+ // View name of the header image. Used for activity scene transitions
+ public static final String VIEW_NAME_HEADER_IMAGE = "detail:header:image";
+
+ // View name of the header title. Used for activity scene transitions
+ public static final String VIEW_NAME_HEADER_TITLE = "detail:header:title";
+
+ private NetworkImageView mHeaderImageView;
+ private TextView mHeaderTitle;
+
+ private ImageLoader mImageLoader;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.details);
+
+ // Construct an ImageLoader instance so that we can load images from the network
+ mImageLoader = new ImageLoader(Volley.newRequestQueue(this), ImageMemoryCache.INSTANCE);
+
+ // Retrieve the correct Item instance, using the ID provided in the Intent
+ Item item = Item.getItem(getIntent().getIntExtra(EXTRA_PARAM_ID, 0));
+
+ mHeaderImageView = (NetworkImageView) findViewById(R.id.imageview_header);
+ mHeaderTitle = (TextView) findViewById(R.id.textview_title);
+
+ // BEGIN_INCLUDE(detail_set_view_name)
+ /**
+ * Set the name of the view's which will be transition to, using the static values above.
+ * This could be done in the layout XML, but exposing it via static variables allows easy
+ * querying from other Activities
+ */
+ mHeaderImageView.setViewName(VIEW_NAME_HEADER_IMAGE);
+ mHeaderTitle.setViewName(VIEW_NAME_HEADER_TITLE);
+ // END_INCLUDE(detail_set_view_name)
+
+ loadItem(item);
+ }
+
+ private void loadItem(Item item) {
+ // Set the title TextView to the item's name and author
+ mHeaderTitle.setText(getString(R.string.image_header, item.getName(), item.getAuthor()));
+
+ final ImageMemoryCache cache = ImageMemoryCache.INSTANCE;
+ Bitmap thumbnailImage = cache.getBitmapFromUrl(item.getThumbnailUrl());
+
+ // Check to see if we already have the thumbnail sized image in the cache. If so, start
+ // loading the full size image and display the thumbnail as a placeholder.
+ if (thumbnailImage != null) {
+ mHeaderImageView.setImageUrl(item.getPhotoUrl(), mImageLoader);
+ mHeaderImageView.setImageBitmap(thumbnailImage);
+ return;
+ }
+
+ // If we get here then we do not have either the full size or the thumbnail in the cache.
+ // Here we just load the full size and make do.
+ mHeaderImageView.setImageUrl(item.getPhotoUrl(), mImageLoader);
+ }
+
+}
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/ImageMemoryCache.java b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/ImageMemoryCache.java
new file mode 100644
index 0000000..53d47ba
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/ImageMemoryCache.java
@@ -0,0 +1,96 @@
+/*
+ * 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.activityscenetransitionbasic;
+
+import com.android.volley.toolbox.ImageLoader;
+
+import android.graphics.Bitmap;
+import android.util.LruCache;
+
+import java.util.Map;
+
+/**
+ * An image memory cache implementation for Volley which allows the retrieval of entires via a URL.
+ * Volley internally inserts items with a key which is a combination of a the size of the image,
+ * and the url.
+ *
+ * This class provide the method {@link #getBitmapFromUrl(String)} which allows the retrieval of
+ * a bitmap solely on the URL.
+ */
+public class ImageMemoryCache extends LruCache<String, Bitmap> implements ImageLoader.ImageCache {
+
+ /**
+ * Singleton instance which has it's maximum size set to be 1/8th of the allowed memory size.
+ */
+ public static final ImageMemoryCache INSTANCE = new ImageMemoryCache(
+ (int) (Runtime.getRuntime().maxMemory() / 8));
+
+ // Cache the last created snapshot
+ private Map<String, Bitmap> mLastSnapshot;
+
+ private ImageMemoryCache(int maxSize) {
+ super(maxSize);
+ }
+
+ public Bitmap getBitmapFromUrl(String url) {
+ // If we do not have a snapshot to use, generate one
+ if (mLastSnapshot == null) {
+ mLastSnapshot = snapshot();
+ }
+
+ // Iterate through the snapshot to find any entries which match our url
+ for (Map.Entry<String, Bitmap> entry : mLastSnapshot.entrySet()) {
+ if (url.equals(extractUrl(entry.getKey()))) {
+ // We've found an entry with the same url, return the bitmap
+ return entry.getValue();
+ }
+ }
+
+ // We didn't find an entry, so return null
+ return null;
+ }
+
+ @Override
+ public Bitmap getBitmap(String key) {
+ return get(key);
+ }
+
+ @Override
+ public void putBitmap(String key, Bitmap bitmap) {
+ put(key, bitmap);
+
+ // An entry has been added, so invalidate the snapshot
+ mLastSnapshot = null;
+ }
+
+ @Override
+ protected void entryRemoved(boolean evicted, String key, Bitmap oldValue, Bitmap newValue) {
+ super.entryRemoved(evicted, key, oldValue, newValue);
+
+ // An entry has been removed, so invalidate the snapshot
+ mLastSnapshot = null;
+ }
+
+ private static String extractUrl(String key) {
+ return key.substring(key.indexOf("http"));
+ }
+
+ @Override
+ protected int sizeOf(String key, Bitmap value) {
+ return value.getAllocationByteCount();
+ }
+}
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/Item.java b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/Item.java
new file mode 100644
index 0000000..e211886
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/Item.java
@@ -0,0 +1,78 @@
+/*
+ * 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.activityscenetransitionbasic;
+
+/**
+ * Represents an Item in our application. Each item has a name, id, full size image url and
+ * thumbnail url.
+ */
+public class Item {
+
+ private static final String LARGE_BASE_URL = "http://storage.googleapis.com/androiddevelopers/sample_data/activity_transition/large/";
+ private static final String THUMB_BASE_URL = "http://storage.googleapis.com/androiddevelopers/sample_data/activity_transition/thumbs/";
+
+ public static Item[] ITEMS = new Item[] {
+ new Item("Flying in the Light", "Romain Guy", "flying_in_the_light.jpg"),
+ new Item("Caterpillar", "Romain Guy", "caterpillar.jpg"),
+ new Item("Look Me in the Eye", "Romain Guy", "look_me_in_the_eye.jpg"),
+ new Item("Flamingo", "Romain Guy", "flamingo.jpg"),
+ new Item("Rainbow", "Romain Guy", "rainbow.jpg"),
+ new Item("Over there", "Romain Guy", "over_there.jpg"),
+ new Item("Jelly Fish 2", "Romain Guy", "jelly_fish_2.jpg"),
+ new Item("Lone Pine Sunset", "Romain Guy", "lone_pine_sunset.jpg"),
+ };
+
+ public static Item getItem(int id) {
+ for (Item item : ITEMS) {
+ if (item.getId() == id) {
+ return item;
+ }
+ }
+ return null;
+ }
+
+ private final String mName;
+ private final String mAuthor;
+ private final String mFileName;
+
+ Item (String name, String author, String fileName) {
+ mName = name;
+ mAuthor = author;
+ mFileName = fileName;
+ }
+
+ public int getId() {
+ return mName.hashCode() + mFileName.hashCode();
+ }
+
+ public String getAuthor() {
+ return mAuthor;
+ }
+
+ public String getName() {
+ return mName;
+ }
+
+ public String getPhotoUrl() {
+ return LARGE_BASE_URL + mFileName;
+ }
+
+ public String getThumbnailUrl() {
+ return THUMB_BASE_URL + mFileName;
+ }
+
+}
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/MainActivity.java b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/MainActivity.java
new file mode 100644
index 0000000..3630990
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/MainActivity.java
@@ -0,0 +1,145 @@
+/*
+ * 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.activityscenetransitionbasic;
+
+import com.android.volley.toolbox.ImageLoader;
+import com.android.volley.toolbox.NetworkImageView;
+import com.android.volley.toolbox.Volley;
+
+import android.app.Activity;
+import android.app.ActivityOptions;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Pair;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.GridView;
+import android.widget.TextView;
+
+/**
+ * Our main Activity in this sample. Displays a grid of items which an image and title. When the
+ * user clicks on an item, {@link DetailActivity} is launched, using the Activity Scene Transitions
+ * framework to animatedly do so.
+ */
+public class MainActivity extends Activity implements AdapterView.OnItemClickListener {
+
+ private GridView mGridView;
+ private GridAdapter mAdapter;
+
+ private ImageLoader mImageLoader;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.grid);
+
+ // Retrieve the ImageLoader we are going to use for NetworkImageView
+ mImageLoader = new ImageLoader(Volley.newRequestQueue(this), ImageMemoryCache.INSTANCE);
+
+ // Setup the GridView and set the adapter
+ mGridView = (GridView) findViewById(R.id.grid);
+ mGridView.setOnItemClickListener(this);
+ mAdapter = new GridAdapter();
+ mGridView.setAdapter(mAdapter);
+ }
+
+ /**
+ * Called when an item in the {@link android.widget.GridView} is clicked. Here will launch the
+ * {@link DetailActivity}, using the Scene Transition animation functionality.
+ */
+ @Override
+ public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
+ Item item = (Item) adapterView.getItemAtPosition(position);
+
+ // Construct an Intent as normal
+ Intent intent = new Intent(this, DetailActivity.class);
+ intent.putExtra(DetailActivity.EXTRA_PARAM_ID, item.getId());
+
+ // BEGIN_INCLUDE(start_activity)
+ /**
+ * Now create an {@link android.app.ActivityOptions} instance using the
+ * {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.app.Activity, android.util.Pair[])} factory method.
+ */
+ ActivityOptions activityOptions = ActivityOptions.makeSceneTransitionAnimation(
+ this,
+
+ // Now we provide a list of Pair items which contain the view we can transitioning
+ // from, and the name of the view it is transitioning to, in the launched activity
+ new Pair<View, String>(
+ view.findViewById(R.id.imageview_item),
+ DetailActivity.VIEW_NAME_HEADER_IMAGE),
+ new Pair<View, String>(
+ view.findViewById(R.id.textview_name),
+ DetailActivity.VIEW_NAME_HEADER_TITLE)
+ );
+
+ // Now we can start the Activity, providing the activity options as a bundle
+ startActivity(intent, activityOptions.toBundle());
+ // END_INCLUDE(start_activity)
+ }
+
+ /**
+ * {@link android.widget.BaseAdapter} which displays items.
+ */
+ private class GridAdapter extends BaseAdapter {
+
+ @Override
+ public int getCount() {
+ return Item.ITEMS.length;
+ }
+
+ @Override
+ public Item getItem(int position) {
+ return Item.ITEMS[position];
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return getItem(position).getId();
+ }
+
+ @Override
+ public View getView(int position, View view, ViewGroup viewGroup) {
+ if (view == null) {
+ view = getLayoutInflater().inflate(R.layout.grid_item, viewGroup, false);
+ }
+
+ final Item item = getItem(position);
+
+ // Load the thumbnail image
+ NetworkImageView image = (NetworkImageView) view.findViewById(R.id.imageview_item);
+ image.setImageUrl(item.getThumbnailUrl(), mImageLoader);
+
+ // Set the TextView's contents
+ TextView name = (TextView) view.findViewById(R.id.textview_name);
+ name.setText(item.getName());
+
+ // BEGIN_INCLUDE(grid_set_view_name)
+ /**
+ * As we're in an adapter we need to set each view's name dynamically, using the
+ * item's ID so that the names are unique.
+ */
+ image.setViewName("grid:image:" + item.getId());
+ name.setViewName("grid:name:" + item.getId());
+ // END_INCLUDE(grid_set_view_name)
+
+ return view;
+ }
+ }
+}
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/SquareFrameLayout.java b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/SquareFrameLayout.java
new file mode 100644
index 0000000..eece73e
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/java/com/example/android/activityscenetransitionbasic/SquareFrameLayout.java
@@ -0,0 +1,74 @@
+/*
+ * 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.activityscenetransitionbasic;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.FrameLayout;
+
+/**
+ * {@link android.widget.FrameLayout} which forces itself to be laid out as square.
+ */
+public class SquareFrameLayout extends FrameLayout {
+
+ public SquareFrameLayout(Context context) {
+ super(context);
+ }
+
+ public SquareFrameLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ public SquareFrameLayout(Context context, AttributeSet attrs,
+ int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+ final int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+
+ if (widthSize == 0 && heightSize == 0) {
+ // If there are no constraints on size, let FrameLayout measure
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ // Now use the smallest of the measured dimensions for both dimensions
+ final int minSize = Math.min(getMeasuredWidth(), getMeasuredHeight());
+ setMeasuredDimension(minSize, minSize);
+ return;
+ }
+
+ final int size;
+ if (widthSize == 0 || heightSize == 0) {
+ // If one of the dimensions has no restriction on size, set both dimensions to be the
+ // on that does
+ size = Math.max(widthSize, heightSize);
+ } else {
+ // Both dimensions have restrictions on size, set both dimensions to be the
+ // smallest of the two
+ size = Math.min(widthSize, heightSize);
+ }
+
+ final int newMeasureSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY);
+ super.onMeasure(newMeasureSpec, newMeasureSpec);
+ }
+}
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..a598447
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..8aaa6c9
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..3667baa
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..e3c4a32
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/layout/details.xml b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/layout/details.xml
new file mode 100644
index 0000000..e61212e
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/layout/details.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <com.example.android.activityscenetransitionbasic.SquareFrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <com.android.volley.toolbox.NetworkImageView
+ android:id="@+id/imageview_header"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop" />
+
+ </com.example.android.activityscenetransitionbasic.SquareFrameLayout>
+
+ <TextView
+ android:id="@+id/textview_title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?android:attr/colorPrimary"
+ android:theme="@android:style/Theme.Material"
+ android:textAppearance="@android:style/TextAppearance.Material.Title"
+ android:maxLines="2"
+ android:padding="16dp" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ android:text="@string/bacon_ipsum"
+ android:textAppearance="@android:style/TextAppearance.Material.Body1" />
+
+ </LinearLayout>
+
+</ScrollView>
\ No newline at end of file
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/layout/grid.xml b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/layout/grid.xml
new file mode 100644
index 0000000..4dded95
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/layout/grid.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<GridView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/grid"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clipToPadding="false"
+ android:columnWidth="120dp"
+ android:drawSelectorOnTop="true"
+ android:horizontalSpacing="@dimen/grid_spacing"
+ android:numColumns="auto_fit"
+ android:padding="@dimen/grid_spacing"
+ android:verticalSpacing="@dimen/grid_spacing" />
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/layout/grid_item.xml b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/layout/grid_item.xml
new file mode 100644
index 0000000..1d28dba
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/layout/grid_item.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <com.example.android.activityscenetransitionbasic.SquareFrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <com.android.volley.toolbox.NetworkImageView
+ android:id="@+id/imageview_item"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop" />
+
+ </com.example.android.activityscenetransitionbasic.SquareFrameLayout>
+
+ <TextView
+ android:id="@+id/textview_name"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?android:attr/colorPrimary"
+ android:theme="@android:style/Theme.Material"
+ android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:maxLines="1"
+ android:padding="16dp" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/transition/grid_detail_transition.xml b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/transition/grid_detail_transition.xml
new file mode 100644
index 0000000..40be3d4
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/transition/grid_detail_transition.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<!--
+ The transitions which us used for the entrance and exit of shared elements. Here we declare
+ two different transitions which are targeting to specific views.
+-->
+<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <!-- changeBounds is used for the TextViews which are shared -->
+ <changeBounds>
+ <!--
+ Set this transitions target IDs to be those which point to the TextViews in both the
+ starting and result Activities
+ -->
+ <targets>
+ <target android:targetId="@id/textview_name" />
+ <target android:targetId="@id/textview_title" />
+ </targets>
+ </changeBounds>
+
+ <!-- moveImage is used for the ImageViews which are shared -->
+ <moveImage>
+ <!--
+ Set this transitions target IDs to be those which point to the ImageViews in both the
+ starting and result Activities
+ -->
+ <targets>
+ <target android:targetId="@id/imageview_header" />
+ <target android:targetId="@id/imageview_item" />
+ </targets>
+ </moveImage>
+
+</transitionSet>
+
+
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/values-v21/styles.xml b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/values-v21/styles.xml
new file mode 100644
index 0000000..fd212b3
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/values-v21/styles.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources>
+
+ <style name="Theme.Sample" parent="Theme.Base">
+ <!-- Set the windowContentTransitions flag to enable Activity scene transitions -->
+ <item name="android:windowContentTransitions">true</item>
+
+ <!-- Set the transitions which are used for the entrance and exit of shared elements -->
+ <item name="android:windowSharedElementEnterTransition">
+ @transition/grid_detail_transition
+ </item>
+ <item name="android:windowSharedElementExitTransition">
+ @transition/grid_detail_transition
+ </item>
+ </style>
+
+</resources>
\ No newline at end of file
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/values/dimens.xml b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..b8e2e56
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/values/dimens.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources>
+
+ <dimen name="grid_spacing">4dp</dimen>
+
+</resources>
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/values/strings.xml b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..2aa0d3b
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/src/main/res/values/strings.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="bacon_ipsum">
+ Bacon ipsum dolor sit amet venison shankle pork chop meatball tri-tip beef ribs turducken.
+ Strip steak ball tip boudin shank, turducken leberkas pork chop beef ribs ham hock sausage
+ frankfurter prosciutto doner ham. Bacon landjaeger ball tip, andouille chuck beef ribs jowl
+ kevin tri-tip turkey biltong frankfurter sausage. Boudin pork belly meatloaf chicken cow
+ tri-tip kielbasa shoulder. Pork loin pig boudin hamburger pastrami short ribs. Sirloin
+ tongue pork loin chicken spare ribs bresaola pastrami.\n\n
+ Tenderloin turducken pork chop, pork belly beef ribs brisket ham. Turducken landjaeger short
+ loin capicola pancetta pork chop strip steak rump meatloaf brisket kevin doner short ribs
+ salami. Beef prosciutto flank leberkas landjaeger swine. Fatback prosciutto sausage, jerky
+ tail tongue hamburger jowl biltong shank pork belly swine filet mignon chicken ground round.
+ Pork chop porchetta ground round tri-tip tail t-bone.\n\n
+ Landjaeger rump bacon salami sausage pork loin pig brisket strip steak corned beef. Biltong
+ sirloin meatloaf ribeye, bresaola cow chicken t-bone frankfurter andouille strip steak jerky
+ capicola. Ribeye porchetta strip steak boudin. Kielbasa cow brisket pastrami ball tip
+ tenderloin bresaola ham. Biltong andouille chuck ham hock jerky beef chicken, flank shankle
+ ball tip venison porchetta kevin fatback kielbasa. Boudin tongue ground round, turkey pork
+ belly salami corned beef pork tri-tip meatloaf sausage andouille strip steak pig. Spare ribs
+ beef meatloaf rump sausage doner frankfurter.\n\n
+ Fatback porchetta pork loin meatball, turducken pork chop drumstick boudin. Kevin tri-tip
+ ground round corned beef, ribeye swine filet mignon salami pork spare ribs pork chop
+ brisket. Filet mignon shankle t-bone bacon. Turducken capicola turkey porchetta kielbasa
+ shank pork loin jerky venison tenderloin boudin ham hock ground round.</string>
+
+ <string name="image_header">%1$s by %2$s</string>
+
+</resources>
\ No newline at end of file
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/tests/AndroidManifest.xml b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/tests/AndroidManifest.xml
new file mode 100644
index 0000000..99605ee
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/tests/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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 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.activityscenetransitionbasic.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="18"
+ android:targetSdkVersion="19" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.example.android.activityscenetransitionbasic"
+ android:label="Tests for com.example.android.activityscenetransitionbasic" />
+
+</manifest>
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/tests/src/com/example/android/activityscenetransitionbasic/tests/SampleTests.java b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/tests/src/com/example/android/activityscenetransitionbasic/tests/SampleTests.java
new file mode 100644
index 0000000..f06d1ae
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/Application/tests/src/com/example/android/activityscenetransitionbasic/tests/SampleTests.java
@@ -0,0 +1,61 @@
+/*
+ * 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.activityscenetransitionbasic.tests;
+
+import com.example.android.activityscenetransitionbasic.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+* Tests for ActivitySceneTransitionBasic sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+ private ActivitySceneTransitionBasicFragment mTestFragment;
+
+ public SampleTests() {
+ super(MainActivity.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 = (ActivitySceneTransitionBasicFragment)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Add more tests below.
+ */
+
+}
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/build.gradle b/ui/activityscenetransition/ActivitySceneTransitionBasic/build.gradle
new file mode 100644
index 0000000..be1fa82
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+// 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/ui/activityscenetransition/ActivitySceneTransitionBasic/buildSrc/build.gradle b/ui/activityscenetransition/ActivitySceneTransitionBasic/buildSrc/build.gradle
new file mode 100644
index 0000000..e344a8c
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/ui/activityscenetransition/ActivitySceneTransitionBasic/gradle/wrapper/gradle-wrapper.jar b/ui/activityscenetransition/ActivitySceneTransitionBasic/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/gradle/wrapper/gradle-wrapper.properties b/ui/activityscenetransition/ActivitySceneTransitionBasic/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..eca7f2f
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Fri Jun 13 16:21:29 BST 2014
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/gradlew b/ui/activityscenetransition/ActivitySceneTransitionBasic/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/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/ui/activityscenetransition/ActivitySceneTransitionBasic/gradlew.bat b/ui/activityscenetransition/ActivitySceneTransitionBasic/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/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/ui/activityscenetransition/ActivitySceneTransitionBasic/settings.gradle b/ui/activityscenetransition/ActivitySceneTransitionBasic/settings.gradle
new file mode 100644
index 0000000..363009d
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'ActivitySceneTransitionBasicSample'
diff --git a/ui/activityscenetransition/ActivitySceneTransitionBasic/template-params.xml b/ui/activityscenetransition/ActivitySceneTransitionBasic/template-params.xml
new file mode 100644
index 0000000..2300e5a
--- /dev/null
+++ b/ui/activityscenetransition/ActivitySceneTransitionBasic/template-params.xml
@@ -0,0 +1,44 @@
+<?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>ActivitySceneTransitionBasic</name>
+ <group>UI</group>
+ <package>com.example.android.activityscenetransitionbasic</package>
+
+ <minSdk>L</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+
+ <dependency_external>'libs/volley.jar'</dependency_external>
+
+ <strings>
+ <intro>
+ <![CDATA[
+ Demonstrates how to the use Activity scene transitions when transitions
+ from one Activity to another. Uses a combination of moveImage and changeBounds
+ to nicely transition a grid of images to an Activity with a large image and detail
+ text.
+ ]]>
+ </intro>
+ </strings>
+
+ <template src="base"/>
+ <common src="logger"/>
+
+</sample>
diff --git a/ui/graphics/PdfRendererBasic/Application/.gitignore b/ui/graphics/PdfRendererBasic/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/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/ui/graphics/PdfRendererBasic/Application/README-fragmentview.txt b/ui/graphics/PdfRendererBasic/Application/README-fragmentview.txt
new file mode 100644
index 0000000..38d903f
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/README-fragmentview.txt
@@ -0,0 +1,37 @@
+<!--
+ 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.
+-->
+
+Steps to implement FragmentView template:
+-in template-params.xml.ftl:
+ -add the following line to common imports
+ <common src="activities"/>
+
+-Add a Fragment to show behavior. In your MainActivity.java class, it will reference a Fragment
+ called (yourProjectName)Fragment.java. Create that file in your project, using the "main" source
+ folder instead of "common" or "templates".
+ For instance, if your package name is com.example.foo, create the file
+ src/main/java/com/example/foo/FooFragment.java
+
+
+-Within this fragment, make sure that the onCreate method has the line
+ "setHasOptionsMenu(true);", to enable the fragment to handle menu events.
+
+-In order to override menu events, override onOptionsItemSelected.
+
+-refer to sampleSamples/fragmentViewSample for a reference implementation of a
+project built on this template.
+
+
diff --git a/ui/graphics/PdfRendererBasic/Application/proguard-project.txt b/ui/graphics/PdfRendererBasic/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/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/ui/graphics/PdfRendererBasic/Application/src/main/AndroidManifest.xml b/ui/graphics/PdfRendererBasic/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..59d187d
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,40 @@
+<?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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.pdfrendererbasic"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L" />
+
+ <application android:allowBackup="true"
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher"
+ android:theme="@style/AppTheme">
+
+ <activity android:name=".MainActivity"
+ 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/ui/graphics/PdfRendererBasic/Application/src/main/assets/sample.pdf b/ui/graphics/PdfRendererBasic/Application/src/main/assets/sample.pdf
new file mode 100644
index 0000000..73f68b1
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/assets/sample.pdf
Binary files differ
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/java/com/example/android/pdfrendererbasic/MainActivity.java b/ui/graphics/PdfRendererBasic/Application/src/main/java/com/example/android/pdfrendererbasic/MainActivity.java
new file mode 100644
index 0000000..54cb54d
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/java/com/example/android/pdfrendererbasic/MainActivity.java
@@ -0,0 +1,56 @@
+/*
+ * 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.pdfrendererbasic;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
+public class MainActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main_real);
+ if (savedInstanceState == null) {
+ getFragmentManager().beginTransaction()
+ .add(R.id.container, new PdfRendererBasicFragment())
+ .commit();
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_info:
+ new AlertDialog.Builder(this)
+ .setMessage(R.string.intro_message)
+ .setPositiveButton(android.R.string.ok, null)
+ .show();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/java/com/example/android/pdfrendererbasic/PdfRendererBasicFragment.java b/ui/graphics/PdfRendererBasic/Application/src/main/java/com/example/android/pdfrendererbasic/PdfRendererBasicFragment.java
new file mode 100644
index 0000000..2d8cf60
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/java/com/example/android/pdfrendererbasic/PdfRendererBasicFragment.java
@@ -0,0 +1,212 @@
+/*
+ * 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.pdfrendererbasic;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.pdf.PdfRenderer;
+import android.os.Bundle;
+import android.os.ParcelFileDescriptor;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+import java.io.IOException;
+
+/**
+ * This fragment has a big {@ImageView} that shows PDF pages, and 2 {@link android.widget.Button}s to move between
+ * pages. We use a {@link android.graphics.pdf.PdfRenderer} to render PDF pages as {@link android.graphics.Bitmap}s.
+ */
+public class PdfRendererBasicFragment extends Fragment implements View.OnClickListener {
+
+ /**
+ * Key string for saving the state of current page index.
+ */
+ private static final String STATE_CURRENT_PAGE_INDEX = "current_page_index";
+
+ /**
+ * File descriptor of the PDF.
+ */
+ private ParcelFileDescriptor mFileDescriptor;
+
+ /**
+ * {@link android.graphics.pdf.PdfRenderer} to render the PDF.
+ */
+ private PdfRenderer mPdfRenderer;
+
+ /**
+ * Page that is currently shown on the screen.
+ */
+ private PdfRenderer.Page mCurrentPage;
+
+ /**
+ * {@link android.widget.ImageView} that shows a PDF page as a {@link android.graphics.Bitmap}
+ */
+ private ImageView mImageView;
+
+ /**
+ * {@link android.widget.Button} to move to the previous page.
+ */
+ private Button mButtonPrevious;
+
+ /**
+ * {@link android.widget.Button} to move to the next page.
+ */
+ private Button mButtonNext;
+
+ public PdfRendererBasicFragment() {
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.fragment_pdf_renderer_basic, container, false);
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ // Retain view references.
+ mImageView = (ImageView) view.findViewById(R.id.image);
+ mButtonPrevious = (Button) view.findViewById(R.id.previous);
+ mButtonNext = (Button) view.findViewById(R.id.next);
+ // Bind events.
+ mButtonPrevious.setOnClickListener(this);
+ mButtonNext.setOnClickListener(this);
+ // Show the first page by default.
+ int index = 0;
+ // If there is a savedInstanceState (screen orientations, etc.), we restore the page index.
+ if (null != savedInstanceState) {
+ index = savedInstanceState.getInt(STATE_CURRENT_PAGE_INDEX, 0);
+ }
+ showPage(index);
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ try {
+ openRenderer(activity);
+ } catch (IOException e) {
+ e.printStackTrace();
+ Toast.makeText(activity, "Error! " + e.getMessage(), Toast.LENGTH_SHORT).show();
+ activity.finish();
+ }
+ }
+
+ @Override
+ public void onDetach() {
+ try {
+ closeRenderer();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ super.onDetach();
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ if (null != mCurrentPage) {
+ outState.putInt(STATE_CURRENT_PAGE_INDEX, mCurrentPage.getIndex());
+ }
+ }
+
+ /**
+ * Sets up a {@link android.graphics.pdf.PdfRenderer} and related resources.
+ */
+ private void openRenderer(Context context) throws IOException {
+ // In this sample, we read a PDF from the assets directory.
+ mFileDescriptor = context.getAssets().openFd("sample.pdf").getParcelFileDescriptor();
+ // This is the PdfRenderer we use to render the PDF.
+ mPdfRenderer = new PdfRenderer(mFileDescriptor);
+ }
+
+ /**
+ * Closes the {@link android.graphics.pdf.PdfRenderer} and related resources.
+ *
+ * @throws java.io.IOException When the PDF file cannot be closed.
+ */
+ private void closeRenderer() throws IOException {
+ if (null != mCurrentPage) {
+ mCurrentPage.close();
+ }
+ mPdfRenderer.close();
+ mFileDescriptor.close();
+ }
+
+ /**
+ * Shows the specified page of PDF to the screen.
+ *
+ * @param index The page index.
+ */
+ private void showPage(int index) {
+ if (mPdfRenderer.getPageCount() <= index) {
+ return;
+ }
+ // Make sure to close the current page before opening another one.
+ if (null != mCurrentPage) {
+ mCurrentPage.close();
+ }
+ // Use `openPage` to open a specific page in PDF.
+ mCurrentPage = mPdfRenderer.openPage(index);
+ // Important: the destination bitmap must be ARGB (not RGB).
+ Bitmap bitmap = Bitmap.createBitmap(mCurrentPage.getWidth(), mCurrentPage.getHeight(),
+ Bitmap.Config.ARGB_8888);
+ // Here, we render the page onto the Bitmap.
+ // To render a portion of the page, use the second and third parameter. Pass nulls to get
+ // the default result.
+ // Pass either RENDER_MODE_FOR_DISPLAY or RENDER_MODE_FOR_PRINT for the last parameter.
+ mCurrentPage.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
+ // We are ready to show the Bitmap to user.
+ mImageView.setImageBitmap(bitmap);
+ updateUi();
+ }
+
+ /**
+ * Updates the state of 2 control buttons in response to the current page index.
+ */
+ private void updateUi() {
+ int index = mCurrentPage.getIndex();
+ int pageCount = mPdfRenderer.getPageCount();
+ mButtonPrevious.setEnabled(0 != index);
+ mButtonNext.setEnabled(index + 1 < pageCount);
+ getActivity().setTitle(getString(R.string.app_name_with_index, index + 1, pageCount));
+ }
+
+ @Override
+ public void onClick(View view) {
+ switch (view.getId()) {
+ case R.id.previous: {
+ // Move to the previous page
+ showPage(mCurrentPage.getIndex() - 1);
+ break;
+ }
+ case R.id.next: {
+ // Move to the next page
+ showPage(mCurrentPage.getIndex() + 1);
+ break;
+ }
+ }
+ }
+
+}
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-hdpi/ic_action_info.png b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-hdpi/ic_action_info.png
new file mode 100644
index 0000000..32bd1aa
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-hdpi/ic_action_info.png
Binary files differ
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..0c9b694
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-mdpi/ic_action_info.png b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-mdpi/ic_action_info.png
new file mode 100644
index 0000000..8efbbf8
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-mdpi/ic_action_info.png
Binary files differ
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..1a6c3d0
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xhdpi/ic_action_info.png b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xhdpi/ic_action_info.png
new file mode 100644
index 0000000..ba143ea
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xhdpi/ic_action_info.png
Binary files differ
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..2081f40
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xxhdpi/ic_action_info.png b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xxhdpi/ic_action_info.png
new file mode 100644
index 0000000..394eb7e
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xxhdpi/ic_action_info.png
Binary files differ
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..b506de4
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/layout/activity_main_real.xml b/ui/graphics/PdfRendererBasic/Application/src/main/res/layout/activity_main_real.xml
new file mode 100644
index 0000000..dcd52be
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/layout/activity_main_real.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<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=".MainActivity"
+ tools:ignore="MergeRootFrame" />
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/layout/fragment_pdf_renderer_basic.xml b/ui/graphics/PdfRendererBasic/Application/src/main/res/layout/fragment_pdf_renderer_basic.xml
new file mode 100644
index 0000000..4a7799b
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/layout/fragment_pdf_renderer_basic.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ tools:context=".MainActivity$PlaceholderFragment">
+
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:background="@android:color/white"
+ android:scaleType="fitCenter" />
+
+ <LinearLayout
+ style="?android:attr/buttonBarStyle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:measureWithLargestChild="true"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/previous"
+ style="?android:attr/buttonBarButtonStyle"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/previous" />
+
+ <Button
+ android:id="@+id/next"
+ style="?android:attr/buttonBarButtonStyle"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/next" />
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/menu/main.xml b/ui/graphics/PdfRendererBasic/Application/src/main/res/menu/main.xml
new file mode 100644
index 0000000..fa452e1
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/menu/main.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@+id/action_info"
+ android:icon="@drawable/ic_action_info"
+ android:showAsAction="always"
+ android:title="@string/info" />
+
+</menu>
\ No newline at end of file
diff --git a/ui/graphics/PdfRendererBasic/Application/src/main/res/values/strings.xml b/ui/graphics/PdfRendererBasic/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..e0182fd
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/Application/src/main/res/values/strings.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<resources>
+
+ <string name="app_name_with_index">PdfRendererBasic (%1$d/%2$d)</string>
+ <string name="info">Info</string>
+ <string name="previous">Previous</string>
+ <string name="next">Next</string>
+
+</resources>
diff --git a/ui/graphics/PdfRendererBasic/build.gradle b/ui/graphics/PdfRendererBasic/build.gradle
new file mode 100644
index 0000000..be1fa82
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+// 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/ui/graphics/PdfRendererBasic/buildSrc/build.gradle b/ui/graphics/PdfRendererBasic/buildSrc/build.gradle
new file mode 100644
index 0000000..e344a8c
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/ui/graphics/PdfRendererBasic/gradle/wrapper/gradle-wrapper.jar b/ui/graphics/PdfRendererBasic/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/graphics/PdfRendererBasic/gradle/wrapper/gradle-wrapper.properties b/ui/graphics/PdfRendererBasic/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..d7f03cf
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
diff --git a/ui/graphics/PdfRendererBasic/gradlew b/ui/graphics/PdfRendererBasic/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/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/ui/graphics/PdfRendererBasic/gradlew.bat b/ui/graphics/PdfRendererBasic/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/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/ui/graphics/PdfRendererBasic/settings.gradle b/ui/graphics/PdfRendererBasic/settings.gradle
new file mode 100644
index 0000000..f34faad
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'PdfRendererBasicSample'
diff --git a/ui/graphics/PdfRendererBasic/template-params.xml b/ui/graphics/PdfRendererBasic/template-params.xml
new file mode 100644
index 0000000..b2a80ef
--- /dev/null
+++ b/ui/graphics/PdfRendererBasic/template-params.xml
@@ -0,0 +1,46 @@
+<?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>PdfRendererBasic</name>
+ <group>UI</group>
+ <package>com.example.android.pdfrendererbasic</package>
+
+
+
+ <!-- change minSdk if needed-->
+ <minSdk>21</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+
+
+ <strings>
+ <intro>
+ <![CDATA[
+ This sample demonstrates how to use PdfRenderer to display PDF documents on the screen.
+ ]]>
+ </intro>
+ </strings>
+
+ <aapt>
+ <noCompress>pdf</noCompress>
+ </aapt>
+
+ <template src="base"/>
+
+</sample>
diff --git a/ui/views/Clipping/ClippingBasic/Application/.gitignore b/ui/views/Clipping/ClippingBasic/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/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/ui/views/Clipping/ClippingBasic/Application/README-fragmentview.txt b/ui/views/Clipping/ClippingBasic/Application/README-fragmentview.txt
new file mode 100644
index 0000000..38d903f
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/README-fragmentview.txt
@@ -0,0 +1,37 @@
+<!--
+ 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.
+-->
+
+Steps to implement FragmentView template:
+-in template-params.xml.ftl:
+ -add the following line to common imports
+ <common src="activities"/>
+
+-Add a Fragment to show behavior. In your MainActivity.java class, it will reference a Fragment
+ called (yourProjectName)Fragment.java. Create that file in your project, using the "main" source
+ folder instead of "common" or "templates".
+ For instance, if your package name is com.example.foo, create the file
+ src/main/java/com/example/foo/FooFragment.java
+
+
+-Within this fragment, make sure that the onCreate method has the line
+ "setHasOptionsMenu(true);", to enable the fragment to handle menu events.
+
+-In order to override menu events, override onOptionsItemSelected.
+
+-refer to sampleSamples/fragmentViewSample for a reference implementation of a
+project built on this template.
+
+
diff --git a/ui/views/Clipping/ClippingBasic/Application/proguard-project.txt b/ui/views/Clipping/ClippingBasic/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/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/ui/views/Clipping/ClippingBasic/Application/src/main/AndroidManifest.xml b/ui/views/Clipping/ClippingBasic/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..282d089
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,40 @@
+<?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.clippingbasic"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <application android:allowBackup="true"
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher"
+ android:theme="@android:style/Theme.Material.Light">
+
+ <activity android:name=".MainActivity"
+ 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/ui/views/Clipping/ClippingBasic/Application/src/main/java/com/example/android/clippingbasic/ClippingBasicFragment.java b/ui/views/Clipping/ClippingBasic/Application/src/main/java/com/example/android/clippingbasic/ClippingBasicFragment.java
new file mode 100644
index 0000000..ef14be1
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/src/main/java/com/example/android/clippingbasic/ClippingBasicFragment.java
@@ -0,0 +1,125 @@
+/*
+ * 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.clippingbasic;
+
+import com.example.android.common.logger.Log;
+
+import android.graphics.Outline;
+import android.support.v4.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+/**
+ * This sample shows how to clip a {@link View} using an {@link Outline}.
+ */
+public class ClippingBasicFragment extends Fragment {
+
+ private final static String TAG = "ClippingBasicFragment";
+
+ /* Store the click count so that we can show a different text on every click. */
+ private int mClickCount = 0;
+
+ /* The {@Link Outline} used to clip the image with. */
+ private Outline mClip;
+
+ /* An array of texts. */
+ private String[] mSampleTexts;
+
+ /* A reference to a {@Link TextView} that shows different text strings when clicked. */
+ private TextView mTextView;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
+ mClip = new Outline();
+ mSampleTexts = getResources().getStringArray(R.array.sample_texts);
+ }
+
+ @Override
+ public View onCreateView(
+ LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.clipping_basic_fragment, container, false);
+ }
+
+ @Override
+ public void onViewCreated(final View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ /* Set the initial text for the TextView. */
+ mTextView = (TextView) view.findViewById(R.id.text_view);
+ changeText();
+
+ /* When the button is clicked, the text is clipped or un-clipped. */
+ view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View bt) {
+
+ View clippedView = view.findViewById(R.id.frame);
+
+ /* The view is already clipped if {Link View#getClipToOutline()} returns true. */
+ if (clippedView.getClipToOutline()) {
+ /* The Outline is set for the View, but disable clipping. */
+ clippedView.setClipToOutline(false);
+
+ Log.d(TAG, String.format("Clipping was removed."));
+ ((Button) bt).setText(R.string.clip_button);
+
+ } else {
+ /*
+ Sets the dimensions and shape of the {@Link Outline}. A rounded rectangle
+ with a margin determined by the width or height.
+ */
+ int margin = Math.min(clippedView.getWidth(), clippedView.getHeight()) / 10;
+ mClip.setRoundRect(margin, margin, clippedView.getWidth() - margin,
+ clippedView.getHeight() - margin, margin / 2);
+ /* Sets the Outline of the View. */
+ clippedView.setOutline(mClip);
+ /* Enables clipping on the View. */
+ clippedView.setClipToOutline(true);
+
+ Log.d(TAG, String.format("View was clipped."));
+ ((Button) bt).setText(R.string.unclip_button);
+ }
+ }
+ });
+
+ /* When the text is clicked, a new string is shown. */
+ view.findViewById(R.id.text_view).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mClickCount++;
+ changeText();
+ }
+ });
+ }
+
+ private void changeText() {
+ /*
+ Compute the position of the string in the array using the number of strings
+ and the number of clicks.
+ */
+ String newText = mSampleTexts[mClickCount % mSampleTexts.length];
+
+ /* Once the text is selected, change the TextView */
+ mTextView.setText(newText);
+ Log.d(TAG, String.format("Text was changed."));
+ }
+}
\ No newline at end of file
diff --git a/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png b/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..d79207b
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png b/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..3ee83ad
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..3b1ae0a
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..64b728d
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable/gradient_drawable.xml b/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable/gradient_drawable.xml
new file mode 100644
index 0000000..c6377cc
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/src/main/res/drawable/gradient_drawable.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <gradient
+ android:startColor="#95C7D8"
+ android:endColor="#607D8B"
+ android:angle="270"/>
+</shape>
\ No newline at end of file
diff --git a/ui/views/Clipping/ClippingBasic/Application/src/main/res/layout/clipping_basic_fragment.xml b/ui/views/Clipping/ClippingBasic/Application/src/main/res/layout/clipping_basic_fragment.xml
new file mode 100644
index 0000000..44efedc
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/src/main/res/layout/clipping_basic_fragment.xml
@@ -0,0 +1,50 @@
+<?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="match_parent">
+
+
+ <FrameLayout
+ android:id="@+id/frame"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/gradient_drawable"
+ android:foreground="?android:attr/selectableItemBackground"
+ android:addStatesFromChildren="true"
+ android:layout_above="@+id/button" >
+ <TextView
+ android:id="@+id/text_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:textSize="26sp"
+ android:textColor="@android:color/white"
+ android:layout_marginLeft="64dp"
+ android:layout_marginRight="64dp"
+ android:gravity="center" />
+ </FrameLayout>
+
+ <Button
+ android:id="@+id/button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/clip_button"
+ android:layout_alignParentBottom="true"
+ android:layout_centerHorizontal="true"
+ android:layout_marginBottom="8dp"
+ android:layout_marginTop="8dp"/>
+</RelativeLayout>
\ No newline at end of file
diff --git a/ui/views/Clipping/ClippingBasic/Application/src/main/res/values/strings.xml b/ui/views/Clipping/ClippingBasic/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..e9cc40d
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/src/main/res/values/strings.xml
@@ -0,0 +1,26 @@
+<?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-array name="sample_texts">
+ <item>Lorem ipsum dolor sit amet, duo numquam nominavi consectetuer at.</item>
+ <item>Vivendo philosophia mea et. Duo te idque appetere.</item>
+ <item>De finibus bonorum et malorum.</item>
+ </string-array>
+
+ <string name="clip_button">Clip</string>
+ <string name="unclip_button">Remove Clipping</string>
+</resources>
\ No newline at end of file
diff --git a/ui/views/Clipping/ClippingBasic/Application/tests/AndroidManifest.xml b/ui/views/Clipping/ClippingBasic/Application/tests/AndroidManifest.xml
new file mode 100644
index 0000000..ea04c40
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/tests/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?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.
+-->
+<!-- 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.clippingbasic.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="18"
+ android:targetSdkVersion="19" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.example.android.clippingbasic"
+ android:label="Tests for com.example.android.clippingbasic" />
+
+</manifest>
\ No newline at end of file
diff --git a/ui/views/Clipping/ClippingBasic/Application/tests/src/com/example/android/clippingbasic/tests/SampleTests.java b/ui/views/Clipping/ClippingBasic/Application/tests/src/com/example/android/clippingbasic/tests/SampleTests.java
new file mode 100644
index 0000000..69d40b2
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/Application/tests/src/com/example/android/clippingbasic/tests/SampleTests.java
@@ -0,0 +1,74 @@
+/*
+* 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.clippingbasic.tests;
+
+import com.example.android.clippingbasic.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.TouchUtils;
+import android.view.View;
+
+/**
+* Tests for ClippingBasic sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+ private ClippingBasicFragment mTestFragment;
+
+ public SampleTests() {
+ super(MainActivity.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 = (ClippingBasicFragment)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+ }
+
+ /**
+ * Test if the test fixture has been set up correctly.
+ */
+ public void testPreconditions() {
+ assertNotNull("mTestActivity is null", mTestActivity);
+ assertNotNull("mTestFragment is null", mTestFragment);
+ assertNotNull("Clipped frame is null", mTestActivity.findViewById(R.id.frame));
+ assertNotNull("Text view is null", mTestActivity.findViewById(R.id.text_view));
+ }
+
+ /**
+ * Triggers a click on the button and tests if the view is clipped afterwards.
+ */
+ public void testClipping() {
+ View clippedView = mTestActivity.findViewById(R.id.frame);
+
+ // Initially, the view is not clipped.
+ assertFalse(clippedView.getClipToOutline());
+
+ // Trigger a click on the button to activate clipping.
+ TouchUtils.clickView(this, mTestActivity.findViewById(R.id.button));
+
+ // Check that the view has been clipped.
+ assertTrue(clippedView.getClipToOutline());
+ }
+}
\ No newline at end of file
diff --git a/ui/views/Clipping/ClippingBasic/build.gradle b/ui/views/Clipping/ClippingBasic/build.gradle
new file mode 100644
index 0000000..cda9c5c
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+// 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/ui/views/Clipping/ClippingBasic/buildSrc/build.gradle b/ui/views/Clipping/ClippingBasic/buildSrc/build.gradle
new file mode 100644
index 0000000..81f445f
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/ui/views/Clipping/ClippingBasic/gradle/wrapper/gradle-wrapper.jar b/ui/views/Clipping/ClippingBasic/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/views/Clipping/ClippingBasic/gradle/wrapper/gradle-wrapper.properties b/ui/views/Clipping/ClippingBasic/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..d7f03cf
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
diff --git a/ui/views/Clipping/ClippingBasic/gradlew b/ui/views/Clipping/ClippingBasic/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/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/ui/views/Clipping/ClippingBasic/gradlew.bat b/ui/views/Clipping/ClippingBasic/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/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/ui/views/Clipping/ClippingBasic/settings.gradle b/ui/views/Clipping/ClippingBasic/settings.gradle
new file mode 100644
index 0000000..670e715
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'ClippingBasicSample'
diff --git a/ui/views/Clipping/ClippingBasic/template-params.xml b/ui/views/Clipping/ClippingBasic/template-params.xml
new file mode 100644
index 0000000..ff3c647
--- /dev/null
+++ b/ui/views/Clipping/ClippingBasic/template-params.xml
@@ -0,0 +1,43 @@
+<?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.
+-->
+
+
+
+<sample>
+ <name>ClippingBasic</name>
+ <group>UI</group>
+ <package>com.example.android.clippingbasic</package>
+
+
+ <minSdk>19</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+
+
+ <strings>
+ <intro>
+ <![CDATA[
+ Basic sample to demonstrate clipping on a View.
+ ]]>
+ </intro>
+ </strings>
+
+ <template src="base"/>
+ <template src="FragmentView"/>
+ <common src="logger"/>
+ <common src="activities"/>
+
+</sample>
diff --git a/ui/views/Elevation/ElevationBasic/Application/.gitignore b/ui/views/Elevation/ElevationBasic/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/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/ui/views/Elevation/ElevationBasic/Application/README-fragmentview.txt b/ui/views/Elevation/ElevationBasic/Application/README-fragmentview.txt
new file mode 100644
index 0000000..38d903f
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/README-fragmentview.txt
@@ -0,0 +1,37 @@
+<!--
+ 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.
+-->
+
+Steps to implement FragmentView template:
+-in template-params.xml.ftl:
+ -add the following line to common imports
+ <common src="activities"/>
+
+-Add a Fragment to show behavior. In your MainActivity.java class, it will reference a Fragment
+ called (yourProjectName)Fragment.java. Create that file in your project, using the "main" source
+ folder instead of "common" or "templates".
+ For instance, if your package name is com.example.foo, create the file
+ src/main/java/com/example/foo/FooFragment.java
+
+
+-Within this fragment, make sure that the onCreate method has the line
+ "setHasOptionsMenu(true);", to enable the fragment to handle menu events.
+
+-In order to override menu events, override onOptionsItemSelected.
+
+-refer to sampleSamples/fragmentViewSample for a reference implementation of a
+project built on this template.
+
+
diff --git a/ui/views/Elevation/ElevationBasic/Application/README-singleview.txt b/ui/views/Elevation/ElevationBasic/Application/README-singleview.txt
new file mode 100644
index 0000000..0cacd46
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/README-singleview.txt
@@ -0,0 +1,47 @@
+<#--
+ 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.
+-->
+
+Steps to implement SingleView template:
+-in template-params.xml.ftl:
+ -add the following line to common imports
+ <common src="activities"/>
+
+ -add a string for the action button's text using the element name "sample_action".
+ This element should be a child of <strings>:
+ <strings>
+ ...
+ <sample_action>ButtonText</sample_action>
+ ...
+ </strings>
+
+
+
+-Add a Fragment to handle behavior. In your MainActivity.java class, it will reference a Fragment
+ called (yourProjectName)Fragment.java. Create that file in your project, using the "main" source
+ folder instead of "common" or "templates".
+ For instance, if your package name is com.example.foo, create the file
+ src/main/java/com/example/foo/FooFragment.java
+
+
+-Within this fragment, make sure that the onCreate method has the line
+ "setHasOptionsMenu(true);", to enable the fragment to handle menu events.
+
+-In order to override menu events, override onOptionsItemSelected.
+
+-refer to sampleSamples/singleViewSample for a reference implementation of a
+project built on this template.
+
+
diff --git a/ui/views/Elevation/ElevationBasic/Application/proguard-project.txt b/ui/views/Elevation/ElevationBasic/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/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/ui/views/Elevation/ElevationBasic/Application/src/main/AndroidManifest.xml b/ui/views/Elevation/ElevationBasic/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..a70cd85
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,40 @@
+<?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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.elevationbasic"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+
+ <application android:allowBackup="true"
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher"
+ android:theme="@android:style/Theme.Material.Light">
+
+ <activity android:name=".MainActivity"
+ android:label="@string/app_name"
+ android:uiOptions="splitActionBarWhenNarrow">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+
+</manifest>
diff --git a/ui/views/Elevation/ElevationBasic/Application/src/main/java/com/example/android/elevationbasic/ElevationBasicFragment.java b/ui/views/Elevation/ElevationBasic/Application/src/main/java/com/example/android/elevationbasic/ElevationBasicFragment.java
new file mode 100644
index 0000000..71edea5
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/src/main/java/com/example/android/elevationbasic/ElevationBasicFragment.java
@@ -0,0 +1,75 @@
+/*
+ * 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.elevationbasic;
+
+import android.support.v4.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.example.android.common.logger.Log;
+
+public class ElevationBasicFragment extends Fragment {
+
+ private final static String TAG = "ElevationBasicFragment";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public View onCreateView(
+ LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ /**
+ * Inflates an XML containing two shapes: the first has a fixed elevation
+ * and the second ones raises when tapped.
+ */
+ View rootView = inflater.inflate(R.layout.elevation_basic, container, false);
+
+ View shape2 = rootView.findViewById(R.id.floating_shape_2);
+
+ /**
+ * Sets a {@Link View.OnTouchListener} that responds to a touch event on shape2.
+ */
+ shape2.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View view, MotionEvent motionEvent) {
+ int action = motionEvent.getActionMasked();
+ /* Raise view on ACTION_DOWN and lower it on ACTION_UP. */
+ switch (action) {
+ case MotionEvent.ACTION_DOWN:
+ Log.d(TAG, "ACTION_DOWN on view.");
+ view.setTranslationZ(120);
+ break;
+ case MotionEvent.ACTION_UP:
+ Log.d(TAG, "ACTION_UP on view.");
+ view.setTranslationZ(0);
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+ });
+ return rootView;
+ }
+}
\ No newline at end of file
diff --git a/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..c28e40d
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..71738ff
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..788ac1f
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..72359c3
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable/shape.xml b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable/shape.xml
new file mode 100644
index 0000000..22ffe05
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable/shape.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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="oval">
+ <solid android:color="@color/color_1" />
+</shape>
\ No newline at end of file
diff --git a/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable/shape2.xml b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable/shape2.xml
new file mode 100644
index 0000000..7060f58
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/src/main/res/drawable/shape2.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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@color/color_2" />
+</shape>
\ No newline at end of file
diff --git a/ui/views/Elevation/ElevationBasic/Application/src/main/res/layout/elevation_basic.xml b/ui/views/Elevation/ElevationBasic/Application/src/main/res/layout/elevation_basic.xml
new file mode 100644
index 0000000..83ab1d2
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/src/main/res/layout/elevation_basic.xml
@@ -0,0 +1,38 @@
+<?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:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <View
+ android:id="@+id/floating_shape"
+ android:layout_width="80dp"
+ android:layout_height="80dp"
+ android:layout_marginRight="40dp"
+ android:background="@drawable/shape"
+ android:elevation="30dp"
+ android:layout_gravity="center"/>
+ <View
+ android:id="@+id/floating_shape_2"
+ android:layout_width="80dp"
+ android:layout_height="80dp"
+ android:layout_marginLeft="25dp"
+ android:background="@drawable/shape2"
+ android:layout_gravity="center"/>
+</FrameLayout>
+
diff --git a/ui/views/Elevation/ElevationBasic/Application/src/main/res/values/colors.xml b/ui/views/Elevation/ElevationBasic/Application/src/main/res/values/colors.xml
new file mode 100644
index 0000000..b5782df
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/src/main/res/values/colors.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>
+ <color name="color_1">#E91E63</color>
+ <color name="color_2">#673AB7</color>
+</resources>
diff --git a/ui/views/Elevation/ElevationBasic/Application/tests/AndroidManifest.xml b/ui/views/Elevation/ElevationBasic/Application/tests/AndroidManifest.xml
new file mode 100644
index 0000000..84b80b1
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/tests/AndroidManifest.xml
@@ -0,0 +1,43 @@
+<?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.
+-->
+
+<!-- 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.elevationbasic.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="19"
+ android:targetSdkVersion="19" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.example.android.elevationbasic"
+ android:label="Tests for com.example.android.elevationbasic" />
+
+</manifest>
\ No newline at end of file
diff --git a/ui/views/Elevation/ElevationBasic/Application/tests/src/com/example/android/elevationbasic/tests/SampleTests.java b/ui/views/Elevation/ElevationBasic/Application/tests/src/com/example/android/elevationbasic/tests/SampleTests.java
new file mode 100644
index 0000000..0da03c6
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/Application/tests/src/com/example/android/elevationbasic/tests/SampleTests.java
@@ -0,0 +1,70 @@
+/*
+* 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.elevationbasic.tests;
+
+import com.example.android.elevationbasic.ElevationBasicFragment;
+import com.example.android.elevationbasic.MainActivity;
+import com.example.android.elevationbasic.R;
+
+import android.test.ActivityInstrumentationTestCase2;
+import android.view.View;
+
+/**
+* Tests for ElevationBasic sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+ private ElevationBasicFragment mTestFragment;
+
+ private View mShape1;
+ private View mShape2;
+
+ public SampleTests() {
+ super(MainActivity.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 = (ElevationBasicFragment)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+ mShape1 = mTestActivity.findViewById(R.id.floating_shape);
+ mShape2 = mTestActivity.findViewById(R.id.floating_shape_2);
+ }
+
+ /**
+ * Test if the test fixture has been set up correctly.
+ */
+ public void testPreconditions() {
+ assertNotNull("mTestActivity is null", mTestActivity);
+ assertNotNull("mTestFragment is null", mTestFragment);
+ }
+
+ /**
+ * Test if the initial Z values of the shapes are correct.
+ */
+ public void testInitialShapeZ() {
+ assertTrue(mShape1.getZ() > 0f);
+ assertEquals(mShape2.getZ(), 0f);
+ }
+}
\ No newline at end of file
diff --git a/ui/views/Elevation/ElevationBasic/build.gradle b/ui/views/Elevation/ElevationBasic/build.gradle
new file mode 100644
index 0000000..cda9c5c
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+// 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/ui/views/Elevation/ElevationBasic/buildSrc/build.gradle b/ui/views/Elevation/ElevationBasic/buildSrc/build.gradle
new file mode 100644
index 0000000..81f445f
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/ui/views/Elevation/ElevationBasic/gradle/wrapper/gradle-wrapper.jar b/ui/views/Elevation/ElevationBasic/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/views/Elevation/ElevationBasic/gradle/wrapper/gradle-wrapper.properties b/ui/views/Elevation/ElevationBasic/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..fe5a0cf
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon May 19 15:36:48 BST 2014
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
diff --git a/ui/views/Elevation/ElevationBasic/gradlew b/ui/views/Elevation/ElevationBasic/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/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/ui/views/Elevation/ElevationBasic/gradlew.bat b/ui/views/Elevation/ElevationBasic/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/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/ui/views/Elevation/ElevationBasic/settings.gradle b/ui/views/Elevation/ElevationBasic/settings.gradle
new file mode 100644
index 0000000..99cb553
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'ElevationBasicSample'
diff --git a/ui/views/Elevation/ElevationBasic/template-params.xml b/ui/views/Elevation/ElevationBasic/template-params.xml
new file mode 100644
index 0000000..a868968
--- /dev/null
+++ b/ui/views/Elevation/ElevationBasic/template-params.xml
@@ -0,0 +1,48 @@
+<?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>ElevationBasic</name>
+ <group>NoGroup</group>
+ <package>com.example.android.elevationbasic</package>
+
+
+
+ <!-- change minSdk if needed-->
+ <minSdk>19</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+
+
+ <strings>
+ <intro>
+ <![CDATA[
+ This sample demonstrates two alternative ways to move a view in the z-axis. The
+ first view has a fixed elevation using XML and the second one is raised when the user
+ taps on it, using setTranslationZ().
+ ]]>
+ </intro>
+ <sample_action>Elevation Basic</sample_action>
+ </strings>
+
+ <template src="base"/>
+ <template src="FragmentView"/>
+ <common src="logger"/>
+ <common src="activities"/>
+
+</sample>
diff --git a/ui/views/Elevation/ElevationDrag/Application/.gitignore b/ui/views/Elevation/ElevationDrag/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/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/ui/views/Elevation/ElevationDrag/Application/README-fragmentview.txt b/ui/views/Elevation/ElevationDrag/Application/README-fragmentview.txt
new file mode 100644
index 0000000..38d903f
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/README-fragmentview.txt
@@ -0,0 +1,37 @@
+<!--
+ 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.
+-->
+
+Steps to implement FragmentView template:
+-in template-params.xml.ftl:
+ -add the following line to common imports
+ <common src="activities"/>
+
+-Add a Fragment to show behavior. In your MainActivity.java class, it will reference a Fragment
+ called (yourProjectName)Fragment.java. Create that file in your project, using the "main" source
+ folder instead of "common" or "templates".
+ For instance, if your package name is com.example.foo, create the file
+ src/main/java/com/example/foo/FooFragment.java
+
+
+-Within this fragment, make sure that the onCreate method has the line
+ "setHasOptionsMenu(true);", to enable the fragment to handle menu events.
+
+-In order to override menu events, override onOptionsItemSelected.
+
+-refer to sampleSamples/fragmentViewSample for a reference implementation of a
+project built on this template.
+
+
diff --git a/ui/views/Elevation/ElevationDrag/Application/proguard-project.txt b/ui/views/Elevation/ElevationDrag/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/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/ui/views/Elevation/ElevationDrag/Application/src/main/AndroidManifest.xml b/ui/views/Elevation/ElevationDrag/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..9fd7d53
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,40 @@
+<?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.
+-->
+
+
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.elevationdrag"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <application android:allowBackup="true"
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher"
+ android:theme="@android:style/Theme.Material.Light" >
+
+ <activity android:name=".MainActivity"
+ 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/ui/views/Elevation/ElevationDrag/Application/src/main/java/com/example/android/elevationdrag/DragFrameLayout.java b/ui/views/Elevation/ElevationDrag/Application/src/main/java/com/example/android/elevationdrag/DragFrameLayout.java
new file mode 100644
index 0000000..0b2a8d2
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/java/com/example/android/elevationdrag/DragFrameLayout.java
@@ -0,0 +1,143 @@
+/*
+ * 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.elevationdrag;
+
+import android.content.Context;
+import android.support.v4.widget.ViewDragHelper;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.FrameLayout;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A {@link FrameLayout} that allows the user to drag and reposition child views.
+ */
+public class DragFrameLayout extends FrameLayout {
+
+ /**
+ * The list of {@link View}s that will be draggable.
+ */
+ private List<View> mDragViews;
+
+ /**
+ * The {@link DragFrameLayoutController} that will be notify on drag.
+ */
+ private DragFrameLayoutController mDragFrameLayoutController;
+
+ private ViewDragHelper mDragHelper;
+
+ public DragFrameLayout(Context context) {
+ this(context, null, 0, 0);
+ }
+
+ public DragFrameLayout(Context context, AttributeSet attrs) {
+ this(context, attrs, 0, 0);
+ }
+
+ public DragFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
+ this(context, attrs, defStyleAttr, 0);
+ }
+
+ public DragFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ mDragViews = new ArrayList<View>();
+
+ /**
+ * Create the {@link ViewDragHelper} and set its callback.
+ */
+ mDragHelper = ViewDragHelper.create(this, 1.0f, new ViewDragHelper.Callback() {
+ @Override
+ public boolean tryCaptureView(View child, int pointerId) {
+ return mDragViews.contains(child);
+ }
+
+ @Override
+ public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
+ super.onViewPositionChanged(changedView, left, top, dx, dy);
+ }
+
+ @Override
+ public int clampViewPositionHorizontal(View child, int left, int dx) {
+ return left;
+ }
+
+ @Override
+ public int clampViewPositionVertical(View child, int top, int dy) {
+ return top;
+ }
+
+ @Override
+ public void onViewCaptured(View capturedChild, int activePointerId) {
+ super.onViewCaptured(capturedChild, activePointerId);
+ if (mDragFrameLayoutController != null) {
+ mDragFrameLayoutController.onDragDrop(true);
+ }
+ }
+
+ @Override
+ public void onViewReleased(View releasedChild, float xvel, float yvel) {
+ super.onViewReleased(releasedChild, xvel, yvel);
+ if (mDragFrameLayoutController != null) {
+ mDragFrameLayoutController.onDragDrop(false);
+ }
+ }
+ });
+ }
+
+ @Override
+ public boolean onInterceptTouchEvent(MotionEvent ev) {
+ final int action = ev.getActionMasked();
+ if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
+ mDragHelper.cancel();
+ return false;
+ }
+ return mDragHelper.shouldInterceptTouchEvent(ev);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent ev) {
+ mDragHelper.processTouchEvent(ev);
+ return true;
+ }
+
+ /**
+ * Adds a new {@link View} to the list of views that are draggable within the container.
+ * @param dragView the {@link View} to make draggable
+ */
+ public void addDragView(View dragView) {
+ mDragViews.add(dragView);
+ }
+
+ /**
+ * Sets the {@link DragFrameLayoutController} that will receive the drag events.
+ * @param dragFrameLayoutController a {@link DragFrameLayoutController}
+ */
+ public void setDragFrameController(DragFrameLayoutController dragFrameLayoutController) {
+ mDragFrameLayoutController = dragFrameLayoutController;
+ }
+
+ /**
+ * A controller that will receive the drag events.
+ */
+ public interface DragFrameLayoutController {
+
+ public void onDragDrop(boolean captured);
+ }
+}
diff --git a/ui/views/Elevation/ElevationDrag/Application/src/main/java/com/example/android/elevationdrag/ElevationDragFragment.java b/ui/views/Elevation/ElevationDrag/Application/src/main/java/com/example/android/elevationdrag/ElevationDragFragment.java
new file mode 100644
index 0000000..4c5fc6a
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/java/com/example/android/elevationdrag/ElevationDragFragment.java
@@ -0,0 +1,164 @@
+/*
+ * 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.elevationdrag;
+
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
+import android.graphics.Outline;
+import android.graphics.Path;
+import android.support.v4.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Spinner;
+import android.widget.Toast;
+
+import com.example.android.common.logger.Log;
+
+public class ElevationDragFragment extends Fragment {
+
+ public static final String TAG = "ElevationDragFragment";
+
+ /* How much to translate each time the Z+ and Z- buttons are clicked. */
+ private static final int ELEVATION_STEP = 40;
+
+ /* Different outlines: */
+
+ private Outline mOutlineCircle;
+
+ private Outline mOutlineRect;
+
+ /* The current elevation of the floating view. */
+ private float mElevation = 0;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.ztranslation, container, false);
+
+ /* Create different outlines. */
+ createOutlines();
+
+ /* Find the {@link View} to apply z-translation to. */
+ final View floatingShape = rootView.findViewById(R.id.circle);
+
+ /* Define the shape of the {@link View}'s shadow by setting one of the {@link Outline}s. */
+ floatingShape.setOutline(mOutlineCircle);
+
+ /* Clip the {@link View} with its outline. */
+ floatingShape.setClipToOutline(true);
+
+ DragFrameLayout dragLayout = ((DragFrameLayout) rootView.findViewById(R.id.main_layout));
+
+ dragLayout.setDragFrameController(new DragFrameLayout.DragFrameLayoutController() {
+
+ @Override
+ public void onDragDrop(boolean captured) {
+ /* Animate the translation of the {@link View}. Note that the translation
+ is being modified, not the elevation. */
+ floatingShape.animate()
+ .translationZ(captured ? 50 : 0)
+ .setDuration(100);
+ Log.d(TAG, captured ? "drag" : "drop");
+ }
+ });
+
+ dragLayout.addDragView(floatingShape);
+
+ /* Raise the circle in z when the "z+" button is clicked. */
+ rootView.findViewById(R.id.raise_bt).setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ mElevation += ELEVATION_STEP;
+ Log.d(TAG, String.format("Elevation: %.1f", mElevation));
+ floatingShape.setElevation(mElevation);
+ }
+ });
+
+ /* Lower the circle in z when the "z-" button is clicked. */
+ rootView.findViewById(R.id.lower_bt).setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ mElevation -= ELEVATION_STEP;
+ // Don't allow for negative values of Z.
+ if (mElevation < 0) {
+ mElevation = 0;
+ }
+ Log.d(TAG, String.format("Elevation: %.1f", mElevation));
+ floatingShape.setElevation(mElevation);
+ }
+ });
+
+ /* Create a spinner with options to change the shape of the object. */
+ Spinner spinner = (Spinner) rootView.findViewById(R.id.shapes_spinner);
+ spinner.setAdapter(new ArrayAdapter<String>(
+ getActivity(),
+ android.R.layout.simple_spinner_dropdown_item,
+ getResources().getStringArray(R.array.shapes)));
+
+ /* Set the appropriate outline when an item is selected. */
+ spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ /* Set the corresponding Outline to the shape. */
+ switch (position) {
+ case 0:
+ floatingShape.setOutline(mOutlineCircle);
+ floatingShape.setClipToOutline(true);
+ break;
+ case 1:
+ floatingShape.setOutline(mOutlineRect);
+ floatingShape.setClipToOutline(true);
+ break;
+ default:
+ floatingShape.setOutline(mOutlineCircle);
+ /* Don't clip the view to the outline in the last case. */
+ floatingShape.setClipToOutline(false);
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+ floatingShape.setOutline(mOutlineCircle);
+ }
+ });
+
+ return rootView;
+
+ }
+
+ private void createOutlines() {
+ /* Outlines define the shape that's used for clipping the View and its shadow. */
+
+ /* Get the size of the shape from resources. */
+ int shapeSize = getResources().getDimensionPixelSize(R.dimen.shape_size);
+
+ /* Create a circular outline. */
+ mOutlineCircle = new Outline();
+ mOutlineCircle.setRoundRect(0, 0, shapeSize, shapeSize, shapeSize / 2);
+
+ /* Create a rectangular outline. */
+ mOutlineRect = new Outline();
+ mOutlineRect.setRoundRect(0, 0, shapeSize, shapeSize, shapeSize / 10);
+ }
+}
\ No newline at end of file
diff --git a/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-hdpi/ic_launcher.png b/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..8d34f6a
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-mdpi/ic_launcher.png b/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..8d9cd3e
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..09e4c8d
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..232dc77
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable/shape.xml b/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable/shape.xml
new file mode 100644
index 0000000..5392e00
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/res/drawable/shape.xml
@@ -0,0 +1,20 @@
+<?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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@color/color_1"/>
+</shape>
\ No newline at end of file
diff --git a/ui/views/Elevation/ElevationDrag/Application/src/main/res/layout/ztranslation.xml b/ui/views/Elevation/ElevationDrag/Application/src/main/res/layout/ztranslation.xml
new file mode 100644
index 0000000..9989fc4
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/res/layout/ztranslation.xml
@@ -0,0 +1,64 @@
+<?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.
+-->
+<com.example.android.elevationdrag.DragFrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/main_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".MainActivity">
+
+ <Spinner
+ android:id="@+id/shapes_spinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="30dp"
+ android:layout_marginRight="30dp"
+ android:layout_marginLeft="30dp"
+ android:layout_marginBottom="0dp"
+ android:layout_gravity="center_horizontal"/>
+
+ <View
+ android:id="@+id/circle"
+ android:layout_width="@dimen/shape_size"
+ android:layout_height="@dimen/shape_size"
+ android:layout_marginTop="80dp"
+ android:layout_marginBottom="60dp"
+ android:layout_gravity="center_horizontal"
+ android:background="@drawable/shape"/>
+
+ <LinearLayout
+ android:layout_margin="16dp"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom">
+
+ <Button
+ android:id="@+id/raise_bt"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.5"
+ android:text="Z+"/>
+
+ <Button
+ android:id="@+id/lower_bt"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.5"
+ android:text="Z-"/>
+ </LinearLayout>
+</com.example.android.elevationdrag.DragFrameLayout>
\ No newline at end of file
diff --git a/ui/views/Elevation/ElevationDrag/Application/src/main/res/values/colors.xml b/ui/views/Elevation/ElevationDrag/Application/src/main/res/values/colors.xml
new file mode 100644
index 0000000..d563796
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/res/values/colors.xml
@@ -0,0 +1,19 @@
+<?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>
+ <color name="color_1">#E91E63</color>
+</resources>
diff --git a/ui/views/Elevation/ElevationDrag/Application/src/main/res/values/dimens.xml b/ui/views/Elevation/ElevationDrag/Application/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..e169867
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/res/values/dimens.xml
@@ -0,0 +1,19 @@
+<?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="shape_size">64dp</dimen>
+</resources>
diff --git a/ui/views/Elevation/ElevationDrag/Application/src/main/res/values/shapes.xml b/ui/views/Elevation/ElevationDrag/Application/src/main/res/values/shapes.xml
new file mode 100644
index 0000000..95beb32
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/src/main/res/values/shapes.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.
+-->
+<resources>
+ <string-array name="shapes">
+ <item>Circle</item>
+ <item>Rounded rectangle</item>
+ <item>Rectangle, circular shadow</item>
+ </string-array>
+</resources>
\ No newline at end of file
diff --git a/ui/views/Elevation/ElevationDrag/Application/tests/AndroidManifest.xml b/ui/views/Elevation/ElevationDrag/Application/tests/AndroidManifest.xml
new file mode 100644
index 0000000..e69afec
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/tests/AndroidManifest.xml
@@ -0,0 +1,61 @@
+<?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.
+-->
+
+
+
+<?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.elevationdrag.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="18"
+ android:targetSdkVersion="19" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.example.android.elevationdrag"
+ android:label="Tests for com.example.android.elevationdrag" />
+
+</manifest>
\ No newline at end of file
diff --git a/ui/views/Elevation/ElevationDrag/Application/tests/src/com/example/android/elevationdrag/tests/SampleTests.java b/ui/views/Elevation/ElevationDrag/Application/tests/src/com/example/android/elevationdrag/tests/SampleTests.java
new file mode 100644
index 0000000..5e7acc0
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/Application/tests/src/com/example/android/elevationdrag/tests/SampleTests.java
@@ -0,0 +1,113 @@
+/*
+* 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.
+*/
+
+
+
+/*
+* 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.elevationdrag.tests;
+
+import com.example.android.elevationdrag.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.TouchUtils;
+import android.view.Gravity;
+import android.view.View;
+
+/**
+* Tests for ElevationDrag sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+ private ElevationDragFragment mTestFragment;
+
+ private View mFloatingShape;
+ private View mDragFrame;
+
+ public SampleTests() {
+ super(MainActivity.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 = (ElevationDragFragment)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+
+ mFloatingShape = mTestActivity.findViewById(R.id.circle);
+ mDragFrame = mTestActivity.findViewById(R.id.main_layout);
+ }
+
+ /**
+ * 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);
+ assertNotNull("mFloatingShape is null", mFloatingShape);
+ assertNotNull("mDragFrame is null", mDragFrame);
+ // Check that the view is not raised yet.
+ assertEquals(mFloatingShape.getZ(), 0f);
+ }
+
+ /**
+ * Test that the floating shape can be dragged and that it's raised while dragging.
+ */
+ public void testDrag() {
+ final float initialX = mFloatingShape.getX();
+ // Drag the shape to the left edge.
+ TouchUtils.dragViewToX(this,
+ mFloatingShape,
+ Gravity.CENTER,
+ 0);
+
+ // Check that the view is dragging and that it's been raised.
+ // We need to use runOnMainSync here as fake dragging uses waitForIdleSync().
+ getInstrumentation().runOnMainSync(new Runnable() {
+ @Override
+ public void run() {
+ // Check that the view has moved.
+ float deltaX = mFloatingShape.getX() - initialX;
+ assertTrue(Math.abs(deltaX) > 0f);
+
+ // Check that the view is raised.
+ assertTrue(mFloatingShape.getZ() > 0f);
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ui/views/Elevation/ElevationDrag/build.gradle b/ui/views/Elevation/ElevationDrag/build.gradle
new file mode 100644
index 0000000..cda9c5c
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+// 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/ui/views/Elevation/ElevationDrag/buildSrc/build.gradle b/ui/views/Elevation/ElevationDrag/buildSrc/build.gradle
new file mode 100644
index 0000000..81f445f
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/ui/views/Elevation/ElevationDrag/gradle/gradle/wrapper/gradle-wrapper.jar b/ui/views/Elevation/ElevationDrag/gradle/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..5838598
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/gradle/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/views/Elevation/ElevationDrag/gradle/gradle/wrapper/gradle-wrapper.properties b/ui/views/Elevation/ElevationDrag/gradle/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..eefbc0a
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/gradle/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue May 20 13:33:02 BST 2014
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
diff --git a/ui/views/Elevation/ElevationDrag/gradle/gradlew b/ui/views/Elevation/ElevationDrag/gradle/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/gradle/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/ui/views/Elevation/ElevationDrag/gradle/gradlew.bat b/ui/views/Elevation/ElevationDrag/gradle/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/gradle/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/ui/views/Elevation/ElevationDrag/gradle/wrapper/gradle-wrapper.jar b/ui/views/Elevation/ElevationDrag/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/views/Elevation/ElevationDrag/gradle/wrapper/gradle-wrapper.properties b/ui/views/Elevation/ElevationDrag/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..d7f03cf
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
diff --git a/ui/views/Elevation/ElevationDrag/gradlew b/ui/views/Elevation/ElevationDrag/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/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/ui/views/Elevation/ElevationDrag/gradlew.bat b/ui/views/Elevation/ElevationDrag/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/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/ui/views/Elevation/ElevationDrag/settings.gradle b/ui/views/Elevation/ElevationDrag/settings.gradle
new file mode 100644
index 0000000..bb7fd61
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'ElevationDragSample'
diff --git a/ui/views/Elevation/ElevationDrag/template-params.xml b/ui/views/Elevation/ElevationDrag/template-params.xml
new file mode 100644
index 0000000..296e75e
--- /dev/null
+++ b/ui/views/Elevation/ElevationDrag/template-params.xml
@@ -0,0 +1,47 @@
+<?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.
+-->
+
+
+
+<sample>
+ <name>ElevationDrag</name>
+ <group>UI</group>
+ <package>com.example.android.elevationdrag</package>
+
+
+ <!-- change minSdk if needed-->
+ <minSdk>19</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+
+
+ <strings>
+ <intro>
+ <![CDATA[
+ This sample demonstrates a drag and drop action on different shapes. Elevation and
+ z-translation are used to render the shadows and the views are clipped using different
+ Outlines.
+ ]]>
+ </intro>
+ <sample_action>Elevation Drag</sample_action>
+ </strings>
+
+ <template src="base"/>
+ <template src="FragmentView"/>
+ <common src="logger"/>
+ <common src="activities"/>
+
+</sample>
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/.gitignore b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/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/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/README-fragmentview.txt b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/README-fragmentview.txt
new file mode 100644
index 0000000..38d903f
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/README-fragmentview.txt
@@ -0,0 +1,37 @@
+<!--
+ 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.
+-->
+
+Steps to implement FragmentView template:
+-in template-params.xml.ftl:
+ -add the following line to common imports
+ <common src="activities"/>
+
+-Add a Fragment to show behavior. In your MainActivity.java class, it will reference a Fragment
+ called (yourProjectName)Fragment.java. Create that file in your project, using the "main" source
+ folder instead of "common" or "templates".
+ For instance, if your package name is com.example.foo, create the file
+ src/main/java/com/example/foo/FooFragment.java
+
+
+-Within this fragment, make sure that the onCreate method has the line
+ "setHasOptionsMenu(true);", to enable the fragment to handle menu events.
+
+-In order to override menu events, override onOptionsItemSelected.
+
+-refer to sampleSamples/fragmentViewSample for a reference implementation of a
+project built on this template.
+
+
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/proguard-project.txt b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/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/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/AndroidManifest.xml b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..eb14a3d
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,40 @@
+<?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.
+-->
+
+
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.floatingactionbuttonbasic"
+ 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=".MainActivity"
+ 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/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/java/com/example/android/floatingactionbuttonbasic/FloatingActionButton.java b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/java/com/example/android/floatingactionbuttonbasic/FloatingActionButton.java
new file mode 100644
index 0000000..213dbf8
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/java/com/example/android/floatingactionbuttonbasic/FloatingActionButton.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * 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.floatingactionbuttonbasic;
+
+import com.example.android.common.logger.Log;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ValueAnimator;
+import android.content.Context;
+import android.graphics.Outline;
+import android.graphics.Point;
+import android.util.AttributeSet;
+import android.view.GestureDetector;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewAnimationUtils;
+import android.view.ViewGroup;
+import android.widget.Checkable;
+import android.widget.FrameLayout;
+
+/**
+ * A Floating Action Button is a {@link android.widget.Checkable} view distinguished by a circled
+ * icon floating above the UI, with special motion behaviors.
+ */
+public class FloatingActionButton extends FrameLayout implements Checkable {
+
+ /**
+ * An array of states.
+ */
+ private static final int[] CHECKED_STATE_SET = {
+ android.R.attr.state_checked
+ };
+
+ private static String TAG = "FloatingActionButton";
+
+ /**
+ * A boolean that tells if the FAB is checked or not.
+ */
+ protected boolean mChecked;
+
+ /*/
+ * The {@link View} that is revealed.
+ */
+ protected View mRevealView;
+
+ /**
+ * The coordinates of a touch action.
+ */
+ protected Point mTouchPoint;
+
+ /**
+ * A {@link android.view.GestureDetector} to detect touch actions.
+ */
+ private GestureDetector mGestureDetector;
+
+ /**
+ * A listener to communicate that the FAB has changed its state.
+ */
+ private OnCheckedChangeListener mOnCheckedChangeListener;
+
+ public FloatingActionButton(Context context) {
+ this(context, null, 0, 0);
+ }
+
+ public FloatingActionButton(Context context, AttributeSet attrs) {
+ this(context, attrs, 0, 0);
+ }
+
+ public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
+ this(context, attrs, defStyleAttr, 0);
+ }
+
+ public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ super(context, attrs, defStyleAttr);
+
+ // When a view is clickable it will change its state to "pressed" on every click.
+ setClickable(true);
+
+ // Create a {@link GestureDetector} to detect single taps.
+ mGestureDetector = new GestureDetector(context,
+ new GestureDetector.SimpleOnGestureListener() {
+ @Override
+ public boolean onSingleTapConfirmed(MotionEvent e) {
+ mTouchPoint = new Point((int) e.getX(), (int) e.getY());
+ Log.d(TAG, "Single tap captured.");
+ toggle();
+ return true;
+ }
+ }
+ );
+
+ // A new {@link View} is created
+ mRevealView = new View(context);
+ addView(mRevealView, ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT);
+ }
+
+ /**
+ * Sets the checked/unchecked state of the FAB.
+ * @param checked
+ */
+ public void setChecked(boolean checked) {
+ // If trying to set the current state, ignore.
+ if (checked == mChecked) {
+ return;
+ }
+ mChecked = checked;
+
+ // Create and start the {@link ValueAnimator} that shows the new state.
+ ValueAnimator anim = createAnimator();
+ anim.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
+ anim.start();
+
+ // Set the new background color of the {@link View} to be revealed.
+ mRevealView.setBackgroundColor(
+ mChecked ? getResources().getColor(R.color.fab_color_2)
+ : getResources().getColor(R.color.fab_color_1)
+ );
+
+ // Show the {@link View} to be revealed. Note that the animation has started already.
+ mRevealView.setVisibility(View.VISIBLE);
+
+ if (mOnCheckedChangeListener != null) {
+ mOnCheckedChangeListener.onCheckedChanged(this, checked);
+ }
+ }
+
+ public void setOnCheckedChangeListener(OnCheckedChangeListener listener) {
+ mOnCheckedChangeListener = listener;
+ setClickable(listener != null);
+ }
+
+ /**
+ * Interface definition for a callback to be invoked when the checked state
+ * of a compound button changes.
+ */
+ public static interface OnCheckedChangeListener {
+
+ /**
+ * Called when the checked state of a FAB has changed.
+ *
+ * @param fabView The FAB view whose state has changed.
+ * @param isChecked The new checked state of buttonView.
+ */
+ void onCheckedChanged(FloatingActionButton fabView, boolean isChecked);
+ }
+
+ protected ValueAnimator createAnimator() {
+
+ // Calculate the longest distance from the hot spot to the edge of the circle.
+ int endRadius = getWidth() / 2 +
+ (int) Math.hypot(getWidth() / 2 - mTouchPoint.y, getWidth() / 2 - mTouchPoint.x);
+
+ // Make sure the touch point is defined or set it to the middle of the view.
+ if (mTouchPoint == null) {
+ mTouchPoint = new Point(getWidth() / 2, getHeight() / 2);
+ }
+ ValueAnimator anim = ViewAnimationUtils.createCircularReveal(
+ mRevealView, mTouchPoint.x, mTouchPoint.y, 0, endRadius);
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ // Now we can refresh the drawable state
+ refreshDrawableState();
+
+ mRevealView.setVisibility(View.GONE);
+ // Reset the touch point as the next call to {@link setChecked} might not come
+ // from a tap.
+ mTouchPoint = null;
+ }
+ });
+ return anim;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (mGestureDetector.onTouchEvent(event)) {
+ return true;
+ }
+ return super.onTouchEvent(event);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return mChecked;
+ }
+
+ @Override
+ public void toggle() {
+ setChecked(!mChecked);
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+
+ Outline outline = new Outline();
+ outline.setOval(0, 0, w, h);
+ setOutline(outline);
+ setClipToOutline(true);
+ }
+
+ @Override
+ protected int[] onCreateDrawableState(int extraSpace) {
+ final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
+ if (isChecked()) {
+ mergeDrawableStates(drawableState, CHECKED_STATE_SET);
+ }
+ return drawableState;
+ }
+}
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/java/com/example/android/floatingactionbuttonbasic/FloatingActionButtonBasicFragment.java b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/java/com/example/android/floatingactionbuttonbasic/FloatingActionButtonBasicFragment.java
new file mode 100644
index 0000000..801ac3c
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/java/com/example/android/floatingactionbuttonbasic/FloatingActionButtonBasicFragment.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * 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.floatingactionbuttonbasic;
+
+import com.example.android.common.logger.Log;
+
+import android.app.Activity;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+
+/**
+ * This fragment inflates a layout with two Floating Action Buttons and acts as a listener to
+ * changes on them.
+ */
+public class FloatingActionButtonBasicFragment extends Fragment implements FloatingActionButton.OnCheckedChangeListener{
+
+ private final static String TAG = "FloatingActionButtonBasicFragment";
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ View rootView = inflater.inflate(R.layout.fab_layout, container, false);
+
+ // Make this {@link Fragment} listen for changes in both FABs.
+ FloatingActionButton fab1 = (FloatingActionButton) rootView.findViewById(R.id.fab_1);
+ fab1.setOnCheckedChangeListener(this);
+ FloatingActionButton fab2 = (FloatingActionButton) rootView.findViewById(R.id.fab_2);
+ fab2.setOnCheckedChangeListener(this);
+ return rootView;
+ }
+
+
+ @Override
+ public void onCheckedChanged(FloatingActionButton fabView, boolean isChecked) {
+ // When a FAB is toggled, log the action.
+ switch (fabView.getId()){
+ case R.id.fab_1:
+ Log.d(TAG, String.format("FAB 1 was %s.", isChecked ? "checked" : "unchecked"));
+ break;
+ case R.id.fab_2:
+ Log.d(TAG, String.format("FAB 2 was %s.", isChecked ? "checked" : "unchecked"));
+ break;
+ default:
+ break;
+ }
+ }
+}
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/animator/fab_anim.xml b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/animator/fab_anim.xml
new file mode 100644
index 0000000..9e7ce4f
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/animator/fab_anim.xml
@@ -0,0 +1,37 @@
+<?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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:state_enabled="true" android:state_pressed="true">
+ <objectAnimator
+ android:duration="@android:integer/config_shortAnimTime"
+ android:propertyName="translationZ"
+ android:valueTo="@dimen/fab_press_translation_z"
+ android:valueType="floatType" />
+ </item>
+
+ <item>
+ <objectAnimator
+ android:duration="@android:integer/config_shortAnimTime"
+ android:propertyName="translationZ"
+ android:valueTo="0"
+ android:valueType="floatType" />
+ </item>
+
+</selector>
\ No newline at end of file
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..5832eda
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..08e272e
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..7803f2d
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xxhdpi/ic_add.png b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xxhdpi/ic_add.png
new file mode 100644
index 0000000..f3166df
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xxhdpi/ic_add.png
Binary files differ
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..a1f819c
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xxhdpi/ic_tick.png b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xxhdpi/ic_tick.png
new file mode 100644
index 0000000..56f0454
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable-xxhdpi/ic_tick.png
Binary files differ
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable/fab_background.xml b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable/fab_background.xml
new file mode 100644
index 0000000..e5e7dbc
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable/fab_background.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:state_checked="true">
+ <ripple android:color="@color/fab_color_2_muted">
+ <item>
+ <shape>
+ <solid android:color="@color/fab_color_2" />
+ </shape>
+ </item>
+ </ripple>
+ </item>
+
+ <item>
+ <ripple android:color="@color/fab_color_1_muted">
+ <item>
+ <shape>
+ <solid android:color="@color/fab_color_1" />
+ </shape>
+ </item>
+ </ripple>
+ </item>
+
+</selector>
\ No newline at end of file
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable/fab_icons.xml b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable/fab_icons.xml
new file mode 100644
index 0000000..0e64385
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/drawable/fab_icons.xml
@@ -0,0 +1,28 @@
+<?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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item android:state_checked="true">
+ <bitmap android:src="@drawable/ic_tick" android:tint="@android:color/white" />
+ </item>
+
+ <item>
+ <bitmap android:src="@drawable/ic_add" android:tint="@android:color/white" />
+ </item>
+
+</selector>
\ No newline at end of file
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/layout/fab_layout.xml b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/layout/fab_layout.xml
new file mode 100644
index 0000000..0cc9f6a
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/layout/fab_layout.xml
@@ -0,0 +1,59 @@
+<?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 android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <com.example.android.floatingactionbuttonbasic.FloatingActionButton
+ android:id="@+id/fab_1"
+ android:layout_width="@dimen/fab_size"
+ android:layout_height="@dimen/fab_size"
+ android:layout_marginTop="16dp"
+ android:elevation="@dimen/fab_elevation"
+ android:background="@drawable/fab_background"
+ android:stateListAnimator="@animator/fab_anim"
+ android:layout_gravity="center_horizontal">
+
+ <ImageView
+ android:layout_width="@dimen/fab_icon_size"
+ android:layout_height="@dimen/fab_icon_size"
+ android:src="@drawable/fab_icons"
+ android:layout_gravity="center"
+ android:duplicateParentState="true"/>
+
+ </com.example.android.floatingactionbuttonbasic.FloatingActionButton>
+
+
+ <com.example.android.floatingactionbuttonbasic.FloatingActionButton
+ android:id="@+id/fab_2"
+ android:layout_width="@dimen/fab_size_small"
+ android:layout_height="@dimen/fab_size_small"
+ android:layout_marginTop="128dp"
+ android:elevation="@dimen/fab_elevation"
+ android:background="@drawable/fab_background"
+ android:stateListAnimator="@animator/fab_anim"
+ android:layout_gravity="center_horizontal">
+
+ <ImageView
+ android:layout_width="@dimen/fab_icon_size"
+ android:layout_height="@dimen/fab_icon_size"
+ android:src="@drawable/fab_icons"
+ android:layout_gravity="center"
+ android:duplicateParentState="true"/>
+
+ </com.example.android.floatingactionbuttonbasic.FloatingActionButton>
+</FrameLayout>
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/values/colors.xml b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/values/colors.xml
new file mode 100644
index 0000000..c89560d
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/values/colors.xml
@@ -0,0 +1,22 @@
+<?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>
+ <color name="fab_color_1">#ff5252</color>
+ <color name="fab_color_1_muted">#ff8080</color>
+ <color name="fab_color_2">#9c27b0</color>
+ <color name="fab_color_2_muted">#a56ab0</color>
+</resources>
\ No newline at end of file
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/values/dimens.xml b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..a16040a
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/src/main/res/values/dimens.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.
+-->
+<resources>
+ <dimen name="fab_elevation">2dp</dimen>
+ <dimen name="fab_press_translation_z">2dp</dimen>
+ <dimen name="fab_size">56dp</dimen>
+ <dimen name="fab_size_small">40dp</dimen>
+ <dimen name="fab_icon_size">24dp</dimen>
+</resources>
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/tests/AndroidManifest.xml b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/tests/AndroidManifest.xml
new file mode 100644
index 0000000..fa93608
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/tests/AndroidManifest.xml
@@ -0,0 +1,61 @@
+<?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.
+-->
+
+
+
+<?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.floatingactionbuttonbasic.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="18"
+ android:targetSdkVersion="19" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.example.android.floatingactionbuttonbasic"
+ android:label="Tests for com.example.android.floatingactionbuttonbasic" />
+
+</manifest>
\ No newline at end of file
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/tests/src/com/example/android/floatingactionbuttonbasic/tests/SampleTests.java b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/tests/src/com/example/android/floatingactionbuttonbasic/tests/SampleTests.java
new file mode 100644
index 0000000..631ae23
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/Application/tests/src/com/example/android/floatingactionbuttonbasic/tests/SampleTests.java
@@ -0,0 +1,79 @@
+/*
+* 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.
+*/
+
+
+
+/*
+* 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.floatingactionbuttonbasic.tests;
+
+import com.example.android.floatingactionbuttonbasic.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+* Tests for FloatingActionButtonBasic sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+ private FloatingActionButton mTestFragment;
+
+ public SampleTests() {
+ super(MainActivity.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 = (FloatingActionButton)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Add more tests below.
+ */
+
+}
\ No newline at end of file
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/build.gradle b/ui/views/FloatingActionButton/FloatingActionButtonBasic/build.gradle
new file mode 100644
index 0000000..cda9c5c
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+// 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/ui/views/FloatingActionButton/FloatingActionButtonBasic/buildSrc/build.gradle b/ui/views/FloatingActionButton/FloatingActionButtonBasic/buildSrc/build.gradle
new file mode 100644
index 0000000..81f445f
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/ui/views/FloatingActionButton/FloatingActionButtonBasic/gradle/wrapper/gradle-wrapper.jar b/ui/views/FloatingActionButton/FloatingActionButtonBasic/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/gradle/wrapper/gradle-wrapper.properties b/ui/views/FloatingActionButton/FloatingActionButtonBasic/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..d7f03cf
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/gradlew b/ui/views/FloatingActionButton/FloatingActionButtonBasic/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/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/ui/views/FloatingActionButton/FloatingActionButtonBasic/gradlew.bat b/ui/views/FloatingActionButton/FloatingActionButtonBasic/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/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/ui/views/FloatingActionButton/FloatingActionButtonBasic/settings.gradle b/ui/views/FloatingActionButton/FloatingActionButtonBasic/settings.gradle
new file mode 100644
index 0000000..d22530e
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'FloatingActionButtonBasicSample'
diff --git a/ui/views/FloatingActionButton/FloatingActionButtonBasic/template-params.xml b/ui/views/FloatingActionButton/FloatingActionButtonBasic/template-params.xml
new file mode 100644
index 0000000..4f3944d
--- /dev/null
+++ b/ui/views/FloatingActionButton/FloatingActionButtonBasic/template-params.xml
@@ -0,0 +1,46 @@
+<?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.
+-->
+
+
+
+<sample>
+ <name>FloatingActionButtonBasic</name>
+ <group>UI</group>
+ <package>com.example.android.floatingactionbuttonbasic</package>
+
+
+
+ <!-- change minSdk if needed-->
+ <minSdk>19</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+
+
+ <strings>
+ <intro>
+ <![CDATA[
+ This sample shows the two sizes of Floating Action Buttons and how to interact with
+ them.
+ ]]>
+ </intro>
+ </strings>
+
+ <template src="base"/>
+ <template src="FragmentView"/>
+ <common src="logger"/>
+ <common src="activities"/>
+
+</sample>
diff --git a/ui/views/NavigationDrawer/Application/.gitignore b/ui/views/NavigationDrawer/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/ui/views/NavigationDrawer/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/ui/views/NavigationDrawer/Application/proguard-project.txt b/ui/views/NavigationDrawer/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/ui/views/NavigationDrawer/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/ui/views/NavigationDrawer/Application/src/main/AndroidManifest.xml b/ui/views/NavigationDrawer/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..1a9931f
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,46 @@
+<?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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.navigationdrawer"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="14"
+ android:targetSdkVersion="19" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name=".NavigationDrawerActivity"
+ android:label="@string/app_name" >
+ </activity>
+ </application>
+
+</manifest>
diff --git a/ui/views/NavigationDrawer/Application/src/main/java/com/example/android/navigationdrawer/NavigationDrawerActivity.java b/ui/views/NavigationDrawer/Application/src/main/java/com/example/android/navigationdrawer/NavigationDrawerActivity.java
new file mode 100644
index 0000000..1176757
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/java/com/example/android/navigationdrawer/NavigationDrawerActivity.java
@@ -0,0 +1,247 @@
+/*
+ * 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.navigationdrawer;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.app.SearchManager;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.view.GravityCompat;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+import java.util.Locale;
+
+/**
+ * This example illustrates a common usage of the DrawerLayout widget
+ * in the Android support library.
+ * <p/>
+ * <p>When a navigation (left) drawer is present, the host activity should detect presses of
+ * the action bar's Up affordance as a signal to open and close the navigation drawer. The
+ * ActionBarDrawerToggle facilitates this behavior.
+ * Items within the drawer should fall into one of two categories:</p>
+ * <p/>
+ * <ul>
+ * <li><strong>View switches</strong>. A view switch follows the same basic policies as
+ * list or tab navigation in that a view switch does not create navigation history.
+ * This pattern should only be used at the root activity of a task, leaving some form
+ * of Up navigation active for activities further down the navigation hierarchy.</li>
+ * <li><strong>Selective Up</strong>. The drawer allows the user to choose an alternate
+ * parent for Up navigation. This allows a user to jump across an app's navigation
+ * hierarchy at will. The application should treat this as it treats Up navigation from
+ * a different task, replacing the current task stack using TaskStackBuilder or similar.
+ * This is the only form of navigation drawer that should be used outside of the root
+ * activity of a task.</li>
+ * </ul>
+ * <p/>
+ * <p>Right side drawers should be used for actions, not navigation. This follows the pattern
+ * established by the Action Bar that navigation should be to the left and actions to the right.
+ * An action should be an operation performed on the current contents of the window,
+ * for example enabling or disabling a data overlay on top of the current content.</p>
+ */
+public class NavigationDrawerActivity extends Activity implements PlanetAdapter.OnItemClickListener {
+ private DrawerLayout mDrawerLayout;
+ private RecyclerView mDrawerList;
+ private ActionBarDrawerToggle mDrawerToggle;
+
+ private CharSequence mDrawerTitle;
+ private CharSequence mTitle;
+ private String[] mPlanetTitles;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_navigation_drawer);
+
+ mTitle = mDrawerTitle = getTitle();
+ mPlanetTitles = getResources().getStringArray(R.array.planets_array);
+ mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ mDrawerList = (RecyclerView) findViewById(R.id.left_drawer);
+
+ // set a custom shadow that overlays the main content when the drawer opens
+ mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
+ // improve performance by indicating the list if fixed size.
+ mDrawerList.setHasFixedSize(true);
+ mDrawerList.setLayoutManager(new LinearLayoutManager(this));
+
+ // set up the drawer's list view with items and click listener
+ mDrawerList.setAdapter(new PlanetAdapter(mPlanetTitles, this));
+ // enable ActionBar app icon to behave as action to toggle nav drawer
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+ getActionBar().setHomeButtonEnabled(true);
+
+ // ActionBarDrawerToggle ties together the the proper interactions
+ // between the sliding drawer and the action bar app icon
+ mDrawerToggle = new ActionBarDrawerToggle(
+ this, /* host Activity */
+ mDrawerLayout, /* DrawerLayout object */
+ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
+ R.string.drawer_open, /* "open drawer" description for accessibility */
+ R.string.drawer_close /* "close drawer" description for accessibility */
+ ) {
+ public void onDrawerClosed(View view) {
+ getActionBar().setTitle(mTitle);
+ invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
+ }
+
+ public void onDrawerOpened(View drawerView) {
+ getActionBar().setTitle(mDrawerTitle);
+ invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
+ }
+ };
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
+
+ if (savedInstanceState == null) {
+ selectItem(0);
+ }
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.navigation_drawer, menu);
+ return true;
+ }
+
+ /* Called whenever we call invalidateOptionsMenu() */
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ // If the nav drawer is open, hide action items related to the content view
+ boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
+ menu.findItem(R.id.action_websearch).setVisible(!drawerOpen);
+ return super.onPrepareOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // The action bar home/up action should open or close the drawer.
+ // ActionBarDrawerToggle will take care of this.
+ if (mDrawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+ // Handle action buttons
+ switch (item.getItemId()) {
+ case R.id.action_websearch:
+ // create intent to perform web search for this planet
+ Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
+ intent.putExtra(SearchManager.QUERY, getActionBar().getTitle());
+ // catch event that there's no activity to handle intent
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ } else {
+ Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
+ }
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ /* The click listener for RecyclerView in the navigation drawer */
+ @Override
+ public void onClick(View view, int position) {
+ selectItem(position);
+ }
+
+ private void selectItem(int position) {
+ // update the main content by replacing fragments
+ Fragment fragment = PlanetFragment.newInstance(position);
+
+ FragmentManager fragmentManager = getFragmentManager();
+ FragmentTransaction ft = fragmentManager.beginTransaction();
+ ft.replace(R.id.content_frame, fragment);
+ ft.commit();
+
+ // update selected item title, then close the drawer
+ setTitle(mPlanetTitles[position]);
+ mDrawerLayout.closeDrawer(mDrawerList);
+ }
+
+ @Override
+ public void setTitle(CharSequence title) {
+ mTitle = title;
+ getActionBar().setTitle(mTitle);
+ }
+
+ /**
+ * When using the ActionBarDrawerToggle, you must call it during
+ * onPostCreate() and onConfigurationChanged()...
+ */
+
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ // Sync the toggle state after onRestoreInstanceState has occurred.
+ mDrawerToggle.syncState();
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ // Pass any configuration change to the drawer toggls
+ mDrawerToggle.onConfigurationChanged(newConfig);
+ }
+
+ /**
+ * Fragment that appears in the "content_frame", shows a planet
+ */
+ public static class PlanetFragment extends Fragment {
+ public static final String ARG_PLANET_NUMBER = "planet_number";
+
+ public PlanetFragment() {
+ // Empty constructor required for fragment subclasses
+ }
+
+ public static Fragment newInstance(int position) {
+ Fragment fragment = new PlanetFragment();
+ Bundle args = new Bundle();
+ args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_planet, container, false);
+ int i = getArguments().getInt(ARG_PLANET_NUMBER);
+ String planet = getResources().getStringArray(R.array.planets_array)[i];
+
+ int imageId = getResources().getIdentifier(planet.toLowerCase(Locale.getDefault()),
+ "drawable", getActivity().getPackageName());
+ ImageView iv = ((ImageView) rootView.findViewById(R.id.image));
+ iv.setImageResource(imageId);
+
+ getActivity().setTitle(planet);
+ return rootView;
+ }
+ }
+}
diff --git a/ui/views/NavigationDrawer/Application/src/main/java/com/example/android/navigationdrawer/PlanetAdapter.java b/ui/views/NavigationDrawer/Application/src/main/java/com/example/android/navigationdrawer/PlanetAdapter.java
new file mode 100644
index 0000000..5b449d0
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/java/com/example/android/navigationdrawer/PlanetAdapter.java
@@ -0,0 +1,81 @@
+/*
+ * 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.navigationdrawer;
+
+import android.content.Context;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.TextView;
+
+/**
+ * Adapter for the planet data used in our drawer menu,
+ */
+public class PlanetAdapter extends RecyclerView.Adapter<PlanetAdapter.ViewHolder> {
+ private String[] mDataset;
+ private OnItemClickListener mListener;
+
+ /**
+ * Interface for receiving click events from cells.
+ */
+ public interface OnItemClickListener {
+ public void onClick(View view, int position);
+ }
+
+ /**
+ * Custom viewholder for our planet views.
+ */
+ public static class ViewHolder extends RecyclerView.ViewHolder {
+ public final TextView mTextView;
+
+ public ViewHolder(TextView v) {
+ super(v);
+ mTextView = v;
+ }
+ }
+
+ public PlanetAdapter(String[] myDataset, OnItemClickListener listener) {
+ mDataset = myDataset;
+ mListener = listener;
+ }
+
+ @Override
+ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ LayoutInflater vi = LayoutInflater.from(parent.getContext());
+ View v = vi.inflate(R.layout.drawer_list_item, parent, false);
+ TextView tv = (TextView) v.findViewById(android.R.id.text1);
+ return new ViewHolder(tv);
+ }
+
+ @Override
+ public void onBindViewHolder(ViewHolder holder, final int position) {
+ holder.mTextView.setText(mDataset[position]);
+ holder.mTextView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mListener.onClick(view, position);
+ }
+ });
+ }
+
+ @Override
+ public int getItemCount() {
+ return mDataset.length;
+ }
+}
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/action_search.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/action_search.png
new file mode 100755
index 0000000..f12e005
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/action_search.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/drawer_shadow.9.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/drawer_shadow.9.png
new file mode 100644
index 0000000..224cc4f
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/drawer_shadow.9.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/ic_drawer.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/ic_drawer.png
new file mode 100644
index 0000000..ff7b1de
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/ic_drawer.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/ic_launcher.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100755
index 0000000..b460d60
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/action_search.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/action_search.png
new file mode 100755
index 0000000..587d9e0
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/action_search.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/drawer_shadow.9.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/drawer_shadow.9.png
new file mode 100644
index 0000000..3797f99
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/drawer_shadow.9.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/ic_drawer.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/ic_drawer.png
new file mode 100644
index 0000000..fb681ba
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/ic_drawer.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/ic_launcher.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100755
index 0000000..dee53f4
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/action_search.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/action_search.png
new file mode 100755
index 0000000..3549f84
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/action_search.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/drawer_shadow.9.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/drawer_shadow.9.png
new file mode 100644
index 0000000..fa3d853
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/drawer_shadow.9.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/ic_drawer.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/ic_drawer.png
new file mode 100644
index 0000000..b9bc3d7
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/ic_drawer.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100755
index 0000000..d4e1215
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/ui/views/NavigationDrawer/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..6ef21e1
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable/earth.jpg b/ui/views/NavigationDrawer/Application/src/main/res/drawable/earth.jpg
new file mode 100644
index 0000000..6cabbf4
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable/earth.jpg
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable/jupiter.jpg b/ui/views/NavigationDrawer/Application/src/main/res/drawable/jupiter.jpg
new file mode 100644
index 0000000..24e8eea
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable/jupiter.jpg
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable/mars.jpg b/ui/views/NavigationDrawer/Application/src/main/res/drawable/mars.jpg
new file mode 100644
index 0000000..db253ef
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable/mars.jpg
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable/mercury.jpg b/ui/views/NavigationDrawer/Application/src/main/res/drawable/mercury.jpg
new file mode 100644
index 0000000..531790b
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable/mercury.jpg
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable/neptune.jpg b/ui/views/NavigationDrawer/Application/src/main/res/drawable/neptune.jpg
new file mode 100644
index 0000000..88467c5
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable/neptune.jpg
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable/saturn.jpg b/ui/views/NavigationDrawer/Application/src/main/res/drawable/saturn.jpg
new file mode 100644
index 0000000..8219d18
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable/saturn.jpg
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable/uranus.jpg b/ui/views/NavigationDrawer/Application/src/main/res/drawable/uranus.jpg
new file mode 100644
index 0000000..fa32e37
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable/uranus.jpg
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/drawable/venus.jpg b/ui/views/NavigationDrawer/Application/src/main/res/drawable/venus.jpg
new file mode 100644
index 0000000..e04f078
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/drawable/venus.jpg
Binary files differ
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/layout/activity_navigation_drawer.xml b/ui/views/NavigationDrawer/Application/src/main/res/layout/activity_navigation_drawer.xml
new file mode 100644
index 0000000..4e61639
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/layout/activity_navigation_drawer.xml
@@ -0,0 +1,48 @@
+<?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.
+ -->
+
+
+<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
+<android.support.v4.widget.DrawerLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/drawer_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <!-- As the main content view, the view below consumes the entire
+ space available using match_parent in both dimensions. -->
+ <FrameLayout
+ android:id="@+id/content_frame"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <!-- android:layout_gravity="start" tells DrawerLayout to treat
+ this as a sliding drawer on the left side for left-to-right
+ languages and on the right side for right-to-left languages.
+ The drawer is given a fixed width in dp and extends the full height of
+ the container. A solid background is used for contrast
+ with the content view. -->
+ <android.support.v7.widget.RecyclerView
+ android:id="@+id/left_drawer"
+ android:scrollbars="vertical"
+ android:layout_width="240dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="left|start"
+ android:choiceMode="singleChoice"
+ android:divider="@null"
+ />
+</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/layout/drawer_list_item.xml b/ui/views/NavigationDrawer/Application/src/main/res/layout/drawer_list_item.xml
new file mode 100644
index 0000000..6d059ca
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/layout/drawer_list_item.xml
@@ -0,0 +1,28 @@
+<?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.
+ -->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/text1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceListItemSmall"
+ android:gravity="center_vertical"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp"
+ android:textColor="#fff"
+ android:background="?android:attr/activatedBackgroundIndicator"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"/>
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/layout/fragment_planet.xml b/ui/views/NavigationDrawer/Application/src/main/res/layout/fragment_planet.xml
new file mode 100644
index 0000000..7471a8f
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/layout/fragment_planet.xml
@@ -0,0 +1,25 @@
+<?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.
+ -->
+
+<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/image"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@android:color/black"
+ android:gravity="center"
+ android:padding="32dp" />
+
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/menu/navigation_drawer.xml b/ui/views/NavigationDrawer/Application/src/main/res/menu/navigation_drawer.xml
new file mode 100644
index 0000000..2549927
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/menu/navigation_drawer.xml
@@ -0,0 +1,23 @@
+<?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.
+ -->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/action_websearch"
+ android:icon="@drawable/action_search"
+ android:title="@string/action_websearch"
+ android:showAsAction="ifRoom|withText" />
+</menu>
\ No newline at end of file
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/values-v20/styles.xml b/ui/views/NavigationDrawer/Application/src/main/res/values-v20/styles.xml
new file mode 100644
index 0000000..01a2e28
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/values-v20/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>
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="android:Theme.Material.Light">
+ </style>
+</resources>
\ No newline at end of file
diff --git a/ui/views/NavigationDrawer/Application/src/main/res/values/strings.xml b/ui/views/NavigationDrawer/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..7f8de63
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/src/main/res/values/strings.xml
@@ -0,0 +1,32 @@
+<?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-array name="planets_array">
+ <item>Mercury</item>
+ <item>Venus</item>
+ <item>Earth</item>
+ <item>Mars</item>
+ <item>Jupiter</item>
+ <item>Saturn</item>
+ <item>Uranus</item>
+ <item>Neptune</item>
+ </string-array>
+ <string name="drawer_open">Open navigation drawer</string>
+ <string name="drawer_close">Close navigation drawer</string>
+ <string name="action_websearch">Web search</string>
+ <string name="app_not_available">Sorry, there\'s no web browser available</string>
+</resources>
diff --git a/ui/views/NavigationDrawer/Application/tests/AndroidManifest.xml b/ui/views/NavigationDrawer/Application/tests/AndroidManifest.xml
new file mode 100644
index 0000000..62ab13a
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/tests/AndroidManifest.xml
@@ -0,0 +1,61 @@
+<?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.
+-->
+
+
+
+<?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.navigationdrawer.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="18"
+ android:targetSdkVersion="19" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.example.android.navigationdrawer"
+ android:label="Tests for com.example.android.navigationdrawer" />
+
+</manifest>
\ No newline at end of file
diff --git a/ui/views/NavigationDrawer/Application/tests/src/com/example/android/navigationdrawer/tests/SampleTests.java b/ui/views/NavigationDrawer/Application/tests/src/com/example/android/navigationdrawer/tests/SampleTests.java
new file mode 100644
index 0000000..eca6b61
--- /dev/null
+++ b/ui/views/NavigationDrawer/Application/tests/src/com/example/android/navigationdrawer/tests/SampleTests.java
@@ -0,0 +1,79 @@
+/*
+* 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.
+*/
+
+
+
+/*
+* 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.navigationdrawer.tests;
+
+import com.example.android.navigationdrawer.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+* Tests for NavigationDrawer sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+ private NavigationDrawerFragment mTestFragment;
+
+ public SampleTests() {
+ super(MainActivity.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 = (NavigationDrawerFragment)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Add more tests below.
+ */
+
+}
\ No newline at end of file
diff --git a/ui/views/NavigationDrawer/build.gradle b/ui/views/NavigationDrawer/build.gradle
new file mode 100644
index 0000000..be1fa82
--- /dev/null
+++ b/ui/views/NavigationDrawer/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+// 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/ui/views/NavigationDrawer/buildSrc/build.gradle b/ui/views/NavigationDrawer/buildSrc/build.gradle
new file mode 100644
index 0000000..e344a8c
--- /dev/null
+++ b/ui/views/NavigationDrawer/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/ui/views/NavigationDrawer/gradle/wrapper/gradle-wrapper.jar b/ui/views/NavigationDrawer/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/ui/views/NavigationDrawer/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/views/NavigationDrawer/gradle/wrapper/gradle-wrapper.properties b/ui/views/NavigationDrawer/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..c819e62
--- /dev/null
+++ b/ui/views/NavigationDrawer/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Jun 09 15:04:51 BST 2014
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
diff --git a/ui/views/NavigationDrawer/gradlew b/ui/views/NavigationDrawer/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/ui/views/NavigationDrawer/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/ui/views/NavigationDrawer/gradlew.bat b/ui/views/NavigationDrawer/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/ui/views/NavigationDrawer/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/ui/views/NavigationDrawer/settings.gradle b/ui/views/NavigationDrawer/settings.gradle
new file mode 100644
index 0000000..feade60
--- /dev/null
+++ b/ui/views/NavigationDrawer/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'NavigationDrawerSample'
diff --git a/ui/views/NavigationDrawer/template-params.xml b/ui/views/NavigationDrawer/template-params.xml
new file mode 100644
index 0000000..1e05ef7
--- /dev/null
+++ b/ui/views/NavigationDrawer/template-params.xml
@@ -0,0 +1,56 @@
+<?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.
+-->
+
+
+
+<sample>
+ <name>Navigation Drawer</name>
+ <group>UI</group>
+ <package>com.example.android.navigationdrawer</package>
+
+ <auto_add_support_lib>false</auto_add_support_lib>
+
+ <!-- change minSdk if needed-->
+ <minSdk>14</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+
+
+ <dependency>com.android.support:support-v13:20.+</dependency>
+ <dependency>com.android.support:appcompat-v7:20.+</dependency>
+ <dependency>com.android.support:recyclerview-v7:+</dependency>
+
+ <strings>
+ <intro>
+ <![CDATA[
+ This example illustrates a common usage of the DrawerLayout widget in the Android
+ support library.
+ ]]>
+ </intro>
+ </strings>
+
+ <activity>
+ <class>NavigationDrawerActivity</class>
+ <title>Navigation Drawer Example</title>
+ <description>This example illustrates a common usage of the DrawerLayout widget in the Android
+ support library.</description>
+ </activity>
+
+ <template src="base"/>
+ <template src="ActivityCards"/>
+ <common src="logger"/>
+
+</sample>
diff --git a/ui/views/RevealEffect/RevealEffectBasic/Application/.gitignore b/ui/views/RevealEffect/RevealEffectBasic/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/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/ui/views/RevealEffect/RevealEffectBasic/Application/README-fragmentview.txt b/ui/views/RevealEffect/RevealEffectBasic/Application/README-fragmentview.txt
new file mode 100644
index 0000000..38d903f
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/README-fragmentview.txt
@@ -0,0 +1,37 @@
+<!--
+ 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.
+-->
+
+Steps to implement FragmentView template:
+-in template-params.xml.ftl:
+ -add the following line to common imports
+ <common src="activities"/>
+
+-Add a Fragment to show behavior. In your MainActivity.java class, it will reference a Fragment
+ called (yourProjectName)Fragment.java. Create that file in your project, using the "main" source
+ folder instead of "common" or "templates".
+ For instance, if your package name is com.example.foo, create the file
+ src/main/java/com/example/foo/FooFragment.java
+
+
+-Within this fragment, make sure that the onCreate method has the line
+ "setHasOptionsMenu(true);", to enable the fragment to handle menu events.
+
+-In order to override menu events, override onOptionsItemSelected.
+
+-refer to sampleSamples/fragmentViewSample for a reference implementation of a
+project built on this template.
+
+
diff --git a/ui/views/RevealEffect/RevealEffectBasic/Application/proguard-project.txt b/ui/views/RevealEffect/RevealEffectBasic/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/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/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/AndroidManifest.xml b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..da8646b
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,41 @@
+<?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.revealeffectbasic"
+ android:versionCode="1"
+ android:versionName="1.0"
+ android:uiOptions="splitActionBarWhenNarrow">
+
+ <application android:allowBackup="true"
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher"
+ android:theme="@style/AppTheme">
+
+ <activity android:name=".MainActivity"
+ 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/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/java/com/example/android/revealeffectbasic/RevealEffectBasicFragment.java b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/java/com/example/android/revealeffectbasic/RevealEffectBasicFragment.java
new file mode 100644
index 0000000..39d5fb0
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/java/com/example/android/revealeffectbasic/RevealEffectBasicFragment.java
@@ -0,0 +1,77 @@
+/*
+ * 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.revealeffectbasic;
+
+import android.animation.ValueAnimator;
+import android.support.v4.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewAnimationUtils;
+import android.view.ViewGroup;
+import android.view.animation.AccelerateDecelerateInterpolator;
+
+/**
+ * This sample shows a view that is revealed when a button is clicked.
+ */
+public class RevealEffectBasicFragment extends Fragment {
+
+ private final static String TAG = "RevealEffectBasicFragment";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public View onCreateView(
+ LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+
+ final View rootView = inflater.inflate(R.layout.reveal_effect_basic, container, false);
+
+ View button = rootView.findViewById(R.id.button);
+
+ /* Set a listener to reveal the view on ACTION_DOWN. */
+ button.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View view, MotionEvent motionEvent) {
+ if (motionEvent.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ View shape = rootView.findViewById(R.id.circle);
+ /* Create a reveal {@Link ValueAnimator} that starts clipping the view from
+ * the top left corner until the whole view is covered. */
+ ValueAnimator animator = ViewAnimationUtils.createCircularReveal(
+ shape,
+ 0,
+ 0,
+ 0,
+ (float) Math.hypot(shape.getWidth(), shape.getHeight()));
+
+ /* Set a natural ease-in/ease-out interpolator. */
+ animator.setInterpolator(new AccelerateDecelerateInterpolator());
+
+ animator.start();
+ return false;
+ }
+ return false;
+ }
+ });
+
+ return rootView;
+ }
+
+}
\ No newline at end of file
diff --git a/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..5acc60a
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..d3977a6
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..71532a7
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..33d9879
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/layout/reveal_effect_basic.xml b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/layout/reveal_effect_basic.xml
new file mode 100644
index 0000000..07b6943
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/layout/reveal_effect_basic.xml
@@ -0,0 +1,44 @@
+<?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="match_parent">
+
+ <View
+ android:id="@+id/circle"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_horizontal"
+ android:background="@color/color_2"
+ android:layout_above="@+id/button"
+ android:layout_marginTop="@dimen/margin_medium"
+ android:layout_marginRight="@dimen/margin_medium"
+ android:layout_marginLeft="@dimen/margin_medium"/>
+ <Button
+ android:id="@+id/button"
+ style="?android:attr/buttonStyleSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/margin_medium"
+ android:text="Reveal"
+ android:layout_centerHorizontal="true"
+ android:layout_marginBottom="16dp"
+ android:layout_gravity="center_horizontal|bottom"
+ android:layout_alignParentBottom="true"
+ />
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/values/colors.xml b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/values/colors.xml
new file mode 100644
index 0000000..195adf8
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/values/colors.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>
+ <color name="color_1">#E91E63</color>
+ <color name="color_2">#673AB7</color>
+</resources>
diff --git a/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/values/dimens.xml b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..e0ffc06
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/src/main/res/values/dimens.xml
@@ -0,0 +1,19 @@
+<?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="shape_size">128dp</dimen>
+</resources>
diff --git a/ui/views/RevealEffect/RevealEffectBasic/Application/tests/AndroidManifest.xml b/ui/views/RevealEffect/RevealEffectBasic/Application/tests/AndroidManifest.xml
new file mode 100644
index 0000000..3a1bb88
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/tests/AndroidManifest.xml
@@ -0,0 +1,61 @@
+<?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.
+-->
+
+
+
+<?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.revealeffectbasic.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="18"
+ android:targetSdkVersion="19" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.example.android.revealeffectbasic"
+ android:label="Tests for com.example.android.revealeffectbasic" />
+
+</manifest>
\ No newline at end of file
diff --git a/ui/views/RevealEffect/RevealEffectBasic/Application/tests/src/com/example/android/revealeffectbasic/tests/SampleTests.java b/ui/views/RevealEffect/RevealEffectBasic/Application/tests/src/com/example/android/revealeffectbasic/tests/SampleTests.java
new file mode 100644
index 0000000..249f1ef
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/Application/tests/src/com/example/android/revealeffectbasic/tests/SampleTests.java
@@ -0,0 +1,75 @@
+/*
+* 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.
+*/
+
+
+
+/*
+* 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.revealeffectbasic.tests;
+
+import com.example.android.revealeffectbasic.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+* Tests for RevealEffectBasic sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+ private RevealEffectBasicFragment mTestFragment;
+
+ public SampleTests() {
+ super(MainActivity.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 = (RevealEffectBasicFragment)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+ }
+
+ /**
+ * 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);
+ assertNotNull("Circle view is null", mTestActivity.findViewById(R.id.circle));
+ }
+}
\ No newline at end of file
diff --git a/ui/views/RevealEffect/RevealEffectBasic/build.gradle b/ui/views/RevealEffect/RevealEffectBasic/build.gradle
new file mode 100644
index 0000000..cda9c5c
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/build.gradle
@@ -0,0 +1,14 @@
+
+
+
+
+// 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/ui/views/RevealEffect/RevealEffectBasic/buildSrc/build.gradle b/ui/views/RevealEffect/RevealEffectBasic/buildSrc/build.gradle
new file mode 100644
index 0000000..81f445f
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/buildSrc/build.gradle
@@ -0,0 +1,18 @@
+
+
+
+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/ui/views/RevealEffect/RevealEffectBasic/gradle/gradle/wrapper/gradle-wrapper.jar b/ui/views/RevealEffect/RevealEffectBasic/gradle/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..5838598
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/gradle/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/views/RevealEffect/RevealEffectBasic/gradle/gradle/wrapper/gradle-wrapper.properties b/ui/views/RevealEffect/RevealEffectBasic/gradle/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..02df8c4
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/gradle/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Fri May 23 13:44:29 BST 2014
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
diff --git a/ui/views/RevealEffect/RevealEffectBasic/gradle/gradlew b/ui/views/RevealEffect/RevealEffectBasic/gradle/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/gradle/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/ui/views/RevealEffect/RevealEffectBasic/gradle/gradlew.bat b/ui/views/RevealEffect/RevealEffectBasic/gradle/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/gradle/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/ui/views/RevealEffect/RevealEffectBasic/gradle/wrapper/gradle-wrapper.jar b/ui/views/RevealEffect/RevealEffectBasic/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/views/RevealEffect/RevealEffectBasic/gradle/wrapper/gradle-wrapper.properties b/ui/views/RevealEffect/RevealEffectBasic/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..19c6ed1
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip
diff --git a/ui/views/RevealEffect/RevealEffectBasic/gradlew b/ui/views/RevealEffect/RevealEffectBasic/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/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/ui/views/RevealEffect/RevealEffectBasic/gradlew.bat b/ui/views/RevealEffect/RevealEffectBasic/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/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/ui/views/RevealEffect/RevealEffectBasic/settings.gradle b/ui/views/RevealEffect/RevealEffectBasic/settings.gradle
new file mode 100644
index 0000000..a52c8f3
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/settings.gradle
@@ -0,0 +1,4 @@
+
+
+
+include 'RevealEffectBasicSample'
diff --git a/ui/views/RevealEffect/RevealEffectBasic/template-params.xml b/ui/views/RevealEffect/RevealEffectBasic/template-params.xml
new file mode 100644
index 0000000..8ebd27a
--- /dev/null
+++ b/ui/views/RevealEffect/RevealEffectBasic/template-params.xml
@@ -0,0 +1,44 @@
+<?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.
+-->
+
+
+
+<sample>
+ <name>RevealEffectBasic</name>
+ <group>UI</group>
+ <package>com.example.android.revealeffectbasic</package>
+
+
+
+ <minSdk>19</minSdk>
+ <compileSdkVersion>"android-L"</compileSdkVersion>
+
+
+ <strings>
+ <intro>
+ <![CDATA[
+ Basic sample to demonstrate the reveal effect.
+ ]]>
+ </intro>
+ </strings>
+
+ <template src="base"/>
+ <template src="FragmentView"/>
+ <common src="logger"/>
+ <common src="activities"/>
+
+</sample>
diff --git a/ui/views/SlidingTabs/SlidingTabsBasic/gradle/wrapper/gradle-wrapper.properties b/ui/views/SlidingTabs/SlidingTabsBasic/gradle/wrapper/gradle-wrapper.properties
index d647dee..7dc3dff 100644
--- a/ui/views/SlidingTabs/SlidingTabsBasic/gradle/wrapper/gradle-wrapper.properties
+++ b/ui/views/SlidingTabs/SlidingTabsBasic/gradle/wrapper/gradle-wrapper.properties
@@ -3,5 +3,5 @@
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
diff --git a/ui/views/SlidingTabs/SlidingTabsColors/gradle/wrapper/gradle-wrapper.properties b/ui/views/SlidingTabs/SlidingTabsColors/gradle/wrapper/gradle-wrapper.properties
index 2ea0b84..5fbce39 100644
--- a/ui/views/SlidingTabs/SlidingTabsColors/gradle/wrapper/gradle-wrapper.properties
+++ b/ui/views/SlidingTabs/SlidingTabsColors/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
diff --git a/ui/views/SwipeRefreshLayout/SwipeRefreshLayoutBasic/gradle/wrapper/gradle-wrapper.properties b/ui/views/SwipeRefreshLayout/SwipeRefreshLayoutBasic/gradle/wrapper/gradle-wrapper.properties
index f699501..a9085ca 100644
--- a/ui/views/SwipeRefreshLayout/SwipeRefreshLayoutBasic/gradle/wrapper/gradle-wrapper.properties
+++ b/ui/views/SwipeRefreshLayout/SwipeRefreshLayoutBasic/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
diff --git a/ui/window/AdvancedImmersiveMode/Application/README-singleview.txt b/ui/window/AdvancedImmersiveMode/Application/README-singleview.txt
new file mode 100644
index 0000000..0cacd46
--- /dev/null
+++ b/ui/window/AdvancedImmersiveMode/Application/README-singleview.txt
@@ -0,0 +1,47 @@
+<#--
+ 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.
+-->
+
+Steps to implement SingleView template:
+-in template-params.xml.ftl:
+ -add the following line to common imports
+ <common src="activities"/>
+
+ -add a string for the action button's text using the element name "sample_action".
+ This element should be a child of <strings>:
+ <strings>
+ ...
+ <sample_action>ButtonText</sample_action>
+ ...
+ </strings>
+
+
+
+-Add a Fragment to handle behavior. In your MainActivity.java class, it will reference a Fragment
+ called (yourProjectName)Fragment.java. Create that file in your project, using the "main" source
+ folder instead of "common" or "templates".
+ For instance, if your package name is com.example.foo, create the file
+ src/main/java/com/example/foo/FooFragment.java
+
+
+-Within this fragment, make sure that the onCreate method has the line
+ "setHasOptionsMenu(true);", to enable the fragment to handle menu events.
+
+-In order to override menu events, override onOptionsItemSelected.
+
+-refer to sampleSamples/singleViewSample for a reference implementation of a
+project built on this template.
+
+
diff --git a/ui/window/AdvancedImmersiveMode/Application/build.gradle b/ui/window/AdvancedImmersiveMode/Application/build.gradle
new file mode 100644
index 0000000..111d4f7
--- /dev/null
+++ b/ui/window/AdvancedImmersiveMode/Application/build.gradle
@@ -0,0 +1,64 @@
+
+
+
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.12.+'
+ }
+}
+
+apply plugin: 'com.android.application'
+
+
+dependencies {
+
+ compile "com.android.support:support-v4:20.+"
+ compile "com.android.support:support-v13:20.+"
+
+}
+
+// The sample build uses multiple directories to
+// keep boilerplate and common code separate from
+// the main sample code.
+List<String> dirs = [
+ 'main', // main sample code; look here for the interesting stuff.
+ 'common', // components that are reused by multiple samples
+ 'template'] // boilerplate code that is generated by the sample template process
+
+android {
+ compileSdkVersion 19
+
+ buildToolsVersion "20.0.0"
+
+ sourceSets {
+ main {
+ dirs.each { dir ->
+ java.srcDirs "src/${dir}/java"
+ res.srcDirs "src/${dir}/res"
+ }
+ }
+ androidTest.setRoot('tests')
+ androidTest.java.srcDirs = ['tests/src']
+
+ }
+
+}
+// BEGIN_EXCLUDE
+// Tasks below this line will be hidden from release output
+
+task preflight (dependsOn: parent.preflight) {
+ project.afterEvaluate {
+ // Inject a preflight task into each variant so we have a place to hook tasks
+ // that need to run before any of the android build tasks.
+ //
+ android.applicationVariants.each { variant ->
+ tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight
+ }
+ }
+}
+
+// END_EXCLUDE
diff --git a/ui/window/AdvancedImmersiveMode/buildSrc/build.gradle b/ui/window/AdvancedImmersiveMode/buildSrc/build.gradle
index 490642d..e344a8c 100644
--- a/ui/window/AdvancedImmersiveMode/buildSrc/build.gradle
+++ b/ui/window/AdvancedImmersiveMode/buildSrc/build.gradle
@@ -1,8 +1,18 @@
+
+
+
repositories {
mavenCentral()
}
-
dependencies {
compile 'org.freemarker:freemarker:2.3.20'
- compile files("libs/buildSrc.jar")
}
+
+sourceSets {
+ main {
+ groovy {
+ srcDir new File(rootDir, "../../../../../../build/buildSrc/src/main/groovy")
+ }
+ }
+}
+
diff --git a/ui/window/AdvancedImmersiveMode/buildSrc/libs/buildSrc.jar b/ui/window/AdvancedImmersiveMode/buildSrc/libs/buildSrc.jar
deleted file mode 100644
index 8154696..0000000
--- a/ui/window/AdvancedImmersiveMode/buildSrc/libs/buildSrc.jar
+++ /dev/null
Binary files differ
diff --git a/ui/window/AdvancedImmersiveMode/gradle/wrapper/gradle-wrapper.properties b/ui/window/AdvancedImmersiveMode/gradle/wrapper/gradle-wrapper.properties
index 9e133a0..7817462 100644
--- a/ui/window/AdvancedImmersiveMode/gradle/wrapper/gradle-wrapper.properties
+++ b/ui/window/AdvancedImmersiveMode/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
diff --git a/wearable/wear/SynchronizedNotifications/README-wear.txt b/wearable/wear/SynchronizedNotifications/README-wear.txt
index 033cde3..17523d7 100644
--- a/wearable/wear/SynchronizedNotifications/README-wear.txt
+++ b/wearable/wear/SynchronizedNotifications/README-wear.txt
@@ -1,5 +1,5 @@
<#--
- Copyright 2013 The Android Open Source Project
+ 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.
diff --git a/wearable/wear/SynchronizedNotifications/Shared/build.gradle b/wearable/wear/SynchronizedNotifications/Shared/build.gradle
index ebdb54b..dda6f07 100644
--- a/wearable/wear/SynchronizedNotifications/Shared/build.gradle
+++ b/wearable/wear/SynchronizedNotifications/Shared/build.gradle
@@ -22,7 +22,7 @@
'template'] // boilerplate code that is generated by the sample template process
android {
- compileSdkVersion 19
+ compileSdkVersion "android-L"
buildToolsVersion '20'
@@ -35,6 +35,4 @@
}
}
- productFlavors {
- }
}
diff --git a/wearable/wear/SynchronizedNotifications/Wearable/build.gradle b/wearable/wear/SynchronizedNotifications/Wearable/build.gradle
index 476fa4a..1d906b2 100644
--- a/wearable/wear/SynchronizedNotifications/Wearable/build.gradle
+++ b/wearable/wear/SynchronizedNotifications/Wearable/build.gradle
@@ -14,6 +14,7 @@
apply plugin: 'com.android.application'
+
dependencies {
compile 'com.google.android.gms:play-services:5.0.+@aar'
compile 'com.android.support:support-v13:20.0.+'
@@ -30,7 +31,7 @@
'template'] // boilerplate code that is generated by the sample template process
android {
- compileSdkVersion 'android-L'
+ compileSdkVersion 'android-20'
buildToolsVersion '20'
@@ -40,9 +41,6 @@
proguardFiles getDefaultProguardFile('proguard-android.txt')
}
}
- lintOptions {
- abortOnError false
- }
sourceSets {
main {
dirs.each { dir ->