summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2012-07-25 15:42:46 +0200
committerMichael Meeks <michael.meeks@suse.com>2012-08-06 10:23:02 +0100
commitf656596761c289155e4a8d68df0134e8d84789c3 (patch)
tree0412e263ca88b6f25c6b4d5a7831ed67e1445889
parent7c0ddee3f8d8e2d4f95e77fe67613c82dbd172bd (diff)
Fully fixed coverflow resizing, added menu, fixed fragment changes.
Change-Id: Iaec671f81dada2dd9c667bde48b34ae2e89a321d
-rw-r--r--android/sdremote/res/drawable/icon_overflow.pngbin0 -> 167 bytes
-rw-r--r--android/sdremote/res/layout/fragment_presentation.xml4
-rw-r--r--android/sdremote/res/layout/slide_thumbnail.xml3
-rw-r--r--android/sdremote/res/menu/actionbar_presentation.xml3
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java57
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java19
6 files changed, 59 insertions, 27 deletions
diff --git a/android/sdremote/res/drawable/icon_overflow.png b/android/sdremote/res/drawable/icon_overflow.png
new file mode 100644
index 000000000000..5265c45101b2
--- /dev/null
+++ b/android/sdremote/res/drawable/icon_overflow.png
Binary files differ
diff --git a/android/sdremote/res/layout/fragment_presentation.xml b/android/sdremote/res/layout/fragment_presentation.xml
index 2b58bde0768c..03c4ee76746c 100644
--- a/android/sdremote/res/layout/fragment_presentation.xml
+++ b/android/sdremote/res/layout/fragment_presentation.xml
@@ -19,7 +19,9 @@
android:id="@+id/presentation_slidenumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- />
+ android:layout_gravity="center_horizontal"
+ android:text="" />
+
<ImageView
android:id="@+id/presentation_handle"
android:layout_width="fill_parent"
diff --git a/android/sdremote/res/layout/slide_thumbnail.xml b/android/sdremote/res/layout/slide_thumbnail.xml
index 448b3ed4fa14..d3834c7e343b 100644
--- a/android/sdremote/res/layout/slide_thumbnail.xml
+++ b/android/sdremote/res/layout/slide_thumbnail.xml
@@ -9,7 +9,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:src="@drawable/ic_launcher" />
+ android:src="@drawable/ic_launcher"
+ android:adjustViewBounds="true"/>
<TextView
android:id="@+id/sub_number"
diff --git a/android/sdremote/res/menu/actionbar_presentation.xml b/android/sdremote/res/menu/actionbar_presentation.xml
index 03524efbac28..a48aad563b9c 100644
--- a/android/sdremote/res/menu/actionbar_presentation.xml
+++ b/android/sdremote/res/menu/actionbar_presentation.xml
@@ -3,7 +3,8 @@
<item
android:id="@+id/actionbar_presentation_submenu"
- android:showAsAction="always">
+ android:showAsAction="always"
+ android:icon="@drawable/icon_overflow">
<menu>
<item
android:id="@+id/actionbar_presentation_submenu_blank"
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
index 78625398bcae..ed6e86f699dc 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
@@ -38,6 +38,9 @@ public class PresentationFragment extends Fragment {
private CommunicationService mCommunicationService;
private SlideShow mSlideShow;
+ private float mOriginalCoverflowWidth;
+ private float mOriginalCoverflowHeight;
+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mContext = container.getContext();
@@ -66,6 +69,9 @@ public class PresentationFragment extends Fragment {
// Call again to set things up if necessary.
setCommunicationService(mCommunicationService);
+ // Save the height/width for future reference
+ mOriginalCoverflowHeight = mTopView.getImageHeight();
+ mOriginalCoverflowWidth = mTopView.getImageWidth();
return v;
}
@@ -84,38 +90,51 @@ public class PresentationFragment extends Fragment {
break;
case MotionEvent.ACTION_MOVE:
LayoutParams aParams = mTopView.getLayoutParams();
- int aHeightOriginal = mTopView.getHeight();
int aHeight = mTopView.getHeight();
+ int aViewSize = mLayout.getHeight();
final int DRAG_MARGIN = 120;
- // Set Height
-
- aParams.height = aHeight + (int) (aEvent.getY());
- int aViewSize = mLayout.getHeight();
- if (aParams.height < DRAG_MARGIN) {
- aParams.height = DRAG_MARGIN;
- } else if (aParams.height > aViewSize - DRAG_MARGIN) {
- aParams.height = aViewSize - DRAG_MARGIN;
+ // Calculate height change, taking limits into account
+ int aDiff = (int) (aEvent.getY());
+ System.out.println("Diff1 is :" + aDiff);
+ if (aDiff + aHeight < DRAG_MARGIN) {
+ aDiff = DRAG_MARGIN - aHeight;
+ } else if ((aHeight + aDiff) > (aViewSize - DRAG_MARGIN)) {
+ aDiff = (aViewSize - DRAG_MARGIN) - aHeight;
}
- int aDiff = aParams.height - aHeightOriginal;
- mTopView.setLayoutParams(aParams);
-
// Now deal with the internal height
- System.out.println("Before:W:" + mTopView.getImageWidth()
- + ":H:" + mTopView.getImageHeight());
AbstractCoverFlowImageAdapter aAdapter = (AbstractCoverFlowImageAdapter) mTopView
.getAdapter();
- int aHeightNew = (int) (mTopView.getImageHeight() + aDiff);
+
+ double aRatio = mOriginalCoverflowWidth
+ / mOriginalCoverflowHeight;
+ System.out.println("Diff2 is :" + aDiff);
+ float aHeightNew = mTopView.getImageHeight() + aDiff;
+ float aWidthNew = (float) (aRatio * aHeightNew);
+
+ // Too wide -- so scale down
+ if (aWidthNew > mLayout.getWidth() - 50) {
+ aWidthNew = mLayout.getWidth() - 50;
+ aHeightNew = (float) (aWidthNew / aRatio);
+ aDiff = (int) (aHeightNew - mTopView.getImageHeight());
+ }
+
+ // Set the new settings -- it turns out that changing the
+ // internal height now works, and changing the views height
+ // is unnecessary / even causes problems.
+ // aParams.height += aDiff;
+ // mTopView.setLayoutParams(aParams);
+
aAdapter.setHeight(aHeightNew);
mTopView.setImageHeight(aHeightNew);
- int aWidthNew = aHeightNew * 180 / 150;
aAdapter.setWidth(aWidthNew);
mTopView.setImageWidth(aWidthNew);
+
+ // We need to update the view now
aAdapter.notifyDataSetChanged();
- System.out.println("After:W:" + mTopView.getImageWidth()
- + ":H:" + mTopView.getImageHeight());
+
break;
}
// TODO Auto-generated method stub
@@ -162,7 +181,7 @@ public class PresentationFragment extends Fragment {
int aSlide = aData.getInt("slide_number");
mTopView.setSelection(aSlide, true);
- mNumberText.setText(mSlideShow.getCurrentSlide() + "/"
+ mNumberText.setText((mSlideShow.getCurrentSlide() + 1) + "/"
+ mSlideShow.getSize());
break;
diff --git a/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java b/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java
index 265327733dcc..74a806df3b2c 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java
@@ -58,6 +58,15 @@ public class ThumbnailFragment extends Fragment {
}
@Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ mGrid = null;
+ mContext = null;
+ mCurrentImage = null;
+ mCurrentText = null;
+ }
+
+ @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -192,14 +201,14 @@ public class ThumbnailFragment extends Fragment {
}
Bitmap aBitmap = mSlideShow.getImage(position);
- if (aBitmap != null) {
- aImage.setImageBitmap(aBitmap);
- }
-
// Width
int aWidth = (mGrid.getWidth()) / 3 - 20;
aImage.setMaxWidth(aWidth);
- aImage.setScaleType(ScaleType.MATRIX);
+ aImage.setScaleType(ScaleType.FIT_CENTER);
+
+ if (aBitmap != null) {
+ aImage.setImageBitmap(aBitmap);
+ }
aText.setText(String.valueOf(position + 1));