diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-02-13 23:40:08 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-02-13 23:40:08 +0100 |
commit | 42c4c1789a75c87b67c38ef9ca3f57ddd10f0548 (patch) | |
tree | c5bf69cb73c3e4c3be0439c175774561f8b0a5e7 /src/de/gultsch/chat/ui/ConversationFragment.java | |
parent | e63109215e9dda9152f0bc92bf230b652413a677 (diff) |
basic otr support
Diffstat (limited to 'src/de/gultsch/chat/ui/ConversationFragment.java')
-rw-r--r-- | src/de/gultsch/chat/ui/ConversationFragment.java | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/de/gultsch/chat/ui/ConversationFragment.java b/src/de/gultsch/chat/ui/ConversationFragment.java index f7513d08..8ec511fc 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); |