Skip to content

Commit

Permalink
Merge pull request #740 from 100mslive/dev
Browse files Browse the repository at this point in the history
1.2.15 release
  • Loading branch information
PratimMallick authored Jun 26, 2024
2 parents 9163e00 + 48fd861 commit 14ab265
Show file tree
Hide file tree
Showing 18 changed files with 178 additions and 80 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dependencies {
implementation "live.100ms:room-kit:$HMS_ROOM_KIT_VERSION"

//100ms noise cancellation dep
def hmsVersion = "2.9.61"
def hmsVersion = "2.9.62"
implementation "live.100ms:hms-noise-cancellation-android:$hmsVersion"

// Navigation
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/live/hms/app2/ui/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ class HomeFragment : Fragment() {
validate()
}

binding.troubleshoot.setOnClickListener {
contextSafe { context, activity ->
HMSRoomKit.launchPreCallDiagnostic(activity)
}
}

binding.edtMeetingUrl.doOnTextChanged { text, _, _, _ ->
if (text.isNullOrEmpty()) {
binding.tvMeetingUrlInputLayout.hint =
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_diagnostic_blue.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="21dp"
android:viewportWidth="20"
android:viewportHeight="21">
<path
android:pathData="M9.999,2.386C10.426,2.369 10.847,2.49 11.2,2.73C11.431,2.887 11.625,3.09 11.771,3.325H11.875C12.165,3.325 12.443,3.44 12.648,3.645C12.816,3.813 12.924,4.03 12.958,4.262H14.219C14.633,4.262 15.031,4.427 15.324,4.72C15.617,5.013 15.781,5.41 15.781,5.825V10.512C15.781,10.857 15.501,11.137 15.156,11.137C14.811,11.137 14.531,10.857 14.531,10.512V5.825C14.531,5.742 14.498,5.662 14.44,5.604C14.381,5.545 14.302,5.512 14.219,5.512H12.969V6.293C12.969,6.583 12.854,6.862 12.648,7.067C12.443,7.272 12.165,7.387 11.875,7.387H8.125C7.835,7.387 7.557,7.272 7.352,7.067C7.146,6.862 7.031,6.583 7.031,6.293V5.512H5.781C5.698,5.512 5.619,5.545 5.56,5.604C5.502,5.662 5.469,5.742 5.469,5.825V10.512C5.469,10.857 5.189,11.137 4.844,11.137C4.499,11.137 4.219,10.857 4.219,10.512V5.825C4.219,5.41 4.383,5.013 4.676,4.72C4.969,4.427 5.367,4.262 5.781,4.262H7.042C7.076,4.03 7.184,3.813 7.352,3.645C7.557,3.44 7.835,3.325 8.125,3.325H8.232C8.378,3.091 8.571,2.888 8.802,2.731C9.154,2.491 9.574,2.37 9.999,2.386ZM8.281,6.137H11.719V4.575H11.378C11.108,4.575 10.869,4.402 10.785,4.145C10.733,3.99 10.632,3.856 10.497,3.764C10.361,3.671 10.199,3.627 10.036,3.636C10.012,3.637 9.989,3.637 9.966,3.636C9.802,3.627 9.641,3.672 9.506,3.764C9.371,3.856 9.27,3.99 9.218,4.146C9.134,4.402 8.895,4.575 8.625,4.575H8.281V6.137ZM8.034,11.154L9.213,14.395C9.27,14.557 9.374,14.698 9.512,14.8C9.652,14.903 9.82,14.962 9.993,14.968C10.167,14.974 10.339,14.927 10.485,14.833C10.63,14.741 10.743,14.608 10.811,14.45L11.911,11.977L12.191,12.537L12.192,12.539C12.263,12.681 12.373,12.801 12.509,12.884C12.644,12.968 12.801,13.012 12.96,13.012C12.96,13.012 12.96,13.012 12.96,13.012H17.031C17.376,13.012 17.656,12.732 17.656,12.387C17.656,12.042 17.376,11.762 17.031,11.762H13.201L12.659,10.677C12.586,10.531 12.474,10.409 12.334,10.325C12.195,10.241 12.034,10.198 11.871,10.202C11.708,10.206 11.55,10.255 11.414,10.346C11.279,10.436 11.172,10.563 11.105,10.711L10.059,13.065L8.899,9.873C8.841,9.715 8.739,9.577 8.604,9.477C8.469,9.377 8.307,9.318 8.14,9.309C7.972,9.299 7.805,9.339 7.66,9.423C7.514,9.508 7.397,9.633 7.322,9.783C7.322,9.783 7.322,9.783 7.322,9.783L6.333,11.762H2.969C2.624,11.762 2.344,12.042 2.344,12.387C2.344,12.732 2.624,13.012 2.969,13.012H6.574C6.573,13.012 6.574,13.012 6.574,13.012C6.733,13.012 6.889,12.968 7.025,12.884C7.161,12.801 7.27,12.681 7.342,12.539L7.343,12.537L8.034,11.154ZM4.844,13.637C5.189,13.637 5.469,13.917 5.469,14.262V16.137C5.469,16.22 5.502,16.299 5.56,16.358C5.619,16.417 5.698,16.449 5.781,16.449H14.219C14.302,16.449 14.381,16.417 14.44,16.358C14.498,16.299 14.531,16.22 14.531,16.137V14.262C14.531,13.917 14.811,13.637 15.156,13.637C15.501,13.637 15.781,13.917 15.781,14.262V16.137C15.781,16.551 15.617,16.949 15.324,17.242C15.031,17.535 14.633,17.699 14.219,17.699H5.781C5.367,17.699 4.969,17.535 4.676,17.242C4.383,16.949 4.219,16.551 4.219,16.137V14.262C4.219,13.917 4.499,13.637 4.844,13.637Z"
android:fillColor="#538DFF"
android:fillType="evenOdd"/>
</vector>
17 changes: 15 additions & 2 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,31 @@ android:orientation="vertical">
android:layout_gravity="center"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="@string/meeting_link_header_description"
android:textColor="#E0ECFF"
android:textSize="16sp" />

<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="15dp"
android:maxLines="1"
android:id="@+id/troubleshoot"
android:drawableLeft="@drawable/ic_diagnostic_blue"
android:textColorLink="#538DFF"
android:text="@string/troubles_joining_str"
android:textColor="#538DFF"
android:textSize="16sp" />

<EditText
android:id="@+id/edit_text_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="40dp"
android:layout_marginTop="24dp"
android:autofillHints=""
android:background="@drawable/gray_round_btn"
android:fontFamily="@font/inter_regular"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
<string name="paste_the_link_here_str">Paste the link here</string>
<string name="joining_link_header">Joining Link</string>
<string name="meeting_link_header_description">Jump right in by pasting a room link or scanning a QR code</string>
<string name="troubles_joining_str">Troubleshoot before you join</string>
<string name="meeting_link_header">Experience the power of 100ms</string>
<string name="join_with_link_instead_str">Join with Link Instead</string>
<string name="scan_qr_code_str">Scan QR Code</string>
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
100MS_APP_VERSION_CODE=375
100MS_APP_VERSION_NAME=5.0.9
100MS_APP_VERSION_CODE=376
100MS_APP_VERSION_NAME=5.0.10
hmsRoomKitGroup=live.100ms
HMS_ROOM_KIT_VERSION=1.2.14
HMS_ROOM_KIT_VERSION=1.2.15
android.suppressUnsupportedCompileSdk=33
8 changes: 8 additions & 0 deletions room-kit/src/main/java/live/hms/roomkit/ViewExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ fun View.setOnSingleClickListener(l: (View) -> Unit) {
setOnClickListener(OnSingleClickListener(l))
}

fun Number?.orZeroIfNullOrNaN(): Number {
return if (this == null || (this is Double && this.isNaN()) || (this is Float && this.isNaN())) {
0
} else {
this
}
}

fun View.gone() {
if (this.visibility != View.GONE)
this.visibility = View.GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.navigation.fragment.findNavController
import live.hms.roomkit.R
import live.hms.roomkit.ui.meeting.MeetingViewModel
import live.hms.roomkit.ui.meeting.MeetingViewModelFactory
import live.hms.roomkit.ui.theme.HMSPrebuiltTheme

class DiagnosticActivity : AppCompatActivity() {

Expand All @@ -21,6 +22,9 @@ class DiagnosticActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_diagnostic)
if (HMSPrebuiltTheme.getColours() == null) {
HMSPrebuiltTheme.setTheme(HMSPrebuiltTheme.getDefaultHmsColorPalette())
}
viewModel.initSDK()
setupNavGraph()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package live.hms.roomkit.ui.diagnostic

import android.app.Application
import android.content.Context
import androidx.core.content.edit
import live.hms.video.diagnostics.HMSDiagnostic
import live.hms.video.sdk.HMSSDK
import java.util.UUID

class DiagnosticProvider(private val application: Application) {
private var hms : Pair<HMSSDK,HMSDiagnostic>? = null
private val consistentUserId = getConsistentUserIdOverSessions()
fun disposeOfDiagnostic() {
hms?.second?.stopConnectivityCheck()
hms = null
}
fun getSdk() = hms?.first ?: createInstance(application).first
fun getDiagnosticSdk() : HMSDiagnostic = hms?.second ?: createInstance(application).second
private fun createInstance(application: Application) : Pair<HMSSDK, HMSDiagnostic> {
val hmsSDK = HMSSDK.Builder(application).build()
val diag = hmsSDK.getDiagnosticSDK(consistentUserId)
return Pair(hmsSDK, diag).apply { hms = this }
}

private fun getConsistentUserIdOverSessions(): String {
val sharedPreferences = application.getSharedPreferences(
"your-activity-preference", Context.MODE_PRIVATE
)
if (sharedPreferences.getString("saved_user_id_blocklist", null) == null) {
sharedPreferences.edit {
putString(
"saved_user_id_blocklist", UUID.randomUUID().toString()
)
}
}
return sharedPreferences.getString("saved_user_id_blocklist", null).orEmpty()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.lifecycle.MutableLiveData
import live.hms.video.audio.HMSAudioManager
import live.hms.video.diagnostics.HMSAudioDeviceCheckListener
import live.hms.video.diagnostics.HMSCameraCheckListener
import live.hms.video.diagnostics.HMSDiagnostic
import live.hms.video.diagnostics.models.ConnectivityCheckResult
import live.hms.video.diagnostics.models.ConnectivityState
import live.hms.video.error.HMSException
Expand All @@ -20,10 +21,12 @@ import java.util.UUID

class DiagnosticViewModel(application: Application) : AndroidViewModel(application) {
// First create a new sdk instance
val hmsSDK by lazy { HMSSDK.Builder(application).build() }
var regionCode = "in"
val diagnosticSDK by lazy { hmsSDK.getDiagnosticSDK(getConsistentUserIdOverSessions()) }

private var regionCode = "in"
private val diagnosticProvider = DiagnosticProvider(application)
private val diagnosticSDK : HMSDiagnostic
get() {return diagnosticProvider.getDiagnosticSdk()}
private val hmsSDK : HMSSDK
get() { return diagnosticProvider.getSdk()}
val cameraTrackLiveData = MutableLiveData<HMSVideoTrack?>()
fun cameraPermssionGranted() {
diagnosticSDK.startCameraCheck(
Expand All @@ -49,21 +52,6 @@ class DiagnosticViewModel(application: Application) : AndroidViewModel(applicati
}
}


private fun getConsistentUserIdOverSessions(): String {
val sharedPreferences = getApplication<Application>().getSharedPreferences(
"your-activity-preference", Context.MODE_PRIVATE
)
if (sharedPreferences.getString("saved_user_id_blocklist", null) == null) {
sharedPreferences.edit {
putString(
"saved_user_id_blocklist", UUID.randomUUID().toString()
)
}
}
return sharedPreferences.getString("saved_user_id_blocklist", null).orEmpty()
}

fun stopCameraCheck() {
diagnosticSDK.stopCameraCheck()
cameraTrackLiveData.postValue(null)
Expand Down Expand Up @@ -126,9 +114,11 @@ class DiagnosticViewModel(application: Application) : AndroidViewModel(applicati
var isMediaCaptured : Boolean = false
var isMediaPublished : Boolean = false
fun startConnectivityTest() {
diagnosticProvider.disposeOfDiagnostic()
isMediaPublished= false
isMediaCaptured = false
connectivityLiveData.postValue(null)
connectivityStateLiveData.postValue(null)
diagnosticSDK.startConnectivityCheck(regionCode,
object : live.hms.video.diagnostics.ConnectivityCheckListener {
override fun onCompleted(result: ConnectivityCheckResult) {
Expand Down Expand Up @@ -156,5 +146,6 @@ class DiagnosticViewModel(application: Application) : AndroidViewModel(applicati
kotlin.runCatching { diagnosticSDK.startSpeakerCheck() }
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class PreCallAudioSwitchDialog(

private fun setAudioType(audioDevice: HMSAudioManager.AudioDevice) {
vm.switchAudioOutput(audioDevice)
onOptionItemClicked?.invoke(vm.hmsSDK.getAudioOutputRouteType(), true)
onOptionItemClicked?.invoke(vm.getAudioOutputRouteType(), true)
dismiss()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import live.hms.roomkit.R
import live.hms.roomkit.databinding.FragmentPreCallCameraBinding
import live.hms.roomkit.databinding.FragmentPreCallMicBinding
import live.hms.roomkit.databinding.FragmentPreCallRegionSelectionBinding
import live.hms.roomkit.gone
import live.hms.roomkit.setOnSingleClickListener
import live.hms.roomkit.show
import live.hms.roomkit.ui.diagnostic.DiagnosticViewModel
import live.hms.roomkit.ui.diagnostic.DiagnosticViewModelFactory
import live.hms.roomkit.ui.theme.applyTheme
Expand Down Expand Up @@ -70,13 +72,15 @@ class PreCallCameraFragment : Fragment() {
}
})

binding.buttonSwitchCamera.gone()
vm.cameraTrackLiveData.observe(viewLifecycleOwner) { cameraTrack ->
cameraTrack?.let {
binding.buttonSwitchCamera.show()
binding.videoView.addTrack(it)
}
}

binding.videoView.setOnSingleClickListener {
binding.buttonSwitchCamera.setOnSingleClickListener {
vm.cameraTrackLiveData.value?.switchCamera()
}
//check if camera permission is granted
Expand Down
Loading

0 comments on commit 14ab265

Please sign in to comment.