Kaydet (Commit) 0a6d7d6e authored tarafından Jacobo Aragunde Pérez's avatar Jacobo Aragunde Pérez

LOAndroid3: Open any text document via intents

Change-Id: I06ed104e4f26191b1ca1eb9c34aa54e3b0422500
üst 133d6d8d
......@@ -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>
......@@ -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() {
......
......@@ -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);
......
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");
......
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