Kaydet (Commit) 45885587 authored tarafından Miklos Vajna's avatar Miklos Vajna

android: fix loading documents from doc browser's about dialog

- LibreOfficeUIActivity needs to start a new activity
- LibreOfficeMainActivity is enough to send a new event

Change-Id: I3a7532a07b37a16bdb49f81072132aa57c2c52e8
üst 6487cb9c
......@@ -3,6 +3,7 @@ package org.libreoffice;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.ComponentName;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.DrawerLayout;
......@@ -16,14 +17,37 @@ import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.content.Intent;
import android.net.Uri;
import java.util.ArrayList;
import java.util.List;
import java.io.File;
public abstract class LOAbout extends Activity {
private static final String DEFAULT_DOC_PATH = "/assets/example.odt";
private boolean mNewActivity;
public LOAbout(boolean newActivity) {
super();
mNewActivity = newActivity;
}
private void loadFromAbout(String input) {
if (mNewActivity) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.fromFile(new File(input)));
i.setComponent(new ComponentName(
"org.libreoffice",
"org.libreoffice.LibreOfficeMainActivity"));
startActivity(i);
} else {
LOKitShell.sendEvent(LOEventFactory.close());
LOKitShell.sendEvent(LOEventFactory.load(input));
}
}
protected void showAbout() {
// Inflate the about message contents
View messageView = getLayoutInflater().inflate(R.layout.about, null, false);
......@@ -42,8 +66,7 @@ public abstract class LOAbout extends Activity {
builder.setNegativeButton(R.string.about_license, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
LOKitShell.sendEvent(LOEventFactory.close());
LOKitShell.sendEvent(LOEventFactory.load("/assets/license.txt"));
loadFromAbout("/assets/license.txt");
dialog.dismiss();
}
});
......@@ -51,8 +74,7 @@ public abstract class LOAbout extends Activity {
builder.setPositiveButton(R.string.about_notice, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
LOKitShell.sendEvent(LOEventFactory.close());
LOKitShell.sendEvent(LOEventFactory.load("/assets/notice.txt"));
loadFromAbout("/assets/notice.txt");
dialog.dismiss();
}
});
......@@ -60,8 +82,7 @@ public abstract class LOAbout extends Activity {
builder.setNeutralButton(R.string.about_moreinfo, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
LOKitShell.sendEvent(LOEventFactory.close());
LOKitShell.sendEvent(LOEventFactory.load(DEFAULT_DOC_PATH));
loadFromAbout(DEFAULT_DOC_PATH);
dialog.dismiss();
}
});
......
......@@ -43,6 +43,10 @@ public class LibreOfficeMainActivity extends LOAbout {
private DocumentPartViewListAdapter mDocumentPartViewListAdapter;
private String mInputFile;
public LibreOfficeMainActivity() {
super(/*newActivity=*/false);
}
public static GeckoLayerClient getLayerClient() {
return mLayerClient;
}
......
......@@ -125,6 +125,10 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
int currentPage;
XRenderable renderable;
public LibreOfficeUIActivity() {
super(/*newActivity=*/true);
}
@Override
public void onCreate(Bundle savedInstanceState) {
......
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