From 3abb9db9dce9cabeb880a9ccb169b46ee7bca04f Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Thu, 16 Feb 2023 13:49:56 +0100 Subject: [PATCH] remove useless bundle entries etc. - add strings for breakout room toasts - remove useless boilerplate code - dismiss call actions dialog when chlicked raise/lower hand Signed-off-by: Marcel Hibbe --- .../talk/activities/CallActivity.java | 13 +++--- .../nextcloud/talk/activities/MainActivity.kt | 1 - .../talk/controllers/ChatController.kt | 45 ++++++++++++------- .../talk/ui/dialog/MoreCallActionsDialog.kt | 2 + app/src/main/res/values/strings.xml | 4 ++ 5 files changed, 42 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java index f1dc883cb..cfc286f84 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -1935,17 +1935,18 @@ public class CallActivity extends CallBaseActivity { 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(); + if (isBreakoutRoom) { + Toast.makeText(context, context.getResources().getString(R.string.switch_to_main_room), + Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(context, context.getResources().getString(R.string.switch_to_breakout_room), + Toast.LENGTH_LONG).show(); + } finish(); } else if (shutDownView) { diff --git a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt index be2af0f49..a95a9d8e1 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt @@ -356,7 +356,6 @@ class MainActivity : BaseActivity(), ActionBarProvider { handleActionFromContact(intent) if (intent.getBooleanExtra(BundleKeys.KEY_SWITCH_TO_ROOM_AND_START_CALL, false)) { - logRouterBackStack(router!!) remapChatController( router!!, diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index 719084084..01badf1ab 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -316,10 +316,10 @@ class ChatController(args: Bundle) : setHasOptionsMenu(true) NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this) - this.conversationUser = args.getParcelable(KEY_USER_ENTITY) - this.roomId = args.getString(KEY_ROOM_ID, "") - this.roomToken = args.getString(KEY_ROOM_TOKEN, "") - this.sharedText = args.getString(BundleKeys.KEY_SHARED_TEXT, "") + conversationUser = args.getParcelable(KEY_USER_ENTITY) + roomId = args.getString(KEY_ROOM_ID, "") + roomToken = args.getString(KEY_ROOM_TOKEN, "") + sharedText = args.getString(BundleKeys.KEY_SHARED_TEXT, "") Log.d(TAG, " roomToken = $roomToken") if (roomToken.isNullOrEmpty()) { @@ -327,11 +327,11 @@ class ChatController(args: Bundle) : } if (args.containsKey(KEY_ACTIVE_CONVERSATION)) { - this.currentConversation = Parcels.unwrap(args.getParcelable(KEY_ACTIVE_CONVERSATION)) - this.participantPermissions = ParticipantPermissions(conversationUser!!, currentConversation!!) + currentConversation = Parcels.unwrap(args.getParcelable(KEY_ACTIVE_CONVERSATION)) + participantPermissions = ParticipantPermissions(conversationUser!!, currentConversation!!) } - this.roomPassword = args.getString(BundleKeys.KEY_CONVERSATION_PASSWORD, "") + roomPassword = args.getString(BundleKeys.KEY_CONVERSATION_PASSWORD, "") credentials = if (conversationUser?.userId == "?") { null @@ -340,14 +340,14 @@ class ChatController(args: Bundle) : } if (args.containsKey(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) { - this.startCallFromNotification = args.getBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL) + 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) + startCallFromRoomSwitch = args.getBoolean(BundleKeys.KEY_SWITCH_TO_ROOM_AND_START_CALL) } - this.voiceOnly = args.getBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false) + voiceOnly = args.getBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false) } private fun getRoomInfo() { @@ -935,13 +935,26 @@ class ChatController(args: Bundle) : 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) + activity?.runOnUiThread { + if (currentConversation?.objectType == BREAKOUT_ROOM_TYPE) { + Toast.makeText( + context, + context.resources.getString(R.string.switch_to_main_room), + Toast.LENGTH_LONG + ).show() + } else { + Toast.makeText( + context, + context.resources.getString(R.string.switch_to_breakout_room), + Toast.LENGTH_LONG + ).show() + } + } + + val bundle = Bundle() + bundle.putParcelable(KEY_USER_ENTITY, conversationUser) + bundle.putString(KEY_ROOM_TOKEN, token) ConductorRemapping.remapChatController( router, diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/MoreCallActionsDialog.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/MoreCallActionsDialog.kt index 620c4171d..717fec352 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/MoreCallActionsDialog.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/MoreCallActionsDialog.kt @@ -130,12 +130,14 @@ class MoreCallActionsDialog(private val callActivity: CallActivity) : BottomShee binding.raiseHandIcon.setImageDrawable( ContextCompat.getDrawable(context, R.drawable.ic_baseline_do_not_touch_24) ) + dismiss() } is RaiseHandViewModel.LoweredHandState -> { binding.raiseHandText.text = context.getText(R.string.raise_hand) binding.raiseHandIcon.setImageDrawable( ContextCompat.getDrawable(context, R.drawable.ic_hand_back_left) ) + dismiss() } else -> {} } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6b2eb1dca..5460faa6c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -633,6 +633,10 @@ 1 hour Chat messages can be expired after a certain time. Note: Files shared in chat will not be deleted for the owner, but will no longer be shared in the conversation. + + Switch to main room + Switch to breakout room + You are not allowed to activate audio! You are not allowed to activate video! Scroll to bottom