fixed image sharing with contacts that have multiple presences
This commit is contained in:
parent
09f488a7e2
commit
4070c33605
|
@ -26,30 +26,31 @@ import android.view.View.OnClickListener;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class ShareWithActivity extends XmppActivity {
|
public class ShareWithActivity extends XmppActivity {
|
||||||
|
|
||||||
private LinearLayout conversations;
|
private LinearLayout conversations;
|
||||||
private LinearLayout contacts;
|
private LinearLayout contacts;
|
||||||
private boolean isImage = false;
|
private boolean isImage = false;
|
||||||
|
|
||||||
private UiCallback<Message> attachImageCallback = new UiCallback<Message>() {
|
private UiCallback<Message> attachImageCallback = new UiCallback<Message>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void userInputRequried(PendingIntent pi, Message object) {
|
public void userInputRequried(PendingIntent pi, Message object) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void success(Message message) {
|
public void success(Message message) {
|
||||||
xmppConnectionService.sendMessage(message);
|
xmppConnectionService.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(int errorCode, Message object) {
|
public void error(int errorCode, Message object) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,8 +82,8 @@ public class ShareWithActivity extends XmppActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onBackendConnected() {
|
void onBackendConnected() {
|
||||||
this.isImage = (getIntent().getType() != null && getIntent()
|
this.isImage = (getIntent().getType() != null && getIntent().getType()
|
||||||
.getType().startsWith("image/"));
|
.startsWith("image/"));
|
||||||
SharedPreferences preferences = PreferenceManager
|
SharedPreferences preferences = PreferenceManager
|
||||||
.getDefaultSharedPreferences(this);
|
.getDefaultSharedPreferences(this);
|
||||||
boolean useSubject = preferences.getBoolean("use_subject_in_muc", true);
|
boolean useSubject = preferences.getBoolean("use_subject_in_muc", true);
|
||||||
|
@ -154,24 +155,32 @@ public class ShareWithActivity extends XmppActivity {
|
||||||
contacts.addView(view);
|
contacts.addView(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void share(final Conversation conversation) {
|
private void share(final Conversation conversation) {
|
||||||
String sharedText = null;
|
String sharedText = null;
|
||||||
if (isImage) {
|
if (isImage) {
|
||||||
final Uri uri = (Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
|
final Uri uri = (Uri) getIntent().getParcelableExtra(
|
||||||
|
Intent.EXTRA_STREAM);
|
||||||
selectPresence(conversation, new OnPresenceSelected() {
|
selectPresence(conversation, new OnPresenceSelected() {
|
||||||
@Override
|
@Override
|
||||||
public void onPresenceSelected() {
|
public void onPresenceSelected() {
|
||||||
ShareWithActivity.this.xmppConnectionService.attachImageToConversation(conversation, uri,attachImageCallback);
|
Toast.makeText(getApplicationContext(),
|
||||||
|
getText(R.string.preparing_image),
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
ShareWithActivity.this.xmppConnectionService
|
||||||
|
.attachImageToConversation(conversation, uri,
|
||||||
|
attachImageCallback);
|
||||||
|
switchToConversation(conversation, null, true);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sharedText = getIntent().getStringExtra(
|
sharedText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
|
||||||
Intent.EXTRA_TEXT);
|
switchToConversation(conversation, sharedText, true);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
switchToConversation(conversation, sharedText, true);
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue