mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-24 22:17:25 +00:00
feat: add stats and starting call bottom sheet
This commit is contained in:
@@ -154,8 +154,8 @@ dependencies {
|
||||
testImplementation 'org.robolectric:shadows-multidex:4.4'
|
||||
}
|
||||
|
||||
def canonicalVersionCode = 221
|
||||
def canonicalVersionName = "1.11.9"
|
||||
def canonicalVersionCode = 222
|
||||
def canonicalVersionName = "1.12.0"
|
||||
|
||||
def postFixSize = 10
|
||||
def abiPostFix = ['armeabi-v7a' : 1,
|
||||
|
@@ -2,7 +2,10 @@ package org.thoughtcrime.securesms.calls
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.android.synthetic.main.activity_webrtc_tests.*
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.isActive
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.messaging.messages.control.CallMessage
|
||||
import org.session.libsession.messaging.sending_receiving.MessageSender
|
||||
@@ -15,7 +18,7 @@ import org.webrtc.*
|
||||
|
||||
|
||||
class WebRtcTestsActivity: PassphraseRequiredActionBarActivity(), PeerConnection.Observer,
|
||||
SdpObserver {
|
||||
SdpObserver, RTCStatsCollectorCallback {
|
||||
|
||||
companion object {
|
||||
const val HD_VIDEO_WIDTH = 320
|
||||
@@ -123,6 +126,20 @@ class WebRtcTestsActivity: PassphraseRequiredActionBarActivity(), PeerConnection
|
||||
callAddress = intent.getParcelableExtra(EXTRA_ADDRESS) ?: run { finish(); return }
|
||||
peerConnection.createOffer(this, MediaConstraints())
|
||||
}
|
||||
|
||||
lifecycleScope.launchWhenResumed {
|
||||
while (this.isActive) {
|
||||
delay(5_000L)
|
||||
peerConnection.getStats(this@WebRtcTestsActivity)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onStatsDelivered(statsReport: RTCStatsReport?) {
|
||||
statsReport?.let { report ->
|
||||
Log.d("Loki-RTC", "report is: $report")
|
||||
}
|
||||
}
|
||||
|
||||
private fun endCall() {
|
||||
@@ -131,6 +148,7 @@ class WebRtcTestsActivity: PassphraseRequiredActionBarActivity(), PeerConnection
|
||||
CallMessage(SignalServiceProtos.CallMessage.Type.END_CALL,emptyList(),emptyList(), emptyList()),
|
||||
callAddress
|
||||
)
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@@ -36,13 +36,12 @@ import org.session.libsession.messaging.sending_receiving.MessageSender
|
||||
import org.session.libsession.messaging.utilities.WebRtcUtils
|
||||
import org.session.libsession.utilities.*
|
||||
import org.session.libsession.utilities.Util
|
||||
import org.session.libsignal.utilities.Log
|
||||
import org.session.libsignal.protos.SignalServiceProtos.CallMessage.Type.*
|
||||
import org.session.libsignal.utilities.ThreadUtils
|
||||
import org.session.libsignal.utilities.toHexString
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.MuteDialog
|
||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||
import org.thoughtcrime.securesms.calls.WebRtcTestsActivity
|
||||
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
||||
import org.thoughtcrime.securesms.conversation.v2.utilities.NotificationUtils
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
||||
@@ -58,6 +57,7 @@ import org.thoughtcrime.securesms.onboarding.SeedActivity
|
||||
import org.thoughtcrime.securesms.onboarding.SeedReminderViewDelegate
|
||||
import org.thoughtcrime.securesms.preferences.SettingsActivity
|
||||
import org.thoughtcrime.securesms.util.*
|
||||
import org.thoughtcrime.securesms.webrtc.CallBottomSheet
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
@@ -139,30 +139,54 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), ConversationClickLis
|
||||
// web rtc channel handling
|
||||
for (message in WebRtcUtils.SIGNAL_QUEUE) {
|
||||
val sender = Address.fromSerialized(message.sender!!)
|
||||
val intent = Intent(this@HomeActivity, WebRtcTestsActivity::class.java)
|
||||
val bundle = bundleOf(
|
||||
WebRtcTestsActivity.EXTRA_ADDRESS to sender,
|
||||
)
|
||||
if (message.sdps.isNotEmpty() && message.sdpMids.isEmpty()) {
|
||||
// offer message
|
||||
Log.d("Loki-RTC", "answer receive")
|
||||
val sdps = message.sdps
|
||||
intent.action = WebRtcTestsActivity.ACTION_ANSWER
|
||||
bundle.putStringArray(WebRtcTestsActivity.EXTRA_SDP, sdps.toTypedArray())
|
||||
} else if (message.sdpMids.isNotEmpty()) {
|
||||
// ice candidates message
|
||||
Log.d("Loki-RTC", "update ice intent")
|
||||
val sdpMLineIndexes = message.sdpMLineIndexes
|
||||
val sdpMids = message.sdpMids
|
||||
val sdps = message.sdps
|
||||
intent.action = WebRtcTestsActivity.ACTION_UPDATE_ICE
|
||||
bundle.putStringArray(WebRtcTestsActivity.EXTRA_SDP, sdps.toTypedArray())
|
||||
bundle.putIntArray(WebRtcTestsActivity.EXTRA_SDP_MLINE_INDEXES, sdpMLineIndexes.toIntArray())
|
||||
bundle.putStringArray(WebRtcTestsActivity.EXTRA_SDP_MIDS, sdpMids.toTypedArray())
|
||||
synchronized(WebRtcUtils.callCache) {
|
||||
val set = WebRtcUtils.callCache[sender] ?: mutableSetOf()
|
||||
set += message
|
||||
WebRtcUtils.callCache[sender] = set
|
||||
}
|
||||
|
||||
intent.putExtras(bundle)
|
||||
startActivity(intent)
|
||||
when (message.type) {
|
||||
OFFER -> {
|
||||
// show bottom sheet
|
||||
CallBottomSheet().apply {
|
||||
arguments = bundleOf(
|
||||
CallBottomSheet.ARGUMENT_ADDRESS to sender,
|
||||
CallBottomSheet.ARGUMENT_SDP to message.sdps.toTypedArray(),
|
||||
CallBottomSheet.ARGUMENT_TYPE to message.type!!.number
|
||||
)
|
||||
show(this@HomeActivity.supportFragmentManager,"call-sheet")
|
||||
}
|
||||
}
|
||||
ICE_CANDIDATES -> {
|
||||
// do nothing, already have candidates saved
|
||||
}
|
||||
END_CALL -> {
|
||||
// do nothing, maybe clear the callCache or something
|
||||
}
|
||||
}
|
||||
// val intent = Intent(this@HomeActivity, WebRtcTestsActivity::class.java)
|
||||
// val bundle = bundleOf(
|
||||
// WebRtcTestsActivity.EXTRA_ADDRESS to sender,
|
||||
// )
|
||||
// if (message.sdps.isNotEmpty() && message.sdpMids.isEmpty()) {
|
||||
// // offer message
|
||||
// Log.d("Loki-RTC", "answer receive")
|
||||
// val sdps = message.sdps
|
||||
// intent.action = WebRtcTestsActivity.ACTION_ANSWER
|
||||
// bundle.putStringArray(WebRtcTestsActivity.EXTRA_SDP, sdps.toTypedArray())
|
||||
// } else if (message.sdpMids.isNotEmpty()) {
|
||||
// // ice candidates message
|
||||
// Log.d("Loki-RTC", "update ice intent")
|
||||
// val sdpMLineIndexes = message.sdpMLineIndexes
|
||||
// val sdpMids = message.sdpMids
|
||||
// val sdps = message.sdps
|
||||
// intent.action = WebRtcTestsActivity.ACTION_UPDATE_ICE
|
||||
// bundle.putStringArray(WebRtcTestsActivity.EXTRA_SDP, sdps.toTypedArray())
|
||||
// bundle.putIntArray(WebRtcTestsActivity.EXTRA_SDP_MLINE_INDEXES, sdpMLineIndexes.toIntArray())
|
||||
// bundle.putStringArray(WebRtcTestsActivity.EXTRA_SDP_MIDS, sdpMids.toTypedArray())
|
||||
// }
|
||||
//
|
||||
// intent.putExtras(bundle)
|
||||
// startActivity(intent)
|
||||
}
|
||||
}
|
||||
lifecycleScope.launchWhenStarted {
|
||||
|
@@ -0,0 +1,45 @@
|
||||
package org.thoughtcrime.securesms.webrtc
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import kotlinx.android.synthetic.main.fragment_user_details_bottom_sheet.*
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.utilities.Address
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
|
||||
class CallBottomSheet: BottomSheetDialogFragment() {
|
||||
|
||||
companion object {
|
||||
const val ARGUMENT_ADDRESS = "CallBottomSheet_ADDRESS"
|
||||
const val ARGUMENT_SDP = "CallBottomSheet_SDP"
|
||||
const val ARGUMENT_TYPE = "CallBottomSheet_TYPE"
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_call_bottom_sheet, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val address = arguments?.getParcelable<Address>(ARGUMENT_ADDRESS) ?: return dismiss()
|
||||
val sdp = arguments?.getStringArray(ARGUMENT_SDP) ?: return dismiss()
|
||||
val type = arguments?.getString(ARGUMENT_TYPE) ?: return dismiss()
|
||||
val recipient = Recipient.from(requireContext(), address, false)
|
||||
profilePictureView.publicKey = address.serialize()
|
||||
profilePictureView.glide = GlideApp.with(this)
|
||||
profilePictureView.isLarge = true
|
||||
profilePictureView.update(recipient, -1)
|
||||
|
||||
nameTextView.text = recipient.name ?: address.serialize()
|
||||
|
||||
}
|
||||
}
|
77
app/src/main/res/layout/fragment_call_bottom_sheet.xml
Normal file
77
app/src/main/res/layout/fragment_call_bottom_sheet.xml
Normal file
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingLeft="@dimen/large_spacing"
|
||||
android:paddingRight="@dimen/large_spacing"
|
||||
android:paddingBottom="@dimen/large_spacing"
|
||||
app:behavior_hideable="true"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
|
||||
<org.thoughtcrime.securesms.components.ProfilePictureView
|
||||
android:id="@+id/profilePictureView"
|
||||
android:layout_width="@dimen/large_profile_picture_size"
|
||||
android:layout_height="@dimen/large_profile_picture_size"
|
||||
android:layout_marginTop="@dimen/large_spacing"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nameTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="@dimen/small_spacing"
|
||||
android:layout_marginEnd="@dimen/small_spacing"
|
||||
android:textSize="@dimen/large_font_size"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/text"
|
||||
android:textAlignment="center"
|
||||
tools:text="Incoming call from... big name here of a user" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_marginTop="@dimen/medium_spacing"
|
||||
android:paddingVertical="@dimen/medium_spacing"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
style="@style/Widget.Session.Button.Common.ProminentOutline"
|
||||
android:layout_marginHorizontal="@dimen/small_spacing"
|
||||
android:id="@+id/acceptButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/medium_button_height"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="@dimen/large_spacing"
|
||||
android:paddingRight="@dimen/large_spacing"
|
||||
android:text="Accept" />
|
||||
|
||||
<TextView
|
||||
style="@style/Widget.Session.Button.Common.ProminentFilled"
|
||||
android:backgroundTint="@color/destructive"
|
||||
android:layout_marginHorizontal="@dimen/small_spacing"
|
||||
android:id="@+id/declineButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/medium_button_height"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="@dimen/large_spacing"
|
||||
android:paddingRight="@dimen/large_spacing"
|
||||
android:text="Decline" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
Reference in New Issue
Block a user