Fix chat on tablet
This commit is contained in:
parent
e48c4a2bd1
commit
c7321069e5
3 changed files with 36 additions and 6 deletions
|
@ -271,6 +271,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
if (message != null) {
|
||||
outState.putString("messageDraft", message.getText().toString());
|
||||
}
|
||||
if (contact != null) {
|
||||
outState.putSerializable("contactDraft",contact);
|
||||
outState.putString("sipUriDraft",sipUri);
|
||||
}
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
|
@ -340,6 +344,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
|
||||
LinphoneAddress lAddress = null;
|
||||
if (sipUri == null) {
|
||||
contact = null; // Tablet rotation issue
|
||||
initNewChatConversation();
|
||||
} else {
|
||||
try {
|
||||
|
@ -354,6 +359,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
LinphoneActivity.instance().updateMissedChatCount();
|
||||
contact = ContactsManager.getInstance().findContactFromAddress(lAddress);
|
||||
if (chatRoom != null) {
|
||||
searchContactField.setVisibility(View.GONE);
|
||||
resultContactsSearch.setVisibility(View.GONE);
|
||||
displayChatHeader(lAddress);
|
||||
displayMessageList();
|
||||
}
|
||||
|
@ -376,13 +383,19 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
}
|
||||
}
|
||||
messagesList.setAdapter(adapter);
|
||||
messagesList.setVisibility(ListView.VISIBLE);
|
||||
}
|
||||
|
||||
private void displayChatHeader(LinphoneAddress address) {
|
||||
if (contact != null) {
|
||||
contactName.setText(contact.getFullName());
|
||||
} else if(address != null){
|
||||
contactName.setText(LinphoneUtils.getAddressDisplayName(address));
|
||||
if (contact != null || address != null) {
|
||||
if (contact != null) {
|
||||
contactName.setText(contact.getFullName());
|
||||
} else {
|
||||
contactName.setText(LinphoneUtils.getAddressDisplayName(address));
|
||||
}
|
||||
topBar.setVisibility(View.VISIBLE);
|
||||
edit.setVisibility(View.VISIBLE);
|
||||
contactName.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -512,8 +525,14 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
|
||||
String draft = getArguments().getString("messageDraft");
|
||||
message.setText(draft);
|
||||
contact = (LinphoneContact)getArguments().getSerializable("contactDraft");
|
||||
if (contact != null) {
|
||||
contactName.setText(contact.getFullName());
|
||||
sipUri = getArguments().getString("sipUriDraft");
|
||||
getArguments().clear();
|
||||
}
|
||||
|
||||
if (!newChatConversation) {
|
||||
if (!newChatConversation || contact != null) {
|
||||
initChatRoom(sipUri);
|
||||
searchContactField.setVisibility(View.GONE);
|
||||
resultContactsSearch.setVisibility(View.GONE);
|
||||
|
@ -635,6 +654,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
chatRoom.sendChatMessage(message);
|
||||
lAddress = chatRoom.getPeerAddress();
|
||||
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().onMessageSent(sipUri, messageToSend);
|
||||
}
|
||||
|
||||
message.setListener(LinphoneManager.getInstance());
|
||||
if (newChatConversation) {
|
||||
exitNewConversationMode(lAddress.asStringUriOnly());
|
||||
|
|
|
@ -89,7 +89,7 @@ public enum FragmentsAvailable {
|
|||
return fragment == CONTACT_DETAIL || fragment == CONTACTS_LIST;
|
||||
|
||||
case CHAT:
|
||||
return fragment == CHAT_LIST;
|
||||
return fragment == CHAT_LIST || fragment == CHAT;
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -775,6 +775,13 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN | WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
}
|
||||
|
||||
public void onMessageSent(String to, String message) {
|
||||
Fragment fragment = getFragmentManager().findFragmentById(R.id.fragmentContainer);
|
||||
if (fragment.getClass() == ChatListFragment.class) {
|
||||
((ChatListFragment)fragment).refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateStatusFragment(StatusFragment fragment) {
|
||||
statusFragment = fragment;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue