implement long click and short click on hangup button

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-10-25 13:09:50 +02:00 committed by Marcel Hibbe
parent 52fd3f9002
commit ed9fc185bf
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
4 changed files with 70 additions and 25 deletions

View file

@ -263,7 +263,7 @@ class CallActivity : CallBaseActivity() {
override fun onCallEndedForAll() {
Log.d(TAG, "A moderator ended the call for all.")
hangup(true)
hangup(true, false)
}
}
private var callParticipantList: CallParticipantList? = null
@ -271,7 +271,7 @@ class CallActivity : CallBaseActivity() {
private var isBreakoutRoom = false
private val localParticipantMessageListener = LocalParticipantMessageListener { token ->
switchToRoomToken = token
hangup(true)
hangup(true,false)
}
private val offerMessageListener = OfferMessageListener { sessionId, roomType, sdp, nick ->
getOrCreatePeerConnectionWrapperForSessionIdAndType(
@ -470,7 +470,7 @@ class CallActivity : CallBaseActivity() {
binding!!.callRecordingIndicator.visibility = View.GONE
}
}
initClickListeners()
initClickListeners(isModerator)
binding!!.microphoneButton.setOnTouchListener(MicrophoneButtonTouchListener())
pulseAnimation = PulseAnimation.create().with(binding!!.microphoneButton)
.setDuration(310)
@ -498,7 +498,7 @@ class CallActivity : CallBaseActivity() {
}
.setNegativeButton(R.string.nc_no) { _, _ ->
recordingConsentGiven = false
hangup(true)
hangup(true,false)
}
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(this, materialAlertDialogBuilder)
@ -613,7 +613,8 @@ class CallActivity : CallBaseActivity() {
}
}
private fun initClickListeners() {
@SuppressLint("ClickableViewAccessibility")
private fun initClickListeners(isModerator:Boolean) {
binding!!.pictureInPictureButton.setOnClickListener { enterPipMode() }
binding!!.audioOutputButton.setOnClickListener {
@ -663,7 +664,22 @@ class CallActivity : CallBaseActivity() {
).show()
}
}
binding!!.hangupButton.setOnClickListener { hangup(true) }
binding!!.hangupButton.setOnClickListener {
hangup(true, false)
}
if (isModerator) {
binding!!. hangupButton.setOnLongClickListener {
showPopupMenu()
true
}
}
binding!!.popupMenu.setOnClickListener {
hangup(true, true)
binding!!.popupMenu.visibility = View.GONE
}
binding!!.switchSelfVideoButton.setOnClickListener { switchCamera() }
binding!!.gridview.onItemClickListener =
AdapterView.OnItemClickListener { _: AdapterView<*>?, _: View?, _: Int, _: Long ->
@ -675,7 +691,7 @@ class CallActivity : CallBaseActivity() {
binding!!.callStates.callStateRelativeLayout.setOnClickListener {
if (currentCallStatus === CallStatus.CALLING_TIMEOUT) {
setCallState(CallStatus.RECONNECTING)
hangupNetworkCalls(false)
hangupNetworkCalls(false, false)
}
}
binding!!.callRecordingIndicator.setOnClickListener {
@ -699,6 +715,11 @@ class CallActivity : CallBaseActivity() {
binding!!.lowerHandButton.setOnClickListener { l: View? -> raiseHandViewModel!!.lowerHand() }
}
private fun showPopupMenu() {
binding!!.popupMenu.visibility = View.VISIBLE
}
private fun createCameraEnumerator() {
var camera2EnumeratorIsSupported = false
try {
@ -1442,7 +1463,7 @@ class CallActivity : CallBaseActivity() {
Log.d(TAG, "localStream is null")
}
if (currentCallStatus !== CallStatus.LEAVING) {
hangup(true)
hangup(true, false)
}
powerManagerUtils!!.updatePhoneState(PowerManagerUtils.PhoneState.IDLE)
super.onDestroy()
@ -1726,7 +1747,7 @@ class CallActivity : CallBaseActivity() {
override fun onError(e: Throwable) {
Log.e(TAG, "Failed to join call", e)
Snackbar.make(binding!!.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
hangup(true)
hangup(true, false)
}
override fun onComplete() {
@ -1877,7 +1898,7 @@ class CallActivity : CallBaseActivity() {
Log.d(TAG, "onMessageEvent 'hello'")
if (!webSocketCommunicationEvent.getHashMap()!!.containsKey("oldResumeId")) {
if (currentCallStatus === CallStatus.RECONNECTING) {
hangup(false)
hangup(false, false)
} else {
setCallState(CallStatus.RECONNECTING)
runOnUiThread { initiateCall() }
@ -1953,7 +1974,7 @@ class CallActivity : CallBaseActivity() {
}
}
private fun hangup(shutDownView: Boolean) {
private fun hangup(shutDownView: Boolean, endCallForAll:Boolean) {
Log.d(TAG, "hangup! shutDownView=$shutDownView")
if (shutDownView) {
setCallState(CallStatus.LEAVING)
@ -2018,17 +2039,18 @@ class CallActivity : CallBaseActivity() {
ApplicationWideCurrentRoomHolder.getInstance().isInCall = false
ApplicationWideCurrentRoomHolder.getInstance().isDialing = false
hangupNetworkCalls(shutDownView)
hangupNetworkCalls(shutDownView,endCallForAll)
}
private fun hangupNetworkCalls(shutDownView: Boolean) {
private fun hangupNetworkCalls(shutDownView: Boolean, endCallForAll: Boolean) {
Log.d(TAG, "hangupNetworkCalls. shutDownView=$shutDownView")
val apiVersion = ApiUtils.getCallApiVersion(conversationUser, intArrayOf(ApiUtils.API_V4, 1))
if (callParticipantList != null) {
callParticipantList!!.removeObserver(callParticipantListObserver)
callParticipantList!!.destroy()
}
ncApi!!.leaveCall(credentials, ApiUtils.getUrlForCall(apiVersion, baseUrl, roomToken!!), false)
ncApi!!.leaveCall(credentials, ApiUtils.getUrlForCall(apiVersion, baseUrl, roomToken!!),endCallForAll)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<GenericOverall> {
@ -2122,7 +2144,7 @@ class CallActivity : CallBaseActivity() {
ApplicationWideCurrentRoomHolder.getInstance().isInCall
) {
Log.d(TAG, "Most probably a moderator ended the call for all.")
hangup(true)
hangup(true, false)
return
}
@ -2249,7 +2271,7 @@ class CallActivity : CallBaseActivity() {
context.resources.getString(R.string.nc_common_error_sorry),
Snackbar.LENGTH_LONG
).show()
hangup(true)
hangup(true,false)
return null
}
peerConnectionWrapper = if (hasMCU && publisher) {
@ -2565,7 +2587,7 @@ class CallActivity : CallBaseActivity() {
}
CallStatus.CALLING_TIMEOUT -> handler!!.post {
hangup(false)
hangup(false, false)
binding!!.callStates.callStateTextView.setText(R.string.nc_call_timeout)
binding!!.callModeTextView.text = descriptionForCallType
if (binding!!.callStates.callStateRelativeLayout.visibility != View.VISIBLE) {
@ -2835,7 +2857,7 @@ class CallActivity : CallBaseActivity() {
if (iceConnectionState == IceConnectionState.FAILED) {
setCallState(CallStatus.PUBLISHER_FAILED)
webSocketClient!!.clearResumeId()
hangup(false)
hangup(false, false)
}
}
}

View file

@ -247,7 +247,7 @@ public interface NcApi {
*/
@DELETE
Observable<GenericOverall> leaveCall(@Nullable @Header("Authorization") String authorization, @Url String url,
@Field("all") Boolean all);
@Query("all") Boolean all);
@GET
Observable<SignalingSettingsOverall> getSignalingSettings(@Nullable @Header("Authorization") String authorization,

View file

@ -94,7 +94,8 @@
android:src="@drawable/record_stop"
android:translationZ="2dp"
android:visibility="gone"
tools:visibility="visible"></ImageView>
tools:visibility="visible">
</ImageView>
</LinearLayout>
<LinearLayout
@ -182,14 +183,31 @@
android:layout_marginBottom="50dp">
</RelativeLayout>
<com.google.android.flexbox.FlexboxLayout
android:id="@+id/flexboxLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/standard_margin"
android:layout_marginBottom="@dimen/standard_half_margin"
app:flexDirection="row"
android:layout_alignParentBottom="true"
app:justifyContent="flex_end"
app:alignItems="center">
<Button
android:id="@+id/popup_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/end_call_for_everyone"
android:layout_marginEnd="8dp"
android:visibility="gone"
tools:visibility ="visible"/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/lower_hand_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="@dimen/standard_margin"
android:layout_marginBottom="@dimen/standard_half_margin"
android:contentDescription="@string/lower_hand"
android:visibility="gone"
app:backgroundTint="@color/call_buttons_background"
@ -200,6 +218,10 @@
app:tint="@color/white"
tools:visibility = "visible"/>
</com.google.android.flexbox.FlexboxLayout>
</RelativeLayout>
<com.google.android.flexbox.FlexboxLayout

View file

@ -310,6 +310,7 @@ How to translate with transifex:
<string name="lower_hand">Lower hand</string>
<string name="restrict_join_other_room_while_call">It\'s not possible to join other rooms while being in a call</string>
<string name="call_running_since_one_hour">The call has been running for one hour.</string>
<string name="end_call_for_everyone">End Call for Everyone</string>
<!-- Picture in Picture -->
<string name="nc_pip_microphone_mute">Mute microphone</string>