fixed scrolling issues
This commit is contained in:
parent
2eb2bac3e6
commit
285ffa86e7
|
@ -54,7 +54,7 @@
|
||||||
android:dividerHeight="0dp"
|
android:dividerHeight="0dp"
|
||||||
android:listSelector="@android:color/transparent"
|
android:listSelector="@android:color/transparent"
|
||||||
android:stackFromBottom="true"
|
android:stackFromBottom="true"
|
||||||
android:transcriptMode="alwaysScroll"
|
android:transcriptMode="normal"
|
||||||
tools:listitem="@layout/message_sent" >
|
tools:listitem="@layout/message_sent" >
|
||||||
</ListView>
|
</ListView>
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,7 @@ public class ConversationFragment extends Fragment {
|
||||||
lastSeenText = (TextView) view.findViewById(R.id.last_seen_text);
|
lastSeenText = (TextView) view.findViewById(R.id.last_seen_text);
|
||||||
|
|
||||||
messagesView = (ListView) view.findViewById(R.id.messages_view);
|
messagesView = (ListView) view.findViewById(R.id.messages_view);
|
||||||
|
messagesView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
|
||||||
|
|
||||||
messageListAdapter = new ArrayAdapter<Message>(this.getActivity()
|
messageListAdapter = new ArrayAdapter<Message>(this.getActivity()
|
||||||
.getApplicationContext(), R.layout.message_sent,
|
.getApplicationContext(), R.layout.message_sent,
|
||||||
|
@ -688,8 +689,11 @@ public class ConversationFragment extends Fragment {
|
||||||
lastSeenText.setText(UIHelper.lastseen(getActivity(),
|
lastSeenText.setText(UIHelper.lastseen(getActivity(),
|
||||||
contact.lastseen.time));
|
contact.lastseen.time));
|
||||||
}
|
}
|
||||||
this.messageList.clear();
|
for(Message message : this.conversation.getMessages()) {
|
||||||
this.messageList.addAll(this.conversation.getMessages());
|
if (!this.messageList.contains(message)) {
|
||||||
|
this.messageList.add(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
updateStatusMessages();
|
updateStatusMessages();
|
||||||
this.messageListAdapter.notifyDataSetChanged();
|
this.messageListAdapter.notifyDataSetChanged();
|
||||||
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
||||||
|
@ -708,9 +712,6 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
getActivity().invalidateOptionsMenu();
|
getActivity().invalidateOptionsMenu();
|
||||||
updateChatMsgHint();
|
updateChatMsgHint();
|
||||||
int size = this.messageList.size();
|
|
||||||
if (size >= 1)
|
|
||||||
messagesView.setSelection(size - 1);
|
|
||||||
if (!activity.shouldPaneBeOpen()) {
|
if (!activity.shouldPaneBeOpen()) {
|
||||||
activity.xmppConnectionService.markRead(conversation);
|
activity.xmppConnectionService.markRead(conversation);
|
||||||
// TODO update notifications
|
// TODO update notifications
|
||||||
|
@ -721,16 +722,32 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void messageSent() {
|
||||||
|
int size = this.messageList.size();
|
||||||
|
if (size >= 1) {
|
||||||
|
messagesView.setSelection(size - 1);
|
||||||
|
}
|
||||||
|
chatMsg.setText("");
|
||||||
|
}
|
||||||
|
|
||||||
protected void updateStatusMessages() {
|
protected void updateStatusMessages() {
|
||||||
|
boolean addedStatusMsg = false;
|
||||||
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
||||||
for (int i = this.messageList.size() - 1; i >= 0; --i) {
|
for (int i = this.messageList.size() - 1; i >= 0; --i) {
|
||||||
if (this.messageList.get(i).getStatus() == Message.STATUS_RECIEVED) {
|
if (addedStatusMsg) {
|
||||||
return;
|
if (this.messageList.get(i).getType() == Message.TYPE_STATUS) {
|
||||||
|
this.messageList.remove(i);
|
||||||
|
--i;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.messageList.get(i).getStatus() == Message.STATUS_SEND_DISPLAYED) {
|
if (this.messageList.get(i).getStatus() == Message.STATUS_RECIEVED) {
|
||||||
this.messageList.add(i + 1,
|
addedStatusMsg = true;
|
||||||
Message.createStatusMessage(conversation));
|
} else {
|
||||||
return;
|
if (this.messageList.get(i).getStatus() == Message.STATUS_SEND_DISPLAYED) {
|
||||||
|
this.messageList.add(i + 1,
|
||||||
|
Message.createStatusMessage(conversation));
|
||||||
|
addedStatusMsg = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -768,7 +785,7 @@ public class ConversationFragment extends Fragment {
|
||||||
protected void sendPlainTextMessage(Message message) {
|
protected void sendPlainTextMessage(Message message) {
|
||||||
ConversationActivity activity = (ConversationActivity) getActivity();
|
ConversationActivity activity = (ConversationActivity) getActivity();
|
||||||
activity.xmppConnectionService.sendMessage(message, null);
|
activity.xmppConnectionService.sendMessage(message, null);
|
||||||
chatMsg.setText("");
|
messageSent();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sendPgpMessage(final Message message) {
|
protected void sendPgpMessage(final Message message) {
|
||||||
|
@ -791,7 +808,7 @@ public class ConversationFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void success(Contact contact) {
|
public void success(Contact contact) {
|
||||||
chatMsg.setText("");
|
messageSent();
|
||||||
activity.encryptTextMessage(message);
|
activity.encryptTextMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,7 +829,7 @@ public class ConversationFragment extends Fragment {
|
||||||
.setNextEncryption(Message.ENCRYPTION_NONE);
|
.setNextEncryption(Message.ENCRYPTION_NONE);
|
||||||
message.setEncryption(Message.ENCRYPTION_NONE);
|
message.setEncryption(Message.ENCRYPTION_NONE);
|
||||||
xmppService.sendMessage(message, null);
|
xmppService.sendMessage(message, null);
|
||||||
chatMsg.setText("");
|
messageSent();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -838,7 +855,7 @@ public class ConversationFragment extends Fragment {
|
||||||
.setNextEncryption(Message.ENCRYPTION_NONE);
|
.setNextEncryption(Message.ENCRYPTION_NONE);
|
||||||
message.setEncryption(Message.ENCRYPTION_NONE);
|
message.setEncryption(Message.ENCRYPTION_NONE);
|
||||||
xmppService.sendMessage(message, null);
|
xmppService.sendMessage(message, null);
|
||||||
chatMsg.setText("");
|
messageSent();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -870,7 +887,7 @@ public class ConversationFragment extends Fragment {
|
||||||
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
final XmppConnectionService xmppService = activity.xmppConnectionService;
|
||||||
if (conversation.hasValidOtrSession()) {
|
if (conversation.hasValidOtrSession()) {
|
||||||
activity.xmppConnectionService.sendMessage(message, null);
|
activity.xmppConnectionService.sendMessage(message, null);
|
||||||
chatMsg.setText("");
|
messageSent();
|
||||||
} else {
|
} else {
|
||||||
activity.selectPresence(message.getConversation(),
|
activity.selectPresence(message.getConversation(),
|
||||||
new OnPresenceSelected() {
|
new OnPresenceSelected() {
|
||||||
|
@ -880,7 +897,7 @@ public class ConversationFragment extends Fragment {
|
||||||
String presence) {
|
String presence) {
|
||||||
if (success) {
|
if (success) {
|
||||||
xmppService.sendMessage(message, presence);
|
xmppService.sendMessage(message, presence);
|
||||||
chatMsg.setText("");
|
messageSent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -888,7 +905,7 @@ public class ConversationFragment extends Fragment {
|
||||||
public void onSendPlainTextInstead() {
|
public void onSendPlainTextInstead() {
|
||||||
message.setEncryption(Message.ENCRYPTION_NONE);
|
message.setEncryption(Message.ENCRYPTION_NONE);
|
||||||
xmppService.sendMessage(message, null);
|
xmppService.sendMessage(message, null);
|
||||||
chatMsg.setText("");
|
messageSent();
|
||||||
}
|
}
|
||||||
}, "otr");
|
}, "otr");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue