[Libreoffice-commits] core.git: 3 commits - android/experimental
Miklos Vajna
vmiklos at collabora.co.uk
Wed Dec 17 01:46:00 PST 2014
android/experimental/LOAndroid3/res/menu/view_menu.xml | 3
android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java | 95 ++++++++++
android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java | 52 -----
android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java | 10 -
4 files changed, 112 insertions(+), 48 deletions(-)
New commits:
commit 4588558789a2bb987d484183535d64c31e30a87b
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Dec 17 10:09:12 2014 +0100
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
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
index 01d2cb2..2b3bf31 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 cb30f4d..062f44c 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 c97e6e9..764cdd0 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) {
commit 6487cb9c811e43d4e08c58d3063737bf6b975def
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Dec 17 09:51:36 2014 +0100
android: show about menu entry in the browser as well
Change-Id: I74a38281dc80790f7593042c205c31a6fc2d2cdc
diff --git a/android/experimental/LOAndroid3/res/menu/view_menu.xml b/android/experimental/LOAndroid3/res/menu/view_menu.xml
index dca660a..f316f5a 100644
--- a/android/experimental/LOAndroid3/res/menu/view_menu.xml
+++ b/android/experimental/LOAndroid3/res/menu/view_menu.xml
@@ -11,4 +11,7 @@
android:title="@string/menu_sort_az"/>
<item android:id="@+id/menu_sort_modified"
android:title="@string/menu_sort_modified"/>
+ <item android:id="@+id/action_about"
+ android:title="@string/action_about"
+ android:orderInCategory="100"/>
</menu>
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 0920ab0..c97e6e9 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -10,6 +10,7 @@
package org.libreoffice.ui;
import org.libreoffice.R;
+import org.libreoffice.LOAbout;
import org.libreoffice.android.Bootstrap;
import java.io.File;
@@ -84,7 +85,7 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.ByteOrder;
-public class LibreOfficeUIActivity extends Activity implements ActionBar.OnNavigationListener {
+public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNavigationListener {
private String tag = "file_manager";
private SharedPreferences prefs;
private File homeDirectory;
@@ -275,6 +276,9 @@ public class LibreOfficeUIActivity extends Activity implements ActionBar.OnNavig
case R.id.menu_sort_modified:
sortFiles(item);
break;
+ case R.id.action_about:
+ showAbout();
+ return true;
default:
return super.onOptionsItemSelected(item);
}
commit 6d9b7738b9007e60ab2992065b7a9da7625adcae
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Dec 17 09:35:51 2014 +0100
android: extract LOAbout from LibreOfficeMainActivity
Change-Id: Ied6a9a64041de94766b307c7ca64eba7edeab64c
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
new file mode 100644
index 0000000..01d2cb2
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOAbout.java
@@ -0,0 +1,74 @@
+package org.libreoffice;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.widget.DrawerLayout;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListView;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class LOAbout extends Activity {
+
+ private static final String DEFAULT_DOC_PATH = "/assets/example.odt";
+
+ protected void showAbout() {
+ // Inflate the about message contents
+ View messageView = getLayoutInflater().inflate(R.layout.about, null, false);
+
+ // When linking text, force to always use default color. This works
+ // around a pressed color state bug.
+ TextView textView = (TextView) messageView.findViewById(R.id.about_credits);
+ int defaultColor = textView.getTextColors().getDefaultColor();
+ textView.setTextColor(defaultColor);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setIcon(R.drawable.lo_icon);
+ builder.setTitle(R.string.app_name);
+ builder.setView(messageView);
+
+ 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"));
+ dialog.dismiss();
+ }
+ });
+
+ 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"));
+ dialog.dismiss();
+ }
+ });
+
+ 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));
+ dialog.dismiss();
+ }
+ });
+
+ AlertDialog dialog = builder.create();
+ dialog.show();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index ff7bb43..cb30f4d 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -24,7 +24,7 @@ import org.mozilla.gecko.gfx.LayerView;
import java.util.ArrayList;
import java.util.List;
-public class LibreOfficeMainActivity extends Activity {
+public class LibreOfficeMainActivity extends LOAbout {
private static final String LOGTAG = "LibreOfficeMainActivity";
private static final String DEFAULT_DOC_PATH = "/assets/example.odt";
@@ -185,52 +185,6 @@ public class LibreOfficeMainActivity extends Activity {
return mDocumentPartViewListAdapter;
}
- private void showAbout() {
- // Inflate the about message contents
- View messageView = getLayoutInflater().inflate(R.layout.about, null, false);
-
- // When linking text, force to always use default color. This works
- // around a pressed color state bug.
- TextView textView = (TextView) messageView.findViewById(R.id.about_credits);
- int defaultColor = textView.getTextColors().getDefaultColor();
- textView.setTextColor(defaultColor);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setIcon(R.drawable.lo_icon);
- builder.setTitle(R.string.app_name);
- builder.setView(messageView);
-
- 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"));
- dialog.dismiss();
- }
- });
-
- 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"));
- dialog.dismiss();
- }
- });
-
- 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));
- dialog.dismiss();
- }
- });
-
- AlertDialog dialog = builder.create();
- dialog.show();
- }
-
public void showProgressSpinner() {
findViewById(R.id.loadingPanel).setVisibility(View.VISIBLE);
}
More information about the Libreoffice-commits
mailing list