diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-12-17 10:09:12 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-12-17 10:45:00 +0100 |
commit | 4588558789a2bb987d484183535d64c31e30a87b (patch) | |
tree | 05f2650fbb6ae07b0aba8fff5b8230cde6b5bee4 /android/experimental | |
parent | 6487cb9c811e43d4e08c58d3063737bf6b975def (diff) |
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
Diffstat (limited to 'android/experimental')
3 files changed, 35 insertions, 6 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java index 01d2cb234ed2..2b3bf31633f2 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java @@ -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(); } }); diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java index cb30f4dd6b31..062f44c4fc46 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java @@ -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; } diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java index c97e6e91f4b1..764cdd0c627c 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java @@ -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) { |