-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: android 12+ pip uses setAutoEnterEnabled api (#1643)
## Main Goal Android 12+ now uses setAutoEnterEnabled api instead of being dependent on onUserHint, which is buggy on these platforms when any external dialog like permission dialog comes. This adds the seamless animation transition support for Android whereever it is available. ## Side optimisiations * Added a a native workaround for PiP views from react native not being updated on Android 14 and above 🎉 * In JS part, moved PiP to one global state in StreamCall to avoid multiple state updates ## Android 15 https://github.com/user-attachments/assets/1d9d9021-d294-4650-b6c7-b39a0dc56cdf
- Loading branch information
1 parent
744b8d3
commit b07a9a6
Showing
18 changed files
with
458 additions
and
377 deletions.
There are no files selected for viewing
34 changes: 23 additions & 11 deletions
34
...ct-native-sdk/android/src/main/java/com/streamvideo/reactnative/StreamVideoReactNative.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,40 @@ | ||
package com.streamvideo.reactnative | ||
import kotlin.properties.Delegates | ||
|
||
import android.content.res.Configuration | ||
import java.util.concurrent.CopyOnWriteArrayList // For thread safety | ||
|
||
object StreamVideoReactNative { | ||
|
||
var pipListeners = ArrayList<(b: Boolean) -> Unit>() | ||
// Use CopyOnWriteArrayList for thread safety | ||
private val pipListeners = CopyOnWriteArrayList<(isInPip: Boolean, newConfig: Configuration) -> Unit>() | ||
|
||
@JvmField | ||
var canAutoEnterPictureInPictureMode = false | ||
|
||
// fires off every time value of the property changes | ||
private var isInPictureInPictureMode: Boolean by Delegates.observable(false) { _, _, newValue -> | ||
pipListeners.forEach {listener -> | ||
listener(newValue) | ||
} | ||
} | ||
private var isInPictureInPictureMode: Boolean = false | ||
|
||
@JvmStatic @Deprecated("No need to use setup() anymore") | ||
@Deprecated("No need to use setup() anymore") | ||
@JvmStatic | ||
fun setup() { | ||
// do nothing | ||
// Do nothing | ||
} | ||
|
||
@JvmStatic | ||
fun addPipListener(listener: (isInPip: Boolean, newConfig: Configuration) -> Unit) { | ||
pipListeners.add(listener) | ||
} | ||
|
||
@JvmStatic | ||
fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) { | ||
fun clearPipListeners() { | ||
pipListeners.clear() | ||
} | ||
|
||
@JvmStatic | ||
fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) { | ||
this.isInPictureInPictureMode = isInPictureInPictureMode | ||
// Iterate safely over the list | ||
pipListeners.forEach { listener -> | ||
listener(isInPictureInPictureMode, newConfig) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.