Added group chat room creation
This commit is contained in:
parent
059ad22044
commit
9b99a452f8
6 changed files with 51 additions and 2 deletions
|
@ -34,6 +34,7 @@ dtmf_player_amp=0.1
|
|||
ec_calibrator_cool_tones=1
|
||||
|
||||
[misc]
|
||||
conference_factory_uri=sips:conference-factory@sip.linphone.org
|
||||
max_calls=10
|
||||
history_max_size=100
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ import org.linphone.core.ChatMessage;
|
|||
import org.linphone.core.ChatMessageListener;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomListener;
|
||||
import org.linphone.core.ChatRoomState;
|
||||
import org.linphone.core.Content;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.Core.AuthMethod;
|
||||
|
@ -622,6 +623,11 @@ public class LinphoneManager implements CoreListener, ChatMessageListener, Senso
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessageReceived(ChatRoom cr, ChatMessage msg) {
|
||||
|
||||
|
|
|
@ -721,6 +721,12 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
}
|
||||
}
|
||||
|
||||
public void goToChat(String sipUri) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putString("SipUri", sipUri);
|
||||
changeCurrentFragment(FragmentsAvailable.GROUP_CHAT, extras);
|
||||
}
|
||||
|
||||
public void displayChatGroupInfos(ArrayList<ContactAddress> contacts, String subject, boolean isAlreadyCreatedGroup, boolean isEditionEnabled) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putBoolean("isAlreadyCreatedGroup", isAlreadyCreatedGroup);
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.linphone.core.ChatMessage;
|
|||
import org.linphone.core.ChatMessageListener;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomListener;
|
||||
import org.linphone.core.ChatRoomState;
|
||||
import org.linphone.core.Content;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.Participant;
|
||||
|
@ -470,6 +471,11 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContactsUpdated() {
|
||||
getContactsForParticipants();
|
||||
|
|
|
@ -31,9 +31,16 @@ import android.widget.ImageView;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
import org.linphone.contacts.ContactAddress;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ChatMessage;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomListener;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -128,7 +135,30 @@ public class GroupInfoFragment extends Fragment {
|
|||
mConfirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//TODO
|
||||
if (!mIsAlreadyCreatedGroup) {
|
||||
ChatRoom chatRoom = LinphoneManager.getLc().createClientGroupChatRoom(mSubjectField.getText().toString());
|
||||
chatRoom.setListener(new ChatRoomListenerStub() {
|
||||
@Override
|
||||
public void onStateChanged(ChatRoom cr, ChatRoom.State newState) {
|
||||
if (newState == ChatRoom.State.Created) {
|
||||
LinphoneActivity.instance().goToChat(cr.getConferenceAddress().asStringUriOnly());
|
||||
} else if (newState == ChatRoom.State.CreationFailed) {
|
||||
//TODO display error
|
||||
Log.e("Group chat room for address " + cr.getConferenceAddress() + " has failed !");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Address addresses[] = new Address[mParticipants.size()];
|
||||
int index = 0;
|
||||
for (ContactAddress ca : mParticipants) {
|
||||
addresses[index] = LinphoneManager.getLc().createAddress(ca.getAddress());
|
||||
index++;
|
||||
}
|
||||
chatRoom.addParticipants(addresses);
|
||||
} else {
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
});
|
||||
mConfirmButton.setEnabled(mSubjectField.getText().length() > 0 && mParticipants.size() > 0);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c88983da3d4a48aaadb1ea2d23f6062897fe31ac
|
||||
Subproject commit 8aa93022dd29dcc73a2ba0a29b256568cb7a3f44
|
Loading…
Reference in a new issue