diff options
author | Iain Billett <iainbillett@gmail.com> | 2012-07-04 18:36:47 +0100 |
---|---|---|
committer | Iain Billett <iainbillett@gmail.com> | 2012-07-04 18:38:24 +0100 |
commit | b8c2ade611f1fc8025aaa8715df9d11dd1d1d631 (patch) | |
tree | 95b5cbc3c6670a006e072b49f7366e4ea55bd287 /android | |
parent | 731332e6cc4156eb851ae31bf33504d0d312d658 (diff) |
Use page thumbnails for icons.
Change-Id: I5df6341e5d1d8d775d2676d4ef5a52a528c6615c
Diffstat (limited to 'android')
6 files changed, 90 insertions, 58 deletions
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 58b94018c71a..ae5bb022eb5c 100644 --- a/android/experimental/LibreOffice4Android/res/layout/file_explorer_grid_item.xml +++ b/android/experimental/LibreOffice4Android/res/layout/file_explorer_grid_item.xml @@ -12,8 +12,8 @@ <ImageView android:id="@+id/grid_item_image" - android:layout_width="50dp" - android:layout_height="75dp" + android:layout_width="100dp" + android:layout_height="142dp" android:paddingTop="15dp" android:paddingBottom="10dp" android:layout_gravity="center" > diff --git a/android/experimental/LibreOffice4Android/res/layout/file_grid.xml b/android/experimental/LibreOffice4Android/res/layout/file_grid.xml index 05edc0469096..72eb6618d5fa 100644 --- a/android/experimental/LibreOffice4Android/res/layout/file_grid.xml +++ b/android/experimental/LibreOffice4Android/res/layout/file_grid.xml @@ -19,6 +19,7 @@ android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:stretchMode="columnWidth" + android:background="#ffeeeeee" android:gravity="center"> </GridView> diff --git a/android/experimental/LibreOffice4Android/res/values/styles.xml b/android/experimental/LibreOffice4Android/res/values/styles.xml index 46edd6719438..26f8cf212f1f 100644 --- a/android/experimental/LibreOffice4Android/res/values/styles.xml +++ b/android/experimental/LibreOffice4Android/res/values/styles.xml @@ -9,4 +9,8 @@ <item name="android:background">#bb000000</item> </style> + <style name="grayBackground"> + <item name="android:background">#dd000000</item> + </style> + </resources>
\ No newline at end of file diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java index 7842b4301b40..6ca7c9d75eec 100644 --- a/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java +++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java @@ -107,8 +107,8 @@ public class DocumentLoader // We pre-render this many pages preceding and succeeding the currently // viewed one, i.e. the total number of rendered pages kept is // PAGECACHE_PLUSMINUS*2+1. - private static final int PAGECACHE_PLUSMINUS = 2; - private static final int PAGECACHE_SIZE = PAGECACHE_PLUSMINUS*2 + 1; + private static int PAGECACHE_PLUSMINUS = 2; + private static int PAGECACHE_SIZE = PAGECACHE_PLUSMINUS*2 + 1; long timingOverhead; XComponentContext context; @@ -157,7 +157,6 @@ public class DocumentLoader flipper.setOutAnimation(outToLeft); flipper.showNext(); - ((PageViewer)flipper.getChildAt((flipper.getDisplayedChild() + PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE)).display(((PageViewer)flipper.getCurrentView()).currentPageNumber + PAGECACHE_PLUSMINUS); return true; } else if (event2.getX() - event1.getX() > 120) { @@ -491,8 +490,11 @@ public class DocumentLoader void display(int number) { Log.i(TAG, "PageViewer display(" + number + ")"); - if (number >= 0) + if (number >= 0){ + waitView = new TextView(DocumentLoader.this); waitView.setText("Page " + (number+1) + ", wait..."); + addView(waitView, 0, matchParent); + } currentPageNumber = number; state = PageState.NONEXISTENT; @@ -520,7 +522,6 @@ public class DocumentLoader waitView.setGravity(Gravity.CENTER); waitView.setBackgroundColor(Color.WHITE); waitView.setTextColor(Color.BLACK); - addView(waitView, 0, matchParent); display(number); } @@ -719,8 +720,9 @@ public class DocumentLoader //flipper = new ViewFlipper(this); flipper = (ViewFlipper)findViewById( R.id.page_flipper ); matchParent = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - flipper.removeViewAt( 0 ); + + currentPage = 0; openPageWithPrefetching( currentPage ); /* @@ -923,7 +925,8 @@ public class DocumentLoader } } - protected void onDestroy(){ + protected void onDestroy() + { super.onDestroy(); //Save the thumbnail of the first page as the grid image. // Could easily make a new (larger) thumb but recycling @@ -974,23 +977,27 @@ public class DocumentLoader * load page && fill cache * if page is */ public void openPageWithPrefetching( int number ){ - //as a first draft clear an refill "cache" on load. - //should move views where "cache window" overlaps - - flipper.removeAllViews(); - flipper.addView(new PageViewer(number), 0, matchParent); - + //as a first draft clear an refill "cache" on load. + //should move views where "cache window" overlaps + Log.i( TAG , Integer.toString( pageCount ) ); + //flipper.removeAllViews(); + flipper.addView(new PageViewer(number), 0, matchParent); + for (int i = 0; i < PAGECACHE_PLUSMINUS; i++){ - if( number + i+1 >= 0 && number + i+1 < pageCount){//pageCount will always be correctly defined when this is called (famous last words) - flipper.addView(new PageViewer( number + i+1), i+1, matchParent); - } + if( number + i+1 >= 0 && number + i+1 < pageCount){//pageCount will always be defined when this is called (famous last words) + flipper.addView(new PageViewer( number + i+1), i+1, matchParent); + }else{ + flipper.addView( new PageViewer( pageCount - 1), i+1, matchParent ); + } } for (int i = 0; i < PAGECACHE_PLUSMINUS; i++){ - if( number - i+1 >= 0 && number - i+1 < pageCount){ + if( number - i+1 >= 0 && number - i+1 < pageCount){ flipper.addView(new PageViewer( number - (i+1)), PAGECACHE_PLUSMINUS + i+1, matchParent); - } + }else{ + flipper.addView( new PageViewer( 0 ), PAGECACHE_PLUSMINUS + i+1, matchParent ); + } } - + } } diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/FileUtilities.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/FileUtilities.java index dc6b04c2cc20..99d35486d15b 100644 --- a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/FileUtilities.java +++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/FileUtilities.java @@ -93,29 +93,33 @@ public class FileUtilities { // Filter by mode, and/or in future by filename/wildcard static private boolean doAccept(String filename, int byMode, String byFilename) { - android.util.Log.d("debug", "doAccept : " + filename + " mode " + byMode + " byFilename " + byFilename); - if (byMode == ALL && byFilename == "") - return true; - // check extension - if (byMode != ALL) { - if (mExtnMap.get (getExtension (filename)) != byMode) - return false; - } - if (byFilename != "") { - // FIXME return false on a non-match - } - return true; + android.util.Log.d("debug", "doAccept : " + filename + " mode " + byMode + " byFilename " + byFilename); + if (byMode == ALL && byFilename == ""){ + if( filename.startsWith(".")){//ignore hidden files + return false; + } + return true; + } + // check extension + if (byMode != ALL) { + if (mExtnMap.get (getExtension (filename)) != byMode) + return false; + } + if (byFilename != "") { + // FIXME return false on a non-match + } + return true; } static FileFilter getFileFilter(final int mode) { - return new FileFilter() { - public boolean accept(File pathname) { - if (pathname.isDirectory()) - return true; - return doAccept(pathname.getName(), mode, ""); - } - }; + return new FileFilter() { + public boolean accept(File pathname) { + if (pathname.isDirectory()) + return true; + return doAccept(pathname.getName(), mode, ""); + } + }; } static FilenameFilter getFilenameFilter(final int mode) diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/GridItemAdapter.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/GridItemAdapter.java index fb26bf11f136..a414d3cdc562 100644 --- a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/GridItemAdapter.java +++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/GridItemAdapter.java @@ -10,6 +10,7 @@ package org.libreoffice.ui; import org.libreoffice.R; + import java.io.File; import android.content.Context; @@ -20,6 +21,8 @@ import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; +import android.graphics.BitmapFactory; +import android.graphics.Bitmap; public class GridItemAdapter extends BaseAdapter{ Context mContext; @@ -77,24 +80,37 @@ public class GridItemAdapter extends BaseAdapter{ // get layout from mobile.xml gridView = inflater.inflate(R.layout.file_explorer_grid_item, null); - // set value into textview - TextView textView = (TextView) gridView - .findViewById(R.id.grid_item_label); - textView.setText(filePaths[position].getName()); - // set image based on selected text - ImageView imageView = (ImageView) gridView - .findViewById(R.id.grid_item_image); - if( filePaths[position].isDirectory() ) // Is a folder - { - // Eventually have thumbnails of each sub file on a black circle - // For now just a folder icon - imageView.setImageResource(R.drawable.folder); - } - else - { - switch (FileUtilities.getType(filePaths[position].getName())) - { - case FileUtilities.DOC: + // set value into textview + TextView textView = (TextView) gridView + .findViewById(R.id.grid_item_label); + textView.setText(filePaths[position].getName()); + // set image based on selected text + ImageView imageView = (ImageView) gridView + .findViewById(R.id.grid_item_image); + if( filePaths[position].isDirectory() ) // Is a folder + { + // Eventually have thumbnails of each sub file on a black circle + // For now just a folder icon + imageView.setImageResource(R.drawable.folder); + } + else + { + File thumbnailFile = new File( filePaths[position].getParent() , "." + + filePaths[position].getName().split("[.]")[0] + ".png"); + BitmapFactory factory = new BitmapFactory(); + Bitmap thumb = factory.decodeFile( thumbnailFile.getAbsolutePath() ); + if(thumb != null){ + Log.i( "GRID" , "true" ); + }else{ + Log.i( "GRID" , thumbnailFile.getAbsolutePath() ); + } + switch (FileUtilities.getType(filePaths[position].getName())) + { + case FileUtilities.DOC: + if( thumb != null){ + imageView.setImageBitmap( thumb ); + break; + } imageView.setImageResource(R.drawable.writer); break; case FileUtilities.CALC: |