Skip to content

Commit

Permalink
Merge pull request #22 from 100mslive/dev
Browse files Browse the repository at this point in the history
Upgrade to 100ms SDK 0.9.16.2
  • Loading branch information
PratimMallick authored Mar 17, 2021
2 parents bdc021a + 3cb4f80 commit b3411fc
Show file tree
Hide file tree
Showing 75 changed files with 702 additions and 451 deletions.
13 changes: 9 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ plugins {

android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "live.hms.android100ms"
minSdkVersion 24
targetSdkVersion 30
versionCode 21
versionName "1.0.19"
versionCode 26
versionName "1.0.20"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -28,12 +28,17 @@ android {
buildConfigField "String", "BUG_REPORT_EMAIL_CC", BUG_REPORT_EMAIL_CC
minifyEnabled false
}

release {
buildConfigField "String", "TOKEN_ENDPOINT", TOKEN_ENDPOINT
buildConfigField "String", "BUG_REPORT_EMAIL_TO", BUG_REPORT_EMAIL_TO
buildConfigField "String", "BUG_REPORT_EMAIL_CC", BUG_REPORT_EMAIL_CC
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

firebaseCrashlytics {
mappingFileUploadEnabled true
}
}
}

Expand All @@ -58,7 +63,7 @@ dependencies {

//100ms.live SDK
implementation 'org.webrtc:google-webrtc:1.0.32006'
implementation 'com.github.100mslive:android-sdk:0.9.16'
implementation 'com.github.100mslive:android-sdk:0.9.16.2'

// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:2.3.3"
Expand Down
14 changes: 13 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

# https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports?platform=android
-keepattributes SourceFile,LineNumberTable # Keep file names and line numbers.
-keep public class * extends java.lang.Exception # Optional: Keep custom exceptions.

# https://developer.android.com/guide/navigation/navigation-pass-data#proguard_considerations
-keepnames class live.hms.android100ms.model.RoomDetails
-keepnames class live.hms.android100ms.ui.settings.SettingsMode

# Video libs
-keep class org.webrtc.** { *; }
-keep class live.hms.video.** { *; }
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
android:theme="@style/Theme.Android100ms.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -50,6 +51,7 @@
android:name=".ui.meeting.MeetingActivity"
android:label="@string/meeting"
android:launchMode="singleTask"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
android:theme="@style/Theme.Android100ms.NoActionBar" />

<provider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package live.hms.android100ms.api

import live.hms.android100ms.BuildConfig
import live.hms.android100ms.util.crashlytics
import live.hms.android100ms.util.crashlyticsLog
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

private const val TAG = "RetrofitBuilder"

private val okHttpClient = OkHttpClient.Builder()
.addInterceptor(HttpLoggingInterceptor().apply {
.addInterceptor(HttpLoggingInterceptor { crashlyticsLog(TAG, it) }.apply {
level = HttpLoggingInterceptor.Level.BODY
})
.callTimeout(10, TimeUnit.SECONDS)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package live.hms.android100ms.model

import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName

@Keep
data class TokenResponse(
@SerializedName("token") val token: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class HomeFragment : Fragment() {
"Created room ${data.roomId} \uD83E\uDD73",
Toast.LENGTH_SHORT
).show()
settings.lastUsedRoomId = data.roomId
tryJoiningRoomAs("Host")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.menu.MenuBuilder
import live.hms.android100ms.R
import live.hms.android100ms.databinding.ActivityMeetingBinding
import live.hms.android100ms.model.RoomDetails
import live.hms.android100ms.util.ROOM_DETAILS

class MeetingActivity : AppCompatActivity() {

Expand All @@ -23,13 +25,13 @@ class MeetingActivity : AppCompatActivity() {
_binding = ActivityMeetingBinding.inflate(layoutInflater)

setContentView(binding.root)
setSupportActionBar(binding.toolbar)
setSupportActionBar(binding.containerToolbar.toolbar)
supportActionBar?.setDisplayShowTitleEnabled(false)

if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
binding.toolbar.visibility = View.GONE
binding.containerToolbar.container.visibility = View.GONE
} else {
binding.toolbar.visibility = View.VISIBLE
binding.containerToolbar.container.visibility= View.VISIBLE
}

window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package live.hms.android100ms.ui.meeting

import android.annotation.SuppressLint
import android.content.Intent
import android.content.SharedPreferences
import android.content.res.Configuration
Expand All @@ -12,6 +13,8 @@ import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import com.google.android.material.badge.BadgeDrawable
import com.google.android.material.badge.BadgeUtils
import live.hms.android100ms.R
import live.hms.android100ms.audio.HMSAudioManager
import live.hms.android100ms.databinding.FragmentMeetingBinding
Expand Down Expand Up @@ -52,6 +55,8 @@ class MeetingFragment : Fragment() {

private var meetingViewMode = MeetingViewMode.GRID

private var isMeetingOngoing = false

private val onSettingsChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
if (SettingsStore.APPLY_CONSTRAINTS_KEYS.contains(key)) {
meetingViewModel.updateLocalMediaStreamConstraints()
Expand Down Expand Up @@ -135,9 +140,9 @@ class MeetingFragment : Fragment() {
private fun updateActionVolumeMenuIcon(item: MenuItem) {
item.apply {
if (meetingViewModel.isAudioMuted) {
setIcon(R.drawable.ic_baseline_volume_off_24)
setIcon(R.drawable.ic_volume_off_24)
} else {
setIcon(R.drawable.ic_baseline_volume_up_24)
setIcon(R.drawable.ic_volume_up_24)
}
}
}
Expand All @@ -148,12 +153,28 @@ class MeetingFragment : Fragment() {
menu.findItem(R.id.action_volume).apply {
updateActionVolumeMenuIcon(this)
setOnMenuItemClickListener {
meetingViewModel.toggleAudio()
updateActionVolumeMenuIcon(this)
if (isMeetingOngoing) {
meetingViewModel.toggleAudio()
updateActionVolumeMenuIcon(this)
}

true
}
}

menu.findItem(R.id.action_flip_camera).apply {
if (!settings.publishVideo) {
isVisible = false
isEnabled = false
} else {
isVisible = true
isEnabled = true
setOnMenuItemClickListener {
if (isMeetingOngoing) meetingViewModel.flipCamera()
true
}
}
}
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down Expand Up @@ -199,9 +220,21 @@ class MeetingFragment : Fragment() {

private fun initViewModel() {
chatViewModel.setSendBroadcastCallback { meetingViewModel.broadcastMessage(it) }
chatViewModel.unreadMessagesCount.observe(viewLifecycleOwner) { count ->
if (count > 0) {
binding.unreadMessageCount.apply {
visibility = View.VISIBLE
text = count.toString()
}
} else {
binding.unreadMessageCount.visibility = View.GONE
}
}

meetingViewModel.state.observe(viewLifecycleOwner) { state ->
Log.v(TAG, "Meeting State: $state")
isMeetingOngoing = false

when (state) {
is MeetingState.Failure -> {
cleanup()
Expand Down Expand Up @@ -248,6 +281,8 @@ class MeetingFragment : Fragment() {
is MeetingState.Ongoing -> {
startAudioManager()
hideProgressBar()

isMeetingOngoing = true
}
is MeetingState.Disconnecting -> {
updateProgressBarUI(state.heading, state.message)
Expand All @@ -266,17 +301,17 @@ class MeetingFragment : Fragment() {
meetingViewModel.isVideoEnabled.observe(viewLifecycleOwner) { enabled ->
binding.buttonToggleVideo.apply {
setIconResource(
if (enabled) R.drawable.ic_baseline_videocam_24
else R.drawable.ic_baseline_videocam_off_24
if (enabled) R.drawable.ic_videocam_24
else R.drawable.ic_videocam_off_24
)
}
}

meetingViewModel.isAudioEnabled.observe(viewLifecycleOwner) { enabled ->
binding.buttonToggleAudio.apply {
setIconResource(
if (enabled) R.drawable.ic_baseline_mic_24
else R.drawable.ic_baseline_mic_off_24
if (enabled) R.drawable.ic_mic_24
else R.drawable.ic_mic_off_24
)
}
}
Expand Down Expand Up @@ -392,19 +427,6 @@ class MeetingFragment : Fragment() {
}

binding.buttonEndCall.setOnSingleClickListener(350L) { meetingViewModel.leaveMeeting() }

binding.buttonFlipCamera.apply {
if (!settings.publishVideo) {
visibility = View.GONE
isEnabled = false
} else {
visibility = View.VISIBLE
isEnabled = true
setOnClickListener {
meetingViewModel.flipCamera()
}
}
}
}

private fun cleanup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import live.hms.android100ms.util.*
import live.hms.video.*
import live.hms.video.error.HMSException
import live.hms.video.events.HMSAnalyticsEventLevel
import live.hms.video.network.HMSNetworkQualityInfo
import live.hms.video.payload.HMSPayloadData
import live.hms.video.payload.HMSPublishStream
import live.hms.video.payload.HMSStreamInfo
Expand All @@ -37,6 +38,7 @@ class MeetingViewModel(
crashlytics.setCustomKey(ROOM_ID, roomId)
crashlytics.setCustomKey(USERNAME, username)
crashlytics.setCustomKey(ROOM_ENDPOINT, endpoint)
crashlytics.setCustomKey(AUTH_TOKEN, authToken)
}
}

Expand Down Expand Up @@ -71,6 +73,9 @@ class MeetingViewModel(
// Dominant speaker
val dominantSpeaker = MutableLiveData<MeetingTrack?>(null)

// Network Info
val networkInfo = MutableLiveData<HMSNetworkQualityInfo>()

val peer = HMSPeer(roomDetails.username, roomDetails.authToken).apply {
crashlytics.setUserId(customerUserId)
}
Expand Down Expand Up @@ -309,6 +314,7 @@ class MeetingViewModel(
Log.v(TAG, "Adding user track $currentDeviceTrack to VideoGrid")

if (settings.detectDominantSpeaker) startDetectDominantSpeakerMonitor()
if (settings.showNetworkInfo) startNetworkInfoMonitor()

state.postValue(MeetingState.Ongoing())
}
Expand Down Expand Up @@ -376,8 +382,9 @@ class MeetingViewModel(
* Resets all the values to default
*/
private fun cleanup() {
/** NOTE: Calling [HMSClient.disconnect] stop's the audio-level monitor
/** NOTE: Calling [HMSClient.disconnect] stop's the audio-level & network-info monitor
* However, we can manually stop it using [HMSClient.stopAudioLevelMonitor]
* and [HMSClient.stopNetworkMonitor] respectively
*/

// NOTE: Make sure that we have stopped capturing whenever we disconnect/leave/handle failures
Expand Down Expand Up @@ -410,6 +417,7 @@ class MeetingViewModel(
*/
private fun handleFailure(exception: HMSException) {
crashlyticsLog(TAG, "handleFailure(${toString(exception)})")
crashlytics.recordException(exception)

client.disconnect()
cleanup()
Expand All @@ -424,6 +432,8 @@ class MeetingViewModel(

override fun onDisconnect(exception: HMSException) {
crashlyticsLog(TAG, "onDisconnect: ${toString(exception)}")
crashlytics.recordException(exception)

cleanup()
state.postValue(MeetingState.Failure(exception))
}
Expand Down Expand Up @@ -541,4 +551,7 @@ class MeetingViewModel(
}
}

private fun startNetworkInfoMonitor() {
client.startNetworkMonitor { networkInfo.postValue(it[0]) }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package live.hms.android100ms.ui.meeting.chat

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import live.hms.android100ms.databinding.ListItemChatBinding
Expand All @@ -17,6 +18,7 @@ class ChatAdapter(
binding.name.text = message.senderName
val messages = message.messages.map { it.message }
binding.message.text = messages.joinToString("\n")
binding.blueBar.visibility = if (message.isSentByMe) View.VISIBLE else View.GONE
}
}

Expand Down
Loading

0 comments on commit b3411fc

Please sign in to comment.