mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-27 08:55:54 +03:00
WIP. Breakout to room from call and chat.
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
c67ce4253f
commit
ebfd15e001
4 changed files with 94 additions and 4 deletions
|
@ -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) {
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue