Browse Source

implement long click and short click on hangup button

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
sowjanyakch 8 months ago
parent
commit
ed9fc185bf

+ 40 - 18
app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt

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

+ 1 - 1
app/src/main/java/com/nextcloud/talk/api/NcApi.java

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

+ 28 - 6
app/src/main/res/layout/call_activity.xml

@@ -94,7 +94,8 @@
                     android:src="@drawable/record_stop"
                     android:src="@drawable/record_stop"
                     android:translationZ="2dp"
                     android:translationZ="2dp"
                     android:visibility="gone"
                     android:visibility="gone"
-                    tools:visibility="visible"></ImageView>
+                    tools:visibility="visible">
+                </ImageView>
             </LinearLayout>
             </LinearLayout>
 
 
             <LinearLayout
             <LinearLayout
@@ -182,14 +183,31 @@
                 android:layout_marginBottom="50dp">
                 android:layout_marginBottom="50dp">
             </RelativeLayout>
             </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
             <com.google.android.material.floatingactionbutton.FloatingActionButton
                 android:id="@+id/lower_hand_button"
                 android:id="@+id/lower_hand_button"
                 android:layout_width="wrap_content"
                 android:layout_width="wrap_content"
                 android:layout_height="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:contentDescription="@string/lower_hand"
                 android:visibility="gone"
                 android:visibility="gone"
                 app:backgroundTint="@color/call_buttons_background"
                 app:backgroundTint="@color/call_buttons_background"
@@ -198,7 +216,11 @@
                 app:shapeAppearance="@style/fab_3_rounded"
                 app:shapeAppearance="@style/fab_3_rounded"
                 app:srcCompat="@drawable/ic_baseline_do_not_touch_24"
                 app:srcCompat="@drawable/ic_baseline_do_not_touch_24"
                 app:tint="@color/white"
                 app:tint="@color/white"
-                tools:visibility="visible" />
+                tools:visibility = "visible"/>
+
+        </com.google.android.flexbox.FlexboxLayout>
+
+
 
 
         </RelativeLayout>
         </RelativeLayout>
 
 

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -310,6 +310,7 @@ How to translate with transifex:
     <string name="lower_hand">Lower hand</string>
     <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="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="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 -->
     <!-- Picture in Picture -->
     <string name="nc_pip_microphone_mute">Mute microphone</string>
     <string name="nc_pip_microphone_mute">Mute microphone</string>