mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 20:52:21 -05:00
fixed share with activity to account for http file upload
This commit is contained in:
parent
e4d1bd415d
commit
c745fbb562
@ -1046,13 +1046,14 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||||||
populateWithOrderedConversations(list, true);
|
populateWithOrderedConversations(list, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateWithOrderedConversations(final List<Conversation> list, boolean includeConferences) {
|
public void populateWithOrderedConversations(final List<Conversation> list, boolean includeNoFileUpload) {
|
||||||
list.clear();
|
list.clear();
|
||||||
if (includeConferences) {
|
if (includeNoFileUpload) {
|
||||||
list.addAll(getConversations());
|
list.addAll(getConversations());
|
||||||
} else {
|
} else {
|
||||||
for (Conversation conversation : getConversations()) {
|
for (Conversation conversation : getConversations()) {
|
||||||
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
if (conversation.getMode() == Conversation.MODE_SINGLE
|
||||||
|
|| conversation.getAccount().httpUploadAvailable()) {
|
||||||
list.add(conversation);
|
list.add(conversation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import android.app.PendingIntent;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -13,10 +12,7 @@ import android.widget.AdapterView.OnItemClickListener;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.nio.charset.UnsupportedCharsetException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -66,18 +62,17 @@ public class ShareWithActivity extends XmppActivity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode,
|
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
|
||||||
final Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == REQUEST_START_NEW_CONVERSATION
|
if (requestCode == REQUEST_START_NEW_CONVERSATION
|
||||||
&& resultCode == RESULT_OK) {
|
&& resultCode == RESULT_OK) {
|
||||||
share.contact = data.getStringExtra("contact");
|
share.contact = data.getStringExtra("contact");
|
||||||
share.account = data.getStringExtra("account");
|
share.account = data.getStringExtra("account");
|
||||||
Log.d(Config.LOGTAG, "contact: " + share.contact + " account:"
|
|
||||||
+ share.account);
|
|
||||||
}
|
}
|
||||||
if (xmppConnectionServiceBound && share != null
|
if (xmppConnectionServiceBound
|
||||||
&& share.contact != null && share.account != null) {
|
&& share != null
|
||||||
|
&& share.contact != null
|
||||||
|
&& share.account != null) {
|
||||||
share();
|
share();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,14 +96,9 @@ public class ShareWithActivity extends XmppActivity {
|
|||||||
mListView.setOnItemClickListener(new OnItemClickListener() {
|
mListView.setOnItemClickListener(new OnItemClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> arg0, View arg1,
|
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
|
||||||
int position, long arg3) {
|
|
||||||
Conversation conversation = mConversations.get(position);
|
|
||||||
if (conversation.getMode() == Conversation.MODE_SINGLE
|
|
||||||
|| share.uris.size() == 0) {
|
|
||||||
share(mConversations.get(position));
|
share(mConversations.get(position));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.share = new Share();
|
this.share = new Share();
|
||||||
@ -124,8 +114,7 @@ public class ShareWithActivity extends XmppActivity {
|
|||||||
public boolean onOptionsItemSelected(final MenuItem item) {
|
public boolean onOptionsItemSelected(final MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_add:
|
case R.id.action_add:
|
||||||
final Intent intent = new Intent(getApplicationContext(),
|
final Intent intent = new Intent(getApplicationContext(), ChooseContactActivity.class);
|
||||||
ChooseContactActivity.class);
|
|
||||||
startActivityForResult(intent, REQUEST_START_NEW_CONVERSATION);
|
startActivityForResult(intent, REQUEST_START_NEW_CONVERSATION);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -157,7 +146,7 @@ public class ShareWithActivity extends XmppActivity {
|
|||||||
this.share.uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
|
this.share.uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
|
||||||
}
|
}
|
||||||
if (xmppConnectionServiceBound) {
|
if (xmppConnectionServiceBound) {
|
||||||
xmppConnectionService.populateWithOrderedConversations(mConversations, this.share.image);
|
xmppConnectionService.populateWithOrderedConversations(mConversations, this.share.uris.size() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -204,7 +193,7 @@ public class ShareWithActivity extends XmppActivity {
|
|||||||
|
|
||||||
private void share(final Conversation conversation) {
|
private void share(final Conversation conversation) {
|
||||||
if (share.uris.size() != 0) {
|
if (share.uris.size() != 0) {
|
||||||
selectPresence(conversation, new OnPresenceSelected() {
|
OnPresenceSelected callback = new OnPresenceSelected() {
|
||||||
@Override
|
@Override
|
||||||
public void onPresenceSelected() {
|
public void onPresenceSelected() {
|
||||||
if (share.image) {
|
if (share.image) {
|
||||||
@ -227,7 +216,12 @@ public class ShareWithActivity extends XmppActivity {
|
|||||||
switchToConversation(conversation, null, true);
|
switchToConversation(conversation, null, true);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
if (conversation.getAccount().httpUploadAvailable()) {
|
||||||
|
callback.onPresenceSelected();
|
||||||
|
} else {
|
||||||
|
selectPresence(conversation, callback);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
switchToConversation(conversation, this.share.text, true);
|
switchToConversation(conversation, this.share.text, true);
|
||||||
finish();
|
finish();
|
||||||
|
Loading…
Reference in New Issue
Block a user