Merge "Change contents animations" into nyc-dev

This commit is contained in:
Chulwoo Lee
2016-05-06 02:07:45 +00:00
committed by Android (Google) Code Review
51 changed files with 178 additions and 40 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 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.
-->
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/tv_content_1" android:duration="33" />
<item android:drawable="@drawable/tv_content_2" android:duration="33" />
<item android:drawable="@drawable/tv_content_3" android:duration="33" />
<item android:drawable="@drawable/tv_content_4" android:duration="33" />
<item android:drawable="@drawable/tv_content_5" android:duration="33" />
<item android:drawable="@drawable/tv_content_6" android:duration="33" />
<item android:drawable="@drawable/tv_content_7" android:duration="33" />
<item android:drawable="@drawable/tv_content_8" android:duration="33" />
<item android:drawable="@drawable/tv_content_9" android:duration="33" />
<item android:drawable="@drawable/tv_content_10" android:duration="33" />
<item android:drawable="@drawable/tv_content_11" android:duration="33" />
<item android:drawable="@drawable/tv_content_12" android:duration="33" />
<item android:drawable="@drawable/tv_content_13" android:duration="33" />
<item android:drawable="@drawable/tv_content_14" android:duration="33" />
<item android:drawable="@drawable/tv_content_15" android:duration="33" />
<item android:drawable="@drawable/tv_content_16" android:duration="33" />
<item android:drawable="@drawable/tv_content_17" android:duration="33" />
<item android:drawable="@drawable/tv_content_18" android:duration="33" />
<item android:drawable="@drawable/tv_content_19" android:duration="33" />
<item android:drawable="@drawable/tv_content_20" android:duration="33" />
<item android:drawable="@drawable/tv_content_21" android:duration="33" />
<item android:drawable="@drawable/tv_content_22" android:duration="33" />
<item android:drawable="@drawable/tv_content_23" android:duration="33" />
<item android:drawable="@drawable/tv_content_24" android:duration="33" />
<item android:drawable="@drawable/tv_content_25" android:duration="33" />
<item android:drawable="@drawable/tv_content_26" android:duration="33" />
<item android:drawable="@drawable/tv_content_27" android:duration="33" />
<item android:drawable="@drawable/tv_content_28" android:duration="33" />
<item android:drawable="@drawable/tv_content_29" android:duration="33" />
<item android:drawable="@drawable/tv_content_30" android:duration="33" />
<item android:drawable="@drawable/tv_content_31" android:duration="33" />
<item android:drawable="@drawable/tv_content_32" android:duration="33" />
<item android:drawable="@drawable/tv_content_33" android:duration="33" />
<item android:drawable="@drawable/tv_content_34" android:duration="33" />
<item android:drawable="@drawable/tv_content_35" android:duration="33" />
<item android:drawable="@drawable/tv_content_36" android:duration="33" />
<item android:drawable="@drawable/tv_content_37" android:duration="33" />
<item android:drawable="@drawable/tv_content_38" android:duration="33" />
<item android:drawable="@drawable/tv_content_39" android:duration="33" />
<item android:drawable="@drawable/tv_content_40" android:duration="33" />
<item android:drawable="@drawable/tv_content_41" android:duration="33" />
<item android:drawable="@drawable/tv_content_42" android:duration="33" />
<item android:drawable="@drawable/tv_content_43" android:duration="33" />
<item android:drawable="@drawable/tv_content_44" android:duration="33" />
</animation-list>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 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.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/background_image"
android:layout_width="215dp"
android:layout_height="128dp"
android:layout_gravity="center"
android:scaleType="fitCenter"
android:contentDescription="@null" />
<ImageView
android:id="@+id/animation_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="center"
android:contentDescription="@null" />
</FrameLayout>

View File

@@ -20,4 +20,5 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:src="@drawable/bg"/> android:src="@drawable/bg"
android:contentDescription="@null" />

View File

@@ -27,7 +27,7 @@
<!-- Descriptions in the onboarding page. --> <!-- Descriptions in the onboarding page. -->
<string-array name="onboarding_page_descriptions"> <string-array name="onboarding_page_descriptions">
<item>Announce your new features.</item> <item>Announce your new features.</item>
<item>Just override OnbaordingFragment and provide the messages and images.</item> <item>Just override OnboardingFragment and provide the messages and images.</item>
<item>Customize your own logo image, splash animation and the contents animations.</item> <item>Customize your own logo image, splash animation and the contents animations.</item>
</string-array> </string-array>
</resources> </resources>

View File

@@ -17,11 +17,11 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.graphics.drawable.AnimationDrawable;
import android.support.v17.leanback.app.OnboardingFragment; import android.support.v17.leanback.app.OnboardingFragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.ImageView; import android.widget.ImageView;
import java.util.ArrayList; import java.util.ArrayList;
@@ -29,18 +29,25 @@ import java.util.ArrayList;
public class OnboardingDemoFragment extends OnboardingFragment { public class OnboardingDemoFragment extends OnboardingFragment {
private static final long ANIMATION_DURATION = 1000; private static final long ANIMATION_DURATION = 1000;
private static final int[] CONTENT_IMAGES = { private static final int[] CONTENT_BACKGROUNDS = {
R.drawable.gallery_photo_1, R.drawable.tv_bg,
R.drawable.gallery_photo_2, R.drawable.gallery_photo_6,
R.drawable.gallery_photo_3 R.drawable.gallery_photo_8
}; };
private static final int[] CONTENT_ANIMATIONS = {
R.drawable.tv_content,
android.R.drawable.stat_sys_download,
android.R.drawable.ic_popup_sync
};
private String[] mTitles; private String[] mTitles;
private String[] mDescriptions; private String[] mDescriptions;
private View mBackgroundView; private View mBackgroundView;
private ImageView mContentView; private View mContentView;
private ImageView mImage1; private ImageView mContentBackgroundView;
private ImageView mImage2; private ImageView mContentAnimationView;
private Animator mContentAnimator; private Animator mContentAnimator;
@@ -75,11 +82,9 @@ public class OnboardingDemoFragment extends OnboardingFragment {
@Override @Override
protected View onCreateContentView(LayoutInflater layoutInflater, ViewGroup viewGroup) { protected View onCreateContentView(LayoutInflater layoutInflater, ViewGroup viewGroup) {
mContentView = (ImageView) layoutInflater.inflate(R.layout.onboarding_image, viewGroup, mContentView = layoutInflater.inflate(R.layout.onboarding_content, viewGroup, false);
false); mContentBackgroundView = (ImageView) mContentView.findViewById(R.id.background_image);
MarginLayoutParams layoutParams = ((MarginLayoutParams) mContentView.getLayoutParams()); mContentAnimationView = (ImageView) mContentView.findViewById(R.id.animation_image);
layoutParams.topMargin = 30;
layoutParams.bottomMargin = 60;
return mContentView; return mContentView;
} }
@@ -92,31 +97,45 @@ public class OnboardingDemoFragment extends OnboardingFragment {
protected Animator onCreateEnterAnimation() { protected Animator onCreateEnterAnimation() {
ArrayList<Animator> animators = new ArrayList<>(); ArrayList<Animator> animators = new ArrayList<>();
animators.add(createFadeInAnimator(mBackgroundView)); animators.add(createFadeInAnimator(mBackgroundView));
mContentView.setImageResource(CONTENT_IMAGES[0]); mContentBackgroundView.setImageResource(CONTENT_BACKGROUNDS[0]);
mContentAnimationView.setImageResource(CONTENT_ANIMATIONS[0]);
mContentAnimator = createFadeInAnimator(mContentView); mContentAnimator = createFadeInAnimator(mContentView);
animators.add(mContentAnimator); animators.add(mContentAnimator);
AnimatorSet set = new AnimatorSet(); AnimatorSet set = new AnimatorSet();
set.playTogether(animators); set.playTogether(animators);
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
((AnimationDrawable) mContentAnimationView.getDrawable()).start();
}
});
return set; return set;
} }
@Override @Override
protected void onPageChanged(final int newPage, int previousPage) { protected void onPageChanged(final int newPage, int previousPage) {
if (mContentAnimator != null) { if (mContentAnimator != null) {
mContentAnimator.end(); mContentAnimator.cancel();
} }
((AnimationDrawable) mContentAnimationView.getDrawable()).stop();
ArrayList<Animator> animators = new ArrayList<>(); ArrayList<Animator> animators = new ArrayList<>();
Animator fadeOut = createFadeOutAnimator(mContentView); Animator fadeOut = createFadeOutAnimator(mContentView);
fadeOut.addListener(new AnimatorListenerAdapter() { fadeOut.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
mContentView.setImageResource(CONTENT_IMAGES[newPage]); mContentBackgroundView.setImageResource(CONTENT_BACKGROUNDS[newPage]);
mContentAnimationView.setImageResource(CONTENT_ANIMATIONS[newPage]);
}
});
Animator fadeIn = createFadeInAnimator(mContentView);
fadeIn.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
((AnimationDrawable) mContentAnimationView.getDrawable()).start();
} }
}); });
animators.add(fadeOut);
animators.add(createFadeInAnimator(mContentView));
AnimatorSet set = new AnimatorSet(); AnimatorSet set = new AnimatorSet();
set.playSequentially(animators); set.playSequentially(fadeOut, fadeIn);
set.start(); set.start();
mContentAnimator = set; mContentAnimator = set;
} }

View File

@@ -19,11 +19,11 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.graphics.drawable.AnimationDrawable;
import android.support.v17.leanback.app.OnboardingSupportFragment; import android.support.v17.leanback.app.OnboardingSupportFragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.ImageView; import android.widget.ImageView;
import java.util.ArrayList; import java.util.ArrayList;
@@ -31,18 +31,25 @@ import java.util.ArrayList;
public class OnboardingDemoSupportFragment extends OnboardingSupportFragment { public class OnboardingDemoSupportFragment extends OnboardingSupportFragment {
private static final long ANIMATION_DURATION = 1000; private static final long ANIMATION_DURATION = 1000;
private static final int[] CONTENT_IMAGES = { private static final int[] CONTENT_BACKGROUNDS = {
R.drawable.gallery_photo_1, R.drawable.tv_bg,
R.drawable.gallery_photo_2, R.drawable.gallery_photo_6,
R.drawable.gallery_photo_3 R.drawable.gallery_photo_8
}; };
private static final int[] CONTENT_ANIMATIONS = {
R.drawable.tv_content,
android.R.drawable.stat_sys_download,
android.R.drawable.ic_popup_sync
};
private String[] mTitles; private String[] mTitles;
private String[] mDescriptions; private String[] mDescriptions;
private View mBackgroundView; private View mBackgroundView;
private ImageView mContentView; private View mContentView;
private ImageView mImage1; private ImageView mContentBackgroundView;
private ImageView mImage2; private ImageView mContentAnimationView;
private Animator mContentAnimator; private Animator mContentAnimator;
@@ -77,11 +84,9 @@ public class OnboardingDemoSupportFragment extends OnboardingSupportFragment {
@Override @Override
protected View onCreateContentView(LayoutInflater layoutInflater, ViewGroup viewGroup) { protected View onCreateContentView(LayoutInflater layoutInflater, ViewGroup viewGroup) {
mContentView = (ImageView) layoutInflater.inflate(R.layout.onboarding_image, viewGroup, mContentView = layoutInflater.inflate(R.layout.onboarding_content, viewGroup, false);
false); mContentBackgroundView = (ImageView) mContentView.findViewById(R.id.background_image);
MarginLayoutParams layoutParams = ((MarginLayoutParams) mContentView.getLayoutParams()); mContentAnimationView = (ImageView) mContentView.findViewById(R.id.animation_image);
layoutParams.topMargin = 30;
layoutParams.bottomMargin = 60;
return mContentView; return mContentView;
} }
@@ -94,31 +99,45 @@ public class OnboardingDemoSupportFragment extends OnboardingSupportFragment {
protected Animator onCreateEnterAnimation() { protected Animator onCreateEnterAnimation() {
ArrayList<Animator> animators = new ArrayList<>(); ArrayList<Animator> animators = new ArrayList<>();
animators.add(createFadeInAnimator(mBackgroundView)); animators.add(createFadeInAnimator(mBackgroundView));
mContentView.setImageResource(CONTENT_IMAGES[0]); mContentBackgroundView.setImageResource(CONTENT_BACKGROUNDS[0]);
mContentAnimationView.setImageResource(CONTENT_ANIMATIONS[0]);
mContentAnimator = createFadeInAnimator(mContentView); mContentAnimator = createFadeInAnimator(mContentView);
animators.add(mContentAnimator); animators.add(mContentAnimator);
AnimatorSet set = new AnimatorSet(); AnimatorSet set = new AnimatorSet();
set.playTogether(animators); set.playTogether(animators);
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
((AnimationDrawable) mContentAnimationView.getDrawable()).start();
}
});
return set; return set;
} }
@Override @Override
protected void onPageChanged(final int newPage, int previousPage) { protected void onPageChanged(final int newPage, int previousPage) {
if (mContentAnimator != null) { if (mContentAnimator != null) {
mContentAnimator.end(); mContentAnimator.cancel();
} }
((AnimationDrawable) mContentAnimationView.getDrawable()).stop();
ArrayList<Animator> animators = new ArrayList<>(); ArrayList<Animator> animators = new ArrayList<>();
Animator fadeOut = createFadeOutAnimator(mContentView); Animator fadeOut = createFadeOutAnimator(mContentView);
fadeOut.addListener(new AnimatorListenerAdapter() { fadeOut.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
mContentView.setImageResource(CONTENT_IMAGES[newPage]); mContentBackgroundView.setImageResource(CONTENT_BACKGROUNDS[newPage]);
mContentAnimationView.setImageResource(CONTENT_ANIMATIONS[newPage]);
}
});
Animator fadeIn = createFadeInAnimator(mContentView);
fadeIn.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
((AnimationDrawable) mContentAnimationView.getDrawable()).start();
} }
}); });
animators.add(fadeOut);
animators.add(createFadeInAnimator(mContentView));
AnimatorSet set = new AnimatorSet(); AnimatorSet set = new AnimatorSet();
set.playSequentially(animators); set.playSequentially(fadeOut, fadeIn);
set.start(); set.start();
mContentAnimator = set; mContentAnimator = set;
} }