[Libreoffice-commits] core.git: 2 commits - android/experimental
Jacobo Aragunde Pérez
jaragunde at igalia.com
Wed Jul 16 01:22:27 PDT 2014
android/experimental/LOAndroid3/AndroidManifest.xml | 7 ++
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java | 26 +++++-----
android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java | 8 ++-
android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java | 12 ++++
android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java | 5 +
android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java | 2
6 files changed, 46 insertions(+), 14 deletions(-)
New commits:
commit 9a6cf48618fcf586cd6c1e390cd49bc1f5d4631d
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date: Tue Jul 15 20:43:22 2014 +0200
LOAndroid3: Prevent crash when opening a nonexistent file
Change-Id: Ic0fbe955dfdb8f044d7bf0f45215a632a111eae2
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index 2db5c0d..456f7b7 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -86,22 +86,24 @@ public class LOKitThread extends Thread {
return true;
}
- private void initialize() {
+ private boolean initialize() {
mApplication = LibreOfficeMainActivity.mAppContext;
mTileProvider = new LOKitTileProvider(mApplication.getLayerController(), mInputFile);
+ return mTileProvider.isReady();
}
public void run() {
- initialize();
- try {
- boolean drawn = false;
- while (true) {
- if (!mEvents.isEmpty()) {
- processEvent(mEvents.poll());
+ if (initialize()) {
+ try {
+ boolean drawn = false;
+ while (true) {
+ if (!mEvents.isEmpty()) {
+ processEvent(mEvents.poll());
+ }
+ Thread.sleep(100L);
}
- Thread.sleep(100L);
+ } catch (InterruptedException ex) {
}
- } catch (InterruptedException ex) {
}
}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index fd1979b..f5b44f7 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -56,6 +56,11 @@ public class LOKitTileProvider implements TileProvider {
return (int) twipToPixel(mDocument.getDocumentHeight(), mDPI);
}
+ @Override
+ public boolean isReady() {
+ return mDocument != null;
+ }
+
public SubTile createTile(int x, int y) {
ByteBuffer buffer = ByteBuffer.allocateDirect(TILE_SIZE * TILE_SIZE * 4);
Bitmap bitmap = Bitmap.createBitmap(TILE_SIZE, TILE_SIZE, Bitmap.Config.ARGB_8888);
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
index 9dd39e4..d3b8664 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
@@ -26,6 +26,11 @@ public class MockTileProvider implements TileProvider {
}
@Override
+ public boolean isReady() {
+ return true;
+ }
+
+ @Override
public SubTile createTile(int x, int y) {
int tiles = (getPageWidth() / TILE_SIZE) + 1;
int tileNumber = (y / TILE_SIZE) * tiles + (x / TILE_SIZE);
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
index 296bf03..6743e0c 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java
@@ -7,5 +7,7 @@ public interface TileProvider {
int getPageWidth();
int getPageHeight();
+ boolean isReady();
+
SubTile createTile(int x, int y);
}
commit 0a6d7d6ef2cd1032ffad06210f843c9240d4b944
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date: Tue Jul 15 20:25:05 2014 +0200
LOAndroid3: Open any text document via intents
Change-Id: I06ed104e4f26191b1ca1eb9c34aa54e3b0422500
diff --git a/android/experimental/LOAndroid3/AndroidManifest.xml b/android/experimental/LOAndroid3/AndroidManifest.xml
index d456ca6..ab2db55 100644
--- a/android/experimental/LOAndroid3/AndroidManifest.xml
+++ b/android/experimental/LOAndroid3/AndroidManifest.xml
@@ -25,6 +25,13 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.intent.action.EDIT" />
+ <action android:name="android.intent.action.PICK" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:mimeType="application/vnd.oasis.opendocument.text" />
+ </intent-filter>
</activity>
</application>
</manifest>
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index 4744cf4..2db5c0d 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -19,8 +19,10 @@ public class LOKitThread extends Thread {
private LibreOfficeMainActivity mApplication;
private TileProvider mTileProvider;
private ViewportMetrics mViewportMetrics;
+ private String mInputFile;
- LOKitThread() {
+ LOKitThread(String inputFile) {
+ mInputFile = inputFile;
}
private boolean draw() throws InterruptedException {
@@ -86,7 +88,7 @@ public class LOKitThread extends Thread {
private void initialize() {
mApplication = LibreOfficeMainActivity.mAppContext;
- mTileProvider = new LOKitTileProvider(mApplication.getLayerController());
+ mTileProvider = new LOKitTileProvider(mApplication.getLayerController(), mInputFile);
}
public void run() {
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 3459e2b..fd1979b 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -33,14 +33,13 @@ public class LOKitTileProvider implements TileProvider {
return (input / dpi) * 1440.0;
}
- public LOKitTileProvider(LayerController layerController) {
+ public LOKitTileProvider(LayerController layerController, String input) {
mLayerController = layerController;
mDPI = (double) LOKitShell.getDpi();
LibreOfficeKit.putenv("SAL_LOG=+WARN+INFO-INFO.legacy.osl-INFO.i18nlangtag");
LibreOfficeKit.init(LibreOfficeMainActivity.mAppContext);
mOffice = new Office(LibreOfficeKit.getLibreOfficeKitHandle());
- String input = "/assets/test1.odt";
mDocument = mOffice.documentLoad(input);
mTileWidth = pixelToTwip(TILE_SIZE, mDPI);
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 1d267d9..a9d17aa 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -1,6 +1,7 @@
package org.libreoffice;
import android.app.Activity;
+import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.DisplayMetrics;
@@ -16,6 +17,7 @@ import org.mozilla.gecko.gfx.LayerController;
public class LibreOfficeMainActivity extends Activity {
private static final String LOGTAG = "LibreOfficeMainActivity";
+ private static final String DEFAULT_DOC_PATH = "/assets/test1.odt";
private LinearLayout mMainLayout;
private RelativeLayout mGeckoLayout;
@@ -61,6 +63,14 @@ public class LibreOfficeMainActivity extends Activity {
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
+ String inputFile = new String();
+ if (getIntent().getData() != null) {
+ inputFile = getIntent().getData().getEncodedPath();
+ }
+ else {
+ inputFile = DEFAULT_DOC_PATH;
+ }
+
setContentView(R.layout.activity_main);
// setup gecko layout
@@ -78,7 +88,7 @@ public class LibreOfficeMainActivity extends Activity {
mGeckoLayout.addView(mLayerController.getView(), 0);
}
- sLOKitThread = new LOKitThread();
+ sLOKitThread = new LOKitThread(inputFile);
sLOKitThread.start();
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - UI almost up");
More information about the Libreoffice-commits
mailing list