summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/experimental/LOAndroid3/res/menu/context_menu.xml2
-rw-r--r--android/experimental/LOAndroid3/res/values/strings.xml2
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java18
3 files changed, 22 insertions, 0 deletions
diff --git a/android/experimental/LOAndroid3/res/menu/context_menu.xml b/android/experimental/LOAndroid3/res/menu/context_menu.xml
index 3951971b4b2c..43824875d867 100644
--- a/android/experimental/LOAndroid3/res/menu/context_menu.xml
+++ b/android/experimental/LOAndroid3/res/menu/context_menu.xml
@@ -2,4 +2,6 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/context_menu_open"
android:title="@string/open"/>
+ <item android:id="@+id/context_menu_share"
+ android:title="@string/share"/>
</menu>
diff --git a/android/experimental/LOAndroid3/res/values/strings.xml b/android/experimental/LOAndroid3/res/values/strings.xml
index bfaa7abee839..473616a9d9e5 100644
--- a/android/experimental/LOAndroid3/res/values/strings.xml
+++ b/android/experimental/LOAndroid3/res/values/strings.xml
@@ -26,5 +26,7 @@
<string name="action_about">About</string>
<string name="action_parts">Parts</string>
<string name="open">Open</string>
+ <string name="share">Share</string>
+ <string name="share_via">Share via</string>
</resources>
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 df7d6fa78d53..61f8450842c8 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/ui/LibreOfficeUIActivity.java
@@ -46,6 +46,7 @@ import android.view.View;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
+import android.webkit.MimeTypeMap;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
@@ -172,6 +173,9 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
case R.id.context_menu_open:
open(info.position);
return true;
+ case R.id.context_menu_share:
+ share(info.position);
+ return true;
default:
return super.onContextItemSelected(item);
}
@@ -221,6 +225,20 @@ public class LibreOfficeUIActivity extends LOAbout implements ActionBar.OnNaviga
}
}
+ private void share(int position) {
+ File file = filePaths[position];
+ Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
+ Uri uri = Uri.fromFile(file);
+ String extension = MimeTypeMap.getFileExtensionFromUrl(uri.toString());
+ sharingIntent.setType(MimeTypeMap.getSingleton()
+ .getMimeTypeFromExtension(extension));
+ sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, uri);
+ sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
+ file.getName());
+ startActivity(Intent.createChooser(sharingIntent,
+ getString(R.string.share_via)));
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();