From 8881c1cf76182a780516d61539944dac8aca65ac Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 21 Feb 2012 18:17:05 +0100 Subject: android app: slide buttons on instead of fading --- android/res/anim/fade_in.xml | 5 --- android/res/anim/fade_out.xml | 5 --- android/res/layout/buttons.xml | 27 +++++++++------ android/src/com/artifex/mupdf/MuPDFActivity.java | 43 +++++++++++++++++++----- 4 files changed, 51 insertions(+), 29 deletions(-) delete mode 100644 android/res/anim/fade_in.xml delete mode 100644 android/res/anim/fade_out.xml (limited to 'android') diff --git a/android/res/anim/fade_in.xml b/android/res/anim/fade_in.xml deleted file mode 100644 index b2af62ca..00000000 --- a/android/res/anim/fade_in.xml +++ /dev/null @@ -1,5 +0,0 @@ - - diff --git a/android/res/anim/fade_out.xml b/android/res/anim/fade_out.xml deleted file mode 100644 index 7d742df3..00000000 --- a/android/res/anim/fade_out.xml +++ /dev/null @@ -1,5 +0,0 @@ - - diff --git a/android/res/layout/buttons.xml b/android/res/layout/buttons.xml index b4d44284..b35f7daa 100644 --- a/android/res/layout/buttons.xml +++ b/android/res/layout/buttons.xml @@ -3,21 +3,11 @@ android:layout_width="match_parent" android:layout_height="match_parent" > - - + + + + + diff --git a/android/src/com/artifex/mupdf/MuPDFActivity.java b/android/src/com/artifex/mupdf/MuPDFActivity.java index 364f94ed..f7de9a4f 100644 --- a/android/src/com/artifex/mupdf/MuPDFActivity.java +++ b/android/src/com/artifex/mupdf/MuPDFActivity.java @@ -17,10 +17,10 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.view.View; +import android.view.animation.Animation; +import android.view.animation.TranslateAnimation; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; -import android.view.animation.Animation; -import android.view.animation.AnimationUtils; import android.widget.Button; import android.widget.EditText; import android.widget.ImageButton; @@ -55,6 +55,7 @@ public class MuPDFActivity extends Activity private ImageButton mCancelButton; private ImageButton mOutlineButton; private ViewSwitcher mTopBarSwitcher; + private View mLowerButtons; private boolean mTopBarIsSearch; private ImageButton mSearchBack; private ImageButton mSearchFwd; @@ -415,15 +416,26 @@ public class MuPDFActivity extends Activity mSearchText.requestFocus(); showKeyboard(); } - Animation anim = AnimationUtils.loadAnimation(this, R.anim.fade_in); + Animation anim = new TranslateAnimation(0, 0, -mTopBarSwitcher.getHeight(), 0); + anim.setDuration(500); + anim.setAnimationListener(new Animation.AnimationListener() { + public void onAnimationStart(Animation animation) { + mTopBarSwitcher.setVisibility(View.VISIBLE); + } + public void onAnimationRepeat(Animation animation) {} + public void onAnimationEnd(Animation animation) {} + }); + mTopBarSwitcher.startAnimation(anim); + anim = new TranslateAnimation(0, 0, mLowerButtons.getHeight(), 0); + anim.setDuration(500); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { - mButtonsView.setVisibility(View.VISIBLE); + mLowerButtons.setVisibility(View.VISIBLE); } public void onAnimationRepeat(Animation animation) {} public void onAnimationEnd(Animation animation) {} }); - mButtonsView.startAnimation(anim); + mLowerButtons.startAnimation(anim); } } @@ -431,15 +443,26 @@ public class MuPDFActivity extends Activity if (mButtonsVisible) { mButtonsVisible = false; hideKeyboard(); - Animation anim = AnimationUtils.loadAnimation(this, R.anim.fade_out); + Animation anim = new TranslateAnimation(0, 0, 0, -mTopBarSwitcher.getHeight()); + anim.setDuration(500); + anim.setAnimationListener(new Animation.AnimationListener() { + public void onAnimationStart(Animation animation) {} + public void onAnimationRepeat(Animation animation) {} + public void onAnimationEnd(Animation animation) { + mTopBarSwitcher.setVisibility(View.INVISIBLE); + } + }); + mTopBarSwitcher.startAnimation(anim); + anim = new TranslateAnimation(0, 0, 0, mLowerButtons.getHeight()); + anim.setDuration(500); anim.setAnimationListener(new Animation.AnimationListener() { public void onAnimationStart(Animation animation) {} public void onAnimationRepeat(Animation animation) {} public void onAnimationEnd(Animation animation) { - mButtonsView.setVisibility(View.INVISIBLE); + mLowerButtons.setVisibility(View.INVISIBLE); } }); - mButtonsView.startAnimation(anim); + mLowerButtons.startAnimation(anim); } } @@ -467,7 +490,6 @@ public class MuPDFActivity extends Activity void makeButtonsView() { mButtonsView = getLayoutInflater().inflate(R.layout.buttons,null); - mButtonsView.setVisibility(View.INVISIBLE); mFilenameView = (TextView)mButtonsView.findViewById(R.id.docNameText); mPageSlider = (SeekBar)mButtonsView.findViewById(R.id.pageSlider); mPageNumberView = (TextView)mButtonsView.findViewById(R.id.pageNumber); @@ -478,6 +500,9 @@ public class MuPDFActivity extends Activity mSearchBack = (ImageButton)mButtonsView.findViewById(R.id.searchBack); mSearchFwd = (ImageButton)mButtonsView.findViewById(R.id.searchForward); mSearchText = (EditText)mButtonsView.findViewById(R.id.searchText); + mLowerButtons = mButtonsView.findViewById(R.id.lowerButtons); + mTopBarSwitcher.setVisibility(View.INVISIBLE); + mLowerButtons.setVisibility(View.INVISIBLE); } void showKeyboard() { -- cgit v1.2.3