Skip to content

Commit

Permalink
Merge pull request #1269 from 100mslive/develop
Browse files Browse the repository at this point in the history
Release 1.9.3: Develop to main
  • Loading branch information
ygit authored Nov 20, 2023
2 parents 22c5ef5 + d81868b commit 21e52c8
Show file tree
Hide file tree
Showing 85 changed files with 3,089 additions and 2,800 deletions.
23 changes: 6 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,13 @@ on:
- "**.txt"

jobs:
check_lint_errors:
name: Trunk Check Runner
runs-on: ubuntu-latest
# trunk-ignore(checkov/CKV2_GHA_1)
permissions:
checks: write
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Trunk Check
uses: trunk-io/trunk-action@v1
with:
post-annotations: true

build_apk:
name: Build APK
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 30

# trunk-ignore(checkov/CKV2_GHA_1)
permissions:
checks: write
contents: read
Expand All @@ -64,6 +48,11 @@ jobs:
- name: Install dependencies
run: cd packages/react-native-room-kit/example/; npm install

- name: Trunk Check
uses: trunk-io/trunk-action@v1
with:
post-annotations: true

- name: Make Gradlew Executable
run: cd packages/react-native-room-kit/example/android && chmod +x ./gradlew

Expand Down
28 changes: 15 additions & 13 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
version: 0.1
cli:
version: 1.16.0
version: 1.17.2
plugins:
sources:
- id: trunk
ref: v1.2.3
ref: v1.2.6
uri: https://github.com/trunk-io/plugins
lint:
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- git-diff-check
- [email protected]
- buildifier@6.3.3
- buildifier@6.4.0
runtimes:
enabled:
- [email protected]
Expand Down
40 changes: 1 addition & 39 deletions 100ms.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion packages/react-native-hms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[![npm](https://img.shields.io/npm/v/@100mslive/react-native-hms)](https://www.npmjs.com/package/@100mslive/react-native-hms)
[![license](https://img.shields.io/npm/l/@100mslive/react-native-hms)](https://www.100ms.live/)
[![quality](https://img.shields.io/npms-io/quality-score/@100mslive/react-native-hms)](https://www.npmjs.com/package/@100mslive/react-native-hms)
[![vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/@100mslive/react-native-hms)](https://www.npmjs.com/package/@100mslive/react-native-hms)
[![collaborators](https://img.shields.io/npm/collaborators/@100mslive/react-native-hms)](https://www.npmjs.com/package/@100mslive/react-native-hms)
[![Documentation](https://img.shields.io/badge/Read-Documentation-blue)](https://docs.100ms.live/react-native/v2/foundation/basics)
[![Discord](https://img.shields.io/discord/843749923060711464?label=Join%20on%20Discord)](https://100ms.live/discord)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import live.hms.video.audio.HMSAudioManager
import live.hms.video.error.HMSException
import live.hms.video.events.AgentType
import live.hms.video.media.settings.*
import live.hms.video.media.tracks.HMSAudioTrack
import live.hms.video.media.tracks.HMSRemoteAudioTrack
import live.hms.video.media.tracks.HMSRemoteVideoTrack
import live.hms.video.media.tracks.HMSTrack
Expand Down Expand Up @@ -126,15 +127,18 @@ object HMSHelper {
val limit = 1
val peerIds = arrayListOf(peerId)
val peerListIterator = hmsSDK.getPeerListIterator(PeerListIteratorOptions(limit = limit, byPeerIds = peerIds))
peerListIterator.next(object : PeerListResultListener {
override fun onError(error: HMSException) {
it.resumeWithException(error)
}
override fun onSuccess(result: ArrayList<HMSPeer>) {
val peerFromIterator = result[0]
it.resume(peerFromIterator as? HMSRemotePeer)
}
})
peerListIterator.next(
object : PeerListResultListener {
override fun onError(error: HMSException) {
it.resumeWithException(error)
}

override fun onSuccess(result: ArrayList<HMSPeer>) {
val peerFromIterator = result[0]
it.resume(peerFromIterator as? HMSRemotePeer)
}
},
)
}
} else {
it.resume(null)
Expand Down Expand Up @@ -184,6 +188,13 @@ object HMSHelper {
return null
}

fun getAllAudioTracks(room: HMSRoom?): ArrayList<HMSAudioTrack>? {
if (room != null) {
return HmsUtilities.getAllAudioTracks(room)
}
return null
}

fun getRemoteVideoTrackFromTrackId(
trackId: String?,
room: HMSRoom?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.util.Rational
import android.view.WindowManager
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationManagerCompat
import com.facebook.react.bridge.*
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.modules.core.DeviceEventManagerModule
Expand All @@ -24,12 +26,13 @@ class HMSManager(reactContext: ReactApplicationContext) :
const val REACT_CLASS = "HMSManager"
var hmsCollection = mutableMapOf<String, HMSRNSDK>()

private var isInPIPMode = false
var reactAppContext: ReactApplicationContext? = null
var pipParamConfig: PipParamConfig? = null;
var pipParamsUntyped: Any? = null;
var pipParamConfig: PipParamConfig? = null
var pipParamsUntyped: Any? = null
var emitter: DeviceEventManagerModule.RCTDeviceEventEmitter? = null

fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) {
private fun emitPipEvent(isInPictureInPictureMode: Boolean) {
emitter?.let {
val data = Arguments.createMap()
data.putBoolean("isInPictureInPictureMode", isInPictureInPictureMode)
Expand All @@ -38,14 +41,32 @@ class HMSManager(reactContext: ReactApplicationContext) :
}
}

fun onPictureInPictureModeChanged(
isInPictureInPictureMode: Boolean,
newConfig: Configuration,
) {
if (isInPictureInPictureMode) {
isInPIPMode = true
}
}

fun onResume() {
if (isInPIPMode) {
isInPIPMode = false
reactAppContext?.currentActivity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
emitPipEvent(false)
}
}

fun onUserLeaveHint() {
val pipParams = pipParamsUntyped
if (
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
Build.VERSION.SDK_INT < Build.VERSION_CODES.S &&
pipParamConfig?.autoEnterPipMode == true &&
pipParams is android.app.PictureInPictureParams
) {
reactAppContext?.currentActivity?.window?.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
emitPipEvent(true)
reactAppContext?.currentActivity?.enterPictureInPictureMode(pipParams)
}
}
Expand All @@ -65,12 +86,13 @@ class HMSManager(reactContext: ReactApplicationContext) :

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
currentActivity?.let {
pipReceiver?.register(it)
pipReceiver?.register(it)
}
}

emitter = reactApplicationContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
emitter =
reactApplicationContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
}
}

Expand Down Expand Up @@ -301,7 +323,10 @@ class HMSManager(reactContext: ReactApplicationContext) :
}

@ReactMethod
fun setPlaybackAllowed(data: ReadableMap, callback: Promise?) {
fun setPlaybackAllowed(
data: ReadableMap,
callback: Promise?,
) {
val hms = HMSHelper.getHms(data, hmsCollection)

hms?.setPlaybackAllowed(data, callback)
Expand Down Expand Up @@ -348,7 +373,10 @@ class HMSManager(reactContext: ReactApplicationContext) :
}

@ReactMethod
fun setVolume(data: ReadableMap, callback: Promise?) {
fun setVolume(
data: ReadableMap,
callback: Promise?,
) {
val hms = HMSHelper.getHms(data, hmsCollection)

hms?.setVolume(data, callback)
Expand All @@ -365,7 +393,10 @@ class HMSManager(reactContext: ReactApplicationContext) :
}

@ReactMethod
fun setPlaybackForAllAudio(data: ReadableMap, callback: Promise?) {
fun setPlaybackForAllAudio(
data: ReadableMap,
callback: Promise?,
) {
val hms = HMSHelper.getHms(data, hmsCollection)

hms?.setPlaybackForAllAudio(data, callback)
Expand Down Expand Up @@ -573,14 +604,20 @@ class HMSManager(reactContext: ReactApplicationContext) :
}

@ReactMethod
fun switchAudioOutput(data: ReadableMap, callback: Promise?) {
fun switchAudioOutput(
data: ReadableMap,
callback: Promise?,
) {
val hms = HMSHelper.getHms(data, hmsCollection)

hms?.switchAudioOutput(data, callback)
}

@ReactMethod
fun setAudioMode(data: ReadableMap, callback: Promise?) {
fun setAudioMode(
data: ReadableMap,
callback: Promise?,
) {
val hms = HMSHelper.getHms(data, hmsCollection)

hms?.setAudioMode(data, callback)
Expand Down Expand Up @@ -851,9 +888,13 @@ class HMSManager(reactContext: ReactApplicationContext) :
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
it.setAutoEnterEnabled(config.autoEnterPipMode)
it.setSeamlessResizeEnabled(false)
}

// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
// it.setAutoEnterEnabled(config.autoEnterPipMode)
// }

// region Setting RemoteActions on PictureInPictureParams
val hmssdk = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]?.hmsSDK

Expand Down Expand Up @@ -1221,6 +1262,24 @@ class HMSManager(reactContext: ReactApplicationContext) :
hms?.peerListIteratorNext(data, promise)
}

@ReactMethod
fun checkNotifications(promise: Promise?) {
val reactAppContext = reactAppContext

if (reactAppContext == null) {
promise?.reject(Throwable("`reactAppContext` is not available!"))
return
}
val enabled = NotificationManagerCompat.from(reactAppContext).areNotificationsEnabled()
val data: WritableMap = Arguments.createMap()

data.putString("status", if (enabled) "granted" else "blocked")
val settings: WritableMap = Arguments.createMap()
data.putMap("settings", settings)

promise?.resolve(data)
}

fun emitEvent(
event: String,
data: WritableMap,
Expand Down
Loading

0 comments on commit 21e52c8

Please sign in to comment.