aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-12-17 07:00:42 +0100
committeriNPUTmice <daniel@gultsch.de>2014-12-17 07:00:42 +0100
commitfd4cf499a2edd517b356d421c23b15c2b5173dde (patch)
tree2d6f4255c8a1c39f0f1fa5a2fb33102326770fc3 /src
parent3f6638cb649b650fbf0217d8a060bf149a9b886f (diff)
parent6659339effb3dc005792714e694ea08cdfe9bd97 (diff)
Merge branch 'issue756' of https://github.com/SamWhited/Conversations into SamWhited-issue756
Diffstat (limited to '')
-rw-r--r--src/main/AndroidManifest.xml2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java60
2 files changed, 37 insertions, 25 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 937b6813..8fdfa85b 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -114,7 +114,7 @@
<category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="image/*" />
+ <data android:mimeType="*/*" />
</intent-filter>
</activity>
<activity
diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java
index 609dc280..fffcfaca 100644
--- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java
@@ -1,17 +1,5 @@
package eu.siacs.conversations.ui;
-import java.util.ArrayList;
-import java.util.List;
-
-import eu.siacs.conversations.Config;
-import eu.siacs.conversations.R;
-import eu.siacs.conversations.entities.Account;
-import eu.siacs.conversations.entities.Conversation;
-import eu.siacs.conversations.entities.Message;
-import eu.siacs.conversations.ui.adapter.ConversationAdapter;
-import eu.siacs.conversations.xmpp.jid.InvalidJidException;
-import eu.siacs.conversations.xmpp.jid.Jid;
-
import android.app.PendingIntent;
import android.content.Intent;
import android.net.Uri;
@@ -25,6 +13,19 @@ import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+
+import eu.siacs.conversations.Config;
+import eu.siacs.conversations.R;
+import eu.siacs.conversations.entities.Account;
+import eu.siacs.conversations.entities.Conversation;
+import eu.siacs.conversations.entities.Message;
+import eu.siacs.conversations.ui.adapter.ConversationAdapter;
+import eu.siacs.conversations.xmpp.jid.InvalidJidException;
+import eu.siacs.conversations.xmpp.jid.Jid;
+
public class ShareWithActivity extends XmppActivity {
private class Share {
@@ -38,9 +39,9 @@ public class ShareWithActivity extends XmppActivity {
private static final int REQUEST_START_NEW_CONVERSATION = 0x0501;
private ListView mListView;
- private List<Conversation> mConversations = new ArrayList<Conversation>();
+ private List<Conversation> mConversations = new ArrayList<>();
- private UiCallback<Message> attachImageCallback = new UiCallback<Message>() {
+ private UiCallback<Message> attachFileCallback = new UiCallback<Message>() {
@Override
public void userInputRequried(PendingIntent pi, Message object) {
@@ -78,11 +79,12 @@ public class ShareWithActivity extends XmppActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
-
super.onCreate(savedInstanceState);
- getActionBar().setDisplayHomeAsUpEnabled(false);
- getActionBar().setHomeButtonEnabled(false);
+ if (getActionBar() != null) {
+ getActionBar().setDisplayHomeAsUpEnabled(false);
+ getActionBar().setHomeButtonEnabled(false);
+ }
setContentView(R.layout.share_with);
setTitle(getString(R.string.title_activity_sharewith));
@@ -128,7 +130,7 @@ public class ShareWithActivity extends XmppActivity {
@Override
public void onStart() {
if (getIntent().getType() != null
- && getIntent().getType().startsWith("image/")) {
+ && !getIntent().getType().startsWith("text/")) {
this.share.uri = (Uri) getIntent().getParcelableExtra(
Intent.EXTRA_STREAM);
} else {
@@ -177,12 +179,22 @@ public class ShareWithActivity extends XmppActivity {
selectPresence(conversation, new OnPresenceSelected() {
@Override
public void onPresenceSelected() {
- Toast.makeText(getApplicationContext(),
- getText(R.string.preparing_image),
- Toast.LENGTH_LONG).show();
- ShareWithActivity.this.xmppConnectionService
+ final String type = URLConnection.guessContentTypeFromName(share.uri.getPath());
+ if (type != null && type.startsWith("image/")) {
+ Toast.makeText(getApplicationContext(),
+ getText(R.string.preparing_image),
+ Toast.LENGTH_LONG).show();
+ ShareWithActivity.this.xmppConnectionService
.attachImageToConversation(conversation, share.uri,
- attachImageCallback);
+ attachFileCallback);
+ } else {
+ Toast.makeText(getApplicationContext(),
+ getText(R.string.preparing_file),
+ Toast.LENGTH_LONG).show();
+ ShareWithActivity.this.xmppConnectionService
+ .attachFileToConversation(conversation, share.uri,
+ attachFileCallback);
+ }
switchToConversation(conversation, null, true);
finish();
}
@@ -195,4 +207,4 @@ public class ShareWithActivity extends XmppActivity {
}
-} \ No newline at end of file
+}