Move AppNavigation samples around
Move AppNavigation to SupportAppNavigation - this one uses the support
lib navigation helpers.
Add AppNavigation as an implementation of the same sample using the
framework features in JB.
Change-Id: I59e0f2e3e11ccccc277b177aee87bd88da8eb2c6
diff --git a/build/sdk.atree b/build/sdk.atree
index 2c10f44..b23f5b3 100644
--- a/build/sdk.atree
+++ b/build/sdk.atree
@@ -228,6 +228,7 @@
${OUT_DIR}/target/common/obj/PACKAGING/android-support-v4_intermediates/android-support-v4.jar extras/android/support/v4/android-support-v4.jar
frameworks/support/v4 extras/android/support/v4/src
development/samples/Support4Demos extras/android/support/samples/Support4Demos
+development/samples/SupportAppNavigation extras/android/support/samples/SupportAppNavigation
${OUT_DIR}/target/common/obj/PACKAGING/android-support-v13_intermediates/android-support-v13.jar extras/android/support/v13/android-support-v13.jar
frameworks/support/v13 extras/android/support/v13/src
diff --git a/samples/AppNavigation/Android.mk b/samples/AppNavigation/Android.mk
index 758201e..cdc0717 100644
--- a/samples/AppNavigation/Android.mk
+++ b/samples/AppNavigation/Android.mk
@@ -7,8 +7,6 @@
LOCAL_PACKAGE_NAME := AppNavigation
-LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
-
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)
diff --git a/samples/AppNavigation/AndroidManifest.xml b/samples/AppNavigation/AndroidManifest.xml
index 135016e..6a600c4 100644
--- a/samples/AppNavigation/AndroidManifest.xml
+++ b/samples/AppNavigation/AndroidManifest.xml
@@ -19,8 +19,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.appnavigation">
- <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
-
<application android:label="@string/app_name">
<activity android:name=".app.AppNavHomeActivity"
android:label="@string/app_nav_home_label">
@@ -31,7 +29,8 @@
</activity>
<activity android:name=".app.SimpleUpActivity"
- android:label="@string/simple_up_label">
+ android:label="@string/simple_up_label"
+ android:parentActivityName=".app.AppNavHomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -41,7 +40,8 @@
</activity>
<activity android:name=".app.PeerActivity"
- android:label="@string/peer_label">
+ android:label="@string/peer_label"
+ android:parentActivityName=".app.AppNavHomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -51,7 +51,8 @@
</activity>
<activity android:name=".app.ViewFromOtherTaskActivity"
- android:label="@string/view_from_other_task_label">
+ android:label="@string/view_from_other_task_label"
+ android:parentActivityName=".app.AppNavHomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -71,7 +72,8 @@
</activity>
<activity android:name=".app.ContentViewActivity"
- android:label="@string/content_view_label">
+ android:label="@string/content_view_label"
+ android:parentActivityName=".app.ContentCategoryActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
@@ -83,7 +85,8 @@
</activity>
<activity android:name=".app.ContentCategoryActivity"
- android:label="@string/content_category_label">
+ android:label="@string/content_category_label"
+ android:parentActivityName=".app.AppNavHomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
@@ -93,7 +96,8 @@
</activity>
<activity android:name=".app.NotificationsActivity"
- android:label="@string/notifications_label">
+ android:label="@string/notifications_label"
+ android:parentActivityName=".app.AppNavHomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
diff --git a/samples/AppNavigation/src/com/example/android/appnavigation/app/ContentCategoryActivity.java b/samples/AppNavigation/src/com/example/android/appnavigation/app/ContentCategoryActivity.java
index 534f391..ad41e9d 100644
--- a/samples/AppNavigation/src/com/example/android/appnavigation/app/ContentCategoryActivity.java
+++ b/samples/AppNavigation/src/com/example/android/appnavigation/app/ContentCategoryActivity.java
@@ -21,8 +21,6 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
-import android.support.v4.app.NavUtils;
-import android.view.MenuItem;
import android.view.View;
public class ContentCategoryActivity extends Activity {
@@ -30,17 +28,6 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_category);
-
- ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- NavUtils.navigateUpFromSameTask(this);
- return true;
- }
- return super.onOptionsItemSelected(item);
}
public void onViewContent(View v) {
diff --git a/samples/AppNavigation/src/com/example/android/appnavigation/app/ContentViewActivity.java b/samples/AppNavigation/src/com/example/android/appnavigation/app/ContentViewActivity.java
index 5283230..ffbbef3 100644
--- a/samples/AppNavigation/src/com/example/android/appnavigation/app/ContentViewActivity.java
+++ b/samples/AppNavigation/src/com/example/android/appnavigation/app/ContentViewActivity.java
@@ -21,11 +21,6 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
-import android.support.v4.app.NavUtils;
-import android.support.v4.app.ShareCompat;
-import android.support.v4.app.TaskStackBuilder;
-import android.text.TextUtils;
-import android.view.MenuItem;
import android.widget.TextView;
public class ContentViewActivity extends Activity {
@@ -36,8 +31,6 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.content_view);
- ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
-
Intent intent = getIntent();
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
TextView tv = (TextView) findViewById(R.id.status_text);
@@ -47,21 +40,4 @@
tv.setText(intent.getStringExtra(EXTRA_TEXT));
}
}
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- Intent upIntent = NavUtils.getParentActivityIntent(this);
- if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
- TaskStackBuilder.from(this)
- .addParentStack(this)
- .startActivities();
- finish();
- } else {
- NavUtils.navigateUpTo(this, upIntent);
- }
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
}
diff --git a/samples/AppNavigation/src/com/example/android/appnavigation/app/InterstitialMessageActivity.java b/samples/AppNavigation/src/com/example/android/appnavigation/app/InterstitialMessageActivity.java
index 1d0154d..c96995c 100644
--- a/samples/AppNavigation/src/com/example/android/appnavigation/app/InterstitialMessageActivity.java
+++ b/samples/AppNavigation/src/com/example/android/appnavigation/app/InterstitialMessageActivity.java
@@ -19,9 +19,9 @@
import com.example.android.appnavigation.R;
import android.app.Activity;
+import android.app.TaskStackBuilder;
import android.content.Intent;
import android.os.Bundle;
-import android.support.v4.app.TaskStackBuilder;
import android.view.View;
public class InterstitialMessageActivity extends Activity {
diff --git a/samples/AppNavigation/src/com/example/android/appnavigation/app/NotificationsActivity.java b/samples/AppNavigation/src/com/example/android/appnavigation/app/NotificationsActivity.java
index f14dbc6..bf338be 100644
--- a/samples/AppNavigation/src/com/example/android/appnavigation/app/NotificationsActivity.java
+++ b/samples/AppNavigation/src/com/example/android/appnavigation/app/NotificationsActivity.java
@@ -19,14 +19,12 @@
import com.example.android.appnavigation.R;
import android.app.Activity;
+import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
+import android.app.TaskStackBuilder;
import android.content.Intent;
import android.os.Bundle;
-import android.support.v4.app.NavUtils;
-import android.support.v4.app.NotificationCompat;
-import android.support.v4.app.TaskStackBuilder;
-import android.view.MenuItem;
import android.view.View;
public class NotificationsActivity extends Activity {
@@ -34,21 +32,10 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.notifications);
-
- ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- NavUtils.navigateUpFromSameTask(this);
- return true;
- }
- return super.onOptionsItemSelected(item);
}
public void onPostDirect(View v) {
- NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
+ Notification.Builder builder = new Notification.Builder(this)
.setTicker("Direct Notification")
.setSmallIcon(android.R.drawable.stat_notify_chat)
.setContentTitle("Direct Notification")
@@ -64,7 +51,7 @@
}
public void onPostInterstitial(View v) {
- NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
+ Notification.Builder builder = new Notification.Builder(this)
.setTicker("Interstitial Notification")
.setSmallIcon(android.R.drawable.stat_notify_chat)
.setContentTitle("Interstitial Notification")
diff --git a/samples/AppNavigation/src/com/example/android/appnavigation/app/PeerActivity.java b/samples/AppNavigation/src/com/example/android/appnavigation/app/PeerActivity.java
index 45083fd..de08108 100644
--- a/samples/AppNavigation/src/com/example/android/appnavigation/app/PeerActivity.java
+++ b/samples/AppNavigation/src/com/example/android/appnavigation/app/PeerActivity.java
@@ -18,12 +18,9 @@
import com.example.android.appnavigation.R;
-import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
-import android.support.v4.app.NavUtils;
-import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
@@ -38,22 +35,11 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.peer);
- ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
-
mPeerCount = getIntent().getIntExtra(EXTRA_PEER_COUNT, 0) + 1;
TextView tv = (TextView) findViewById(R.id.peer_counter);
tv.setText(getResources().getText(R.string.peer_count).toString() + mPeerCount);
}
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- NavUtils.navigateUpFromSameTask(this);
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
public void onLaunchPeer(View v) {
Intent target = new Intent(this, PeerActivity.class);
target.putExtra(EXTRA_PEER_COUNT, mPeerCount);
diff --git a/samples/AppNavigation/src/com/example/android/appnavigation/app/SimpleUpActivity.java b/samples/AppNavigation/src/com/example/android/appnavigation/app/SimpleUpActivity.java
index 4141951..9366678 100644
--- a/samples/AppNavigation/src/com/example/android/appnavigation/app/SimpleUpActivity.java
+++ b/samples/AppNavigation/src/com/example/android/appnavigation/app/SimpleUpActivity.java
@@ -18,27 +18,13 @@
import com.example.android.appnavigation.R;
-import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle;
-import android.support.v4.app.NavUtils;
-import android.view.MenuItem;
public class SimpleUpActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_up);
-
- ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- NavUtils.navigateUpFromSameTask(this);
- return true;
- }
- return super.onOptionsItemSelected(item);
}
}
diff --git a/samples/AppNavigation/src/com/example/android/appnavigation/app/ViewFromOtherTaskActivity.java b/samples/AppNavigation/src/com/example/android/appnavigation/app/ViewFromOtherTaskActivity.java
index 06e1699..f183554 100644
--- a/samples/AppNavigation/src/com/example/android/appnavigation/app/ViewFromOtherTaskActivity.java
+++ b/samples/AppNavigation/src/com/example/android/appnavigation/app/ViewFromOtherTaskActivity.java
@@ -21,8 +21,6 @@
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
-import android.support.v4.app.NavUtils;
-import android.view.MenuItem;
import android.view.View;
public class ViewFromOtherTaskActivity extends Activity {
@@ -30,17 +28,6 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_from_other_task);
-
- ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- NavUtils.navigateUpFromSameTask(this);
- return true;
- }
- return false;
}
public void onLaunchOtherTask(View v) {
diff --git a/samples/SupportAppNavigation/Android.mk b/samples/SupportAppNavigation/Android.mk
new file mode 100644
index 0000000..6a30e1f
--- /dev/null
+++ b/samples/SupportAppNavigation/Android.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := samples tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := SupportAppNavigation
+
+LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
+
+LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+
+# Use the following include to make our test apk.
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/samples/SupportAppNavigation/AndroidManifest.xml b/samples/SupportAppNavigation/AndroidManifest.xml
new file mode 100644
index 0000000..c8e4fa8
--- /dev/null
+++ b/samples/SupportAppNavigation/AndroidManifest.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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 android:versionCode="1"
+ android:versionName="1"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.support.appnavigation">
+
+ <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
+
+ <application android:label="@string/app_name">
+ <activity android:name=".app.AppNavHomeActivity"
+ android:label="@string/app_nav_home_label">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".app.SimpleUpActivity"
+ android:label="@string/simple_up_label">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ <meta-data android:name="android.support.PARENT_ACTIVITY"
+ android:value=".app.AppNavHomeActivity" />
+ </activity>
+
+ <activity android:name=".app.PeerActivity"
+ android:label="@string/peer_label">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ <meta-data android:name="android.support.PARENT_ACTIVITY"
+ android:value=".app.AppNavHomeActivity" />
+ </activity>
+
+ <activity android:name=".app.ViewFromOtherTaskActivity"
+ android:label="@string/view_from_other_task_label">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ <meta-data android:name="android.support.PARENT_ACTIVITY"
+ android:value=".app.AppNavHomeActivity" />
+ </activity>
+
+ <activity android:name=".app.OutsideTaskActivity"
+ android:label="@string/outside_task_label"
+ android:theme="@style/Theme.Light"
+ android:taskAffinity="com.example.android.appnavigation.outsidetask">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".app.ContentViewActivity"
+ android:label="@string/content_view_label">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <action android:name="android.intent.action.VIEW" />
+ <data android:mimeType="application/x-example" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data android:name="android.support.PARENT_ACTIVITY"
+ android:value=".app.ContentCategoryActivity" />
+ </activity>
+
+ <activity android:name=".app.ContentCategoryActivity"
+ android:label="@string/content_category_label">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ <meta-data android:name="android.support.PARENT_ACTIVITY"
+ android:value=".app.AppNavHomeActivity" />
+ </activity>
+
+ <activity android:name=".app.NotificationsActivity"
+ android:label="@string/notifications_label">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ <meta-data android:name="android.support.PARENT_ACTIVITY"
+ android:value=".app.AppNavHomeActivity" />
+ </activity>
+
+ <activity android:name=".app.InterstitialMessageActivity"
+ android:label="@string/interstitial_label"
+ android:theme="@style/Theme.Dialog"
+ android:launchMode="singleTask"
+ android:excludeFromRecents="true"
+ android:taskAffinity="">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/samples/SupportAppNavigation/res/layout/content_category.xml b/samples/SupportAppNavigation/res/layout/content_category.xml
new file mode 100644
index 0000000..2727260
--- /dev/null
+++ b/samples/SupportAppNavigation/res/layout/content_category.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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:padding="16dp"
+ android:orientation="vertical">
+ <TextView android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/intermediate_description" />
+ <Button android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/launch_content_view"
+ android:onClick="onViewContent" />
+</LinearLayout>
diff --git a/samples/SupportAppNavigation/res/layout/content_view.xml b/samples/SupportAppNavigation/res/layout/content_view.xml
new file mode 100644
index 0000000..eabd2eb
--- /dev/null
+++ b/samples/SupportAppNavigation/res/layout/content_view.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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:padding="16dp"
+ android:orientation="vertical">
+ <TextView android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/content_view_description" />
+ <TextView android:id="@+id/status_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/default_status_text" />
+</LinearLayout>
\ No newline at end of file
diff --git a/samples/SupportAppNavigation/res/layout/interstitial_message.xml b/samples/SupportAppNavigation/res/layout/interstitial_message.xml
new file mode 100644
index 0000000..d957ecd
--- /dev/null
+++ b/samples/SupportAppNavigation/res/layout/interstitial_message.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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"
+ style="@style/InterstitialDialogLayout">
+ <TextView android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/interstitial_description"
+ android:layout_marginTop="16dp"
+ android:layout_marginBottom="16dp"
+ android:layout_marginLeft="16dp"
+ android:layout_marginRight="16dp"/>
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/ButtonBar">
+ <Button android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/launch_content_view"
+ android:onClick="onViewContent"
+ style="@style/ButtonBarButton"/>
+ </LinearLayout>
+</LinearLayout>
diff --git a/samples/SupportAppNavigation/res/layout/notifications.xml b/samples/SupportAppNavigation/res/layout/notifications.xml
new file mode 100644
index 0000000..10112f3
--- /dev/null
+++ b/samples/SupportAppNavigation/res/layout/notifications.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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:padding="16dp"
+ android:orientation="vertical">
+ <TextView android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/notifications_description" />
+ <Button android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/post_direct_notification"
+ android:onClick="onPostDirect" />
+ <Button android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/post_interstitial_notification"
+ android:onClick="onPostInterstitial" />
+</LinearLayout>
diff --git a/samples/SupportAppNavigation/res/layout/outside_task.xml b/samples/SupportAppNavigation/res/layout/outside_task.xml
new file mode 100644
index 0000000..00c78aa
--- /dev/null
+++ b/samples/SupportAppNavigation/res/layout/outside_task.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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:padding="16dp"
+ android:orientation="vertical">
+ <TextView android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/outside_task_description" />
+ <Button android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/launch_content_view"
+ android:onClick="onViewContent" />
+</LinearLayout>
diff --git a/samples/SupportAppNavigation/res/layout/peer.xml b/samples/SupportAppNavigation/res/layout/peer.xml
new file mode 100644
index 0000000..ee706b3
--- /dev/null
+++ b/samples/SupportAppNavigation/res/layout/peer.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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:padding="16dp"
+ android:orientation="vertical">
+ <TextView android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/peer_description" />
+ <TextView android:id="@+id/peer_counter"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/peer_count" />
+ <Button android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/launch_peer"
+ android:onClick="onLaunchPeer" />
+</LinearLayout>
\ No newline at end of file
diff --git a/samples/SupportAppNavigation/res/layout/simple_up.xml b/samples/SupportAppNavigation/res/layout/simple_up.xml
new file mode 100644
index 0000000..2897d84
--- /dev/null
+++ b/samples/SupportAppNavigation/res/layout/simple_up.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:text="@string/simple_up_description"
+ android:padding="16dp" />
diff --git a/samples/SupportAppNavigation/res/layout/view_from_other_task.xml b/samples/SupportAppNavigation/res/layout/view_from_other_task.xml
new file mode 100644
index 0000000..941d74c
--- /dev/null
+++ b/samples/SupportAppNavigation/res/layout/view_from_other_task.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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:padding="16dp"
+ android:orientation="vertical">
+ <TextView android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/view_from_other_task_description" />
+ <Button android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/launch_other_task"
+ android:onClick="onLaunchOtherTask" />
+</LinearLayout>
\ No newline at end of file
diff --git a/samples/SupportAppNavigation/res/values-v11/styles.xml b/samples/SupportAppNavigation/res/values-v11/styles.xml
new file mode 100644
index 0000000..e61e9d4
--- /dev/null
+++ b/samples/SupportAppNavigation/res/values-v11/styles.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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="InterstitialDialogLayout">
+ <item name="android:divider">?android:attr/dividerHorizontal</item>
+ <item name="android:showDividers">middle</item>
+ </style>
+
+ <style name="ButtonBar" parent="@android:style/Holo.ButtonBar.AlertDialog" />
+ <style name="ButtonBarButton" parent="@android:style/Widget.Holo.Button.Borderless" />
+
+</resources>
diff --git a/samples/SupportAppNavigation/res/values-v11/themes.xml b/samples/SupportAppNavigation/res/values-v11/themes.xml
new file mode 100644
index 0000000..b9f7fdb
--- /dev/null
+++ b/samples/SupportAppNavigation/res/values-v11/themes.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.Light" parent="@android:style/Theme.Holo.Light" />
+ <style name="Theme.Dialog" parent="@android:style/Theme.Holo.Dialog" />
+</resources>
diff --git a/samples/SupportAppNavigation/res/values-v14/themes.xml b/samples/SupportAppNavigation/res/values-v14/themes.xml
new file mode 100644
index 0000000..79fabda
--- /dev/null
+++ b/samples/SupportAppNavigation/res/values-v14/themes.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.Light" parent="@android:style/Theme.DeviceDefault.Light" />
+</resources>
diff --git a/samples/SupportAppNavigation/res/values/ids.xml b/samples/SupportAppNavigation/res/values/ids.xml
new file mode 100644
index 0000000..c143cf7
--- /dev/null
+++ b/samples/SupportAppNavigation/res/values/ids.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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>
+ <item type="id" name="direct_notification" />
+ <item type="id" name="interstitial_notification" />
+</resources>
diff --git a/samples/SupportAppNavigation/res/values/strings.xml b/samples/SupportAppNavigation/res/values/strings.xml
new file mode 100644
index 0000000..e939b3f
--- /dev/null
+++ b/samples/SupportAppNavigation/res/values/strings.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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">Support App Navigation Sample</string>
+ <string name="app_nav_home_label">Support App Navigation</string>
+
+ <string name="simple_up_label">Simple Up Navigation</string>
+ <string name="simple_up_description">This demo shows the simple case of up navigation that does not ever need to cross across different tasks. Press the up button on the action bar to return to the demo list. For simple drill-down navigation, the application up and system back buttons will navigate to the same location, leaving the task\'s back stack in the same state.</string>
+
+ <string name="peer_label">Peer Activities</string>
+ <string name="peer_description">This is an activity that shows content with many navigation peers. Think of a content browser that offers links to related content items. Pressing back from this activity will return to the previously viewed content item if you reached this point through a related link. If you reached it from the app nav example home activity, back will return there. Navigating up from this activity will always return to the app nav example home activity and clean up the back stack along the way.</string>
+ <string name="launch_peer">Link to another peer activity</string>
+ <string name="peer_count">Peer count: </string>
+
+ <string name="view_from_other_task_label">View from other task</string>
+ <string name="view_from_other_task_description">This combined demo shows how to handle up navigation when another task has launched your app\'s activity on its own task stack. Navigating up in this scenario should synthesize a task stack representing the most common or direct navigation path to the parent activity. The code example shows how to handle this using helper code from the support library. Press the button below to launch a separate task and begin the demo.</string>
+ <string name="launch_other_task">Launch new task</string>
+
+ <string name="outside_task_label">Outside Task</string>
+ <string name="outside_task_description">This activity has been launched in a new task. You can confirm this by pressing the Recents button now and switching back to the app navigation example task. This activity will view content with the fake mimetype \"application/x-example\" which will be received by another code example activity to continue the demo. Press the View button below.</string>
+
+ <string name="content_view_label">Content Viewer</string>
+ <string name="content_view_description">This activity can receive ACTION_VIEW intents with the mimetype \"application/x-example\", sent by the outside task component of this demo. If you launched the activity this way then it will be on the viewing activity\'s task stack. Press the back button to finish this activity and return to the activity that wanted to view the content. Press the up button in the action bar to jump back into the main demo task with a synthesized back stack. This matches the pattern for content viewers such as a photo gallery or video player.</string>
+ <string name="default_status_text">Navigated here from category</string>
+
+ <string name="content_category_label">Content Category</string>
+ <string name="intermediate_description">This activity is a parent for the example content viewer activity. Navigating up from the content viewer will lead here. Navigating up from here will lead back to the app navigation home activity. Note that if you reached this activity by navigating up from the example content viewer activity, you are back on the main app navigation example task. Press the button below to navigate to the content viewer activity.</string>
+ <string name="launch_content_view">Launch content view activity</string>
+
+ <string name="notifications_label">Notifications</string>
+ <string name="notifications_description">There are two classes of notifications: notifications that deep-link into an app directly, (e.g. an incoming SMS) and notifications that present an interstitial/summary of multiple collapsed notifications before linking into the app itself. (e.g. Calendar event notifications.) The buttons below will create notifications of each type.</string>
+ <string name="post_direct_notification">Post direct notification</string>
+ <string name="post_interstitial_notification">Post interstitial notification</string>
+
+ <string name="interstitial_label">Interstitial</string>
+ <string name="interstitial_description">This is an interstitial activity running in response to a notification. It presents a summary of info in a lightweight manner that does not exist as a task in Recents. Tap the button below to jump to the primary content.</string>
+
+</resources>
diff --git a/samples/SupportAppNavigation/res/values/styles.xml b/samples/SupportAppNavigation/res/values/styles.xml
new file mode 100644
index 0000000..d869170
--- /dev/null
+++ b/samples/SupportAppNavigation/res/values/styles.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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="InterstitialDialogLayout" />
+
+ <style name="ButtonBar" parent="@android:style/ButtonBar" />
+ <style name="ButtonBarButton" parent="@android:style/Widget.Button" />
+
+</resources>
diff --git a/samples/SupportAppNavigation/res/values/themes.xml b/samples/SupportAppNavigation/res/values/themes.xml
new file mode 100644
index 0000000..beebacf
--- /dev/null
+++ b/samples/SupportAppNavigation/res/values/themes.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.Light" parent="@android:style/Theme.Light" />
+ <style name="Theme.Dialog" parent="@android:style/Theme.Dialog" />
+</resources>
diff --git a/samples/AppNavigation/src/com/example/android/appnavigation/app/ActionBarCompat.java b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ActionBarCompat.java
similarity index 96%
rename from samples/AppNavigation/src/com/example/android/appnavigation/app/ActionBarCompat.java
rename to samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ActionBarCompat.java
index 0822336..6f22280 100644
--- a/samples/AppNavigation/src/com/example/android/appnavigation/app/ActionBarCompat.java
+++ b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ActionBarCompat.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.example.android.appnavigation.app;
+package com.example.android.support.appnavigation.app;
import android.app.Activity;
import android.os.Build;
diff --git a/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/AppNavHomeActivity.java b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/AppNavHomeActivity.java
new file mode 100644
index 0000000..17f4d5b
--- /dev/null
+++ b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/AppNavHomeActivity.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2012 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.support.appnavigation.app;
+
+import android.app.ListActivity;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Home activity for app navigation code samples.
+ */
+public class AppNavHomeActivity extends ListActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setListAdapter(new SampleAdapter(querySampleActivities()));
+ }
+
+ @Override
+ protected void onListItemClick(ListView lv, View v, int pos, long id) {
+ SampleInfo info = (SampleInfo) getListAdapter().getItem(pos);
+ startActivity(info.intent);
+ }
+
+ protected List<SampleInfo> querySampleActivities() {
+ Intent intent = new Intent(Intent.ACTION_MAIN, null);
+ intent.setPackage(getPackageName());
+ intent.addCategory(Intent.CATEGORY_SAMPLE_CODE);
+
+ PackageManager pm = getPackageManager();
+ List<ResolveInfo> infos = pm.queryIntentActivities(intent, 0);
+
+ ArrayList<SampleInfo> samples = new ArrayList<SampleInfo>();
+
+ final int count = infos.size();
+ for (int i = 0; i < count; i++) {
+ final ResolveInfo info = infos.get(i);
+ final CharSequence labelSeq = info.loadLabel(pm);
+ String label = labelSeq != null ? labelSeq.toString() : info.activityInfo.name;
+
+ Intent target = new Intent();
+ target.setClassName(info.activityInfo.applicationInfo.packageName,
+ info.activityInfo.name);
+ SampleInfo sample = new SampleInfo(label, target);
+ samples.add(sample);
+ }
+
+ return samples;
+ }
+
+ static class SampleInfo {
+ String name;
+ Intent intent;
+
+ SampleInfo(String name, Intent intent) {
+ this.name = name;
+ this.intent = intent;
+ }
+ }
+
+ class SampleAdapter extends BaseAdapter {
+ private List<SampleInfo> mItems;
+
+ public SampleAdapter(List<SampleInfo> items) {
+ mItems = items;
+ }
+
+ @Override
+ public int getCount() {
+ return mItems.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return mItems.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ if (convertView == null) {
+ convertView = getLayoutInflater().inflate(android.R.layout.simple_list_item_1,
+ parent, false);
+ convertView.setTag(convertView.findViewById(android.R.id.text1));
+ }
+ TextView tv = (TextView) convertView.getTag();
+ tv.setText(mItems.get(position).name);
+ return convertView;
+ }
+
+ }
+}
diff --git a/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ContentCategoryActivity.java b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ContentCategoryActivity.java
new file mode 100644
index 0000000..d93482c
--- /dev/null
+++ b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ContentCategoryActivity.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 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.support.appnavigation.app;
+
+import com.example.android.support.appnavigation.R;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.NavUtils;
+import android.view.MenuItem;
+import android.view.View;
+
+public class ContentCategoryActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.content_category);
+
+ ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ NavUtils.navigateUpFromSameTask(this);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ public void onViewContent(View v) {
+ Intent target = new Intent(this, ContentViewActivity.class);
+ startActivity(target);
+ }
+}
diff --git a/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ContentViewActivity.java b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ContentViewActivity.java
new file mode 100644
index 0000000..42e25ea
--- /dev/null
+++ b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ContentViewActivity.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 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.support.appnavigation.app;
+
+import com.example.android.support.appnavigation.R;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.NavUtils;
+import android.support.v4.app.ShareCompat;
+import android.support.v4.app.TaskStackBuilder;
+import android.text.TextUtils;
+import android.view.MenuItem;
+import android.widget.TextView;
+
+public class ContentViewActivity extends Activity {
+ public static final String EXTRA_TEXT = "com.example.android.appnavigation.EXTRA_TEXT";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.content_view);
+
+ ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
+
+ Intent intent = getIntent();
+ if (Intent.ACTION_VIEW.equals(intent.getAction())) {
+ TextView tv = (TextView) findViewById(R.id.status_text);
+ tv.setText("Viewing content from ACTION_VIEW");
+ } else if (intent.hasExtra(EXTRA_TEXT)) {
+ TextView tv = (TextView) findViewById(R.id.status_text);
+ tv.setText(intent.getStringExtra(EXTRA_TEXT));
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ Intent upIntent = NavUtils.getParentActivityIntent(this);
+ if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
+ TaskStackBuilder.from(this)
+ .addParentStack(this)
+ .startActivities();
+ finish();
+ } else {
+ NavUtils.navigateUpTo(this, upIntent);
+ }
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/InterstitialMessageActivity.java b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/InterstitialMessageActivity.java
new file mode 100644
index 0000000..72c3565
--- /dev/null
+++ b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/InterstitialMessageActivity.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2012 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.support.appnavigation.app;
+
+import com.example.android.support.appnavigation.R;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.TaskStackBuilder;
+import android.view.View;
+
+public class InterstitialMessageActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.interstitial_message);
+ }
+
+ public void onViewContent(View v) {
+ TaskStackBuilder.from(this)
+ .addParentStack(ContentViewActivity.class)
+ .addNextIntent(new Intent(this, ContentViewActivity.class)
+ .putExtra(ContentViewActivity.EXTRA_TEXT, "From Interstitial Notification"))
+ .startActivities();
+ finish();
+ }
+}
diff --git a/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/NotificationsActivity.java b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/NotificationsActivity.java
new file mode 100644
index 0000000..0f80938
--- /dev/null
+++ b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/NotificationsActivity.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2012 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.support.appnavigation.app;
+
+import com.example.android.support.appnavigation.R;
+
+import android.app.Activity;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.NavUtils;
+import android.support.v4.app.NotificationCompat;
+import android.support.v4.app.TaskStackBuilder;
+import android.view.MenuItem;
+import android.view.View;
+
+public class NotificationsActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.notifications);
+
+ ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ NavUtils.navigateUpFromSameTask(this);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ public void onPostDirect(View v) {
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
+ .setTicker("Direct Notification")
+ .setSmallIcon(android.R.drawable.stat_notify_chat)
+ .setContentTitle("Direct Notification")
+ .setContentText("This will open the content viewer")
+ .setAutoCancel(true)
+ .setContentIntent(TaskStackBuilder.from(this)
+ .addParentStack(ContentViewActivity.class)
+ .addNextIntent(new Intent(this, ContentViewActivity.class)
+ .putExtra(ContentViewActivity.EXTRA_TEXT, "From Notification"))
+ .getPendingIntent(0, 0));
+ NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ nm.notify("direct_tag", R.id.direct_notification, builder.getNotification());
+ }
+
+ public void onPostInterstitial(View v) {
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
+ .setTicker("Interstitial Notification")
+ .setSmallIcon(android.R.drawable.stat_notify_chat)
+ .setContentTitle("Interstitial Notification")
+ .setContentText("This will show a detail page")
+ .setAutoCancel(true)
+ .setContentIntent(PendingIntent.getActivity(this, 0,
+ new Intent(this, InterstitialMessageActivity.class)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
+ Intent.FLAG_ACTIVITY_CLEAR_TASK), 0));
+ NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ nm.notify("interstitial_tag", R.id.interstitial_notification, builder.getNotification());
+ }
+}
diff --git a/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/OutsideTaskActivity.java b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/OutsideTaskActivity.java
new file mode 100644
index 0000000..2f75d6b
--- /dev/null
+++ b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/OutsideTaskActivity.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 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.support.appnavigation.app;
+
+import com.example.android.support.appnavigation.R;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+
+public class OutsideTaskActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.outside_task);
+ }
+
+ public void onViewContent(View v) {
+ Intent intent = new Intent(Intent.ACTION_VIEW)
+ .setType("application/x-example")
+ .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
+ startActivity(intent);
+ }
+}
diff --git a/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/PeerActivity.java b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/PeerActivity.java
new file mode 100644
index 0000000..a6dbca4
--- /dev/null
+++ b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/PeerActivity.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2012 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.support.appnavigation.app;
+
+import com.example.android.support.appnavigation.R;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.NavUtils;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.TextView;
+
+public class PeerActivity extends Activity {
+ private static final String EXTRA_PEER_COUNT =
+ "com.example.android.appnavigation.EXTRA_PEER_COUNT";
+
+ private int mPeerCount;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.peer);
+
+ ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
+
+ mPeerCount = getIntent().getIntExtra(EXTRA_PEER_COUNT, 0) + 1;
+ TextView tv = (TextView) findViewById(R.id.peer_counter);
+ tv.setText(getResources().getText(R.string.peer_count).toString() + mPeerCount);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ NavUtils.navigateUpFromSameTask(this);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ public void onLaunchPeer(View v) {
+ Intent target = new Intent(this, PeerActivity.class);
+ target.putExtra(EXTRA_PEER_COUNT, mPeerCount);
+ startActivity(target);
+ }
+}
diff --git a/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/SimpleUpActivity.java b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/SimpleUpActivity.java
new file mode 100644
index 0000000..7c09051
--- /dev/null
+++ b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/SimpleUpActivity.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2012 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.support.appnavigation.app;
+
+import com.example.android.support.appnavigation.R;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.os.Bundle;
+import android.support.v4.app.NavUtils;
+import android.view.MenuItem;
+
+public class SimpleUpActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.simple_up);
+
+ ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ NavUtils.navigateUpFromSameTask(this);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ViewFromOtherTaskActivity.java b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ViewFromOtherTaskActivity.java
new file mode 100644
index 0000000..46e6349
--- /dev/null
+++ b/samples/SupportAppNavigation/src/com/example/android/support/appnavigation/app/ViewFromOtherTaskActivity.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2012 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.support.appnavigation.app;
+
+import com.example.android.support.appnavigation.R;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.NavUtils;
+import android.view.MenuItem;
+import android.view.View;
+
+public class ViewFromOtherTaskActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.view_from_other_task);
+
+ ActionBarCompat.setDisplayHomeAsUpEnabled(this, true);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ NavUtils.navigateUpFromSameTask(this);
+ return true;
+ }
+ return false;
+ }
+
+ public void onLaunchOtherTask(View v) {
+ Intent target = new Intent(this, OutsideTaskActivity.class)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
+ Intent.FLAG_ACTIVITY_TASK_ON_HOME);
+ startActivity(target);
+ }
+}