WIP. Breakout to room from call and chat.

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Daniel Calviño Sánchez 2023-01-26 13:30:56 +01:00 committed by Marcel Hibbe
parent c67ce4253f
commit ebfd15e001
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
4 changed files with 94 additions and 4 deletions

View file

@ -180,11 +180,14 @@ import static com.nextcloud.talk.utils.bundle.BundleKeys.KEY_PARTICIPANT_PERMISS
import static com.nextcloud.talk.utils.bundle.BundleKeys.KEY_RECORDING_STATE;
import static com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_ID;
import static com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN;
import static com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SWITCH_TO_ROOM_AND_START_CALL;
import static com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY;
@AutoInjector(NextcloudTalkApplication.class)
public class CallActivity extends CallBaseActivity {
public static boolean active = false;
public static final String VIDEO_STREAM_TYPE_SCREEN = "screen";
public static final String VIDEO_STREAM_TYPE_VIDEO = "video";
@ -304,10 +307,14 @@ public class CallActivity extends CallBaseActivity {
private CallParticipantList callParticipantList;
private String switchToRoomToken = "";
private SignalingMessageReceiver.LocalParticipantMessageListener localParticipantMessageListener =
new SignalingMessageReceiver.LocalParticipantMessageListener() {
@Override
public void onSwitchTo(String token) {
switchToRoomToken = token;
hangup(true);
}
};
@ -456,6 +463,7 @@ public class CallActivity extends CallBaseActivity {
@Override
public void onStart() {
super.onStart();
active = true;
initFeaturesVisibility();
try {
@ -465,6 +473,12 @@ public class CallActivity extends CallBaseActivity {
}
}
@Override
public void onStop() {
super.onStop();
active = false;
}
@RequiresApi(api = Build.VERSION_CODES.S)
private void requestBluetoothPermission() {
if (ContextCompat.checkSelfPermission(
@ -1870,7 +1884,29 @@ public class CallActivity extends CallBaseActivity {
@Override
public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) {
if (shutDownView) {
if (!switchToRoomToken.isEmpty()) {
Intent intent = new Intent(context, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle bundle = new Bundle();
bundle.putBoolean(KEY_SWITCH_TO_ROOM_AND_START_CALL, true);
bundle.putString(KEY_ROOM_TOKEN, switchToRoomToken);
// bundle.putString(KEY_ROOM_ID, roomId);
bundle.putParcelable(KEY_USER_ENTITY, conversationUser);
// conversationName = extras.getString(KEY_CONVERSATION_NAME, "");
bundle.putBoolean(KEY_CALL_VOICE_ONLY, isVoiceOnlyCall);
bundle.putBoolean(KEY_CALL_WITHOUT_NOTIFICATION, true);
bundle.putBoolean(KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_AUDIO, canPublishAudioStream);
bundle.putBoolean(KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_VIDEO, canPublishVideoStream);
intent.putExtras(bundle);
startActivity(intent);
Toast.makeText(context, "going to breakout room...", Toast.LENGTH_LONG).show();
finish();
} else if (shutDownView) {
finish();
} else if (currentCallStatus == CallStatus.RECONNECTING
|| currentCallStatus == CallStatus.PUBLISHER_FAILED) {

View file

@ -354,6 +354,21 @@ class MainActivity : BaseActivity(), ActionBarProvider {
private fun handleIntent(intent: Intent) {
handleActionFromContact(intent)
if (intent.getBooleanExtra(BundleKeys.KEY_SWITCH_TO_ROOM_AND_START_CALL, false)) {
logRouterBackStack(router!!)
remapChatController(
router!!,
intent.getParcelableExtra<User>(KEY_USER_ENTITY)!!.id!!,
intent.getStringExtra(KEY_ROOM_TOKEN)!!,
intent.extras!!,
true,
true
)
logRouterBackStack(router!!)
}
if (intent.hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) {
if (intent.getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)) {
if (!router!!.hasRootController()) {

View file

@ -266,6 +266,7 @@ class ChatController(args: Bundle) :
private var lookingIntoFuture = false
var newMessagesCount = 0
var startCallFromNotification: Boolean? = null
var startCallFromRoomSwitch: Boolean = false
val roomId: String
val voiceOnly: Boolean
var isFirstMessagesProcessing = true
@ -302,6 +303,9 @@ class ChatController(args: Bundle) :
private val localParticipantMessageListener = object : SignalingMessageReceiver.LocalParticipantMessageListener {
override fun onSwitchTo(token: String?) {
if (token != null) {
switchToRoom(token)
}
}
}
@ -338,6 +342,10 @@ class ChatController(args: Bundle) :
this.startCallFromNotification = args.getBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)
}
if (args.containsKey(BundleKeys.KEY_SWITCH_TO_ROOM_AND_START_CALL)) {
this.startCallFromRoomSwitch = args.getBoolean(BundleKeys.KEY_SWITCH_TO_ROOM_AND_START_CALL)
}
this.voiceOnly = args.getBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false)
}
@ -920,6 +928,30 @@ class ChatController(args: Bundle) :
super.onViewBound(view)
}
private fun switchToRoom(token: String) {
if (CallActivity.active) {
Log.d(TAG, "CallActivity is running. Ignore to switch chat in ChatController...")
return
}
val conversationIntent = Intent(activity, CallActivity::class.java)
val bundle = Bundle()
bundle.putParcelable(KEY_USER_ENTITY, conversationUser)
bundle.putString(KEY_ROOM_TOKEN, token)
if (conversationUser != null) {
conversationIntent.putExtras(bundle)
ConductorRemapping.remapChatController(
router,
conversationUser.id!!,
token,
bundle,
true
)
}
}
private fun showSendButtonMenu() {
val popupMenu = PopupMenu(
ContextThemeWrapper(view?.context, R.style.ChatSendButtonMenu),
@ -1972,6 +2004,10 @@ class ChatController(args: Bundle) :
startCallFromNotification = false
startACall(voiceOnly, false)
}
if (startCallFromRoomSwitch) {
startACall(voiceOnly, true)
}
}
override fun onError(e: Throwable) {
@ -2398,9 +2434,11 @@ class ChatController(args: Bundle) :
}
private fun updateReadStatusOfAllMessages(xChatLastCommonRead: Int?) {
for (message in adapter!!.items) {
xChatLastCommonRead?.let {
updateReadStatusOfMessage(message, it)
if (adapter != null) {
for (message in adapter!!.items) {
xChatLastCommonRead?.let {
updateReadStatusOfMessage(message, it)
}
}
}
}

View file

@ -80,4 +80,5 @@ object BundleKeys {
const val KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_AUDIO = "KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_AUDIO"
const val KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_VIDEO = "KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_VIDEO"
const val KEY_IS_MODERATOR = "KEY_IS_MODERATOR"
const val KEY_SWITCH_TO_ROOM_AND_START_CALL = "KEY_SWITCH_TO_ROOM_AND_START_CALL"
}