Kaydet (Commit) b8c2ade6 authored tarafından Iain Billett's avatar Iain Billett

Use page thumbnails for icons.

Change-Id: I5df6341e5d1d8d775d2676d4ef5a52a528c6615c
üst 731332e6
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<ImageView <ImageView
android:id="@+id/grid_item_image" android:id="@+id/grid_item_image"
android:layout_width="50dp" android:layout_width="100dp"
android:layout_height="75dp" android:layout_height="142dp"
android:paddingTop="15dp" android:paddingTop="15dp"
android:paddingBottom="10dp" android:paddingBottom="10dp"
android:layout_gravity="center" > android:layout_gravity="center" >
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
android:verticalSpacing="10dp" android:verticalSpacing="10dp"
android:horizontalSpacing="10dp" android:horizontalSpacing="10dp"
android:stretchMode="columnWidth" android:stretchMode="columnWidth"
android:background="#ffeeeeee"
android:gravity="center"> android:gravity="center">
</GridView> </GridView>
......
...@@ -9,4 +9,8 @@ ...@@ -9,4 +9,8 @@
<item name="android:background">#bb000000</item> <item name="android:background">#bb000000</item>
</style> </style>
<style name="grayBackground">
<item name="android:background">#dd000000</item>
</style>
</resources> </resources>
\ No newline at end of file
...@@ -107,8 +107,8 @@ public class DocumentLoader ...@@ -107,8 +107,8 @@ public class DocumentLoader
// We pre-render this many pages preceding and succeeding the currently // We pre-render this many pages preceding and succeeding the currently
// viewed one, i.e. the total number of rendered pages kept is // viewed one, i.e. the total number of rendered pages kept is
// PAGECACHE_PLUSMINUS*2+1. // PAGECACHE_PLUSMINUS*2+1.
private static final int PAGECACHE_PLUSMINUS = 2; private static int PAGECACHE_PLUSMINUS = 2;
private static final int PAGECACHE_SIZE = PAGECACHE_PLUSMINUS*2 + 1; private static int PAGECACHE_SIZE = PAGECACHE_PLUSMINUS*2 + 1;
long timingOverhead; long timingOverhead;
XComponentContext context; XComponentContext context;
...@@ -157,7 +157,6 @@ public class DocumentLoader ...@@ -157,7 +157,6 @@ public class DocumentLoader
flipper.setOutAnimation(outToLeft); flipper.setOutAnimation(outToLeft);
flipper.showNext(); flipper.showNext();
((PageViewer)flipper.getChildAt((flipper.getDisplayedChild() + PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE)).display(((PageViewer)flipper.getCurrentView()).currentPageNumber + PAGECACHE_PLUSMINUS); ((PageViewer)flipper.getChildAt((flipper.getDisplayedChild() + PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE)).display(((PageViewer)flipper.getCurrentView()).currentPageNumber + PAGECACHE_PLUSMINUS);
return true; return true;
} else if (event2.getX() - event1.getX() > 120) { } else if (event2.getX() - event1.getX() > 120) {
...@@ -491,8 +490,11 @@ public class DocumentLoader ...@@ -491,8 +490,11 @@ public class DocumentLoader
void display(int number) void display(int number)
{ {
Log.i(TAG, "PageViewer display(" + number + ")"); Log.i(TAG, "PageViewer display(" + number + ")");
if (number >= 0) if (number >= 0){
waitView = new TextView(DocumentLoader.this);
waitView.setText("Page " + (number+1) + ", wait..."); waitView.setText("Page " + (number+1) + ", wait...");
addView(waitView, 0, matchParent);
}
currentPageNumber = number; currentPageNumber = number;
state = PageState.NONEXISTENT; state = PageState.NONEXISTENT;
...@@ -520,7 +522,6 @@ public class DocumentLoader ...@@ -520,7 +522,6 @@ public class DocumentLoader
waitView.setGravity(Gravity.CENTER); waitView.setGravity(Gravity.CENTER);
waitView.setBackgroundColor(Color.WHITE); waitView.setBackgroundColor(Color.WHITE);
waitView.setTextColor(Color.BLACK); waitView.setTextColor(Color.BLACK);
addView(waitView, 0, matchParent);
display(number); display(number);
} }
...@@ -719,8 +720,9 @@ public class DocumentLoader ...@@ -719,8 +720,9 @@ public class DocumentLoader
//flipper = new ViewFlipper(this); //flipper = new ViewFlipper(this);
flipper = (ViewFlipper)findViewById( R.id.page_flipper ); flipper = (ViewFlipper)findViewById( R.id.page_flipper );
matchParent = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); matchParent = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
flipper.removeViewAt( 0 ); flipper.removeViewAt( 0 );
currentPage = 0; currentPage = 0;
openPageWithPrefetching( currentPage ); openPageWithPrefetching( currentPage );
/* /*
...@@ -923,7 +925,8 @@ public class DocumentLoader ...@@ -923,7 +925,8 @@ public class DocumentLoader
} }
} }
protected void onDestroy(){ protected void onDestroy()
{
super.onDestroy(); super.onDestroy();
//Save the thumbnail of the first page as the grid image. //Save the thumbnail of the first page as the grid image.
// Could easily make a new (larger) thumb but recycling // Could easily make a new (larger) thumb but recycling
...@@ -974,23 +977,27 @@ public class DocumentLoader ...@@ -974,23 +977,27 @@ public class DocumentLoader
* load page && fill cache * load page && fill cache
* if page is */ * if page is */
public void openPageWithPrefetching( int number ){ public void openPageWithPrefetching( int number ){
//as a first draft clear an refill "cache" on load. //as a first draft clear an refill "cache" on load.
//should move views where "cache window" overlaps //should move views where "cache window" overlaps
Log.i( TAG , Integer.toString( pageCount ) );
flipper.removeAllViews(); //flipper.removeAllViews();
flipper.addView(new PageViewer(number), 0, matchParent); flipper.addView(new PageViewer(number), 0, matchParent);
for (int i = 0; i < PAGECACHE_PLUSMINUS; i++){ 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) 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); 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++){ 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); flipper.addView(new PageViewer( number - (i+1)), PAGECACHE_PLUSMINUS + i+1, matchParent);
} }else{
flipper.addView( new PageViewer( 0 ), PAGECACHE_PLUSMINUS + i+1, matchParent );
}
} }
} }
} }
......
...@@ -93,29 +93,33 @@ public class FileUtilities { ...@@ -93,29 +93,33 @@ public class FileUtilities {
// Filter by mode, and/or in future by filename/wildcard // Filter by mode, and/or in future by filename/wildcard
static private boolean doAccept(String filename, int byMode, String byFilename) static private boolean doAccept(String filename, int byMode, String byFilename)
{ {
android.util.Log.d("debug", "doAccept : " + filename + " mode " + byMode + " byFilename " + byFilename); android.util.Log.d("debug", "doAccept : " + filename + " mode " + byMode + " byFilename " + byFilename);
if (byMode == ALL && byFilename == "") if (byMode == ALL && byFilename == ""){
return true; if( filename.startsWith(".")){//ignore hidden files
// check extension return false;
if (byMode != ALL) { }
if (mExtnMap.get (getExtension (filename)) != byMode) return true;
return false; }
} // check extension
if (byFilename != "") { if (byMode != ALL) {
// FIXME return false on a non-match if (mExtnMap.get (getExtension (filename)) != byMode)
} return false;
return true; }
if (byFilename != "") {
// FIXME return false on a non-match
}
return true;
} }
static FileFilter getFileFilter(final int mode) static FileFilter getFileFilter(final int mode)
{ {
return new FileFilter() { return new FileFilter() {
public boolean accept(File pathname) { public boolean accept(File pathname) {
if (pathname.isDirectory()) if (pathname.isDirectory())
return true; return true;
return doAccept(pathname.getName(), mode, ""); return doAccept(pathname.getName(), mode, "");
} }
}; };
} }
static FilenameFilter getFilenameFilter(final int mode) static FilenameFilter getFilenameFilter(final int mode)
......
...@@ -10,6 +10,7 @@ package org.libreoffice.ui; ...@@ -10,6 +10,7 @@ package org.libreoffice.ui;
import org.libreoffice.R; import org.libreoffice.R;
import java.io.File; import java.io.File;
import android.content.Context; import android.content.Context;
...@@ -20,6 +21,8 @@ import android.view.ViewGroup; ...@@ -20,6 +21,8 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap;
public class GridItemAdapter extends BaseAdapter{ public class GridItemAdapter extends BaseAdapter{
Context mContext; Context mContext;
...@@ -77,24 +80,37 @@ public class GridItemAdapter extends BaseAdapter{ ...@@ -77,24 +80,37 @@ public class GridItemAdapter extends BaseAdapter{
// get layout from mobile.xml // get layout from mobile.xml
gridView = inflater.inflate(R.layout.file_explorer_grid_item, null); gridView = inflater.inflate(R.layout.file_explorer_grid_item, null);
// set value into textview // set value into textview
TextView textView = (TextView) gridView TextView textView = (TextView) gridView
.findViewById(R.id.grid_item_label); .findViewById(R.id.grid_item_label);
textView.setText(filePaths[position].getName()); textView.setText(filePaths[position].getName());
// set image based on selected text // set image based on selected text
ImageView imageView = (ImageView) gridView ImageView imageView = (ImageView) gridView
.findViewById(R.id.grid_item_image); .findViewById(R.id.grid_item_image);
if( filePaths[position].isDirectory() ) // Is a folder if( filePaths[position].isDirectory() ) // Is a folder
{ {
// Eventually have thumbnails of each sub file on a black circle // Eventually have thumbnails of each sub file on a black circle
// For now just a folder icon // For now just a folder icon
imageView.setImageResource(R.drawable.folder); imageView.setImageResource(R.drawable.folder);
} }
else else
{ {
switch (FileUtilities.getType(filePaths[position].getName())) File thumbnailFile = new File( filePaths[position].getParent() , "."
{ + filePaths[position].getName().split("[.]")[0] + ".png");
case FileUtilities.DOC: 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); imageView.setImageResource(R.drawable.writer);
break; break;
case FileUtilities.CALC: case FileUtilities.CALC:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment