diff --git a/samples/IntentPlayground/Android.mk b/samples/IntentPlayground/Android.mk
new file mode 100644
index 000000000..7cd3b5a94
--- /dev/null
+++ b/samples/IntentPlayground/Android.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := samples tests
+
+# Only compile source java files in this apk.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_STATIC_JAVA_LIBRARIES = android-support-v13
+
+LOCAL_PACKAGE_NAME := IntentPlayground
+
+LOCAL_SDK_VERSION := current
+
+
+include $(BUILD_PACKAGE)
+
+# Use the folloing include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/samples/IntentPlayground/AndroidManifest.xml b/samples/IntentPlayground/AndroidManifest.xml
new file mode 100644
index 000000000..210df6692
--- /dev/null
+++ b/samples/IntentPlayground/AndroidManifest.xml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/drawable/card_background.xml b/samples/IntentPlayground/res/drawable/card_background.xml
new file mode 100644
index 000000000..001247aaa
--- /dev/null
+++ b/samples/IntentPlayground/res/drawable/card_background.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/drawable/divider.xml b/samples/IntentPlayground/res/drawable/divider.xml
new file mode 100644
index 000000000..0a0dec325
--- /dev/null
+++ b/samples/IntentPlayground/res/drawable/divider.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/drawable/expand_less_mtrl.xml b/samples/IntentPlayground/res/drawable/expand_less_mtrl.xml
new file mode 100644
index 000000000..ee5cddf1c
--- /dev/null
+++ b/samples/IntentPlayground/res/drawable/expand_less_mtrl.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
diff --git a/samples/IntentPlayground/res/drawable/expand_more_mtrl.xml b/samples/IntentPlayground/res/drawable/expand_more_mtrl.xml
new file mode 100644
index 000000000..55def3d1f
--- /dev/null
+++ b/samples/IntentPlayground/res/drawable/expand_more_mtrl.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
diff --git a/samples/IntentPlayground/res/drawable/expander_group_material.xml b/samples/IntentPlayground/res/drawable/expander_group_material.xml
new file mode 100644
index 000000000..1b497da64
--- /dev/null
+++ b/samples/IntentPlayground/res/drawable/expander_group_material.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
diff --git a/samples/IntentPlayground/res/drawable/info_icon.xml b/samples/IntentPlayground/res/drawable/info_icon.xml
new file mode 100644
index 000000000..77ef9f3cb
--- /dev/null
+++ b/samples/IntentPlayground/res/drawable/info_icon.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
diff --git a/samples/IntentPlayground/res/drawable/success_card_background.xml b/samples/IntentPlayground/res/drawable/success_card_background.xml
new file mode 100644
index 000000000..bc48008e6
--- /dev/null
+++ b/samples/IntentPlayground/res/drawable/success_card_background.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/layout/activity_main.xml b/samples/IntentPlayground/res/layout/activity_main.xml
new file mode 100644
index 000000000..d74e44038
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/activity_main.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
diff --git a/samples/IntentPlayground/res/layout/activity_node.xml b/samples/IntentPlayground/res/layout/activity_node.xml
new file mode 100644
index 000000000..bd35d8f72
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/activity_node.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/IntentPlayground/res/layout/activity_radio_list_item.xml b/samples/IntentPlayground/res/layout/activity_radio_list_item.xml
new file mode 100644
index 000000000..18cccf025
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/activity_radio_list_item.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
diff --git a/samples/IntentPlayground/res/layout/checkbox_list_item.xml b/samples/IntentPlayground/res/layout/checkbox_list_item.xml
new file mode 100644
index 000000000..9ffc93c6f
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/checkbox_list_item.xml
@@ -0,0 +1,23 @@
+
+
+
diff --git a/samples/IntentPlayground/res/layout/dialog_list_item.xml b/samples/IntentPlayground/res/layout/dialog_list_item.xml
new file mode 100644
index 000000000..6be9d74e3
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/dialog_list_item.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/layout/fragment_build_intent.xml b/samples/IntentPlayground/res/layout/fragment_build_intent.xml
new file mode 100644
index 000000000..5cc5f47e4
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/fragment_build_intent.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/layout/fragment_current_task.xml b/samples/IntentPlayground/res/layout/fragment_current_task.xml
new file mode 100644
index 000000000..d299f8b44
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/fragment_current_task.xml
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/layout/fragment_intent.xml b/samples/IntentPlayground/res/layout/fragment_intent.xml
new file mode 100644
index 000000000..76e885744
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/fragment_intent.xml
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/layout/fragment_intent_dialog.xml b/samples/IntentPlayground/res/layout/fragment_intent_dialog.xml
new file mode 100644
index 000000000..eb8d6ad12
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/fragment_intent_dialog.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/layout/fragment_tree.xml b/samples/IntentPlayground/res/layout/fragment_tree.xml
new file mode 100644
index 000000000..8856e7924
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/fragment_tree.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/layout/section_header.xml b/samples/IntentPlayground/res/layout/section_header.xml
new file mode 100644
index 000000000..5edf23d0c
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/section_header.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/layout/simple_list_item.xml b/samples/IntentPlayground/res/layout/simple_list_item.xml
new file mode 100644
index 000000000..02c5d4523
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/simple_list_item.xml
@@ -0,0 +1,20 @@
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/layout/task_node.xml b/samples/IntentPlayground/res/layout/task_node.xml
new file mode 100644
index 000000000..9d1d0d9cb
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/task_node.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/IntentPlayground/res/layout/tree_node_composite.xml b/samples/IntentPlayground/res/layout/tree_node_composite.xml
new file mode 100644
index 000000000..e944762de
--- /dev/null
+++ b/samples/IntentPlayground/res/layout/tree_node_composite.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/mipmap-hdpi/ic_launcher.png b/samples/IntentPlayground/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 000000000..cde69bccc
Binary files /dev/null and b/samples/IntentPlayground/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/samples/IntentPlayground/res/mipmap-hdpi/ic_launcher_round.png b/samples/IntentPlayground/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 000000000..9a078e3e1
Binary files /dev/null and b/samples/IntentPlayground/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/samples/IntentPlayground/res/mipmap-mdpi/ic_launcher.png b/samples/IntentPlayground/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 000000000..c133a0cbd
Binary files /dev/null and b/samples/IntentPlayground/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/samples/IntentPlayground/res/mipmap-mdpi/ic_launcher_round.png b/samples/IntentPlayground/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 000000000..efc028a63
Binary files /dev/null and b/samples/IntentPlayground/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/samples/IntentPlayground/res/mipmap-xhdpi/ic_launcher.png b/samples/IntentPlayground/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 000000000..bfa42f0e7
Binary files /dev/null and b/samples/IntentPlayground/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/samples/IntentPlayground/res/mipmap-xhdpi/ic_launcher_round.png b/samples/IntentPlayground/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 000000000..3af2608a4
Binary files /dev/null and b/samples/IntentPlayground/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/samples/IntentPlayground/res/mipmap-xxhdpi/ic_launcher.png b/samples/IntentPlayground/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 000000000..324e72cdd
Binary files /dev/null and b/samples/IntentPlayground/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/samples/IntentPlayground/res/mipmap-xxhdpi/ic_launcher_round.png b/samples/IntentPlayground/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 000000000..9bec2e623
Binary files /dev/null and b/samples/IntentPlayground/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/samples/IntentPlayground/res/mipmap-xxxhdpi/ic_launcher.png b/samples/IntentPlayground/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 000000000..aee44e138
Binary files /dev/null and b/samples/IntentPlayground/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/samples/IntentPlayground/res/mipmap-xxxhdpi/ic_launcher_round.png b/samples/IntentPlayground/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 000000000..34947cd6b
Binary files /dev/null and b/samples/IntentPlayground/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/samples/IntentPlayground/res/values/colors.xml b/samples/IntentPlayground/res/values/colors.xml
new file mode 100644
index 000000000..6e7ce912c
--- /dev/null
+++ b/samples/IntentPlayground/res/values/colors.xml
@@ -0,0 +1,43 @@
+
+
+
+ #3F51B5
+ #303F9F
+ #FF4081
+
+ #F44336
+ #E91E63
+ #9C27B0
+ #673AB7
+ #3F51B5
+ #2196F3
+ #03A9F4
+ #00BCD4
+ #009688
+ #4CAF50
+ #8BC34A
+ #CDDC39
+ #9E9E9E
+ #FFC107
+ #FFEB3B
+ #FF9800
+ #FF5722
+ #795548
+ #607D8B
+ @color/md_teal_500
+ @android:color/white
+
diff --git a/samples/IntentPlayground/res/values/dimens.xml b/samples/IntentPlayground/res/values/dimens.xml
new file mode 100644
index 000000000..73e89fe24
--- /dev/null
+++ b/samples/IntentPlayground/res/values/dimens.xml
@@ -0,0 +1,17 @@
+
+
+ @android:dimen/dialog_min_width_major
+ 8dp
+ 16dp
+ 24dp
+ 32dp
+ 2dp
+ 20sp
+ 16sp
+ 12sp
+ 48dp
+ 48dp
+ 24dp
+ 24dp
+ 1dp
+
\ No newline at end of file
diff --git a/samples/IntentPlayground/res/values/strings.xml b/samples/IntentPlayground/res/values/strings.xml
new file mode 100644
index 000000000..83f39a8b7
--- /dev/null
+++ b/samples/IntentPlayground/res/values/strings.xml
@@ -0,0 +1,65 @@
+
+
+
+ Intent Playground
+ com.example.android.intentplayground.taskId
+ com.example.android.intentplayground.activityIndex
+ CompName
+ #1
+ This button triggers the intent list dialog for this activity
+ Build Intent
+ Select flags with which the intent for the launched activity will be built:
+ Select the target activity:
+ Launch activity
+ Activity Name
+ View Intent flags
+ Activity description
+ CheckBox
+ intent flag
+ Current Task
+ None
+ Current Activity
+ None
+ Last Task
+ None
+ Last Activity
+ None
+ Intent passed to current activity
+ Current Intent
+ Label for the action of the current intent
+ Action
+ which action?
+ Label for the action of the current intent
+ Data URI
+ ://
+ Label for the action of the current intent
+ Type
+ which action?
+ Label for the action of the current intent
+ Package
+ which action?
+ Label for the action of the current intent
+ Categories
+ Label for the action of the current intent
+ Flags
+ Hierarchy
+ Title
+ placeholder
+ remove
+ Move to front
+ Current Hierarchy
+ Expected Hierarchy
+
diff --git a/samples/IntentPlayground/res/values/styles.xml b/samples/IntentPlayground/res/values/styles.xml
new file mode 100644
index 000000000..ef4cd22f3
--- /dev/null
+++ b/samples/IntentPlayground/res/values/styles.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/BaseActivity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/BaseActivity.java
new file mode 100644
index 000000000..b9b70e1aa
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/BaseActivity.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.LinearLayout;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * All of the other activities extend BaseActivity, the shared functionality is implemented here
+ */
+public abstract class BaseActivity extends Activity {
+ public final static String LAUNCH_FORWARD = "com.example.android.launchForward";
+ public final static String BUILDER_FRAGMENT = "com.example.android.builderFragment";
+ protected ComponentName mActivityToLaunch;
+ protected List mTasks;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ if (BuildConfig.DEBUG) Log.d(this.getLocalClassName(), "onCreate()");
+ Intent intent = getIntent();
+ FragmentManager fragmentManager = getFragmentManager();
+ FragmentTransaction transaction = fragmentManager.beginTransaction();
+ transaction.add(R.id.fragment_container, new CurrentTaskFragment());
+ TreeFragment currentTaskFrag = new TreeFragment();
+ Bundle args = new Bundle();
+ args.putString(TreeFragment.FRAGMENT_TITLE,
+ getString(R.string.current_task_hierarchy_title));
+ currentTaskFrag.setArguments(args);
+ transaction.add(R.id.fragment_container, currentTaskFrag);
+
+ if (intent.hasExtra(TestBase.EXPECTED_HIERARCHY)) {
+ // That means this activity was launched as a test show the result fragment
+ TreeFragment expectedView = new TreeFragment();
+ Bundle expectedArgs = new Bundle();
+ expectedArgs.putParcelable(TreeFragment.TREE_NODE,
+ intent.getParcelableExtra(TestBase.EXPECTED_HIERARCHY));
+ expectedArgs.putString(TreeFragment.FRAGMENT_TITLE,
+ getString(R.string.expected_task_hierarchy_title));
+ expectedView.setArguments(expectedArgs);
+ transaction.add(R.id.fragment_container, expectedView);
+ }
+
+ transaction.add(R.id.fragment_container, new IntentFragment());
+ transaction.add(R.id.fragment_container, new IntentBuilderFragment(), BUILDER_FRAGMENT);
+ transaction.commit();
+
+ if (intent.hasExtra(LAUNCH_FORWARD)) {
+ ArrayList intents = intent.getParcelableArrayListExtra(LAUNCH_FORWARD);
+ if (!intents.isEmpty()) {
+ Intent nextIntent = intents.remove(0);
+ nextIntent.putParcelableArrayListExtra(LAUNCH_FORWARD, intents);
+ if (BuildConfig.DEBUG) {
+ Log.d(this.getLocalClassName(),
+ LAUNCH_FORWARD + " " + nextIntent.getComponent().toString());
+ }
+ startActivity(nextIntent);
+ }
+ }
+ }
+
+ /**
+ * Launches activity with the selected options
+ */
+ public void launchActivity(View view) {
+ Intent customIntent = new Intent();
+ LinearLayout flagBuilder = findViewById(R.id.build_intent_flags);
+ // Gather flags from flag builder checkbox list
+ childrenOfGroup(flagBuilder, CheckBox.class)
+ .forEach(checkbox -> {
+ int flagVal = FlagUtils.value(checkbox.getText().toString());
+ if (checkbox.isChecked()) customIntent.addFlags(flagVal);
+ else customIntent.removeFlags(flagVal);
+ });
+ customIntent.setComponent(mActivityToLaunch);
+ startActivity(customIntent);
+ }
+
+ /**
+ * Convenience method to retrieve children of a certain type from a {@link ViewGroup}
+ * @param group the ViewGroup to retrieve children from
+ */
+ protected static List childrenOfGroup(ViewGroup group, Class viewType) {
+ List list = new LinkedList<>();
+ for (int i = 0; i < group.getChildCount(); i++) {
+ View v = group.getChildAt(i);
+ if (viewType.isAssignableFrom(v.getClass())) list.add(viewType.cast(v));
+ }
+ return list;
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ setIntent(intent);
+ }
+}
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/ClearTaskOnLaunchActivity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/ClearTaskOnLaunchActivity.java
new file mode 100644
index 000000000..3eea73c15
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/ClearTaskOnLaunchActivity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+/**
+ * An activity with clearTaskOnLaunch flag set in AndroidManifest.xml
+ */
+public class ClearTaskOnLaunchActivity extends BaseActivity {}
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/DocumentLaunchAlwaysActivity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/DocumentLaunchAlwaysActivity.java
new file mode 100644
index 000000000..3e018a2c0
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/DocumentLaunchAlwaysActivity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+/**
+ * An activity with documentLaunch="always" set in AndroidManifest.xml
+ */
+public class DocumentLaunchAlwaysActivity extends BaseActivity {}
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/DocumentLaunchIntoActivity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/DocumentLaunchIntoActivity.java
new file mode 100644
index 000000000..b66055c29
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/DocumentLaunchIntoActivity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+/**
+ * An activity with documentLaunch="intoExisting" set in AndroidManifest.xml
+ */
+public class DocumentLaunchIntoActivity extends BaseActivity {}
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/DocumentLaunchNeverActivity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/DocumentLaunchNeverActivity.java
new file mode 100644
index 000000000..d0e93d6e2
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/DocumentLaunchNeverActivity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+/**
+ * An activity with documentLaunch="never" set in AndroidManifest.xml
+ */
+public class DocumentLaunchNeverActivity extends BaseActivity {}
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/LauncherActivity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/LauncherActivity.java
new file mode 100644
index 000000000..70429e4d5
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/LauncherActivity.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+import android.content.ComponentName;
+import android.content.Intent;
+import android.os.Bundle;
+
+/**
+ * A singleInstance activity that is responsible for a launching a bootstrap stack of activities
+ */
+public class LauncherActivity extends BaseActivity {
+ private TestBase mTester;
+ public static final String TAG = "LauncherActivity";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Node mRoot = new Node(new ComponentName(this, LauncherActivity.class));
+ // Describe initial setup of tasks
+ // create singleTask, singleInstance, and two documents in separate tasks
+ mRoot.addChild( new Node(new ComponentName(this, SingleTaskActivity.class)))
+ .addChild( new Node(new ComponentName(this, DocumentLaunchAlwaysActivity.class)))
+ .addChild( new Node(new ComponentName(this, DocumentLaunchIntoActivity.class)));
+ // Create three tasks with three activities each, with affinity set
+ Node taskAffinity1 = new Node(new ComponentName(this, TaskAffinity1Activity.class));
+ taskAffinity1
+ .addChild(new Node(new ComponentName(this, TaskAffinity1Activity.class)))
+ .addChild(new Node(new ComponentName(this, TaskAffinity1Activity.class)));
+ Node taskAffinity2 = new Node(new ComponentName(this, ClearTaskOnLaunchActivity.class));
+ taskAffinity2
+ .addChild(new Node(new ComponentName(this, TaskAffinity2Activity.class)))
+ .addChild(new Node(new ComponentName(this, TaskAffinity2Activity.class)));
+ Node taskAffinity3 = new Node(new ComponentName(this, TaskAffinity3Activity.class));
+ taskAffinity3
+ .addChild(new Node(new ComponentName(this, TaskAffinity3Activity.class)))
+ .addChild(new Node(new ComponentName(this, TaskAffinity3Activity.class)));
+ mRoot.addChild(taskAffinity1).addChild(taskAffinity2).addChild(taskAffinity3);
+ mTester = new TestBase(this, mRoot);
+ mTester.setupActivities(TestBase.LaunchStyle.TASK_STACK_BUILDER);
+ }
+
+ /**
+ * Launches activity with the selected options
+ */
+ public void launchActivity(Intent customIntent) {
+ customIntent.putExtra(TestBase.EXPECTED_HIERARCHY, mTester.computeExpected(customIntent));
+ startActivity(customIntent);
+ }
+}
\ No newline at end of file
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/NoHistoryActivity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/NoHistoryActivity.java
new file mode 100644
index 000000000..06dae2586
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/NoHistoryActivity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+/**
+ * An activity with noHistory="true" set in AndroidManifest.xml
+ */
+public class NoHistoryActivity extends BaseActivity {}
\ No newline at end of file
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/Shims.java b/samples/IntentPlayground/src/com/example/android/intentplayground/Shims.java
new file mode 100644
index 000000000..46bdaf7d3
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/Shims.java
@@ -0,0 +1,76 @@
+/** TODO: http://go/java-style#javadoc */
+package com.example.android.intentplayground;
+
+import android.app.Fragment;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.view.View;
+
+import java.util.List;
+import java.util.Map;
+
+class TestBase {
+ static final String EXPECTED_HIERARCHY = "";
+ enum LaunchStyle { TASK_STACK_BUILDER, COMMAND_LINE, LAUNCH_FORWARD }
+ TestBase(Context context, Node hierarchy) {}
+ void setupActivities(LaunchStyle style) {}
+ Node computeExpected(Intent intent) { return null; }
+ static Node describeTaskHierarchy(Context context) { return null; }
+
+}
+class TreeFragment extends Fragment {
+ static final String TREE_NODE = "";
+ static final String FRAGMENT_TITLE = "";
+}
+class CurrentTaskFragment extends Fragment {}
+class IntentFragment extends Fragment {}
+class IntentBuilderFragment extends Fragment implements View.OnClickListener {
+ ComponentName mActivityToLaunch;
+ void selectLaunchMode(View view) {}
+ public void onClick(View view) {}
+ void clearFlags() {}
+ void selectFlags(List flags) {}
+}
+class BuildConfig {
+ static final boolean DEBUG = true;
+}
+class Node implements Parcelable, Comparable {
+ ComponentName name;
+ boolean isTaskNode;
+ int taskId;
+ static final String TAG = "";
+ public static final Creator CREATOR = new Creator() {
+ @Override
+ public Node createFromParcel(Parcel in) {
+ return new Node(in);
+ }
+
+ @Override
+ public Node[] newArray(int size) {
+ return new Node[size];
+ }
+ };;
+ List children;
+ Node(ComponentName data) {}
+ Node(int taskId) {}
+ Node(Node other) {}
+ Node(Parcel in) {}
+ Node addChild(Node child) { return null; }
+ boolean equals(Node other) { return false; }
+ public int compareTo(Node o) {return 0;}
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {}
+ @Override
+ public int describeContents() { return 0; }
+}
+class FlagUtils {
+ static List discoverFlags(Intent intent) { return null; }
+ static List intentFlags() { return null; }
+ static Map> intentFlagsByCategory() { return null; }
+ static int value(String flagName) { return 0; }
+ static List discoverActivityFlags() { return null; }
+ static String camelify(String snake) { return null; }
+}
\ No newline at end of file
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/SingleInstanceActivity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/SingleInstanceActivity.java
new file mode 100644
index 000000000..968778023
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/SingleInstanceActivity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+/**
+ * An activity with launchMode="singleInstance" set in AndroidManifest.xml
+ */
+public class SingleInstanceActivity extends BaseActivity {}
\ No newline at end of file
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/SingleTaskActivity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/SingleTaskActivity.java
new file mode 100644
index 000000000..8d3137f4c
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/SingleTaskActivity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+/**
+ * An activity with launchMode="singleTask" set in AndroidManifest.xml
+ */
+public class SingleTaskActivity extends BaseActivity {}
\ No newline at end of file
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/SingleTopActivity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/SingleTopActivity.java
new file mode 100644
index 000000000..b4f846ee1
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/SingleTopActivity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+/**
+ * An activity with launchMode="singleTop" set in AndroidManifest.xml
+ */
+public class SingleTopActivity extends BaseActivity {}
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/TaskAffinity1Activity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/TaskAffinity1Activity.java
new file mode 100644
index 000000000..14609d803
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/TaskAffinity1Activity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+/**
+ * An activity with taskAffinity=".t1" set in AndroidManifest.xml
+ */
+public class TaskAffinity1Activity extends BaseActivity {}
\ No newline at end of file
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/TaskAffinity2Activity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/TaskAffinity2Activity.java
new file mode 100644
index 000000000..bf1e9e961
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/TaskAffinity2Activity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+/**
+ * An activity with taskAffinity=".t2" set in AndroidManifest.xml
+ */
+public class TaskAffinity2Activity extends BaseActivity {}
\ No newline at end of file
diff --git a/samples/IntentPlayground/src/com/example/android/intentplayground/TaskAffinity3Activity.java b/samples/IntentPlayground/src/com/example/android/intentplayground/TaskAffinity3Activity.java
new file mode 100644
index 000000000..c48e9fd1b
--- /dev/null
+++ b/samples/IntentPlayground/src/com/example/android/intentplayground/TaskAffinity3Activity.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 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.intentplayground;
+
+/**
+ * An activity with taskAffinity=".t3" set in AndroidManifest.xml
+ */
+public class TaskAffinity3Activity extends BaseActivity {}
\ No newline at end of file