From 967d1e6caff3b7556cf3aa798a73c94ea8f8a46b Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 19 Mar 2012 17:49:14 -0700 Subject: [PATCH 1/2] Update animation sample to use new activity options API. Change-Id: Id73663f1e5f159c5b073cd9c074501958ca5a81f --- .../res/layout/activity_animation.xml | 15 +++++++- samples/ApiDemos/res/values/strings.xml | 2 + .../example/android/apis/app/Animation.java | 38 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/samples/ApiDemos/res/layout/activity_animation.xml b/samples/ApiDemos/res/layout/activity_animation.xml index 2432c907e..34db58be1 100644 --- a/samples/ApiDemos/res/layout/activity_animation.xml +++ b/samples/ApiDemos/res/layout/activity_animation.xml @@ -28,15 +28,26 @@ android:text="@string/activity_animation_msg"/> + + + + diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml index fd159837d..0b68807c6 100644 --- a/samples/ApiDemos/res/values/strings.xml +++ b/samples/ApiDemos/res/values/strings.xml @@ -64,6 +64,8 @@ Press a button to launch an activity with a custom animation. Fade in Zoom in + Modern fade in + Modern zoom in App/Activity/Save & Restore State Demonstration of saving and restoring activity state in onSaveInstanceState() and onCreate(). diff --git a/samples/ApiDemos/src/com/example/android/apis/app/Animation.java b/samples/ApiDemos/src/com/example/android/apis/app/Animation.java index bd2bd89b8..5d55691f2 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/Animation.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/Animation.java @@ -22,6 +22,7 @@ import com.example.android.apis.R; import com.example.android.apis.view.Controls1; import android.app.Activity; +import android.app.ActivityOptions; import android.content.Intent; import android.os.Bundle; import android.view.View; @@ -44,6 +45,15 @@ public class Animation extends Activity { button.setOnClickListener(mFadeListener); button = (Button)findViewById(R.id.zoom_animation); button.setOnClickListener(mZoomListener); + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { + button = (Button)findViewById(R.id.modern_fade_animation); + button.setOnClickListener(mModernFadeListener); + button = (Button)findViewById(R.id.modern_zoom_animation); + button.setOnClickListener(mModernZoomListener); + } else { + findViewById(R.id.modern_fade_animation).setEnabled(false); + findViewById(R.id.modern_zoom_animation).setEnabled(false); + } } private OnClickListener mFadeListener = new OnClickListener() { @@ -70,5 +80,33 @@ public class Animation extends Activity { overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit); } }; + + private OnClickListener mModernFadeListener = new OnClickListener() { + public void onClick(View v) { + // Create the desired custom animation, involving transformations + // on both this (exit) and the new (enter) activity. Note how for + // the duration of the animation we force the exiting activity + // to be Z-ordered on top (even though it really isn't) to achieve + // the effect we want. + ActivityOptions opts = ActivityOptions.makeCustomAnimation(Animation.this, + R.anim.fade, R.anim.hold); + // Request the activity be started, using the custom animation options. + startActivity(new Intent(Animation.this, Controls1.class), opts.toBundle()); + } + }; + + private OnClickListener mModernZoomListener = new OnClickListener() { + public void onClick(View v) { + // Create a more complicated animation, involving transformations + // on both this (exit) and the new (enter) activity. Note how for + // the duration of the animation we force the exiting activity + // to be Z-ordered on top (even though it really isn't) to achieve + // the effect we want. + ActivityOptions opts = ActivityOptions.makeCustomAnimation(Animation.this, + R.anim.zoom_enter, R.anim.zoom_enter); + // Request the activity be started, using the custom animation options. + startActivity(new Intent(Animation.this, Controls1.class), opts.toBundle()); + } + }; } From f9e6097f2fb58b71c12871681e66a16af5049b13 Mon Sep 17 00:00:00 2001 From: Andrew Hsieh Date: Tue, 20 Mar 2012 12:46:16 +0800 Subject: [PATCH 2/2] Fixed inconsistent minSdkVersion and target= in NDK samples Also removed Dummy.java and auto-gen files Inspired by http://code.google.com/p/android/issues/detail?id=20017 Change-Id: I5a59c86b8b85c15eccca3b3157459b70a4815684 --- .../samples/native-media/project.properties | 13 ------------- .../samples/bitmap-plasma/default.properties | 2 +- .../samples/native-activity/default.properties | 2 +- .../samples/native-plasma/AndroidManifest.xml | 2 +- .../samples/native-plasma/default.properties | 2 +- .../android-9/samples/native-plasma/src/Dummy.java | 4 ---- ndk/samples/hello-jni/default.properties | 2 +- ndk/samples/hello-neon/AndroidManifest.xml | 1 + ndk/samples/hello-neon/default.properties | 2 +- 9 files changed, 7 insertions(+), 23 deletions(-) delete mode 100644 ndk/platforms/android-14/samples/native-media/project.properties delete mode 100644 ndk/platforms/android-9/samples/native-plasma/src/Dummy.java diff --git a/ndk/platforms/android-14/samples/native-media/project.properties b/ndk/platforms/android-14/samples/native-media/project.properties deleted file mode 100644 index 8f51418b2..000000000 --- a/ndk/platforms/android-14/samples/native-media/project.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Indicates whether an apk should be generated for each density. -split.density=false -# Project target. -target=android-14 diff --git a/ndk/platforms/android-8/samples/bitmap-plasma/default.properties b/ndk/platforms/android-8/samples/bitmap-plasma/default.properties index 9a2c9f6c8..0b9250e02 100644 --- a/ndk/platforms/android-8/samples/bitmap-plasma/default.properties +++ b/ndk/platforms/android-8/samples/bitmap-plasma/default.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-9 +target=android-8 diff --git a/ndk/platforms/android-9/samples/native-activity/default.properties b/ndk/platforms/android-9/samples/native-activity/default.properties index 9d135cb85..9a2c9f6c8 100644 --- a/ndk/platforms/android-9/samples/native-activity/default.properties +++ b/ndk/platforms/android-9/samples/native-activity/default.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-7 +target=android-9 diff --git a/ndk/platforms/android-9/samples/native-plasma/AndroidManifest.xml b/ndk/platforms/android-9/samples/native-plasma/AndroidManifest.xml index 28408b9b0..43acf0d27 100644 --- a/ndk/platforms/android-9/samples/native-plasma/AndroidManifest.xml +++ b/ndk/platforms/android-9/samples/native-plasma/AndroidManifest.xml @@ -3,7 +3,7 @@ package="com.example.native_plasma" android:versionCode="1" android:versionName="1.0"> - + + diff --git a/ndk/samples/hello-neon/default.properties b/ndk/samples/hello-neon/default.properties index 4513a1e4f..9d79b12c7 100644 --- a/ndk/samples/hello-neon/default.properties +++ b/ndk/samples/hello-neon/default.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-3 +target=android-4