diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 937b68134..8fdfa85b4 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -114,7 +114,7 @@
-
+
mConversations = new ArrayList();
+ private List mConversations = new ArrayList<>();
- private UiCallback attachImageCallback = new UiCallback() {
+ private UiCallback attachFileCallback = new UiCallback() {
@Override
public void userInputRequried(PendingIntent pi, Message object) {
@@ -78,11 +79,12 @@ public class ShareWithActivity extends XmppActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
-
super.onCreate(savedInstanceState);
- getActionBar().setDisplayHomeAsUpEnabled(false);
- getActionBar().setHomeButtonEnabled(false);
+ if (getActionBar() != null) {
+ getActionBar().setDisplayHomeAsUpEnabled(false);
+ getActionBar().setHomeButtonEnabled(false);
+ }
setContentView(R.layout.share_with);
setTitle(getString(R.string.title_activity_sharewith));
@@ -128,7 +130,7 @@ public class ShareWithActivity extends XmppActivity {
@Override
public void onStart() {
if (getIntent().getType() != null
- && getIntent().getType().startsWith("image/")) {
+ && !getIntent().getType().startsWith("text/")) {
this.share.uri = (Uri) getIntent().getParcelableExtra(
Intent.EXTRA_STREAM);
} else {
@@ -177,12 +179,22 @@ public class ShareWithActivity extends XmppActivity {
selectPresence(conversation, new OnPresenceSelected() {
@Override
public void onPresenceSelected() {
- Toast.makeText(getApplicationContext(),
- getText(R.string.preparing_image),
- Toast.LENGTH_LONG).show();
- ShareWithActivity.this.xmppConnectionService
+ final String type = URLConnection.guessContentTypeFromName(share.uri.getPath());
+ if (type != null && type.startsWith("image/")) {
+ Toast.makeText(getApplicationContext(),
+ getText(R.string.preparing_image),
+ Toast.LENGTH_LONG).show();
+ ShareWithActivity.this.xmppConnectionService
.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);
finish();
}
@@ -195,4 +207,4 @@ public class ShareWithActivity extends XmppActivity {
}
-}
\ No newline at end of file
+}