From bd43fbe93187837f32c93dcc0cd3fbdaf82b2ab3 Mon Sep 17 00:00:00 2001 From: Liam Clark Date: Fri, 9 Nov 2018 17:40:35 -0800 Subject: [PATCH] Intent Playground sample application The app allows a user to explore the behaviour of different launch modes, task affinities and intent flags. It displays the current state of all tasks in the application and their corresponding flags. It allows the user to launch a set amount of activities on launch. This bring the user directly into a state where many options for exploration are available, rather than having to go through a complicated setup first. Access the activity field of RecentTaskInfo using reflection and mirror the ActivityInstanceInfo into our own value object. This breaks the compile time dependency on the ActivityInstanceInfo api and turns it into a runtime dependency. If the api is missing on the device we can still show the task structure and log an error with the missing activity instance info. Known bug: The enable suggestion button crashes the application. Test: Build and Run Change-Id: Id0274bae159c16aee6dccd805deb53851ffcf21d --- samples/IntentPlayground/Android.mk | 7 +- samples/IntentPlayground/AndroidManifest.xml | 4 + .../res/color/default_checkbox.xml | 24 ++ .../res/color/suggested_checkbox.xml | 21 + .../res/drawable/card_background.xml | 13 +- .../IntentPlayground/res/drawable/divider.xml | 2 + .../res/drawable/expand_less_mtrl.xml | 9 +- .../res/drawable/expand_more_mtrl.xml | 8 +- .../res/drawable/help_outline.xml | 24 ++ .../res/drawable/icon_close.xml | 24 ++ .../res/drawable/icon_launch.xml | 24 ++ .../res/drawable/icon_tests.xml | 24 ++ .../res/drawable/icon_verify.xml | 24 ++ .../res/drawable/info_icon.xml | 8 +- .../res/drawable/label_background.xml | 20 + .../IntentPlayground/res/drawable/shade.xml | 18 + .../res/drawable/showcase_background.xml | 25 ++ .../res/drawable/snack_background.xml | 20 + .../res/drawable/tutorial_card.xml | 23 ++ .../res/layout/activity_main.xml | 41 +- .../res/layout/activity_node.xml | 2 +- .../res/layout/activity_radio_list_item.xml | 2 +- .../res/layout/checkbox_list_item.xml | 9 +- .../res/layout/dialog_list_item.xml | 4 +- .../res/layout/fragment_intent.xml | 1 - .../res/layout/fragment_intent_dialog.xml | 1 - .../res/layout/fragment_result.xml | 47 +++ .../res/layout/fragment_tree.xml | 1 + .../res/layout/section_header.xml | 9 +- .../res/layout/showcase_skeleton.xml | 70 ++++ .../res/layout/snack_loading.xml | 31 ++ .../IntentPlayground/res/layout/task_node.xml | 4 +- ...build_intent.xml => view_build_intent.xml} | 46 ++- samples/IntentPlayground/res/menu/app_bar.xml | 32 ++ .../IntentPlayground/res/values/colors.xml | 7 + .../IntentPlayground/res/values/dimens.xml | 35 +- samples/IntentPlayground/res/values/ids.xml | 21 + .../IntentPlayground/res/values/strings.xml | 42 +- .../IntentPlayground/res/values/styles.xml | 11 +- .../android/intentplayground/AMControl.java | 84 ++++ .../intentplayground/ActivityFlag.java | 27 ++ .../intentplayground/BaseActivity.java | 223 +++++++---- .../ClearTaskOnLaunchActivity.java | 2 +- .../intentplayground/ColorManager.java | 91 +++++ .../intentplayground/CurrentTaskFragment.java | 81 ++++ .../DocumentLaunchAlwaysActivity.java | 2 +- .../DocumentLaunchIntoActivity.java | 2 +- .../DocumentLaunchNeverActivity.java | 2 +- .../intentplayground/ExpandableAdapter.java | 193 +++++++++ .../android/intentplayground/FlagUtils.java | 350 +++++++++++++++++ .../intentplayground/IntentBuilderView.java | 338 ++++++++++++++++ .../IntentDialogFragment.java | 96 +++++ .../android/intentplayground/IntentFlags.java | 102 +++++ .../intentplayground/IntentFragment.java | 97 +++++ .../intentplayground/LauncherActivity.java | 193 +++++++-- .../intentplayground/NoHistoryActivity.java | 2 +- .../android/intentplayground/Node.java | 276 +++++++++++++ .../intentplayground/RegularActivity.java | 22 ++ .../android/intentplayground/Shims.java | 84 +--- .../intentplayground/ShowcaseFragment.java | 230 +++++++++++ .../intentplayground/SingleTaskActivity.java | 2 +- .../intentplayground/SingleTopActivity.java | 2 +- .../android/intentplayground/StepAdapter.java | 105 +++++ .../TaskAffinity1Activity.java | 2 +- .../TaskAffinity2Activity.java | 2 +- .../TaskAffinity3Activity.java | 2 +- .../android/intentplayground/TaskInfo.java | 98 +++++ .../android/intentplayground/TestBase.java | 369 ++++++++++++++++++ .../intentplayground/TreeFragment.java | 158 ++++++++ 69 files changed, 3730 insertions(+), 245 deletions(-) create mode 100644 samples/IntentPlayground/res/color/default_checkbox.xml create mode 100644 samples/IntentPlayground/res/color/suggested_checkbox.xml create mode 100644 samples/IntentPlayground/res/drawable/help_outline.xml create mode 100644 samples/IntentPlayground/res/drawable/icon_close.xml create mode 100644 samples/IntentPlayground/res/drawable/icon_launch.xml create mode 100644 samples/IntentPlayground/res/drawable/icon_tests.xml create mode 100644 samples/IntentPlayground/res/drawable/icon_verify.xml create mode 100644 samples/IntentPlayground/res/drawable/label_background.xml create mode 100644 samples/IntentPlayground/res/drawable/shade.xml create mode 100644 samples/IntentPlayground/res/drawable/showcase_background.xml create mode 100644 samples/IntentPlayground/res/drawable/snack_background.xml create mode 100644 samples/IntentPlayground/res/drawable/tutorial_card.xml create mode 100644 samples/IntentPlayground/res/layout/fragment_result.xml create mode 100644 samples/IntentPlayground/res/layout/showcase_skeleton.xml create mode 100644 samples/IntentPlayground/res/layout/snack_loading.xml rename samples/IntentPlayground/res/layout/{fragment_build_intent.xml => view_build_intent.xml} (65%) create mode 100644 samples/IntentPlayground/res/menu/app_bar.xml create mode 100644 samples/IntentPlayground/res/values/ids.xml create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/AMControl.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/ActivityFlag.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/ColorManager.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/CurrentTaskFragment.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/ExpandableAdapter.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/FlagUtils.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/IntentBuilderView.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/IntentDialogFragment.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/IntentFlags.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/IntentFragment.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/Node.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/RegularActivity.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/ShowcaseFragment.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/StepAdapter.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/TaskInfo.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/TestBase.java create mode 100644 samples/IntentPlayground/src/com/example/android/intentplayground/TreeFragment.java diff --git a/samples/IntentPlayground/Android.mk b/samples/IntentPlayground/Android.mk index 21cdc3f3c..9a316f5d5 100644 --- a/samples/IntentPlayground/Android.mk +++ b/samples/IntentPlayground/Android.mk @@ -8,6 +8,11 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res +LOCAL_STATIC_ANDROID_LIBRARIES := \ + android-support-v13 \ + android-support-v7-appcompat \ + android-support-v4 \ + LOCAL_USE_AAPT2 := true LOCAL_PACKAGE_NAME := IntentPlayground @@ -17,5 +22,5 @@ LOCAL_SDK_VERSION := current include $(BUILD_PACKAGE) -# Use the folloing include to make our test apk. +# Use the following 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 index 210df6692..329c90ec4 100644 --- a/samples/IntentPlayground/AndroidManifest.xml +++ b/samples/IntentPlayground/AndroidManifest.xml @@ -16,7 +16,10 @@ + + + + diff --git a/samples/IntentPlayground/res/color/default_checkbox.xml b/samples/IntentPlayground/res/color/default_checkbox.xml new file mode 100644 index 000000000..ebf820f51 --- /dev/null +++ b/samples/IntentPlayground/res/color/default_checkbox.xml @@ -0,0 +1,24 @@ + + + + + + + + + + diff --git a/samples/IntentPlayground/res/color/suggested_checkbox.xml b/samples/IntentPlayground/res/color/suggested_checkbox.xml new file mode 100644 index 000000000..6a8fa1f88 --- /dev/null +++ b/samples/IntentPlayground/res/color/suggested_checkbox.xml @@ -0,0 +1,21 @@ + + + + + + + + \ No newline at end of file diff --git a/samples/IntentPlayground/res/drawable/card_background.xml b/samples/IntentPlayground/res/drawable/card_background.xml index 001247aaa..84b56432f 100644 --- a/samples/IntentPlayground/res/drawable/card_background.xml +++ b/samples/IntentPlayground/res/drawable/card_background.xml @@ -14,7 +14,14 @@ limitations under the License. --> - - - + + + + + + \ No newline at end of file diff --git a/samples/IntentPlayground/res/drawable/divider.xml b/samples/IntentPlayground/res/drawable/divider.xml index 0a0dec325..8878ce347 100644 --- a/samples/IntentPlayground/res/drawable/divider.xml +++ b/samples/IntentPlayground/res/drawable/divider.xml @@ -14,6 +14,8 @@ limitations under the License. --> + + \ 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 index ee5cddf1c..692e77d5e 100644 --- a/samples/IntentPlayground/res/drawable/expand_less_mtrl.xml +++ b/samples/IntentPlayground/res/drawable/expand_less_mtrl.xml @@ -14,10 +14,11 @@ limitations under the License. --> + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + diff --git a/samples/IntentPlayground/res/drawable/expand_more_mtrl.xml b/samples/IntentPlayground/res/drawable/expand_more_mtrl.xml index 55def3d1f..f8402aa2a 100644 --- a/samples/IntentPlayground/res/drawable/expand_more_mtrl.xml +++ b/samples/IntentPlayground/res/drawable/expand_more_mtrl.xml @@ -14,10 +14,10 @@ limitations under the License. --> + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> diff --git a/samples/IntentPlayground/res/drawable/help_outline.xml b/samples/IntentPlayground/res/drawable/help_outline.xml new file mode 100644 index 000000000..415c72a53 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/help_outline.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/samples/IntentPlayground/res/drawable/icon_close.xml b/samples/IntentPlayground/res/drawable/icon_close.xml new file mode 100644 index 000000000..6960825ab --- /dev/null +++ b/samples/IntentPlayground/res/drawable/icon_close.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/samples/IntentPlayground/res/drawable/icon_launch.xml b/samples/IntentPlayground/res/drawable/icon_launch.xml new file mode 100644 index 000000000..2084bb295 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/icon_launch.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/samples/IntentPlayground/res/drawable/icon_tests.xml b/samples/IntentPlayground/res/drawable/icon_tests.xml new file mode 100644 index 000000000..77c5a9a71 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/icon_tests.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/samples/IntentPlayground/res/drawable/icon_verify.xml b/samples/IntentPlayground/res/drawable/icon_verify.xml new file mode 100644 index 000000000..cd55cc501 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/icon_verify.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/samples/IntentPlayground/res/drawable/info_icon.xml b/samples/IntentPlayground/res/drawable/info_icon.xml index 77ef9f3cb..1848e8ce8 100644 --- a/samples/IntentPlayground/res/drawable/info_icon.xml +++ b/samples/IntentPlayground/res/drawable/info_icon.xml @@ -14,10 +14,10 @@ limitations under the License. --> + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> diff --git a/samples/IntentPlayground/res/drawable/label_background.xml b/samples/IntentPlayground/res/drawable/label_background.xml new file mode 100644 index 000000000..ec0b4e8c9 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/label_background.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/samples/IntentPlayground/res/drawable/shade.xml b/samples/IntentPlayground/res/drawable/shade.xml new file mode 100644 index 000000000..e5107c819 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/shade.xml @@ -0,0 +1,18 @@ + + + + + diff --git a/samples/IntentPlayground/res/drawable/showcase_background.xml b/samples/IntentPlayground/res/drawable/showcase_background.xml new file mode 100644 index 000000000..750dd1f92 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/showcase_background.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/samples/IntentPlayground/res/drawable/snack_background.xml b/samples/IntentPlayground/res/drawable/snack_background.xml new file mode 100644 index 000000000..6fe2c4850 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/snack_background.xml @@ -0,0 +1,20 @@ + + + + + + + diff --git a/samples/IntentPlayground/res/drawable/tutorial_card.xml b/samples/IntentPlayground/res/drawable/tutorial_card.xml new file mode 100644 index 000000000..88a0ea7b2 --- /dev/null +++ b/samples/IntentPlayground/res/drawable/tutorial_card.xml @@ -0,0 +1,23 @@ + + + + + + + + + + diff --git a/samples/IntentPlayground/res/layout/activity_main.xml b/samples/IntentPlayground/res/layout/activity_main.xml index d74e44038..19c01f888 100644 --- a/samples/IntentPlayground/res/layout/activity_main.xml +++ b/samples/IntentPlayground/res/layout/activity_main.xml @@ -13,19 +13,40 @@ See the License for the specific language governing permissions and limitations under the License. --> - + android:layout_height="match_parent"> + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + - + \ No newline at end of file diff --git a/samples/IntentPlayground/res/layout/activity_node.xml b/samples/IntentPlayground/res/layout/activity_node.xml index bd35d8f72..391ecd283 100644 --- a/samples/IntentPlayground/res/layout/activity_node.xml +++ b/samples/IntentPlayground/res/layout/activity_node.xml @@ -34,7 +34,7 @@ android:id="@+id/color_label" android:layout_width="match_parent" android:layout_height="match_parent" - android:src="@drawable/card_background" + android:src="@drawable/label_background" android:tint="@color/defaultTint" /> diff --git a/samples/IntentPlayground/res/layout/checkbox_list_item.xml b/samples/IntentPlayground/res/layout/checkbox_list_item.xml index 9ffc93c6f..0a2407047 100644 --- a/samples/IntentPlayground/res/layout/checkbox_list_item.xml +++ b/samples/IntentPlayground/res/layout/checkbox_list_item.xml @@ -13,11 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. --> - diff --git a/samples/IntentPlayground/res/layout/dialog_list_item.xml b/samples/IntentPlayground/res/layout/dialog_list_item.xml index 6be9d74e3..5f6b55ccd 100644 --- a/samples/IntentPlayground/res/layout/dialog_list_item.xml +++ b/samples/IntentPlayground/res/layout/dialog_list_item.xml @@ -22,6 +22,4 @@ android:paddingRight="@dimen/fullMargin" android:text="@string/dialog_intent_flag_placeholder" android:textAppearance="@style/normal" - android:textSize="@dimen/regularText"> - - \ No newline at end of file + android:textSize="@dimen/regularText" /> \ No newline at end of file diff --git a/samples/IntentPlayground/res/layout/fragment_intent.xml b/samples/IntentPlayground/res/layout/fragment_intent.xml index 76e885744..fc3a6b982 100644 --- a/samples/IntentPlayground/res/layout/fragment_intent.xml +++ b/samples/IntentPlayground/res/layout/fragment_intent.xml @@ -23,7 +23,6 @@ android:layout_marginRight="@dimen/smallMargin" android:layout_marginStart="@dimen/smallMargin" android:layout_marginTop="@dimen/smallMargin" - android:background="@drawable/card_background" android:elevation="@dimen/cardElevation" android:orientation="vertical" android:padding="@dimen/medMargin"> diff --git a/samples/IntentPlayground/res/layout/fragment_intent_dialog.xml b/samples/IntentPlayground/res/layout/fragment_intent_dialog.xml index eb8d6ad12..2398a36a8 100644 --- a/samples/IntentPlayground/res/layout/fragment_intent_dialog.xml +++ b/samples/IntentPlayground/res/layout/fragment_intent_dialog.xml @@ -14,7 +14,6 @@ limitations under the License. --> diff --git a/samples/IntentPlayground/res/layout/fragment_result.xml b/samples/IntentPlayground/res/layout/fragment_result.xml new file mode 100644 index 000000000..d902a9468 --- /dev/null +++ b/samples/IntentPlayground/res/layout/fragment_result.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + diff --git a/samples/IntentPlayground/res/layout/fragment_tree.xml b/samples/IntentPlayground/res/layout/fragment_tree.xml index 8856e7924..86783685f 100644 --- a/samples/IntentPlayground/res/layout/fragment_tree.xml +++ b/samples/IntentPlayground/res/layout/fragment_tree.xml @@ -32,6 +32,7 @@ android:layout_marginTop="@dimen/medMargin" android:text="@string/task_tree_title" android:textAppearance="@style/title" /> + - + android:paddingTop="@dimen/denseSectionMargin" + android:paddingBottom="@dimen/smallMargin"> + + + + + +