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) {
|
if (message != null) {
|
||||||
outState.putString("messageDraft", message.getText().toString());
|
outState.putString("messageDraft", message.getText().toString());
|
||||||
}
|
}
|
||||||
|
if (contact != null) {
|
||||||
|
outState.putSerializable("contactDraft",contact);
|
||||||
|
outState.putString("sipUriDraft",sipUri);
|
||||||
|
}
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,6 +344,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
LinphoneAddress lAddress = null;
|
LinphoneAddress lAddress = null;
|
||||||
if (sipUri == null) {
|
if (sipUri == null) {
|
||||||
|
contact = null; // Tablet rotation issue
|
||||||
initNewChatConversation();
|
initNewChatConversation();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
@ -354,6 +359,8 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
LinphoneActivity.instance().updateMissedChatCount();
|
LinphoneActivity.instance().updateMissedChatCount();
|
||||||
contact = ContactsManager.getInstance().findContactFromAddress(lAddress);
|
contact = ContactsManager.getInstance().findContactFromAddress(lAddress);
|
||||||
if (chatRoom != null) {
|
if (chatRoom != null) {
|
||||||
|
searchContactField.setVisibility(View.GONE);
|
||||||
|
resultContactsSearch.setVisibility(View.GONE);
|
||||||
displayChatHeader(lAddress);
|
displayChatHeader(lAddress);
|
||||||
displayMessageList();
|
displayMessageList();
|
||||||
}
|
}
|
||||||
|
@ -376,13 +383,19 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
messagesList.setAdapter(adapter);
|
messagesList.setAdapter(adapter);
|
||||||
|
messagesList.setVisibility(ListView.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayChatHeader(LinphoneAddress address) {
|
private void displayChatHeader(LinphoneAddress address) {
|
||||||
if (contact != null) {
|
if (contact != null || address != null) {
|
||||||
contactName.setText(contact.getFullName());
|
if (contact != null) {
|
||||||
} else if(address != null){
|
contactName.setText(contact.getFullName());
|
||||||
contactName.setText(LinphoneUtils.getAddressDisplayName(address));
|
} 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");
|
String draft = getArguments().getString("messageDraft");
|
||||||
message.setText(draft);
|
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);
|
initChatRoom(sipUri);
|
||||||
searchContactField.setVisibility(View.GONE);
|
searchContactField.setVisibility(View.GONE);
|
||||||
resultContactsSearch.setVisibility(View.GONE);
|
resultContactsSearch.setVisibility(View.GONE);
|
||||||
|
@ -635,6 +654,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
chatRoom.sendChatMessage(message);
|
chatRoom.sendChatMessage(message);
|
||||||
lAddress = chatRoom.getPeerAddress();
|
lAddress = chatRoom.getPeerAddress();
|
||||||
|
|
||||||
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
|
LinphoneActivity.instance().onMessageSent(sipUri, messageToSend);
|
||||||
|
}
|
||||||
|
|
||||||
message.setListener(LinphoneManager.getInstance());
|
message.setListener(LinphoneManager.getInstance());
|
||||||
if (newChatConversation) {
|
if (newChatConversation) {
|
||||||
exitNewConversationMode(lAddress.asStringUriOnly());
|
exitNewConversationMode(lAddress.asStringUriOnly());
|
||||||
|
|
|
@ -89,7 +89,7 @@ public enum FragmentsAvailable {
|
||||||
return fragment == CONTACT_DETAIL || fragment == CONTACTS_LIST;
|
return fragment == CONTACT_DETAIL || fragment == CONTACTS_LIST;
|
||||||
|
|
||||||
case CHAT:
|
case CHAT:
|
||||||
return fragment == CHAT_LIST;
|
return fragment == CHAT_LIST || fragment == CHAT;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
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);
|
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) {
|
public void updateStatusFragment(StatusFragment fragment) {
|
||||||
statusFragment = fragment;
|
statusFragment = fragment;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue