Fix crash in chat
This commit is contained in:
parent
0e4b5d7d0b
commit
bb217a3a6e
2 changed files with 15 additions and 16 deletions
|
@ -3,7 +3,7 @@
|
||||||
android:id="@+id/layout"
|
android:id="@+id/layout"
|
||||||
android:background="@drawable/list_selector"
|
android:background="@drawable/list_selector"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="50dp"
|
android:layout_height="60dp"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
|
@ -146,7 +146,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
if(getArguments() == null || getArguments().getString("SipUri") == null) {
|
if(getArguments() == null || getArguments().getString("SipUri") == null) {
|
||||||
newChatConversation = true;
|
newChatConversation = true;
|
||||||
Log.w("lala");
|
|
||||||
} else {
|
} else {
|
||||||
//Retrieve parameter from intent
|
//Retrieve parameter from intent
|
||||||
sipUri = getArguments().getString("SipUri");
|
sipUri = getArguments().getString("SipUri");
|
||||||
|
@ -468,7 +467,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
chatRoom = lc.getChatRoom(lAddress);
|
chatRoom = lc.getChatRoom(lAddress);
|
||||||
chatRoom.markAsRead();
|
chatRoom.markAsRead();
|
||||||
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||||
displayChatHeader(lAddress);
|
if(chatRoom != null) {
|
||||||
|
displayChatHeader(lAddress);
|
||||||
|
dispayMessageList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -493,12 +495,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
this.pictureUri = pictureUri;
|
this.pictureUri = pictureUri;
|
||||||
|
|
||||||
initChatRoom(sipUri);
|
initChatRoom(sipUri);
|
||||||
|
|
||||||
if(chatRoom != null) {
|
|
||||||
LinphoneAddress lAddress = chatRoom.getPeerAddress();
|
|
||||||
displayChatHeader(lAddress);
|
|
||||||
dispayMessageList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -608,12 +604,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
LinphoneManager.addListener(this);
|
LinphoneManager.addListener(this);
|
||||||
|
|
||||||
// Force hide keyboard
|
// Force hide keyboard
|
||||||
boolean isOrientationLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
||||||
if(isOrientationLandscape) {
|
|
||||||
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
|
||||||
} else {
|
|
||||||
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
String draft = getArguments().getString("messageDraft");
|
String draft = getArguments().getString("messageDraft");
|
||||||
message.setText(draft);
|
message.setText(draft);
|
||||||
|
@ -621,7 +612,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
if(!newChatConversation) {
|
if(!newChatConversation) {
|
||||||
initChatRoom(sipUri);
|
initChatRoom(sipUri);
|
||||||
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
||||||
dispayMessageList();
|
|
||||||
}
|
}
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
@ -709,6 +699,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
editList.setVisibility(View.VISIBLE);
|
editList.setVisibility(View.VISIBLE);
|
||||||
isEditMode = true;
|
isEditMode = true;
|
||||||
dispayMessageList();
|
dispayMessageList();
|
||||||
|
//TODO refaire la liste
|
||||||
}
|
}
|
||||||
if(id == R.id.start_call){
|
if(id == R.id.start_call){
|
||||||
LinphoneActivity.instance().setAddresGoToDialerAndCall(sipUri, LinphoneUtils.getUsernameFromAddress(sipUri), null);
|
LinphoneActivity.instance().setAddresGoToDialerAndCall(sipUri, LinphoneUtils.getUsernameFromAddress(sipUri), null);
|
||||||
|
@ -740,6 +731,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
if (chatRoom != null && messageToSend != null && messageToSend.length() > 0 && isNetworkReachable) {
|
if (chatRoom != null && messageToSend != null && messageToSend.length() > 0 && isNetworkReachable) {
|
||||||
LinphoneChatMessage message = chatRoom.createLinphoneChatMessage(messageToSend);
|
LinphoneChatMessage message = chatRoom.createLinphoneChatMessage(messageToSend);
|
||||||
chatRoom.sendChatMessage(message);
|
chatRoom.sendChatMessage(message);
|
||||||
|
lAddress = chatRoom.getPeerAddress();
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().onMessageSent(sipUri, messageToSend);
|
LinphoneActivity.instance().onMessageSent(sipUri, messageToSend);
|
||||||
|
@ -761,6 +753,13 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
private void sendImageMessage(String path, int imageSize) {
|
private void sendImageMessage(String path, int imageSize) {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();
|
boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();
|
||||||
|
|
||||||
|
if(newChatConversation && chatRoom == null) {
|
||||||
|
String address = searchContactField.getText().toString();
|
||||||
|
if (address != null && !address.equals("")) {
|
||||||
|
initChatRoom(address);
|
||||||
|
}
|
||||||
|
}
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
||||||
if (chatRoom != null && path != null && path.length() > 0 && isNetworkReachable) {
|
if (chatRoom != null && path != null && path.length() > 0 && isNetworkReachable) {
|
||||||
|
|
Loading…
Reference in a new issue