From 30a0be299809613eb61a720c78f86af7bde44a94 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Sun, 15 Jun 2014 12:01:46 +0200 Subject: fixed bug in intent filter. cleaned share with activity --- .../siacs/conversations/ui/ShareWithActivity.java | 55 ++++++++++++++++------ 1 file changed, 40 insertions(+), 15 deletions(-) (limited to 'src/eu/siacs/conversations/ui/ShareWithActivity.java') diff --git a/src/eu/siacs/conversations/ui/ShareWithActivity.java b/src/eu/siacs/conversations/ui/ShareWithActivity.java index bf64248b..72c20a7a 100644 --- a/src/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/eu/siacs/conversations/ui/ShareWithActivity.java @@ -11,7 +11,9 @@ import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; +import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.utils.UIHelper; +import android.app.PendingIntent; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Bitmap; @@ -29,6 +31,27 @@ public class ShareWithActivity extends XmppActivity { private LinearLayout conversations; private LinearLayout contacts; + private boolean isImage = false; + + private UiCallback attachImageCallback = new UiCallback() { + + @Override + public void userInputRequried(PendingIntent pi, Message object) { + // TODO Auto-generated method stub + + } + + @Override + public void success(Message message) { + xmppConnectionService.sendMessage(message); + } + + @Override + public void error(int errorCode, Message object) { + // TODO Auto-generated method stub + + } + }; @Override protected void onCreate(Bundle savedInstanceState) { @@ -58,7 +81,7 @@ public class ShareWithActivity extends XmppActivity { @Override void onBackendConnected() { - final boolean isImage = (getIntent().getType() != null && getIntent() + this.isImage = (getIntent().getType() != null && getIntent() .getType().startsWith("image/")); SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(this); @@ -85,16 +108,7 @@ public class ShareWithActivity extends XmppActivity { @Override public void onClick(View v) { - String sharedText = null; - if (isImage) { - Uri uri = (Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM); - Log.d(LOGTAG,uri.toString()); - } else { - sharedText = getIntent().getStringExtra( - Intent.EXTRA_TEXT); - } - switchToConversation(conversation, sharedText, true); - finish(); + share(conversation); } }); conversations.addView(view); @@ -131,17 +145,28 @@ public class ShareWithActivity extends XmppActivity { @Override public void onClick(View v) { - String sharedText = getIntent().getStringExtra( - Intent.EXTRA_TEXT); Conversation conversation = xmppConnectionService .findOrCreateConversation(con.getAccount(), con.getJid(), false); - switchToConversation(conversation, sharedText, true); - finish(); + share(conversation); } }); contacts.addView(view); } } + + private void share(Conversation conversation) { + String sharedText = null; + if (isImage) { + Uri uri = (Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM); + Log.d(LOGTAG,uri.toString()); + ShareWithActivity.this.xmppConnectionService.attachImageToConversation(conversation, uri,attachImageCallback); + } else { + sharedText = getIntent().getStringExtra( + Intent.EXTRA_TEXT); + } + switchToConversation(conversation, sharedText, true); + finish(); + } } -- cgit v1.2.3