aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/ui
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-13 23:40:08 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-13 23:40:08 +0100
commit42c4c1789a75c87b67c38ef9ca3f57ddd10f0548 (patch)
treec5bf69cb73c3e4c3be0439c175774561f8b0a5e7 /src/de/gultsch/chat/ui
parente63109215e9dda9152f0bc92bf230b652413a677 (diff)
basic otr support
Diffstat (limited to 'src/de/gultsch/chat/ui')
-rw-r--r--src/de/gultsch/chat/ui/ConversationActivity.java18
-rw-r--r--src/de/gultsch/chat/ui/ConversationFragment.java35
2 files changed, 33 insertions, 20 deletions
diff --git a/src/de/gultsch/chat/ui/ConversationActivity.java b/src/de/gultsch/chat/ui/ConversationActivity.java
index 66cec2e7b..011261e7a 100644
--- a/src/de/gultsch/chat/ui/ConversationActivity.java
+++ b/src/de/gultsch/chat/ui/ConversationActivity.java
@@ -9,6 +9,7 @@ import de.gultsch.chat.R;
import de.gultsch.chat.R.id;
import de.gultsch.chat.entities.Contact;
import de.gultsch.chat.entities.Conversation;
+import de.gultsch.chat.entities.Message;
import de.gultsch.chat.utils.UIHelper;
import android.net.Uri;
import android.os.Bundle;
@@ -114,7 +115,7 @@ public class ConversationActivity extends XmppActivity {
Collections.sort(this.conversationList, new Comparator<Conversation>() {
@Override
public int compare(Conversation lhs, Conversation rhs) {
- return (int) (rhs.getLatestMessageDate() - lhs.getLatestMessageDate());
+ return (int) (rhs.getLatestMessage().getTimeSent() - lhs.getLatestMessage().getTimeSent());
}
});
}
@@ -143,7 +144,7 @@ public class ConversationActivity extends XmppActivity {
TextView convName = (TextView) view.findViewById(R.id.conversation_name);
convName.setText(conv.getName());
TextView convLastMsg = (TextView) view.findViewById(R.id.conversation_lastmsg);
- convLastMsg.setText(conv.getLatestMessage());
+ convLastMsg.setText(conv.getLatestMessage().getBody());
if(!conv.isRead()) {
convName.setTypeface(null,Typeface.BOLD);
@@ -154,7 +155,7 @@ public class ConversationActivity extends XmppActivity {
}
((TextView) view.findViewById(R.id.conversation_lastupdate))
- .setText(UIHelper.readableTimeDifference(getItem(position).getLatestMessageDate()));
+ .setText(UIHelper.readableTimeDifference(getItem(position).getLatestMessage().getTimeSent()));
Uri profilePhoto = getItem(position).getProfilePhotoUri();
ImageView imageView = (ImageView) view.findViewById(R.id.conversation_image);
@@ -238,18 +239,23 @@ public class ConversationActivity extends XmppActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.conversations, menu);
-
+ MenuItem menuSecure = (MenuItem) menu.findItem(R.id.action_security);
+
if (spl.isOpen()) {
((MenuItem) menu.findItem(R.id.action_archive)).setVisible(false);
((MenuItem) menu.findItem(R.id.action_details)).setVisible(false);
- ((MenuItem) menu.findItem(R.id.action_security)).setVisible(false);
+ menuSecure.setVisible(false);
} else {
((MenuItem) menu.findItem(R.id.action_add)).setVisible(false);
if (this.getSelectedConversation()!=null) {
if (this.getSelectedConversation().getMode() == Conversation.MODE_MULTI) {
((MenuItem) menu.findItem(R.id.action_security)).setVisible(false);
- ((MenuItem) menu.findItem(R.id.action_details)).setVisible(false);
+ menuSecure.setVisible(false);
((MenuItem) menu.findItem(R.id.action_archive)).setTitle("Leave conference");
+ } else {
+ if (this.getSelectedConversation().getLatestMessage().getEncryption() != Message.ENCRYPTION_NONE) {
+ menuSecure.setIcon(R.drawable.ic_action_secure);
+ }
}
}
}
diff --git a/src/de/gultsch/chat/ui/ConversationFragment.java b/src/de/gultsch/chat/ui/ConversationFragment.java
index f7513d08b..8ec511fc2 100644
--- a/src/de/gultsch/chat/ui/ConversationFragment.java
+++ b/src/de/gultsch/chat/ui/ConversationFragment.java
@@ -15,7 +15,6 @@ import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -36,38 +35,30 @@ public class ConversationFragment extends Fragment {
protected ArrayAdapter<Message> messageListAdapter;
protected Contact contact;
+ private EditText chatMsg;
+ private int nextMessageEncryption = Message.ENCRYPTION_NONE;
+
@Override
public View onCreateView(final LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
this.inflater = inflater;
-
final View view = inflater.inflate(R.layout.fragment_conversation,
container, false);
+ chatMsg = (EditText) view.findViewById(R.id.textinput);
((ImageButton) view.findViewById(R.id.textSendButton))
.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ConversationActivity activity = (ConversationActivity) getActivity();
- EditText chatMsg = (EditText) view
- .findViewById(R.id.textinput);
if (chatMsg.getText().length() < 1)
return;
Message message = new Message(conversation, chatMsg
- .getText().toString(), Message.ENCRYPTION_NONE);
+ .getText().toString(), nextMessageEncryption);
activity.xmppConnectionService.sendMessage(conversation.getAccount(),message);
chatMsg.setText("");
-
- /*if (conversation.getMode()==Conversation.MODE_SINGLE) {
- conversation.getMessages().add(message);
- messageList.add(message);
- }*/
-
- //activity.updateConversationList();
-
- //messagesView.setSelection(messageList.size() - 1);
}
});
@@ -213,6 +204,22 @@ public class ConversationFragment extends Fragment {
this.messageList.clear();
this.messageList.addAll(this.conversation.getMessages());
this.messageListAdapter.notifyDataSetChanged();
+ if (messageList.size()>=1) {
+ nextMessageEncryption = this.conversation.getLatestMessage().getEncryption();
+ }
+ getActivity().invalidateOptionsMenu();
+ switch (nextMessageEncryption) {
+ case Message.ENCRYPTION_NONE:
+ chatMsg.setHint("Send plain text message");
+ break;
+ case Message.ENCRYPTION_OTR:
+ chatMsg.setHint("Send OTR encrypted message");
+ break;
+ case Message.ENCRYPTION_PGP:
+ chatMsg.setHint("Send openPGP encryted messeage");
+ default:
+ break;
+ }
int size = this.messageList.size();
if (size >= 1)
messagesView.setSelection(size - 1);