aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/menu/attachment_choices.xml11
-rw-r--r--res/values/strings.xml2
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java30
3 files changed, 42 insertions, 1 deletions
diff --git a/res/menu/attachment_choices.xml b/res/menu/attachment_choices.xml
new file mode 100644
index 00000000..84e777b6
--- /dev/null
+++ b/res/menu/attachment_choices.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <item
+ android:id="@+id/attach_choose_picture"
+ android:title="@string/attach_choose_picture"/>
+ <item
+ android:id="@+id/attach_take_picture"
+ android:title="@string/attach_take_picture"/>
+
+</menu> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 10dfb592..ed855467 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -128,4 +128,6 @@
<string name="send_presence_updates">Send presence updates</string>
<string name="receive_presence_updates">Receive presence updates</string>
<string name="ask_for_presence_updates">Ask for presence updates</string>
+ <string name="attach_choose_picture">Choose picture</string>
+ <string name="attach_take_picture">Take picture</string>
</resources>
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index 88728245..aed6f1e1 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -19,6 +19,7 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.provider.MediaStore;
import android.app.AlertDialog;
import android.app.FragmentTransaction;
import android.app.PendingIntent;
@@ -65,6 +66,7 @@ public class ConversationActivity extends XmppActivity {
public static final int REQUEST_SEND_MESSAGE = 0x75441;
public static final int REQUEST_DECRYPT_PGP = 0x76783;
private static final int REQUEST_ATTACH_FILE_DIALOG = 0x48502;
+ private static final int REQUEST_IMAGE_CAPTURE = 0x33788;
private static final int REQUEST_SEND_PGP_IMAGE = 0x53883;
private static final int REQUEST_ATTACH_FILE = 0x73824;
public static final int REQUEST_ENCRYPT_MESSAGE = 0x378018;
@@ -347,6 +349,14 @@ public class ConversationActivity extends XmppActivity {
}
},"file");
}
+
+ private void takePicture() {
+ Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
+ startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
+ }
+
+ }
private void attachFile() {
final Conversation conversation = getSelectedConversation();
@@ -423,7 +433,25 @@ public class ConversationActivity extends XmppActivity {
spl.openPane();
break;
case R.id.action_attach_file:
- attachFile();
+ View menuAttachFile = findViewById(R.id.action_attach_file);
+ PopupMenu attachFilePopup = new PopupMenu(this, menuAttachFile);
+ attachFilePopup.inflate(R.menu.attachment_choices);
+ attachFilePopup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
+
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.attach_choose_picture:
+ attachFile();
+ break;
+ case R.id.attach_take_picture:
+ takePicture();
+ break;
+ }
+ return false;
+ }
+ });
+ attachFilePopup.show();
break;
case R.id.action_add:
startActivity(new Intent(this, ContactsActivity.class));