diff options
author | Iain Billett <iainbillett@gmail.com> | 2012-08-02 17:47:48 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-08-07 15:23:54 +0100 |
commit | 36e1debe4ad0c8a58095501ead01993bd8c120d5 (patch) | |
tree | d2832b996cd002cdf50f493679b7148e7c9e327d /android | |
parent | 12fff840aba5e6d93d9becf9efcf94b4849c36e0 (diff) |
Quick fix for upside down thumbnails.
Change-Id: I089c78f050fbea068b394de9205322dc62e28764
Diffstat (limited to 'android')
4 files changed, 33 insertions, 13 deletions
diff --git a/android/experimental/LibreOffice4Android/res/drawable/black_white_gradient.xml b/android/experimental/LibreOffice4Android/res/drawable/black_white_gradient.xml new file mode 100644 index 000000000000..3ed538ccec34 --- /dev/null +++ b/android/experimental/LibreOffice4Android/res/drawable/black_white_gradient.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <gradient + android:type="radial" + android:gradientRadius="200" + android:startColor="#FF000000" + android:endColor="#00FFFFFF" + android:angle="45"/> + <padding android:left="7dp" + android:top="7dp" + android:right="7dp" + android:bottom="7dp" /> + <corners android:radius="8dp" /> +</shape>
\ No newline at end of file diff --git a/android/experimental/LibreOffice4Android/res/layout/file_explorer_grid_item.xml b/android/experimental/LibreOffice4Android/res/layout/file_explorer_grid_item.xml index 62609be5600b..585a805ffe7a 100644 --- a/android/experimental/LibreOffice4Android/res/layout/file_explorer_grid_item.xml +++ b/android/experimental/LibreOffice4Android/res/layout/file_explorer_grid_item.xml @@ -8,16 +8,15 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" + android:paddingTop="10dp" android:orientation="vertical" > <ImageView android:id="@+id/grid_item_image" android:layout_width="100dp" android:layout_height="142dp" - android:paddingTop="15dp" - android:paddingBottom="10dp" android:scaleType="fitStart" - android:layout_gravity="center" > + android:layout_gravity="center"> </ImageView> <TextView @@ -27,6 +26,7 @@ android:text="@+id/label" android:paddingLeft="10dp" android:paddingRight="10dp" + android:paddingTop="10dp" android:layout_gravity="center" android:textSize="15dp" android:textStyle="bold" diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java index f26eedbc3b8a..f69d26299280 100644 --- a/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java +++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java @@ -33,6 +33,7 @@ import org.libreoffice.R; import android.app.Activity; import android.graphics.Bitmap; +import android.graphics.Matrix; import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; @@ -1110,22 +1111,21 @@ public class DocumentLoader // Could easily make a new (larger) thumb but recycling // should be faster & more efficient, better for the environment ;-) //ll = (LinearLayout)findViewById( R.id.navigator); -// Bitmap bmp = ( (ThumbnailView)ll.getChildAt( 0 ) ).getBitmap(); - ByteBuffer bb = renderPage( 0 , 100 , (int)( 100*Math.sqrt(2) ) ); -// bb.flip(); - Bitmap bmp = Bitmap.createBitmap( 100, (int)( 100*Math.sqrt(2) ), Bitmap.Config.ARGB_8888); - bmp.copyPixelsFromBuffer(bb); + Bitmap bmpAlpha = ( (ThumbnailView)ll.getChildAt( 0 ) ).getBitmap(); + //For now use these 3 lines to turn the bitmap right way up. + Matrix m = new Matrix(); + m.preScale( 1.0f , -1.0f ); + Bitmap bmp = Bitmap.createBitmap( bmpAlpha, 0, 0, bmpAlpha.getWidth(), bmpAlpha.getHeight(), m, true); File file = new File(extras.getString("input")); Log.i(TAG ,"onDestroy " + extras.getString("input")); File dir = file.getParentFile(); File thumbnailFile = new File( dir , "." + file.getName().split("[.]")[0] + ".png"); try { - /*(ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - bmp.compress(Bitmap.CompressFormat.JPEG, 40, bytes); - if( !thumbnailFile.isFile() ) - thumbnailFile.createNewFile(); + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + bmp.compress(Bitmap.CompressFormat.PNG, 40, bytes); + thumbnailFile.createNewFile(); FileOutputStream fo = new FileOutputStream( thumbnailFile ); fo.write(bytes.toByteArray());*/ if( !thumbnailFile.isFile() ) diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java index c5cfc531e14c..a4d03369dd90 100644 --- a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java +++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java @@ -38,6 +38,7 @@ import android.app.ActionBar.OnNavigationListener; import android.app.Activity; import android.os.AsyncTask; import android.graphics.Bitmap; +import android.graphics.Matrix; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -855,11 +856,15 @@ class ListItemAdapter implements ListAdapter{ ByteBuffer bb = renderPage( 0 , widthInPx , heightInPx); Bitmap bm = Bitmap.createBitmap( widthInPx , heightInPx , Bitmap.Config.ARGB_8888); bm.copyPixelsFromBuffer(bb); + + Matrix m = new Matrix(); + m.preScale( 1.0f , -1.0f ); + Bitmap bmp = Bitmap.createBitmap( bm, 0, 0, bm.getWidth(), bm.getHeight(), m, true); File dir = file.getParentFile(); File thumbnailFile = new File( dir , "." + file.getName().split("[.]")[0] + ".png"); try { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - bm.compress(Bitmap.CompressFormat.PNG, 40, bytes); + bmp.compress(Bitmap.CompressFormat.PNG, 40, bytes); thumbnailFile.createNewFile(); FileOutputStream fo = new FileOutputStream( thumbnailFile ); fo.write(bytes.toByteArray()); |