mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-15 13:35:04 -05:00
parent
e2f50ab855
commit
6659339eff
@ -114,7 +114,7 @@
|
|||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
|
||||||
<data android:mimeType="image/*" />
|
<data android:mimeType="*/*" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
|
@ -1,17 +1,5 @@
|
|||||||
package eu.siacs.conversations.ui;
|
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.app.PendingIntent;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -25,6 +13,19 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
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 {
|
public class ShareWithActivity extends XmppActivity {
|
||||||
|
|
||||||
private class Share {
|
private class Share {
|
||||||
@ -38,9 +39,9 @@ public class ShareWithActivity extends XmppActivity {
|
|||||||
|
|
||||||
private static final int REQUEST_START_NEW_CONVERSATION = 0x0501;
|
private static final int REQUEST_START_NEW_CONVERSATION = 0x0501;
|
||||||
private ListView mListView;
|
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
|
@Override
|
||||||
public void userInputRequried(PendingIntent pi, Message object) {
|
public void userInputRequried(PendingIntent pi, Message object) {
|
||||||
@ -78,11 +79,12 @@ public class ShareWithActivity extends XmppActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
if (getActionBar() != null) {
|
||||||
getActionBar().setDisplayHomeAsUpEnabled(false);
|
getActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
getActionBar().setHomeButtonEnabled(false);
|
getActionBar().setHomeButtonEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
setContentView(R.layout.share_with);
|
setContentView(R.layout.share_with);
|
||||||
setTitle(getString(R.string.title_activity_sharewith));
|
setTitle(getString(R.string.title_activity_sharewith));
|
||||||
@ -128,7 +130,7 @@ public class ShareWithActivity extends XmppActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
if (getIntent().getType() != null
|
if (getIntent().getType() != null
|
||||||
&& getIntent().getType().startsWith("image/")) {
|
&& !getIntent().getType().startsWith("text/")) {
|
||||||
this.share.uri = (Uri) getIntent().getParcelableExtra(
|
this.share.uri = (Uri) getIntent().getParcelableExtra(
|
||||||
Intent.EXTRA_STREAM);
|
Intent.EXTRA_STREAM);
|
||||||
} else {
|
} else {
|
||||||
@ -177,12 +179,22 @@ public class ShareWithActivity extends XmppActivity {
|
|||||||
selectPresence(conversation, new OnPresenceSelected() {
|
selectPresence(conversation, new OnPresenceSelected() {
|
||||||
@Override
|
@Override
|
||||||
public void onPresenceSelected() {
|
public void onPresenceSelected() {
|
||||||
|
final String type = URLConnection.guessContentTypeFromName(share.uri.getPath());
|
||||||
|
if (type != null && type.startsWith("image/")) {
|
||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
getText(R.string.preparing_image),
|
getText(R.string.preparing_image),
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
ShareWithActivity.this.xmppConnectionService
|
ShareWithActivity.this.xmppConnectionService
|
||||||
.attachImageToConversation(conversation, share.uri,
|
.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);
|
switchToConversation(conversation, null, true);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user