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