aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java126
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java14
-rw-r--r--src/eu/siacs/conversations/ui/OnPresenceSelected.java3
-rw-r--r--src/eu/siacs/conversations/ui/ShareWithActivity.java13
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java74
5 files changed, 106 insertions, 124 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index 64b4529d..59c8fc4f 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -6,11 +6,9 @@ import java.util.ArrayList;
import java.util.List;
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.entities.Presences;
import eu.siacs.conversations.services.ImageProvider;
import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.utils.UIHelper;
@@ -345,39 +343,29 @@ public class ConversationActivity extends XmppActivity {
selectPresence(getSelectedConversation(), new OnPresenceSelected() {
@Override
- public void onPresenceSelected(boolean success, String presence) {
- if (success) {
- if (attachmentChoice == ATTACHMENT_CHOICE_TAKE_PHOTO) {
- Intent takePictureIntent = new Intent(
- MediaStore.ACTION_IMAGE_CAPTURE);
- takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
- ImageProvider.getIncomingContentUri());
- if (takePictureIntent
- .resolveActivity(getPackageManager()) != null) {
- startActivityForResult(takePictureIntent,
- REQUEST_IMAGE_CAPTURE);
- }
- } else if (attachmentChoice == ATTACHMENT_CHOICE_CHOOSE_IMAGE) {
- Intent attachFileIntent = new Intent();
- attachFileIntent.setType("image/*");
- attachFileIntent.setAction(Intent.ACTION_GET_CONTENT);
- Intent chooser = Intent.createChooser(attachFileIntent,
- getString(R.string.attach_file));
- startActivityForResult(chooser,
- REQUEST_ATTACH_FILE_DIALOG);
- } else if (attachmentChoice == ATTACHMENT_CHOICE_RECORD_VOICE) {
- Intent intent = new Intent(
- MediaStore.Audio.Media.RECORD_SOUND_ACTION);
- startActivityForResult(intent, REQUEST_RECORD_AUDIO);
+ public void onPresenceSelected() {
+ if (attachmentChoice == ATTACHMENT_CHOICE_TAKE_PHOTO) {
+ Intent takePictureIntent = new Intent(
+ MediaStore.ACTION_IMAGE_CAPTURE);
+ takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
+ ImageProvider.getIncomingContentUri());
+ if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
+ startActivityForResult(takePictureIntent,
+ REQUEST_IMAGE_CAPTURE);
}
+ } else if (attachmentChoice == ATTACHMENT_CHOICE_CHOOSE_IMAGE) {
+ Intent attachFileIntent = new Intent();
+ attachFileIntent.setType("image/*");
+ attachFileIntent.setAction(Intent.ACTION_GET_CONTENT);
+ Intent chooser = Intent.createChooser(attachFileIntent,
+ getString(R.string.attach_file));
+ startActivityForResult(chooser, REQUEST_ATTACH_FILE_DIALOG);
+ } else if (attachmentChoice == ATTACHMENT_CHOICE_RECORD_VOICE) {
+ Intent intent = new Intent(
+ MediaStore.Audio.Media.RECORD_SOUND_ACTION);
+ startActivityForResult(intent, REQUEST_RECORD_AUDIO);
}
}
-
- @Override
- public void onSendPlainTextInstead() {
- // TODO Auto-generated method stub
-
- }
});
}
@@ -851,59 +839,6 @@ public class ConversationActivity extends XmppActivity {
listView.invalidateViews();
}
- public void selectPresence(final Conversation conversation,
- final OnPresenceSelected listener) {
- Contact contact = conversation.getContact();
- if (contact == null) {
- showAddToRosterDialog(conversation);
- listener.onPresenceSelected(false, null);
- } else {
- Presences presences = contact.getPresences();
- if (presences.size() == 0) {
- conversation.setNextPresence(null);
- listener.onPresenceSelected(true, null);
- } else if (presences.size() == 1) {
- String presence = (String) presences.asStringArray()[0];
- conversation.setNextPresence(presence);
- listener.onPresenceSelected(true, presence);
- } else {
- final StringBuilder presence = new StringBuilder();
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.choose_presence));
- final String[] presencesArray = presences.asStringArray();
- int preselectedPresence = 0;
- for (int i = 0; i < presencesArray.length; ++i) {
- if (presencesArray[i].equals(contact.lastseen.presence)) {
- preselectedPresence = i;
- break;
- }
- }
- presence.append(presencesArray[preselectedPresence]);
- builder.setSingleChoiceItems(presencesArray,
- preselectedPresence,
- new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog,
- int which) {
- presence.delete(0, presence.length());
- presence.append(presencesArray[which]);
- }
- });
- builder.setNegativeButton(R.string.cancel, null);
- builder.setPositiveButton(R.string.ok, new OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- conversation.setNextPresence(presence.toString());
- listener.onPresenceSelected(true, presence.toString());
- }
- });
- builder.create().show();
- }
- }
- }
-
public boolean showLastseen() {
if (getSelectedConversation() == null) {
return false;
@@ -913,27 +848,6 @@ public class ConversationActivity extends XmppActivity {
}
}
- private void showAddToRosterDialog(final Conversation conversation) {
- String jid = conversation.getContactJid();
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(jid);
- builder.setMessage(getString(R.string.not_in_roster));
- builder.setNegativeButton(getString(R.string.cancel), null);
- builder.setPositiveButton(getString(R.string.add_contact),
- new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- String jid = conversation.getContactJid();
- Account account = getSelectedConversation()
- .getAccount();
- Contact contact = account.getRoster().getContact(jid);
- xmppConnectionService.createContact(contact);
- }
- });
- builder.create().show();
- }
-
public void runIntent(PendingIntent pi, int requestCode) {
try {
this.startIntentSenderForResult(pi.getIntentSender(), requestCode,
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 383cb2fd..91da81e2 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -925,18 +925,8 @@ public class ConversationFragment extends Fragment {
new OnPresenceSelected() {
@Override
- public void onPresenceSelected(boolean success,
- String presence) {
- if (success) {
- message.setPresence(presence);
- xmppService.sendMessage(message);
- messageSent();
- }
- }
-
- @Override
- public void onSendPlainTextInstead() {
- message.setEncryption(Message.ENCRYPTION_NONE);
+ public void onPresenceSelected() {
+ message.setPresence(conversation.getNextPresence());
xmppService.sendMessage(message);
messageSent();
}
diff --git a/src/eu/siacs/conversations/ui/OnPresenceSelected.java b/src/eu/siacs/conversations/ui/OnPresenceSelected.java
index b3a995dc..1c967224 100644
--- a/src/eu/siacs/conversations/ui/OnPresenceSelected.java
+++ b/src/eu/siacs/conversations/ui/OnPresenceSelected.java
@@ -1,6 +1,5 @@
package eu.siacs.conversations.ui;
public interface OnPresenceSelected {
- public void onPresenceSelected(boolean success, String presence);
- public void onSendPlainTextInstead();
+ public void onPresenceSelected();
}
diff --git a/src/eu/siacs/conversations/ui/ShareWithActivity.java b/src/eu/siacs/conversations/ui/ShareWithActivity.java
index 72c20a7a..d4d23ddf 100644
--- a/src/eu/siacs/conversations/ui/ShareWithActivity.java
+++ b/src/eu/siacs/conversations/ui/ShareWithActivity.java
@@ -155,12 +155,17 @@ public class ShareWithActivity extends XmppActivity {
}
}
- private void share(Conversation conversation) {
+ private void share(final 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);
+ final Uri uri = (Uri) getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
+ selectPresence(conversation, new OnPresenceSelected() {
+ @Override
+ public void onPresenceSelected() {
+ ShareWithActivity.this.xmppConnectionService.attachImageToConversation(conversation, uri,attachImageCallback);
+ }
+ });
+
} else {
sharedText = getIntent().getStringExtra(
Intent.EXTRA_TEXT);
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index a6cf0588..c95cbfec 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -2,8 +2,10 @@ package eu.siacs.conversations.ui;
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.entities.Presences;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
import eu.siacs.conversations.utils.ExceptionHelper;
@@ -219,4 +221,76 @@ public abstract class XmppActivity extends Activity {
});
}
+
+ protected void showAddToRosterDialog(final Conversation conversation) {
+ String jid = conversation.getContactJid();
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(jid);
+ builder.setMessage(getString(R.string.not_in_roster));
+ builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.setPositiveButton(getString(R.string.add_contact),
+ new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ String jid = conversation.getContactJid();
+ Account account = conversation.getAccount();
+ Contact contact = account.getRoster().getContact(jid);
+ xmppConnectionService.createContact(contact);
+ }
+ });
+ builder.create().show();
+ }
+
+ public void selectPresence(final Conversation conversation,
+ final OnPresenceSelected listener) {
+ Contact contact = conversation.getContact();
+ if (contact == null) {
+ showAddToRosterDialog(conversation);
+ } else {
+ Presences presences = contact.getPresences();
+ if (presences.size() == 0) {
+ conversation.setNextPresence(null);
+ listener.onPresenceSelected();
+ } else if (presences.size() == 1) {
+ String presence = (String) presences.asStringArray()[0];
+ conversation.setNextPresence(presence);
+ listener.onPresenceSelected();
+ } else {
+ final StringBuilder presence = new StringBuilder();
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(getString(R.string.choose_presence));
+ final String[] presencesArray = presences.asStringArray();
+ int preselectedPresence = 0;
+ for (int i = 0; i < presencesArray.length; ++i) {
+ if (presencesArray[i].equals(contact.lastseen.presence)) {
+ preselectedPresence = i;
+ break;
+ }
+ }
+ presence.append(presencesArray[preselectedPresence]);
+ builder.setSingleChoiceItems(presencesArray,
+ preselectedPresence,
+ new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog,
+ int which) {
+ presence.delete(0, presence.length());
+ presence.append(presencesArray[which]);
+ }
+ });
+ builder.setNegativeButton(R.string.cancel, null);
+ builder.setPositiveButton(R.string.ok, new OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ conversation.setNextPresence(presence.toString());
+ listener.onPresenceSelected();
+ }
+ });
+ builder.create().show();
+ }
+ }
+ }
}