diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-06-15 12:01:46 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-06-16 14:06:50 +0200 |
commit | 30a0be299809613eb61a720c78f86af7bde44a94 (patch) | |
tree | 3f5c365cbfd432d4845e3f8373f843a69ef3a196 /src/eu/siacs/conversations | |
parent | 0102032fc5a29f05a3e39f8f57a51713a3517e90 (diff) |
fixed bug in intent filter. cleaned share with activity
Diffstat (limited to '')
-rw-r--r-- | src/eu/siacs/conversations/ui/ShareWithActivity.java | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/src/eu/siacs/conversations/ui/ShareWithActivity.java b/src/eu/siacs/conversations/ui/ShareWithActivity.java index bf64248ba..72c20a7a5 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<Message> attachImageCallback = new UiCallback<Message>() { + + @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(); + } } |