[Libreoffice-commits] .: 2 commits - android/experimental
Iain Billett
iainb at kemper.freedesktop.org
Thu Jun 28 11:45:43 PDT 2012
android/experimental/LibreOffice4Android/AndroidManifest.xml | 1
android/experimental/LibreOffice4Android/res/layout/document_viewer.xml | 27
android/experimental/LibreOffice4Android/res/layout/navigation_grid_item.xml | 16
android/experimental/LibreOffice4Android/res/values/styles.xml | 2
android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java | 359 +++++++++-
android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java | 3
6 files changed, 398 insertions(+), 10 deletions(-)
New commits:
commit 06b935baa5696f90caedf51e4d3a0302350a446b
Author: Iain Billett <iainbillett at gmail.com>
Date: Thu Jun 28 19:36:29 2012 +0100
First draft of "navigator", a strip of "live" thumbnails which are clickable.
Open method to open random page, not first.
Put some UI set up in documentLoadTask as the UI requires the number of pages in the document which is only know on load.
diff --git a/android/experimental/LibreOffice4Android/res/layout/document_viewer.xml b/android/experimental/LibreOffice4Android/res/layout/document_viewer.xml
index 2f84be9..fbb25c8 100644
--- a/android/experimental/LibreOffice4Android/res/layout/document_viewer.xml
+++ b/android/experimental/LibreOffice4Android/res/layout/document_viewer.xml
@@ -13,11 +13,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/page_flipper"
+ android:scrollbarAlwaysDrawHorizontalTrack="true"
android:background="#aa000000">
<LinearLayout
android:id="@+id/navigator"
android:layout_width="wrap_content"
- android:layout_height="150dp"
+ android:layout_height="120dp"
+ android:layout_margin="15dp"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView >
diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java
index 2c839a5..bd40040 100644
--- a/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java
+++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java
@@ -95,7 +95,7 @@ public class DocumentLoader
extends Activity
{
private static final String TAG = "DocumentLoader";
-
+
// Size of a small virtual (bitmap) device used to find out page count and
// page sizes
private static final int SMALLSIZE = 128;
@@ -152,7 +152,7 @@ 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) {
@@ -523,7 +523,13 @@ public class DocumentLoader
View thumbnailView;
//PageState state = PageState.NONEXISTENT;
Bitmap bm;
-
+ final float scale;
+ final int widthInPx;
+ final int heightInPx;
+ final int defaultWidthPx = 120;
+ final int defaultHeightPx = 120;
+ final int thumbnailPaddingDp = 10;
+
class ThumbLoadTask
extends AsyncTask<Integer, Void, Integer>
{
@@ -535,8 +541,8 @@ public class DocumentLoader
return -1;
//state = PageState.LOADING;
- ByteBuffer bb = renderPage( number , 120 , 120);
- bm = Bitmap.createBitmap( 120 , 120 , Bitmap.Config.ARGB_8888);
+ ByteBuffer bb = renderPage( number , widthInPx , heightInPx);
+ bm = Bitmap.createBitmap( widthInPx , heightInPx , Bitmap.Config.ARGB_8888);
bm.copyPixelsFromBuffer(bb);
return number;
@@ -552,7 +558,8 @@ public class DocumentLoader
ImageView thumbImage = new ImageView(DocumentLoader.this);//(ImageView)findViewById( R.id.thumbnail );
thumbImage.setImageBitmap(bm);
-
+ int paddingPx = (int) (thumbnailPaddingDp* scale + 0.5f);
+ thumbImage.setPadding( paddingPx , 0 , paddingPx , 0 );
thumbImage.setScaleY(-1);
Log.i( TAG, Integer.toString( thumbImage.getWidth() ) );
@@ -570,15 +577,31 @@ public class DocumentLoader
if (number >= 0)
waitView.setText("Page " + (number+1) + ", wait...");
//state = PageState.NONEXISTENT;
-
if (number >= 0) {
new ThumbLoadTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, number);
}
}
+ ThumbnailView(int number , int widthInDp , int heightInDp)
+ {
+ super(DocumentLoader.this);
+ scale = getContext().getResources().getDisplayMetrics().density;
+ widthInPx = (int) (widthInDp * scale + 0.5f);
+ heightInPx = (int) (heightInDp* scale + 0.5f);
+ waitView = new TextView( DocumentLoader.this );
+ thumbnailView = inflater.inflate( R.layout.navigation_grid_item , null);
+
+ display(number);
+
+
+ }
+
ThumbnailView(int number)
{
super(DocumentLoader.this);
+ scale = getContext().getResources().getDisplayMetrics().density;
+ widthInPx = defaultWidthPx;
+ heightInPx = defaultHeightPx;
waitView = new TextView( DocumentLoader.this );
thumbnailView = inflater.inflate( R.layout.navigation_grid_item , null);
@@ -589,9 +612,21 @@ public class DocumentLoader
}
class DocumentLoadTask
- extends AsyncTask<String, Void, Void>
+ extends AsyncTask<String, Void, Integer>
{
- protected Void doInBackground(String... params)
+ protected void onPreExecute (){
+ TextView waitView = new TextView(DocumentLoader.this);
+ waitView.setTextSize(24);
+ waitView.setGravity(Gravity.CENTER);
+ waitView.setBackgroundColor(Color.WHITE);
+ waitView.setTextColor(Color.BLACK);
+ waitView.setText("Page " + (1) + ", wait...");
+ flipper = new ViewFlipper(DocumentLoader.this);
+ flipper = (ViewFlipper)findViewById( R.id.page_flipper );
+ matchParent = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+ flipper.addView( waitView , 0 , matchParent);
+ }
+ protected Integer doInBackground(String... params)
{
try {
String url = params[0];
@@ -645,7 +680,46 @@ public class DocumentLoader
e.printStackTrace(System.err);
finish();
}
- return null;
+ return new Integer( pageCount );
+ }
+
+ protected void onPostExecute(Integer result){
+ Log.i(TAG, "onPostExecute: " + result);
+ if (result == -1)
+ return;
+ //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 );
+
+ //Should check that pages exist ie >=0 && < pageCount
+ flipper.addView(new PageViewer(0), 0, matchParent);
+ for (int i = 0; i < PAGECACHE_PLUSMINUS; i++)
+ flipper.addView(new PageViewer(i+1), i+1, matchParent);
+ for (int i = 0; i < PAGECACHE_PLUSMINUS; i++)
+ flipper.addView(new PageViewer(-1), PAGECACHE_PLUSMINUS + i+1, matchParent);
+
+ ll = (LinearLayout)findViewById( R.id.navigator);
+ inflater = (LayoutInflater) getApplicationContext().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+
+
+
+ for( int i = 0; i < result.intValue() ; i++ ){
+ ThumbnailView thumb = new ThumbnailView( i , (int)(120.0f / Math.sqrt(2) ) , 120 );
+ final int pos = i;
+ thumb.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ Log.d("nav" , Integer.toString( pos ) );
+ openPageWithPrefetching( pos );
+ }
+ });
+ ll.addView ( thumb );
+ }
}
}
@@ -771,14 +845,18 @@ public class DocumentLoader
Log.i(TAG, "componentLoader is" + (componentLoader!=null ? " not" : "") + " null");
+ setContentView( R.layout.document_viewer );
// Load the wanted document
new DocumentLoadTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, "file://" + input);
- setContentView( R.layout.document_viewer );
+ /*
//flipper = new ViewFlipper(this);
flipper = (ViewFlipper)findViewById( R.id.page_flipper );
matchParent = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+ // should have document load task publish pageCount before this happens: Shouldn't try to pre-fetch
+ // non-existant pages && need to know how many navigation thumbnails to render.
+ // Should put these on anothe serial executor?
flipper.addView(new PageViewer(0), 0, matchParent);
for (int i = 0; i < PAGECACHE_PLUSMINUS; i++)
flipper.addView(new PageViewer(i+1), i+1, matchParent);
@@ -788,20 +866,11 @@ public class DocumentLoader
ll = (LinearLayout)findViewById( R.id.navigator);
inflater = (LayoutInflater) getApplicationContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
-
-
-
- //ThumbnailView pv = new ThumbnailView(0);
- /*Bitmap thumbnailBitmap = Bitmap.createBitmap(120, 120, Bitmap.Config.ARGB_8888);
- thumbnailBitmap.copyPixelsFromBuffer(bb);
- ImageView pageImage = (ImageView)findViewById( R.id.thumbnail );
- pageImage.setImageBitmap( thumbnailBitmap );
- */
+
for( int i = 0; i < 2 ; i++ ){
- View thumbnailView = inflater.inflate( R.layout.navigation_grid_item , null );
- ThumbnailView thumb = new ThumbnailView( i );
+ ThumbnailView thumb = new ThumbnailView( i , (int)(120.0f / Math.sqrt(2) ) , 120 );
final int pos = i;
thumb.setOnClickListener(new OnClickListener() {
@@ -809,11 +878,11 @@ public class DocumentLoader
public void onClick(View v) {
// TODO Auto-generated method stub
Log.d("nav" , Integer.toString( pos ) );
- //(PageViewer)flipper.getChildAt( (flipper.getDisplayedChild() + PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE)).display( ( (PageViewer)flipper.getCurrentView() ).currentPageNumber + PAGECACHE_PLUSMINUS);
+
}
});
ll.addView ( thumb );
- }
+ }*/
}
@@ -843,6 +912,26 @@ public class DocumentLoader
return super.onOptionsItemSelected(item);
}
}
+
+ /* if page is more than 2*+- away then no cache over lap
+ * 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);
+ 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);
+ }
+ }
+ for (int i = 0; i < PAGECACHE_PLUSMINUS; i++){
+ if( number + i+1 >= 0 && number + i+1 < pageCount){
+ flipper.addView(new PageViewer( number - (i+1)), PAGECACHE_PLUSMINUS + i+1, matchParent);
+ }
+ }
+ }
}
// vim:set shiftwidth=4 softtabstop=4 expandtab:
commit 797df2912a91ad493f2368c508999d73635c8c35
Author: Iain Billett <iainbillett at gmail.com>
Date: Wed Jun 27 22:56:06 2012 +0100
Some styling of document viewer. Transparent overlayed action bar with hide/show on tap. Navigation overlay with page thumbnails.
diff --git a/android/experimental/LibreOffice4Android/AndroidManifest.xml b/android/experimental/LibreOffice4Android/AndroidManifest.xml
index fcf6210..9386d8c 100644
--- a/android/experimental/LibreOffice4Android/AndroidManifest.xml
+++ b/android/experimental/LibreOffice4Android/AndroidManifest.xml
@@ -15,6 +15,7 @@
<!-- Original Document Loader activity - file Viewer -->
<activity android:name=".android.DocumentLoader"
+ android:theme="@style/DocumentViewer"
android:label="DocumentLoader"
android:configChanges="orientation|keyboardHidden">
<!-- <intent-filter>
diff --git a/android/experimental/LibreOffice4Android/res/layout/document_viewer.xml b/android/experimental/LibreOffice4Android/res/layout/document_viewer.xml
new file mode 100644
index 0000000..2f84be9
--- /dev/null
+++ b/android/experimental/LibreOffice4Android/res/layout/document_viewer.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:id="@+id/document_viewer_root">
+ <ViewFlipper
+ android:id="@+id/page_flipper"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ </ViewFlipper>
+ <HorizontalScrollView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignBottom="@id/page_flipper"
+ android:background="#aa000000">
+ <LinearLayout
+ android:id="@+id/navigator"
+ android:layout_width="wrap_content"
+ android:layout_height="150dp"
+ android:orientation="horizontal">
+ </LinearLayout>
+ </HorizontalScrollView >
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/experimental/LibreOffice4Android/res/layout/navigation_grid_item.xml b/android/experimental/LibreOffice4Android/res/layout/navigation_grid_item.xml
new file mode 100644
index 0000000..75a27b3
--- /dev/null
+++ b/android/experimental/LibreOffice4Android/res/layout/navigation_grid_item.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="150dp"
+ android:layout_height="150dp"
+ android:layout_gravity="center"
+ android:background="#00880000"
+ android:orientation="vertical" >
+ <!-- Can I give all thumbs the same ID? works in grid adapter "getView" -->
+ <ImageView
+ android:src="@drawable/dummy_page"
+ android:id="@+id/thumbnail"
+ android:layout_width="120dp"
+ android:layout_height="120dp"
+ android:layout_margin="15dp"
+ android:layout_gravity="center"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/android/experimental/LibreOffice4Android/res/values/styles.xml b/android/experimental/LibreOffice4Android/res/values/styles.xml
index 5e74240..46edd67 100644
--- a/android/experimental/LibreOffice4Android/res/values/styles.xml
+++ b/android/experimental/LibreOffice4Android/res/values/styles.xml
@@ -6,7 +6,7 @@
<item name="android:actionBarStyle">@style/TransparentDarkActionBar</item>
</style>
<style name="TransparentDarkActionBar" parent="@android:style/Widget.Holo.ActionBar">
- <item name="android:background">#dd000000</item>
+ <item name="android:background">#bb000000</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 9fa07f8..2c839a5 100644
--- a/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java
+++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java
@@ -28,6 +28,7 @@
// "3" into a parameter below.
package org.libreoffice.android;
+import org.libreoffice.R;
import android.app.Activity;
import android.graphics.Bitmap;
@@ -46,6 +47,23 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ViewFlipper;
import android.widget.ViewSwitcher;
+import android.view.MenuItem;
+import android.content.Intent;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.BaseAdapter;
+import android.view.View.OnClickListener;
+// Obsolete?
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.GridView;
+import android.widget.AdapterView;
+
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.LinearLayout.LayoutParams;
+import android.graphics.BitmapFactory;
import com.polites.android.GestureImageView;
@@ -71,6 +89,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import org.libreoffice.android.Bootstrap;
+import org.libreoffice.ui.LibreOfficeUIActivity;
public class DocumentLoader
extends Activity
@@ -102,6 +121,11 @@ public class DocumentLoader
ViewGroup.LayoutParams matchParent;
ViewFlipper flipper;
+
+ Bundle extras;
+
+ LinearLayout ll ;
+ LayoutInflater inflater ;
class GestureListener
extends GestureDetector.SimpleOnGestureListener
@@ -153,6 +177,29 @@ public class DocumentLoader
}
return false;
}
+
+ @Override
+ public boolean onSingleTapUp(MotionEvent event){
+ if( getActionBar().isShowing() ){
+ getActionBar().hide();
+ }else{
+ getActionBar().show();
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onDoubleTap(MotionEvent event){
+ LinearLayout ll = (LinearLayout)findViewById( R.id.navigator);
+ if( ll.isShown() ){
+ ll.setVisibility( View.GONE );
+ }else{
+ ll.setVisibility( View.VISIBLE );
+ }
+ return true;
+ }
+
+
}
class MyXController
@@ -303,6 +350,90 @@ public class DocumentLoader
return null;
}
+
+ ByteBuffer renderPage(int number, int width , int height)
+ {
+ try {
+ // Use dummySmallDevice with no scale of offset just to find out
+ // the paper size of this page.
+
+ PropertyValue renderProps[] = new PropertyValue[3];
+ renderProps[0] = new PropertyValue();
+ renderProps[0].Name = "IsPrinter";
+ renderProps[0].Value = new Boolean(true);
+ renderProps[1] = new PropertyValue();
+ renderProps[1].Name = "RenderDevice";
+ renderProps[1].Value = dummySmallDevice;
+ renderProps[2] = new PropertyValue();
+ renderProps[2].Name = "View";
+ renderProps[2].Value = new MyXController();
+
+ // getRenderer returns a set of properties that include the PageSize
+ long t0 = System.currentTimeMillis();
+ PropertyValue rendererProps[] = renderable.getRenderer(number, doc, renderProps);
+ long t1 = System.currentTimeMillis();
+ Log.i(TAG, "w,h getRenderer took " + ((t1-t0)-timingOverhead) + " ms");
+
+ int pageWidth = 0, pageHeight = 0;
+ for (int i = 0; i < rendererProps.length; i++) {
+ if (rendererProps[i].Name.equals("PageSize")) {
+ pageWidth = ((Size) rendererProps[i].Value).Width;
+ pageHeight = ((Size) rendererProps[i].Value).Height;
+ Log.i(TAG, " w,h PageSize: " + pageWidth + "x" + pageHeight);
+ }
+ }
+
+ // Create a new device with the correct scale and offset
+ ByteBuffer bb = ByteBuffer.allocateDirect(width*height*4);
+ long wrapped_bb = Bootstrap.new_byte_buffer_wrapper(bb);
+
+ XDevice device;
+ if (pageWidth == 0) {
+ // Huh?
+ device = toolkit.createScreenCompatibleDeviceUsingBuffer(width, height, 1, 1, 0, 0, wrapped_bb);
+ } else {
+
+ // Scale so that it fits our device which has a resolution of 96/in (see
+ // SvpSalGraphics::GetResolution()). The page size returned from getRenderer() is in 1/mm * 100.
+
+ int scaleNumerator, scaleDenominator;
+
+ // If the view has a wider aspect ratio than the page, fit
+ // height; otherwise, fit width
+ if ((double) width / height > (double) pageWidth / pageHeight) {
+ scaleNumerator = height;
+ scaleDenominator = pageHeight / 2540 * 96;
+ } else {
+ scaleNumerator = width;
+ scaleDenominator = pageWidth / 2540 * 96;
+ }
+ Log.i(TAG, "w,h Scaling with " + scaleNumerator + "/" + scaleDenominator);
+
+ device = toolkit.createScreenCompatibleDeviceUsingBuffer(width, height,
+ scaleNumerator, scaleDenominator,
+ 0, 0,
+ wrapped_bb);
+ }
+
+ // Update the property that points to the device
+ renderProps[1].Value = device;
+
+ t0 = System.currentTimeMillis();
+ renderable.render(number, doc, renderProps);
+ t1 = System.currentTimeMillis();
+ Log.i(TAG, "w,h Rendering page " + number + " took " + ((t1-t0)-timingOverhead) + " ms");
+
+ Bootstrap.force_full_alpha_bb(bb, 0, width * height * 4);
+
+ return bb;
+ }
+ catch (Exception e) {
+ e.printStackTrace(System.err);
+ finish();
+ }
+
+ return null;
+ }
enum PageState { NONEXISTENT, LOADING, READY };
@@ -384,6 +515,79 @@ public class DocumentLoader
}
}
+ class ThumbnailView
+ extends ViewSwitcher
+ {
+ int currentPageNumber = -1;
+ TextView waitView;
+ View thumbnailView;
+ //PageState state = PageState.NONEXISTENT;
+ Bitmap bm;
+
+ class ThumbLoadTask
+ extends AsyncTask<Integer, Void, Integer>
+ {
+ protected Integer doInBackground(Integer... params)
+ {
+ int number = params[0];
+
+ if (number >= pageCount)
+ return -1;
+
+ //state = PageState.LOADING;
+ ByteBuffer bb = renderPage( number , 120 , 120);
+ bm = Bitmap.createBitmap( 120 , 120 , Bitmap.Config.ARGB_8888);
+ bm.copyPixelsFromBuffer(bb);
+
+ return number;
+ }
+
+ protected void onPostExecute(Integer result)
+ {
+ Log.i(TAG, "onPostExecute: " + result);
+ if (result == -1)
+ return;
+
+ //ImageView imageView = new ImageView(DocumentLoader.this);
+
+ ImageView thumbImage = new ImageView(DocumentLoader.this);//(ImageView)findViewById( R.id.thumbnail );
+ thumbImage.setImageBitmap(bm);
+
+ thumbImage.setScaleY(-1);
+
+ Log.i( TAG, Integer.toString( thumbImage.getWidth() ) );
+ if (getChildCount() == 1)
+ removeViewAt(0);
+ addView(thumbImage, matchParent);
+ showNext();
+ //state = PageState.READY;
+ }
+ }
+
+ void display(int number)
+ {
+ Log.i(TAG, "PageViewer display(" + number + ")");
+ if (number >= 0)
+ waitView.setText("Page " + (number+1) + ", wait...");
+ //state = PageState.NONEXISTENT;
+
+ if (number >= 0) {
+ new ThumbLoadTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, number);
+ }
+ }
+
+ ThumbnailView(int number)
+ {
+ super(DocumentLoader.this);
+ waitView = new TextView( DocumentLoader.this );
+ thumbnailView = inflater.inflate( R.layout.navigation_grid_item , null);
+
+ display(number);
+
+
+ }
+ }
+
class DocumentLoadTask
extends AsyncTask<String, Void, Void>
{
@@ -510,6 +714,8 @@ public class DocumentLoader
{
super.onCreate(savedInstanceState);
+ extras = getIntent().getExtras();
+
gestureDetector = new GestureDetector(this, new GestureListener());
try {
@@ -568,8 +774,9 @@ public class DocumentLoader
// Load the wanted document
new DocumentLoadTask().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, "file://" + input);
- flipper = new ViewFlipper(this);
-
+ setContentView( R.layout.document_viewer );
+ //flipper = new ViewFlipper(this);
+ flipper = (ViewFlipper)findViewById( R.id.page_flipper );
matchParent = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
flipper.addView(new PageViewer(0), 0, matchParent);
@@ -577,8 +784,38 @@ public class DocumentLoader
flipper.addView(new PageViewer(i+1), i+1, matchParent);
for (int i = 0; i < PAGECACHE_PLUSMINUS; i++)
flipper.addView(new PageViewer(-1), PAGECACHE_PLUSMINUS + i+1, matchParent);
-
- setContentView(flipper);
+
+ ll = (LinearLayout)findViewById( R.id.navigator);
+ inflater = (LayoutInflater) getApplicationContext().getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+
+
+
+ //ThumbnailView pv = new ThumbnailView(0);
+ /*Bitmap thumbnailBitmap = Bitmap.createBitmap(120, 120, Bitmap.Config.ARGB_8888);
+ thumbnailBitmap.copyPixelsFromBuffer(bb);
+ ImageView pageImage = (ImageView)findViewById( R.id.thumbnail );
+ pageImage.setImageBitmap( thumbnailBitmap );
+ */
+
+
+ for( int i = 0; i < 2 ; i++ ){
+ View thumbnailView = inflater.inflate( R.layout.navigation_grid_item , null );
+ ThumbnailView thumb = new ThumbnailView( i );
+ final int pos = i;
+ thumb.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ Log.d("nav" , Integer.toString( pos ) );
+ //(PageViewer)flipper.getChildAt( (flipper.getDisplayedChild() + PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE)).display( ( (PageViewer)flipper.getCurrentView() ).currentPageNumber + PAGECACHE_PLUSMINUS);
+ }
+ });
+ ll.addView ( thumb );
+ }
+
+
}
catch (Exception e) {
e.printStackTrace(System.err);
@@ -591,6 +828,21 @@ public class DocumentLoader
{
return gestureDetector.onTouchEvent(event);
}
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ // app icon in action bar clicked; go home
+ Intent intent = new Intent(this, LibreOfficeUIActivity.class);
+ intent.putExtras( extras );
+ //intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(intent);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
}
// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
index 420b485..7721d2b 100644
--- a/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -169,6 +169,9 @@ public class LibreOfficeUIActivity extends Activity implements OnNavigationListe
*/
Intent i = new Intent( this , DocumentLoader.class );
i.putExtra("input",new File( currentDirectory , file).getAbsolutePath() );
+ i.putExtra( CURRENT_DIRECTORY_KEY , currentDirectory.getAbsolutePath() );
+ i.putExtra( FILTER_MODE_KEY , filterMode );
+ i.putExtra( EXPLORER_VIEW_TYPE_KEY , viewMode );
startActivity( i );
}
More information about the Libreoffice-commits
mailing list