summaryrefslogtreecommitdiffstats
path: root/samples/MultiWindow/src
diff options
context:
space:
mode:
authorAndrii Kulian <akulian@google.com>2016-05-17 19:26:48 -0700
committerAndrii Kulian <akulian@google.com>2016-05-19 01:27:08 -0700
commit7d7cc03dbcb22b345bf49823ae6b364bf17963a5 (patch)
tree5539f69107822a41c4dc6ee7c73193eb46542ac5 /samples/MultiWindow/src
parente1d8a63bc231ccd377d3b9c1825655d3986f56cf (diff)
downloadandroid_development-7d7cc03dbcb22b345bf49823ae6b364bf17963a5.tar.gz
android_development-7d7cc03dbcb22b345bf49823ae6b364bf17963a5.tar.bz2
android_development-7d7cc03dbcb22b345bf49823ae6b364bf17963a5.zip
Improve MultiWindow sample
Now using only one activity able to showcase supported launching options. Added instance counter for better visibility. Bug: 28848683 Change-Id: Ib98dad994d39aff1b617dce4371699c846d06f6f
Diffstat (limited to 'samples/MultiWindow/src')
-rw-r--r--samples/MultiWindow/src/com/example/android/multiwindow/LaunchingAdjacentActivity.java71
-rw-r--r--samples/MultiWindow/src/com/example/android/multiwindow/LaunchingToSideActivity.java45
-rw-r--r--samples/MultiWindow/src/com/example/android/multiwindow/MoveTaskToSideActivity.java22
3 files changed, 71 insertions, 67 deletions
diff --git a/samples/MultiWindow/src/com/example/android/multiwindow/LaunchingAdjacentActivity.java b/samples/MultiWindow/src/com/example/android/multiwindow/LaunchingAdjacentActivity.java
new file mode 100644
index 000000000..1216ff1e0
--- /dev/null
+++ b/samples/MultiWindow/src/com/example/android/multiwindow/LaunchingAdjacentActivity.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2015 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.multiwindow;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.TextView;
+
+public class LaunchingAdjacentActivity extends Activity implements View.OnClickListener {
+
+ private static final String INSTANCE_NUMBER_KEY = "instance_number";
+
+ private static int mInstanceCount;
+ private int mInstanceNumber;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.launching_adjacent_layout);
+ findViewById(R.id.launch_settings_adjacent).setOnClickListener(this);
+ findViewById(R.id.launch_new_task).setOnClickListener(this);
+ findViewById(R.id.launch_new_task_adjacent).setOnClickListener(this);
+ if (savedInstanceState != null) {
+ mInstanceNumber = savedInstanceState.getInt(INSTANCE_NUMBER_KEY);
+ } else {
+ mInstanceNumber = mInstanceCount++;
+ }
+ ((TextView) findViewById(R.id.instance_number))
+ .setText(getString(R.string.instance_number) + mInstanceNumber);
+ }
+
+ @Override
+ public void onClick(View v) {
+ if (v.getId() == R.id.launch_settings_adjacent) {
+ Intent intent = new Intent("android.settings.SETTINGS");
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
+ startActivity(intent);
+ } else if (v.getId() == R.id.launch_new_task) {
+ Intent intent = new Intent(this, LaunchingAdjacentActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ } else if (v.getId() == R.id.launch_new_task_adjacent) {
+ Intent intent = new Intent(this, LaunchingAdjacentActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK
+ | Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
+ startActivity(intent);
+ }
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle savedInstanceState) {
+ savedInstanceState.putInt(INSTANCE_NUMBER_KEY, mInstanceNumber);
+ super.onSaveInstanceState(savedInstanceState);
+ }
+}
diff --git a/samples/MultiWindow/src/com/example/android/multiwindow/LaunchingToSideActivity.java b/samples/MultiWindow/src/com/example/android/multiwindow/LaunchingToSideActivity.java
deleted file mode 100644
index f94ff570e..000000000
--- a/samples/MultiWindow/src/com/example/android/multiwindow/LaunchingToSideActivity.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2015 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.multiwindow;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-
-public class LaunchingToSideActivity extends Activity implements View.OnClickListener {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.launching_to_side_layout);
- findViewById(R.id.launch_to_the_side).setOnClickListener(this);
- findViewById(R.id.launch_new_task).setOnClickListener(this);
- }
-
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.launch_to_the_side) {
- Intent intent = new Intent("android.settings.SETTINGS");
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
- startActivity(intent);
- } else if (v.getId() == R.id.launch_new_task) {
- Intent intent = new Intent(this, MoveTaskToSideActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
- startActivity(intent);
- }
- }
-}
diff --git a/samples/MultiWindow/src/com/example/android/multiwindow/MoveTaskToSideActivity.java b/samples/MultiWindow/src/com/example/android/multiwindow/MoveTaskToSideActivity.java
deleted file mode 100644
index 90d35525d..000000000
--- a/samples/MultiWindow/src/com/example/android/multiwindow/MoveTaskToSideActivity.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.example.android.multiwindow;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-
-public class MoveTaskToSideActivity extends Activity implements View.OnClickListener {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.move_task_to_side_layout);
- findViewById(R.id.button).setOnClickListener(this);
- }
-
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(this, LaunchingToSideActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
- startActivity(intent);
- }
-}