set calling/dialing state by ApplicationWideCurrentRoomHolder

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2021-10-11 22:47:12 +02:00
parent 78384e7b55
commit d4d23c1855
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
3 changed files with 17 additions and 12 deletions

View File

@ -844,7 +844,7 @@ public class CallController extends BaseController {
@RequiresApi(api = Build.VERSION_CODES.O)
@OnClick(R.id.callControlEnterPip)
void onToggleChatClick() {
void enterPipMode() {
((MagicCallActivity) getActivity()).enterPipMode();
}
@ -1304,6 +1304,7 @@ public class CallController extends BaseController {
setCallState(CallStatus.JOINED);
ApplicationWideCurrentRoomHolder.getInstance().setInCall(true);
ApplicationWideCurrentRoomHolder.getInstance().setDialing(false);
if (!TextUtils.isEmpty(roomToken)) {
NotificationUtils.INSTANCE.cancelExistingNotificationsForRoom(getApplicationContext(),
@ -1581,6 +1582,7 @@ public class CallController extends BaseController {
}
hangupNetworkCalls(shutDownView);
ApplicationWideCurrentRoomHolder.getInstance().setInCall(false);
}
private void hangupNetworkCalls(boolean shutDownView) {

View File

@ -232,7 +232,6 @@ class ChatController(args: Bundle) :
val roomId: String
val voiceOnly: Boolean
var isFirstMessagesProcessing = true
var isLeavingForConversation: Boolean = false
var wasDetached: Boolean = false
var emojiPopup: EmojiPopup? = null
@ -1367,10 +1366,8 @@ class ChatController(args: Bundle) :
activity?.findViewById<View>(R.id.toolbar)?.setOnClickListener { v -> showConversationInfoScreen() }
}
isLeavingForConversation = false
ApplicationWideCurrentRoomHolder.getInstance().currentRoomId = roomId
ApplicationWideCurrentRoomHolder.getInstance().currentRoomToken = roomId
ApplicationWideCurrentRoomHolder.getInstance().isInCall = false
ApplicationWideCurrentRoomHolder.getInstance().userInRoom = conversationUser
val smileyButton = binding.messageInputView.findViewById<ImageButton>(R.id.smileyButton)
@ -1434,11 +1431,6 @@ class ChatController(args: Bundle) :
override fun onDetach(view: View) {
super.onDetach(view)
if (!isLeavingForConversation) {
// current room is still "active", we need the info
ApplicationWideCurrentRoomHolder.getInstance().clear()
}
eventBus?.unregister(this)
if (activity != null) {
@ -1448,9 +1440,10 @@ class ChatController(args: Bundle) :
if (conversationUser != null &&
activity != null &&
!activity?.isChangingConfigurations!! &&
!isLeavingForConversation
!ApplicationWideCurrentRoomHolder.getInstance().isInCall &&
!ApplicationWideCurrentRoomHolder.getInstance().isDialing
) {
// TODO: don't leave room when going back to call from PIP Mode!!
ApplicationWideCurrentRoomHolder.getInstance().clear()
wasDetached = true
leaveRoom()
}
@ -2121,7 +2114,7 @@ class ChatController(args: Bundle) :
}
private fun startACall(isVoiceOnlyCall: Boolean) {
isLeavingForConversation = true
ApplicationWideCurrentRoomHolder.getInstance().isDialing = true
val callIntent = getIntentForCall(isVoiceOnlyCall)
if (callIntent != null) {
startActivity(callIntent)

View File

@ -28,6 +28,7 @@ public class ApplicationWideCurrentRoomHolder {
private String currentRoomToken = "";
private UserEntity userInRoom = new UserEntity();
private boolean inCall = false;
private boolean isDialing = false;
private String session = "";
public static ApplicationWideCurrentRoomHolder getInstance() {
@ -38,6 +39,7 @@ public class ApplicationWideCurrentRoomHolder {
currentRoomId = "";
userInRoom = new UserEntity();
inCall = false;
isDialing = false;
currentRoomToken = "";
session = "";
}
@ -74,6 +76,14 @@ public class ApplicationWideCurrentRoomHolder {
this.inCall = inCall;
}
public boolean isDialing() {
return isDialing;
}
public void setDialing(boolean dialing) {
isDialing = dialing;
}
public String getSession() {
return session;
}