diff options
author | Chung-yih Wang <cywang@google.com> | 2011-09-13 16:35:26 +0800 |
---|---|---|
committer | Chung-yih Wang <cywang@google.com> | 2011-09-15 10:17:53 +0800 |
commit | 507aaa672eb8ad5464159021f1b3596cafeede1d (patch) | |
tree | e17acec4bd5fa63647290f6436c4ca5fb158bef1 | |
parent | 48ccad73c132753904a08651ce04cdb27377ef28 (diff) | |
download | LegacyCamera-507aaa672eb8ad5464159021f1b3596cafeede1d.zip LegacyCamera-507aaa672eb8ad5464159021f1b3596cafeede1d.tar.gz LegacyCamera-507aaa672eb8ad5464159021f1b3596cafeede1d.tar.bz2 |
Fix animation for second-level indicator bar.
Change-Id: I8accf9eedf8df439ebed1453c332cb9f9e7b3567
-rw-r--r-- | res/anim/grow_fade_in_from_top.xml | 18 | ||||
-rw-r--r-- | res/anim/shrink_fade_out_from_bottom.xml | 18 | ||||
-rw-r--r-- | src/com/android/camera/ui/IndicatorControlBarContainer.java | 34 |
3 files changed, 65 insertions, 5 deletions
diff --git a/res/anim/grow_fade_in_from_top.xml b/res/anim/grow_fade_in_from_top.xml new file mode 100644 index 0000000..22c33f7 --- /dev/null +++ b/res/anim/grow_fade_in_from_top.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 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. +--> +<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> + <translate android:fromYDelta="-100%p" android:toYDelta="0" android:duration="300" /> +</set> diff --git a/res/anim/shrink_fade_out_from_bottom.xml b/res/anim/shrink_fade_out_from_bottom.xml new file mode 100644 index 0000000..04bfd6e --- /dev/null +++ b/res/anim/shrink_fade_out_from_bottom.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 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. +--> +<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> + <translate android:fromYDelta="0" android:toYDelta="-100%p" android:duration="300" /> +</set> diff --git a/src/com/android/camera/ui/IndicatorControlBarContainer.java b/src/com/android/camera/ui/IndicatorControlBarContainer.java index d425c59..60eb6b2 100644 --- a/src/com/android/camera/ui/IndicatorControlBarContainer.java +++ b/src/com/android/camera/ui/IndicatorControlBarContainer.java @@ -25,6 +25,7 @@ import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.view.animation.Animation; +import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; /** @@ -36,6 +37,7 @@ public class IndicatorControlBarContainer extends IndicatorControlContainer private static final String TAG = "IndicatorControlBarContainer"; private Animation mFadeIn, mFadeOut; + private Animation mSecondLevelFadeIn, mSecondLevelFadeOut; private IndicatorControlBar mIndicatorControlBar; private ZoomControlBar mZoomControlBar; private ZoomIndexBar mZoomIndexBar; @@ -44,9 +46,15 @@ public class IndicatorControlBarContainer extends IndicatorControlContainer public IndicatorControlBarContainer(Context context, AttributeSet attrs) { super(context, attrs); mFadeIn = AnimationUtils.loadAnimation( - context, R.anim.grow_fade_in_from_bottom); + context, R.anim.grow_fade_in_from_top); mFadeOut = AnimationUtils.loadAnimation( + context, R.anim.shrink_fade_out_from_bottom); + mFadeOut.setAnimationListener(mAnimationListener); + mSecondLevelFadeIn = AnimationUtils.loadAnimation( + context, R.anim.grow_fade_in_from_bottom); + mSecondLevelFadeOut = AnimationUtils.loadAnimation( context, R.anim.shrink_fade_out_from_top); + mSecondLevelFadeOut.setAnimationListener(mAnimationListener); } @Override @@ -96,18 +104,34 @@ public class IndicatorControlBarContainer extends IndicatorControlContainer return true; } + private AnimationListener mAnimationListener = new AnimationListener() { + public void onAnimationEnd(Animation animation) { + if (animation == mSecondLevelFadeOut) { + mSecondLevelIndicatorControlBar.setVisibility(View.GONE); + } else if (animation == mFadeOut) { + mIndicatorControlBar.setVisibility(View.GONE); + } + } + + public void onAnimationRepeat(Animation animation) { + } + + public void onAnimationStart(Animation animation) { + } + }; + public void onIndicatorEvent(int event) { switch (event) { case OnIndicatorEventListener.EVENT_ENTER_SECOND_LEVEL_INDICATOR_BAR: - mIndicatorControlBar.setVisibility(View.GONE); - mSecondLevelIndicatorControlBar.startAnimation(mFadeIn); + mIndicatorControlBar.startAnimation(mFadeOut); + mSecondLevelIndicatorControlBar.startAnimation(mSecondLevelFadeIn); mSecondLevelIndicatorControlBar.setVisibility(View.VISIBLE); break; case OnIndicatorEventListener.EVENT_LEAVE_SECOND_LEVEL_INDICATOR_BAR: - mSecondLevelIndicatorControlBar.startAnimation(mFadeOut); - mSecondLevelIndicatorControlBar.setVisibility(View.GONE); + mIndicatorControlBar.startAnimation(mFadeIn); mIndicatorControlBar.setVisibility(View.VISIBLE); + mSecondLevelIndicatorControlBar.startAnimation(mSecondLevelFadeOut); break; case OnIndicatorEventListener.EVENT_ENTER_ZOOM_CONTROL: |