diff options
author | Paul Gardiner <paul@glidos.net> | 2012-02-20 16:43:54 +0000 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2012-02-21 17:38:23 +0100 |
commit | 3b20948bb65fd52c15935a660e19cfeff75af2fc (patch) | |
tree | d3cd03c928ca5b7b6a02614ef9b99bcb4eedea8c /android | |
parent | a1538974d2abf2d29a3a70d018ee681bc8a517ba (diff) | |
download | mupdf-3b20948bb65fd52c15935a660e19cfeff75af2fc.tar.xz |
Go back to using a direct fade animation in favour of the ViewAnimator
Diffstat (limited to 'android')
-rw-r--r-- | android/res/layout/buttons.xml | 207 | ||||
-rw-r--r-- | android/src/com/artifex/mupdf/MuPDFActivity.java | 31 |
2 files changed, 120 insertions, 118 deletions
diff --git a/android/res/layout/buttons.xml b/android/res/layout/buttons.xml index cb5b4075..82cfc94d 100644 --- a/android/res/layout/buttons.xml +++ b/android/res/layout/buttons.xml @@ -1,129 +1,116 @@ <?xml version="1.0" encoding="utf-8"?> -<ViewAnimator xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/buttons" +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="match_parent" - android:inAnimation="@anim/fade_in" - android:outAnimation="@anim/fade_out"> + android:layout_height="match_parent" > - <RelativeLayout - android:id="@+id/dummy" - android:layout_width="0dp" - android:layout_height="0dp" /> - - <RelativeLayout + <SeekBar + android:id="@+id/pageSlider" android:layout_width="match_parent" - android:layout_height="match_parent" > + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true" + android:layout_margin="10dp" + android:background="@drawable/slider" /> - <SeekBar - android:id="@+id/pageSlider" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_alignParentBottom="true" - android:layout_centerHorizontal="true" - android:layout_margin="10dp" - android:background="@drawable/slider" /> + <ViewSwitcher + android:id="@+id/switcher" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:layout_below="@+id/topBar" + android:layout_centerHorizontal="true" > - <ViewSwitcher - android:id="@+id/switcher" - android:layout_width="wrap_content" + <RelativeLayout + android:id="@+id/topBar" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:layout_below="@+id/topBar" - android:layout_centerHorizontal="true" > + android:background="#CC444444" + android:paddingBottom="0dp" + android:paddingLeft="5dp" + android:paddingRight="5dp" + android:paddingTop="0dp" > - <RelativeLayout - android:id="@+id/topBar" - android:layout_width="match_parent" + <ImageButton + android:id="@+id/searchButton" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="#CC444444" - android:paddingBottom="0dp" - android:paddingLeft="5dp" - android:paddingRight="5dp" - android:paddingTop="0dp" > + android:layout_alignParentRight="true" + android:layout_centerVertical="true" + android:contentDescription="@string/search_document" + android:src="@drawable/ic_btn_search" /> - <ImageButton - android:id="@+id/searchButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:layout_centerVertical="true" - android:contentDescription="@string/search_document" - android:src="@drawable/ic_btn_search" /> + <ImageButton + android:id="@+id/outlineButton" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:layout_toLeftOf="@+id/searchButton" + android:contentDescription="@string/search_document" + android:src="@drawable/btn_star_big_off" /> - <ImageButton - android:id="@+id/outlineButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_toLeftOf="@+id/searchButton" - android:layout_centerVertical="true" - android:contentDescription="@string/search_document" - android:src="@drawable/btn_star_big_off" /> + <TextView + android:id="@+id/docNameText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:layout_centerVertical="true" + android:layout_toLeftOf="@+id/outlineButton" + android:singleLine="true" + android:textAppearance="?android:attr/textAppearanceMedium" /> + </RelativeLayout> - <TextView - android:id="@+id/docNameText" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:singleLine="true" - android:layout_alignParentLeft="true" - android:layout_toLeftOf="@+id/outlineButton" - android:layout_centerVertical="true" - android:textAppearance="?android:attr/textAppearanceMedium" /> - </RelativeLayout> + <RelativeLayout + android:id="@+id/topBar2" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="#CC444444" > - <RelativeLayout - android:id="@+id/topBar2" - android:layout_width="match_parent" + <Button + android:id="@+id/cancel" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="#CC444444" > - - <Button - android:id="@+id/cancel" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_centerVertical="true" - android:text="@string/cancel" /> + android:layout_alignParentLeft="true" + android:layout_centerVertical="true" + android:text="@string/cancel" /> - <EditText - android:id="@+id/searchText" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerHorizontal="true" - android:layout_toLeftOf="@+id/searchBack" - android:layout_toRightOf="@+id/cancel" - android:singleLine="true" - android:inputType="text" /> + <EditText + android:id="@+id/searchText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_toLeftOf="@+id/searchBack" + android:layout_toRightOf="@+id/cancel" + android:inputType="text" + android:singleLine="true" /> - <ImageButton - android:id="@+id/searchBack" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_centerVertical="true" - android:layout_toLeftOf="@+id/searchForward" - android:contentDescription="@string/search_backwards" - android:src="@drawable/ic_media_previous" /> + <ImageButton + android:id="@+id/searchBack" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:layout_toLeftOf="@+id/searchForward" + android:contentDescription="@string/search_backwards" + android:src="@drawable/ic_media_previous" /> - <ImageButton - android:id="@+id/searchForward" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:layout_centerVertical="true" - android:contentDescription="@string/search_forwards" - android:src="@drawable/ic_media_next" /> - </RelativeLayout> - </ViewSwitcher> + <ImageButton + android:id="@+id/searchForward" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:layout_centerVertical="true" + android:contentDescription="@string/search_forwards" + android:src="@drawable/ic_media_next" /> + </RelativeLayout> + </ViewSwitcher> - <TextView - android:id="@+id/pageNumber" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_above="@+id/pageSlider" - android:layout_centerHorizontal="true" - android:layout_marginBottom="10dp" - android:background="@drawable/page_num" - android:textAppearance="?android:attr/textAppearanceMedium" /> - </RelativeLayout> + <TextView + android:id="@+id/pageNumber" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_above="@+id/pageSlider" + android:layout_centerHorizontal="true" + android:layout_marginBottom="10dp" + android:background="@drawable/page_num" + android:textAppearance="?android:attr/textAppearanceMedium" /> -</ViewAnimator>
\ No newline at end of file +</RelativeLayout>
\ No newline at end of file diff --git a/android/src/com/artifex/mupdf/MuPDFActivity.java b/android/src/com/artifex/mupdf/MuPDFActivity.java index 45c92f96..4e0625b6 100644 --- a/android/src/com/artifex/mupdf/MuPDFActivity.java +++ b/android/src/com/artifex/mupdf/MuPDFActivity.java @@ -17,13 +17,14 @@ import android.view.ScaleGestureDetector; import android.view.View; 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; import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.TextView; -import android.widget.ViewAnimator; import android.widget.ViewSwitcher; class SearchTaskResult { @@ -41,7 +42,7 @@ public class MuPDFActivity extends Activity private MuPDFCore core; private String mFileName; private ReaderView mDocView; - private ViewAnimator mButtonsView; + private View mButtonsView; private boolean mButtonsVisible; private EditText mPasswordView; private TextView mFilenameView; @@ -398,7 +399,15 @@ public class MuPDFActivity extends Activity mSearchText.requestFocus(); showKeyboard(); } - mButtonsView.showNext(); + Animation anim = AnimationUtils.loadAnimation(this, R.anim.fade_in); + anim.setAnimationListener(new Animation.AnimationListener() { + public void onAnimationStart(Animation animation) { + mButtonsView.setVisibility(View.VISIBLE); + } + public void onAnimationRepeat(Animation animation) {} + public void onAnimationEnd(Animation animation) {} + }); + mButtonsView.startAnimation(anim); } } @@ -406,7 +415,15 @@ public class MuPDFActivity extends Activity if (mButtonsVisible) { mButtonsVisible = false; hideKeyboard(); - mButtonsView.showPrevious(); + Animation anim = AnimationUtils.loadAnimation(this, R.anim.fade_out); + anim.setAnimationListener(new Animation.AnimationListener() { + public void onAnimationStart(Animation animation) {} + public void onAnimationRepeat(Animation animation) {} + public void onAnimationEnd(Animation animation) { + mButtonsView.setVisibility(View.INVISIBLE); + } + }); + mButtonsView.startAnimation(anim); } } @@ -433,10 +450,8 @@ public class MuPDFActivity extends Activity } void makeButtonsView() { - // mButtonsView is a ViewAnimator between an initial dummy empty view - // and the actual control view. showNext and showPrevious can be used - // to fade it in an out - mButtonsView = (ViewAnimator)getLayoutInflater().inflate(R.layout.buttons,null); + 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); |