fixed message hint

This commit is contained in:
iNPUTmice 2014-08-25 15:43:50 +02:00
parent 4e791c8a01
commit 07b422d4c8

View file

@ -77,13 +77,13 @@ public class ConversationFragment extends Fragment {
@Override @Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) { if (actionId == EditorInfo.IME_ACTION_DONE) {
InputMethodManager imm = (InputMethodManager) v.getContext() InputMethodManager imm = (InputMethodManager) v.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE); .getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0); imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
return true; return true;
} else { } else {
return false; return false;
} }
} }
}; };
@ -159,7 +159,6 @@ public class ConversationFragment extends Fragment {
private ConversationActivity activity; private ConversationActivity activity;
private void sendMessage() { private void sendMessage() {
if (mEditMessage.getText().length() < 1) { if (mEditMessage.getText().length() < 1) {
if (this.conversation.getMode() == Conversation.MODE_MULTI) { if (this.conversation.getMode() == Conversation.MODE_MULTI) {
@ -187,12 +186,16 @@ public class ConversationFragment extends Fragment {
} }
public void updateChatMsgHint() { public void updateChatMsgHint() {
if (conversation.getNextPresence() != null) { if (conversation.getMode() == Conversation.MODE_MULTI
this.mEditMessage.setHint(getString(R.string.send_private_message_to,conversation.getNextPresence())); && conversation.getNextPresence() != null) {
this.mEditMessage.setHint(getString(
R.string.send_private_message_to,
conversation.getNextPresence()));
} else { } else {
switch (conversation.getNextEncryption()) { switch (conversation.getNextEncryption()) {
case Message.ENCRYPTION_NONE: case Message.ENCRYPTION_NONE:
mEditMessage.setHint(getString(R.string.send_plain_text_message)); mEditMessage
.setHint(getString(R.string.send_plain_text_message));
break; break;
case Message.ENCRYPTION_OTR: case Message.ENCRYPTION_OTR:
mEditMessage.setHint(getString(R.string.send_otr_message)); mEditMessage.setHint(getString(R.string.send_otr_message));
@ -241,33 +244,36 @@ public class ConversationFragment extends Fragment {
messagesView = (ListView) view.findViewById(R.id.messages_view); messagesView = (ListView) view.findViewById(R.id.messages_view);
messagesView.setOnScrollListener(mOnScrollListener); messagesView.setOnScrollListener(mOnScrollListener);
messagesView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL); messagesView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
messageListAdapter = new MessageAdapter((ConversationActivity) getActivity(), this.messageList); messageListAdapter = new MessageAdapter(
messageListAdapter.setOnContactPictureClicked(new OnContactPictureClicked() { (ConversationActivity) getActivity(), this.messageList);
messageListAdapter
.setOnContactPictureClicked(new OnContactPictureClicked() {
@Override @Override
public void onContactPictureClicked(Message message) { public void onContactPictureClicked(Message message) {
if (message.getConversation().getMode() == Conversation.MODE_MULTI) { if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
if (message.getPresence() != null) { if (message.getPresence() != null) {
highlightInConference(message.getPresence()); highlightInConference(message.getPresence());
} else { } else {
highlightInConference(message.getCounterpart()); highlightInConference(message.getCounterpart());
}
}
} }
} });
} messageListAdapter
}); .setOnContactPictureLongClicked(new OnContactPictureLongClicked() {
messageListAdapter.setOnContactPictureLongClicked(new OnContactPictureLongClicked() {
@Override @Override
public void onContactPictureLongClicked(Message message) { public void onContactPictureLongClicked(Message message) {
if (message.getConversation().getMode() == Conversation.MODE_MULTI) { if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
if (message.getPresence() != null) { if (message.getPresence() != null) {
privateMessageWith(message.getPresence()); privateMessageWith(message.getPresence());
} else { } else {
privateMessageWith(message.getCounterpart()); privateMessageWith(message.getCounterpart());
}
}
} }
} });
}
});
messagesView.setAdapter(messageListAdapter); messagesView.setAdapter(messageListAdapter);
return view; return view;
@ -384,15 +390,19 @@ public class ConversationFragment extends Fragment {
final ConversationActivity activity = (ConversationActivity) getActivity(); final ConversationActivity activity = (ConversationActivity) getActivity();
if (this.conversation != null) { if (this.conversation != null) {
final Contact contact = this.conversation.getContact(); final Contact contact = this.conversation.getContact();
if (!contact.showInRoster() && contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) { if (!contact.showInRoster()
showSnackbar(R.string.contact_added_you, R.string.add_back, new OnClickListener() { && contact
.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
showSnackbar(R.string.contact_added_you, R.string.add_back,
new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
activity.xmppConnectionService.createContact(contact); activity.xmppConnectionService
activity.switchToContactDetails(contact); .createContact(contact);
} activity.switchToContactDetails(contact);
}); }
});
} }
for (Message message : this.conversation.getMessages()) { for (Message message : this.conversation.getMessages()) {
if ((message.getEncryption() == Message.ENCRYPTION_PGP) if ((message.getEncryption() == Message.ENCRYPTION_PGP)