diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2014-12-25 18:03:20 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2014-12-25 18:13:12 +0900 |
commit | f69f3bfd9d8019365023eace8c1f1abdf31e1ef9 (patch) | |
tree | bc9d8e01bc4f95e408e711936063df8abe65a796 /android | |
parent | 6d6da4c94b7ca434deb5ee569c18fa3e3dfe6070 (diff) |
android: Tweak initial zoom of documents in different situations
- In case of Writer document always show document by full width.
- Otherwise show the whole document on the screen even when the
orientation is portrait or landscape.
Change-Id: Ia6704432c850a5487aee1693ed12e039ae6ef0cb
Diffstat (limited to 'android')
5 files changed, 31 insertions, 4 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java index 8099c7397384..8fc75b2e394d 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java @@ -2,6 +2,7 @@ package org.libreoffice; import android.graphics.Bitmap; import android.graphics.PointF; +import android.graphics.RectF; import android.util.Log; import org.mozilla.gecko.gfx.CairoImage; @@ -45,7 +46,16 @@ public class LOKitThread extends Thread { mLayerClient.setPageRect(0, 0, mTileProvider.getPageWidth(), mTileProvider.getPageHeight()); mViewportMetrics = mLayerClient.getViewportMetrics(); mLayerClient.setViewportMetrics(mViewportMetrics); - mLayerClient.zoomToPageWidth(mTileProvider.getPageWidth()); + + if (mTileProvider.isTextDocument()) { + float centerY = mViewportMetrics.getCssViewport().centerY(); + mLayerClient.zoomTo(new RectF (0, centerY, mTileProvider.getPageWidth(), centerY)); + } else if (mViewportMetrics.getViewport().width() < mViewportMetrics.getViewport().height()) { + mLayerClient.zoomTo(mTileProvider.getPageWidth(), 0); + } else { + mLayerClient.zoomTo(0, mTileProvider.getPageHeight()); + } + mLayerClient.forceRedraw(); } diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java index bda810d15277..513d13d5faa1 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java @@ -247,6 +247,11 @@ public class LOKitTileProvider implements TileProvider { } @Override + public boolean isTextDocument() { + return mDocument.getDocumentType() == Document.DOCTYPE_TEXT; + } + + @Override protected void finalize() throws Throwable { close(); super.finalize(); diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java index b8d7a3c305a0..79fef43a491d 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java @@ -74,6 +74,11 @@ public class MockTileProvider implements TileProvider { } @Override + public boolean isTextDocument() { + return true; + } + + @Override public void changePart(int partIndex) { } diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java index 7142bc31310c..988e53a0fcdf 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java @@ -22,4 +22,6 @@ public interface TileProvider { Bitmap thumbnail(int size); void close(); + + boolean isTextDocument(); } diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java index 934d19a7aa71..09120ec2c5e6 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java @@ -460,12 +460,17 @@ public class GeckoLayerClient implements PanZoomTarget, LayerView.Listener { return mContext; } - public void zoomToPageWidth(int pageWidth) { - if (mPanZoomController instanceof JavaPanZoomController) { - ((JavaPanZoomController) mPanZoomController).animatedZoomTo(new RectF(0, 0, pageWidth, 0)); + + public void zoomTo(RectF rect) { + if (mPanZoomController instanceof JavaPanZoomController) { + ((JavaPanZoomController) mPanZoomController).animatedZoomTo(rect); } } + public void zoomTo(float pageWidth, float pageHeight) { + zoomTo(new RectF(0, 0, pageWidth, pageHeight)); + } + private class AdjustRunnable implements Runnable { public void run() { mPendingViewportAdjust = false; |