diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2012-07-25 16:51:41 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-08-06 10:23:02 +0100 |
commit | 91d4180ba673dccf424fb71078e9074841be9f78 (patch) | |
tree | ea90286a1e0d9fb4ce31b47e323362683e5a75c0 /android | |
parent | f656596761c289155e4a8d68df0134e8d84789c3 (diff) |
Added proper toggling for thumbnail button.
Change-Id: I2dc83bd3503c17d27c6461cd925cc22af7f61af8
Diffstat (limited to 'android')
-rw-r--r-- | android/sdremote/res/drawable/actionbar_none.png | bin | 0 -> 106 bytes | |||
-rw-r--r-- | android/sdremote/res/drawable/actionbar_pressed.png | bin | 0 -> 115 bytes | |||
-rw-r--r-- | android/sdremote/res/drawable/actionbar_selected.png | bin | 0 -> 115 bytes | |||
-rw-r--r-- | android/sdremote/res/drawable/actionbar_thumbs.xml | 9 | ||||
-rw-r--r-- | android/sdremote/res/drawable/actionbar_toggle.xml | 8 | ||||
-rw-r--r-- | android/sdremote/res/layout/fragment_thumbnail.xml | 1 | ||||
-rw-r--r-- | android/sdremote/res/layout/presentation_actionbar.xml | 11 | ||||
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java | 37 |
8 files changed, 50 insertions, 16 deletions
diff --git a/android/sdremote/res/drawable/actionbar_none.png b/android/sdremote/res/drawable/actionbar_none.png Binary files differnew file mode 100644 index 000000000000..d7895e55dab2 --- /dev/null +++ b/android/sdremote/res/drawable/actionbar_none.png diff --git a/android/sdremote/res/drawable/actionbar_pressed.png b/android/sdremote/res/drawable/actionbar_pressed.png Binary files differnew file mode 100644 index 000000000000..812c92b467fd --- /dev/null +++ b/android/sdremote/res/drawable/actionbar_pressed.png diff --git a/android/sdremote/res/drawable/actionbar_selected.png b/android/sdremote/res/drawable/actionbar_selected.png Binary files differnew file mode 100644 index 000000000000..9c471a306075 --- /dev/null +++ b/android/sdremote/res/drawable/actionbar_selected.png diff --git a/android/sdremote/res/drawable/actionbar_thumbs.xml b/android/sdremote/res/drawable/actionbar_thumbs.xml new file mode 100644 index 000000000000..2dbf5ea46b1a --- /dev/null +++ b/android/sdremote/res/drawable/actionbar_thumbs.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > + + <item android:drawable="@drawable/actionbar_toggle"/> + <item><bitmap + android:src="@drawable/icon_thumbs" + android:gravity="center" /></item> + +</layer-list>
\ No newline at end of file diff --git a/android/sdremote/res/drawable/actionbar_toggle.xml b/android/sdremote/res/drawable/actionbar_toggle.xml new file mode 100644 index 000000000000..3f53266b1ef6 --- /dev/null +++ b/android/sdremote/res/drawable/actionbar_toggle.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + + <item android:drawable="@drawable/actionbar_selected" android:state_checked="true" /> + <item android:drawable="@drawable/actionbar_pressed" android:state_pressed="true"/> + <item android:drawable="@drawable/actionbar_none"/> + +</selector>
\ No newline at end of file diff --git a/android/sdremote/res/layout/fragment_thumbnail.xml b/android/sdremote/res/layout/fragment_thumbnail.xml index 068ab7893317..ecd8855c9fe7 100644 --- a/android/sdremote/res/layout/fragment_thumbnail.xml +++ b/android/sdremote/res/layout/fragment_thumbnail.xml @@ -7,6 +7,7 @@ android:gravity="center" android:horizontalSpacing="10dp" android:numColumns="auto_fit" + android:paddingTop="10dp" android:stretchMode="columnWidth" android:verticalSpacing="10dp" > diff --git a/android/sdremote/res/layout/presentation_actionbar.xml b/android/sdremote/res/layout/presentation_actionbar.xml index 01f0d51d830d..818748bd7366 100644 --- a/android/sdremote/res/layout/presentation_actionbar.xml +++ b/android/sdremote/res/layout/presentation_actionbar.xml @@ -4,19 +4,20 @@ android:layout_height="match_parent" android:orientation="horizontal" > - <ImageButton + <ToggleButton android:id="@+id/actionbar_thumbnailtoggle" android:layout_width="wrap_content" android:layout_height="match_parent" - android:background="@drawable/empty" - android:src="@drawable/icon_thumbs" /> + android:background="@drawable/actionbar_thumbs" + android:textOff="" + android:textOn="" /> <TextView android:id="@+id/actionbar_time" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" - android:textSize="22dp" - android:textColor="#FFFFFF"/> + android:textColor="#FFFFFF" + android:textSize="22dp" /> </LinearLayout>
\ No newline at end of file diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java index 8b6d75f6d1d5..795ab53e9cd3 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java @@ -20,8 +20,8 @@ import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.FrameLayout; -import android.widget.ImageButton; import android.widget.TextView; +import android.widget.ToggleButton; public class PresentationActivity extends Activity { private CommunicationService mCommunicationService; @@ -104,10 +104,11 @@ public class PresentationActivity extends Activity { } } - private class ActionBarManager implements OnClickListener { + private class ActionBarManager implements OnClickListener, + FragmentManager.OnBackStackChangedListener { private TextView mTimeLabel; - private ImageButton mThumbnailButton; + private ToggleButton mThumbnailButton; private String aTimeFormat = getResources().getString( R.string.actionbar_timeformat); @@ -129,14 +130,17 @@ public class PresentationActivity extends Activity { aBar.setCustomView(R.layout.presentation_actionbar); // Set up the various components - mThumbnailButton = (ImageButton) aBar.getCustomView().findViewById( - R.id.actionbar_thumbnailtoggle); + mThumbnailButton = (ToggleButton) aBar.getCustomView() + .findViewById(R.id.actionbar_thumbnailtoggle); mThumbnailButton.setOnClickListener(this); mTimeLabel = (TextView) aBar.getCustomView().findViewById( R.id.actionbar_time); mThumbnailButton.setOnClickListener(this); + // Listen for fragment changes + getFragmentManager().addOnBackStackChangedListener(this); + // Setup the auto updater timerHandler.removeCallbacks(timerUpdateThread); timerHandler.postDelayed(timerUpdateThread, 50); @@ -170,17 +174,28 @@ public class PresentationActivity extends Activity { @Override public void onClick(View aSource) { if (aSource == mThumbnailButton) { - FragmentTransaction ft = getFragmentManager() - .beginTransaction(); - ft.replace(R.id.framelayout, mThumbnailFragment); - ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); - ft.addToBackStack(null); - ft.commit(); + if (!mThumbnailFragment.isVisible()) { + FragmentTransaction ft = getFragmentManager() + .beginTransaction(); + ft.replace(R.id.framelayout, mThumbnailFragment); + ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); + ft.addToBackStack(null); + ft.commit(); + } else { + getFragmentManager().popBackStack(); + } } else if (aSource == mTimeLabel) { } } + + @Override + public void onBackStackChanged() { + if (getFragmentManager().getBackStackEntryCount() == 0) { + mThumbnailButton.setChecked(false); + } + } } } |