@robono/calling-react-native 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/SBOM.spdx.json +402 -354
- package/android/consumer-rules.pro +4 -0
- package/android/src/main/java/com/robono/calling/CallingPackage.java +1 -1
- package/android/src/main/java/com/robono/calling/CallingPictureInPicture.java +102 -0
- package/app.plugin.cjs +8 -0
- package/dist/components.d.ts +4 -0
- package/dist/components.js +5 -4
- package/dist/native-video.js +18 -1
- package/dist/versions.d.ts +1 -1
- package/dist/versions.js +1 -1
- package/ios/RobonoCallingRuntime.m +1 -0
- package/package.json +1 -1
- package/plugin/picture-in-picture.cjs +26 -0
|
@@ -12,3 +12,7 @@
|
|
|
12
12
|
public void onNewToken(java.lang.String);
|
|
13
13
|
public void onDeletedMessages();
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
# Optional WebRTC renderer uses its normal public manager, including its thread and release handling.
|
|
17
|
+
-keep class com.oney.WebRTCModule.WebRTCView { public <init>(android.content.Context); public void setObjectFit(java.lang.String); }
|
|
18
|
+
-keep class com.oney.WebRTCModule.RTCVideoViewManager { public <init>(); public void setStreamURL(com.oney.WebRTCModule.WebRTCView,java.lang.String); }
|
|
@@ -9,7 +9,7 @@ import java.util.List;
|
|
|
9
9
|
|
|
10
10
|
public final class CallingPackage implements ReactPackage {
|
|
11
11
|
public List<NativeModule> createNativeModules(ReactApplicationContext context) {
|
|
12
|
-
return java.util.Arrays.asList(new CallingRuntime(context),new SystemCalling(context));
|
|
12
|
+
return java.util.Arrays.asList(new CallingRuntime(context),new SystemCalling(context),new CallingPictureInPicture(context));
|
|
13
13
|
}
|
|
14
14
|
public List<ViewManager> createViewManagers(ReactApplicationContext context) { return Collections.emptyList(); }
|
|
15
15
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
package com.robono.calling;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.app.Application;
|
|
5
|
+
import android.app.PictureInPictureParams;
|
|
6
|
+
import android.os.Build;
|
|
7
|
+
import android.os.Bundle;
|
|
8
|
+
import android.os.Handler;
|
|
9
|
+
import android.os.Looper;
|
|
10
|
+
import android.graphics.Color;
|
|
11
|
+
import android.view.View;
|
|
12
|
+
import android.view.ViewGroup;
|
|
13
|
+
import android.widget.FrameLayout;
|
|
14
|
+
import com.facebook.react.bridge.*;
|
|
15
|
+
import java.lang.ref.WeakReference;
|
|
16
|
+
import java.util.IdentityHashMap;
|
|
17
|
+
|
|
18
|
+
/** Uses the existing activity: Android forbids starting a new activity after Home. */
|
|
19
|
+
public final class CallingPictureInPicture extends ReactContextBaseJavaModule implements Application.ActivityLifecycleCallbacks {
|
|
20
|
+
private static WeakReference<CallingPictureInPicture> instance = new WeakReference<>(null);
|
|
21
|
+
private final Handler handler = new Handler(Looper.getMainLooper());
|
|
22
|
+
private final IdentityHashMap<View,Integer> hidden = new IdentityHashMap<>();
|
|
23
|
+
private WeakReference<Activity> owner = new WeakReference<>(null);
|
|
24
|
+
private String streamURL, renderedURL;
|
|
25
|
+
private int width=9,height=16,sourceTag;
|
|
26
|
+
private FrameLayout mainCover;
|
|
27
|
+
private FrameLayout overlay;
|
|
28
|
+
private View renderer;
|
|
29
|
+
private Object manager;
|
|
30
|
+
private Class<?> videoView;
|
|
31
|
+
private boolean launching;
|
|
32
|
+
private final Runnable observe = new Runnable(){public void run(){
|
|
33
|
+
Activity activity=owner.get();
|
|
34
|
+
if(activity==null||activity.isDestroyed()||!activity.isInPictureInPictureMode())release();
|
|
35
|
+
else handler.postDelayed(this,250);
|
|
36
|
+
}};
|
|
37
|
+
public CallingPictureInPicture(ReactApplicationContext context){super(context);instance=new WeakReference<>(this);((Application)context.getApplicationContext()).registerActivityLifecycleCallbacks(this);}
|
|
38
|
+
@Override public String getName(){return "RobonoCallingPictureInPicture";}
|
|
39
|
+
@ReactMethod public void setSource(String url,int sourceWidth,int sourceHeight,boolean enabled,int reactTag,Promise promise){
|
|
40
|
+
UiThreadUtil.runOnUiThread(()->{
|
|
41
|
+
sourceTag=reactTag;
|
|
42
|
+
streamURL=enabled&&url!=null&&!url.isEmpty()?url:null;
|
|
43
|
+
if(sourceWidth>0&&sourceHeight>0){width=sourceWidth;height=sourceHeight;}
|
|
44
|
+
Activity activity=owner.get();
|
|
45
|
+
if(streamURL==null){
|
|
46
|
+
// Keep the opaque cover until Android has removed the pinned window.
|
|
47
|
+
detachVideo();
|
|
48
|
+
if(activity!=null&&Build.VERSION.SDK_INT>=26&&activity.isInPictureInPictureMode())activity.moveTaskToBack(true);
|
|
49
|
+
else release();
|
|
50
|
+
}else if(renderer!=null){try{refreshSource();if(activity!=null)activity.setPictureInPictureParams(params());}catch(Exception e){stop();}}
|
|
51
|
+
promise.resolve(Build.VERSION.SDK_INT>=26);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
@ReactMethod public void status(Promise promise){UiThreadUtil.runOnUiThread(()->{Activity activity=owner.get();WritableMap state=Arguments.createMap();state.putBoolean("available",Build.VERSION.SDK_INT>=26&&getReactApplicationContext().getPackageManager().hasSystemFeature("android.software.picture_in_picture"));state.putBoolean("ready",streamURL!=null);state.putBoolean("active",activity!=null&&Build.VERSION.SDK_INT>=26&&activity.isInPictureInPictureMode());state.putBoolean("launching",launching);promise.resolve(state);});}
|
|
55
|
+
@ReactMethod public void enter(Promise promise){UiThreadUtil.runOnUiThread(()->promise.resolve(launch(getCurrentActivity())));}
|
|
56
|
+
public static void onUserLeaveHint(Activity activity){CallingPictureInPicture module=instance.get();if(module!=null)module.launch(activity);}
|
|
57
|
+
private PictureInPictureParams params(){double value=(double)width/height;android.util.Rational ratio=value<0.418?new android.util.Rational(9,21):value>2.39?new android.util.Rational(21,9):new android.util.Rational(width,height);return new PictureInPictureParams.Builder().setAspectRatio(ratio).build();}
|
|
58
|
+
private boolean launch(Activity activity){
|
|
59
|
+
if(Build.VERSION.SDK_INT<26||streamURL==null||launching||overlay!=null||activity==null||activity.isFinishing()||activity.isInPictureInPictureMode())return false;
|
|
60
|
+
if(!activity.getPackageManager().hasSystemFeature("android.software.picture_in_picture"))return false;
|
|
61
|
+
try{
|
|
62
|
+
launching=true;owner=new WeakReference<>(activity);
|
|
63
|
+
videoView=Class.forName("com.oney.WebRTCModule.WebRTCView");
|
|
64
|
+
renderer=(View)videoView.getConstructor(android.content.Context.class).newInstance(getReactApplicationContext());
|
|
65
|
+
manager=Class.forName("com.oney.WebRTCModule.RTCVideoViewManager").getConstructor().newInstance();
|
|
66
|
+
videoView.getMethod("setObjectFit",String.class).invoke(renderer,"contain");
|
|
67
|
+
ViewGroup decor=(ViewGroup)activity.getWindow().getDecorView();
|
|
68
|
+
ViewGroup sourceRoot=decor;
|
|
69
|
+
if(sourceTag>0){
|
|
70
|
+
com.facebook.react.bridge.UIManager ui=com.facebook.react.uimanager.UIManagerHelper.getUIManagerForReactTag(getReactApplicationContext(),sourceTag);
|
|
71
|
+
View original=ui==null?null:ui.resolveView(sourceTag);
|
|
72
|
+
if(original!=null&&original.getRootView() instanceof ViewGroup)sourceRoot=(ViewGroup)original.getRootView();
|
|
73
|
+
}
|
|
74
|
+
if(sourceRoot!=decor){
|
|
75
|
+
coverChildren(decor);
|
|
76
|
+
mainCover=new FrameLayout(activity);mainCover.setBackgroundColor(Color.BLACK);decor.addView(mainCover,new ViewGroup.LayoutParams(-1,-1));
|
|
77
|
+
}
|
|
78
|
+
decor=sourceRoot;
|
|
79
|
+
overlay=new FrameLayout(activity);overlay.setBackgroundColor(Color.BLACK);
|
|
80
|
+
overlay.addView(renderer,new FrameLayout.LayoutParams(-1,-1));
|
|
81
|
+
// Hide every original child, including native host navigation. Restore exact visibility afterward.
|
|
82
|
+
coverChildren(decor);
|
|
83
|
+
decor.addView(overlay,new ViewGroup.LayoutParams(-1,-1));refreshSource();
|
|
84
|
+
boolean entered=activity.enterPictureInPictureMode(params());launching=false;
|
|
85
|
+
if(!entered){release();return false;}
|
|
86
|
+
handler.postDelayed(observe,250);return true;
|
|
87
|
+
}catch(Exception error){android.util.Log.w("RobonoCallingPiP","Unable to enter picture-in-picture",error);release();return false;}
|
|
88
|
+
}
|
|
89
|
+
private void coverChildren(ViewGroup decor){for(int i=0;i<decor.getChildCount();i++){View child=decor.getChildAt(i);hidden.put(child,child.getVisibility());child.setVisibility(View.INVISIBLE);}}
|
|
90
|
+
private void refreshSource()throws Exception{if(renderer!=null&&streamURL!=null&&!streamURL.equals(renderedURL)){manager.getClass().getMethod("setStreamURL",videoView,String.class).invoke(manager,renderer,streamURL);renderedURL=streamURL;}}
|
|
91
|
+
private void detachVideo(){if(renderer!=null){try{manager.getClass().getMethod("setStreamURL",videoView,String.class).invoke(manager,renderer,null);}catch(Exception ignored){}if(renderer.getParent() instanceof ViewGroup)((ViewGroup)renderer.getParent()).removeView(renderer);}renderer=null;manager=null;renderedURL=null;}
|
|
92
|
+
private void stop(){Activity activity=owner.get();detachVideo();if(activity!=null&&Build.VERSION.SDK_INT>=26&&activity.isInPictureInPictureMode()){activity.moveTaskToBack(true);handler.removeCallbacks(observe);handler.postDelayed(observe,250);}else release();}
|
|
93
|
+
private void release(){handler.removeCallbacks(observe);detachVideo();if(overlay!=null&&overlay.getParent() instanceof ViewGroup)((ViewGroup)overlay.getParent()).removeView(overlay);overlay=null;if(mainCover!=null&&mainCover.getParent() instanceof ViewGroup)((ViewGroup)mainCover.getParent()).removeView(mainCover);mainCover=null;for(java.util.Map.Entry<View,Integer> entry:hidden.entrySet())entry.getKey().setVisibility(entry.getValue());hidden.clear();owner.clear();launching=false;}
|
|
94
|
+
@Override public void onActivityResumed(Activity activity){if(activity==owner.get()&&Build.VERSION.SDK_INT>=26&&!activity.isInPictureInPictureMode()&&!launching)release();}
|
|
95
|
+
@Override public void onActivityDestroyed(Activity activity){if(activity==owner.get())release();}
|
|
96
|
+
@Override public void onActivityCreated(Activity activity,Bundle state){}
|
|
97
|
+
@Override public void onActivityStarted(Activity activity){}
|
|
98
|
+
@Override public void onActivityPaused(Activity activity){}
|
|
99
|
+
@Override public void onActivityStopped(Activity activity){}
|
|
100
|
+
@Override public void onActivitySaveInstanceState(Activity activity,Bundle state){}
|
|
101
|
+
@Override public void invalidate(){((Application)getReactApplicationContext().getApplicationContext()).unregisterActivityLifecycleCallbacks(this);UiThreadUtil.runOnUiThread(()->{streamURL=null;stop();if(instance.get()==this)instance=new WeakReference<>(null);});super.invalidate();}
|
|
102
|
+
}
|
package/app.plugin.cjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const {withInfoPlist, withAndroidManifest, createRunOncePlugin} = require('expo/config-plugins');
|
|
2
2
|
function withCallingRuntime(config, options = {}) {
|
|
3
|
+
if(options.video&&options.pictureInPicture!==false)config=require('./plugin/picture-in-picture.cjs').withCallPictureInPicture(config);
|
|
3
4
|
if(options.incomingCalls!==false)config=require('./plugin/incoming-calls.cjs').withIncomingCalls(config);
|
|
4
5
|
if(options.screenSharing)config=require('./plugin/screensharing.cjs').withScreenSharing(config,typeof options.screenSharing==='object'?options.screenSharing:{});
|
|
5
6
|
config = withInfoPlist(config, value => {
|
|
7
|
+
value.modResults.RobonoPictureInPictureEnabled=options.video===true&&options.pictureInPicture!==false;
|
|
6
8
|
if (options.video) value.modResults.NSCameraUsageDescription ||= options.cameraPermission || 'Allow camera access to make video calls.';
|
|
7
9
|
value.modResults.UIBackgroundModes = [...new Set([...(value.modResults.UIBackgroundModes || []), 'audio'])];
|
|
8
10
|
if(options.incomingCalls!==false){value.modResults.RobonoSystemCallingEnabled=true;value.modResults.UIBackgroundModes=[...new Set([...value.modResults.UIBackgroundModes,'voip','remote-notification'])];}
|
|
@@ -14,6 +16,12 @@ function withCallingRuntime(config, options = {}) {
|
|
|
14
16
|
const manifest = value.modResults.manifest;
|
|
15
17
|
const app=manifest.application?.[0];
|
|
16
18
|
if(app){
|
|
19
|
+
if(options.video&&options.pictureInPicture!==false){
|
|
20
|
+
const main=app.activity?.find(activity=>activity['intent-filter']?.some(filter=>filter.action?.some(action=>action.$['android:name']==='android.intent.action.MAIN')));
|
|
21
|
+
if(!main)throw Error('Calling picture-in-picture requires a main Android activity.');
|
|
22
|
+
main.$['android:supportsPictureInPicture']='true';main.$['android:resizeableActivity']='true';
|
|
23
|
+
main.$['android:configChanges']=[...new Set([...(main.$['android:configChanges']||'').split('|').filter(Boolean),'screenSize','smallestScreenSize','screenLayout','orientation'])].join('|');
|
|
24
|
+
}
|
|
17
25
|
const meta=app['meta-data']||=[];const key='com.robono.calling.SYSTEM_CALLING';
|
|
18
26
|
const row=meta.find(v=>v.$['android:name']===key);const data={'android:name':key,'android:value':options.incomingCalls===false?'false':'true'};if(row)row.$=data;else meta.push({$:data});
|
|
19
27
|
app.service=(app.service||[]).filter(v=>v.$['android:name']!=='com.robono.calling.SystemCallMessagingService');
|
package/dist/components.d.ts
CHANGED
|
@@ -66,6 +66,8 @@ export interface CallingScreenComponents {
|
|
|
66
66
|
ActionButton?: ComponentType<CallingActionButtonProps>;
|
|
67
67
|
}
|
|
68
68
|
export interface CallingScreenProps {
|
|
69
|
+
/** Allow the connected remote video to use the operating system floating window. */
|
|
70
|
+
pictureInPicture?: boolean;
|
|
69
71
|
state: CallingState;
|
|
70
72
|
appearance?: CallingAppearance;
|
|
71
73
|
onScreenShare?(): void;
|
|
@@ -76,6 +78,7 @@ export interface CallingScreenProps {
|
|
|
76
78
|
stream: MediaStream;
|
|
77
79
|
local: boolean;
|
|
78
80
|
screen?: boolean;
|
|
81
|
+
pictureInPicture?: boolean;
|
|
79
82
|
style: StyleProp<ViewStyle>;
|
|
80
83
|
}): ReactNode;
|
|
81
84
|
onResume?(): void;
|
|
@@ -94,6 +97,7 @@ export interface CallingScreenProps {
|
|
|
94
97
|
components?: CallingScreenComponents;
|
|
95
98
|
}
|
|
96
99
|
export interface CallingUIValue {
|
|
100
|
+
pictureInPicture: boolean;
|
|
97
101
|
renderVideo?: CallingScreenProps['renderVideo'];
|
|
98
102
|
state: Readonly<CallingState>;
|
|
99
103
|
appearance?: CallingAppearance;
|
package/dist/components.js
CHANGED
|
@@ -52,7 +52,7 @@ export function CallingUIProvider({ children, ...props }) {
|
|
|
52
52
|
};
|
|
53
53
|
const fontFamily = Platform.OS === 'ios' ? design.fontFamily.ios : Platform.OS === 'android' ? design.fontFamily.android : design.fontFamily.web;
|
|
54
54
|
const value = {
|
|
55
|
-
state: s, renderVideo: props.renderVideo, appearance: props.appearance, theme: c, labels: t, design,
|
|
55
|
+
state: s, pictureInPicture: props.pictureInPicture !== false, renderVideo: props.renderVideo, appearance: props.appearance, theme: c, labels: t, design,
|
|
56
56
|
insets: props.insets || safeArea, components: props.components || {},
|
|
57
57
|
title: s.contact?.name || t.contact,
|
|
58
58
|
status: s.phase === 'connected' ? duration : s.phase === 'error' || s.phase === 'idle' ? '' : s.phase === 'incoming' && s.kind === 'video' ? t.incomingVideo : t[s.phase],
|
|
@@ -164,12 +164,13 @@ const styles = StyleSheet.create({
|
|
|
164
164
|
});
|
|
165
165
|
/** Video uses the same SDK layout, labels and controls on native and web. */
|
|
166
166
|
export function CallingVideo({ style } = {}) {
|
|
167
|
-
const { state, renderVideo, theme, typography, labels, design } = useCallingUI();
|
|
167
|
+
const { state, renderVideo, pictureInPicture, theme, typography, labels, design } = useCallingUI();
|
|
168
168
|
const [area, setArea] = useState({ width: 0, height: 0 });
|
|
169
169
|
if (state.group && ['outgoing', 'connecting', 'connected', 'held'].includes(state.phase)) {
|
|
170
170
|
const members = state.groupMembers?.filter(m => !['left', 'declined'].includes(m.state)) ?? [], sharing = members.find(m => m.sharing);
|
|
171
|
+
const pipMember = members.find(m => !m.local && !m.held && m.sharing && m.stream) ?? members.find(m => !m.local && !m.held && m.stream);
|
|
171
172
|
const tile = (member, tileStyle, compact = false) => _jsxs(View, { style: [{ flex: 1, minHeight: 60, overflow: 'hidden', borderRadius: 12, backgroundColor: theme.control, alignItems: 'center', justifyContent: 'center' }, tileStyle], children: [state.kind === 'video' && member.stream && renderVideo && !member.held && state.phase !== 'held' && (member.sharing || !member.local || state.cameraEnabled !== false)
|
|
172
|
-
? renderVideo({ stream: member.stream, local: !!member.local, screen: member.sharing, style: { position: 'absolute', width: '100%', height: '100%' } })
|
|
173
|
+
? renderVideo({ stream: member.stream, local: !!member.local, screen: member.sharing, pictureInPicture: pictureInPicture && state.phase === 'connected' && member === pipMember, style: { position: 'absolute', width: '100%', height: '100%' } })
|
|
173
174
|
: design.presentation.showAvatar && _jsx(View, { style: { width: compact ? 36 : avatarSize, height: compact ? 36 : avatarSize, borderRadius: 40, backgroundColor: theme.background, alignItems: 'center', justifyContent: 'center' }, children: member.avatarUri ? _jsx(Image, { source: { uri: member.avatarUri }, style: { width: compact ? 36 : avatarSize, height: compact ? 36 : avatarSize, borderRadius: 40 } }) : _jsx(Text, { style: [typography(28), { color: theme.accent }], children: member.name.slice(0, 1) }) }), _jsx(View, { style: { position: 'absolute', bottom: 8, left: 8, maxWidth: '90%', borderRadius: 6, paddingHorizontal: 8, paddingVertical: 4, backgroundColor: '#000000b0' }, children: _jsxs(Text, { numberOfLines: 1, style: [typography(12), { color: '#ffffff', textAlign: 'left' }], children: [member.name, member.sharing ? ' · ' + labels.sharingScreen : '', member.held ? ' · ' + labels.held : member.state === 'invited' ? ' · ' + labels.outgoing : ''] }) })] }, member.id);
|
|
174
175
|
const landscape = area.width > area.height;
|
|
175
176
|
const columns = Math.max(1, Math.min(members.length, landscape && area.width > 700 && members.length > 4 ? 4 : landscape || members.length > 2 ? 2 : 1));
|
|
@@ -180,6 +181,6 @@ export function CallingVideo({ style } = {}) {
|
|
|
180
181
|
if (state.kind !== 'video' || !['outgoing', 'connecting', 'connected', 'held'].includes(state.phase) || !renderVideo)
|
|
181
182
|
return null;
|
|
182
183
|
const visible = !['held', 'idle', 'error'].includes(state.phase);
|
|
183
|
-
return _jsxs(View, { style: [{ flex: 1, minHeight: 100, borderRadius: 16, overflow: 'hidden', backgroundColor: theme.control }, style], children: [visible && state.remoteStream ? renderVideo({ stream: state.remoteStream, local: false, screen: state.remoteScreenSharing, style: { width: '100%', height: '100%' } }) :
|
|
184
|
+
return _jsxs(View, { style: [{ flex: 1, minHeight: 100, borderRadius: 16, overflow: 'hidden', backgroundColor: theme.control }, style], children: [visible && state.remoteStream ? renderVideo({ stream: state.remoteStream, local: false, screen: state.remoteScreenSharing, pictureInPicture: pictureInPicture && state.phase === 'connected', style: { width: '100%', height: '100%' } }) :
|
|
184
185
|
_jsxs(View, { style: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 16 }, children: [_jsx(CallingAvatar, { size: 80 }), _jsx(Text, { style: [typography(16), { color: theme.secondary }], children: state.phase === 'held' ? labels.held : labels.connecting })] }), visible && (state.screenSharing || state.remoteScreenSharing) && _jsx(Text, { style: [typography(13), { position: 'absolute', top: 8, left: 8, padding: 6, borderRadius: 5, color: '#ffffff', backgroundColor: '#000000b0' }], children: labels.sharingScreen }), visible && state.localStream && (state.screenSharing || state.cameraEnabled !== false) && _jsx(View, { style: { position: 'absolute', right: 10, bottom: 10, width: 86, height: 114, borderRadius: 10, overflow: 'hidden' }, children: renderVideo({ stream: state.displayStream || state.localStream, local: true, screen: state.screenSharing, style: { width: '100%', height: '100%' } }) })] });
|
|
185
186
|
}
|
package/dist/native-video.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState, useRef } from 'react';
|
|
3
|
+
import { NativeModules, Platform, findNodeHandle } from 'react-native';
|
|
2
4
|
import { RTCView } from 'react-native-webrtc';
|
|
3
5
|
import { CallingOverlay } from './screens.js';
|
|
4
|
-
|
|
6
|
+
function NativeCallVideo({ stream, local, screen, style, pictureInPicture }) {
|
|
7
|
+
const view = useRef(null);
|
|
8
|
+
const url = stream.toURL();
|
|
9
|
+
const [size, setSize] = useState(screen ? { width: 16, height: 9 } : { width: 9, height: 16 });
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (Platform.OS === 'android' && pictureInPicture && !local)
|
|
12
|
+
void NativeModules.RobonoCallingPictureInPicture?.setSource(url, size.width, size.height, true, findNodeHandle(view.current) ?? 0).catch(() => { });
|
|
13
|
+
}, [url, pictureInPicture, local, size.width, size.height]);
|
|
14
|
+
useEffect(() => () => {
|
|
15
|
+
if (Platform.OS === 'android' && pictureInPicture && !local)
|
|
16
|
+
void NativeModules.RobonoCallingPictureInPicture?.setSource('', 9, 16, false, 0).catch(() => { });
|
|
17
|
+
}, [url, pictureInPicture, local]);
|
|
18
|
+
return _jsx(RTCView, { ref: view, streamURL: url, onDimensionsChange: event => { const { width, height } = event.nativeEvent; if (width > 0 && height > 0)
|
|
19
|
+
setSize(previous => previous.width === width && previous.height === height ? previous : { width, height }); }, mirror: local && !screen, objectFit: screen ? "contain" : "cover", zOrder: local ? 1 : 0, style: style, iosPIP: Platform.OS === 'ios' && !local && pictureInPicture && NativeModules.RobonoCallingRuntime?.pictureInPictureEnabled !== false ? { enabled: true, startAutomatically: true, stopAutomatically: true, preferredSize: screen ? { width: 640, height: 360 } : { width: 360, height: 640 } } : { enabled: false } });
|
|
20
|
+
}
|
|
21
|
+
export const renderNativeCallVideo = props => _jsx(NativeCallVideo, { ...props });
|
|
5
22
|
/** Optional complete native screen; the calling engine can also use your UI. */
|
|
6
23
|
export function NativeCallingOverlay(props) {
|
|
7
24
|
return _jsx(CallingOverlay, { ...props, renderVideo: props.renderVideo || renderNativeCallVideo });
|
package/dist/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const mobileVersion = "0.
|
|
1
|
+
export declare const mobileVersion = "0.7.0";
|
|
2
2
|
export declare const engineVersion = "0.4.0";
|
package/dist/versions.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
@implementation RobonoCallingRuntime
|
|
17
17
|
RCT_EXPORT_MODULE();
|
|
18
|
+
- (NSDictionary *)constantsToExport { return @{@"pictureInPictureEnabled": @(![[[NSBundle mainBundle] objectForInfoDictionaryKey:@"RobonoPictureInPictureEnabled"] isEqual:@NO])}; }
|
|
18
19
|
+ (BOOL)requiresMainQueueSetup { return YES; }
|
|
19
20
|
- (dispatch_queue_t)methodQueue { return dispatch_get_main_queue(); }
|
|
20
21
|
- (NSArray<NSString *> *)supportedEvents { return @[@"RobonoCallingRuntimeEvent"]; }
|
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const {withMainActivity}=require('expo/config-plugins');
|
|
2
|
+
const marker='// @robono/call-picture-in-picture';
|
|
3
|
+
// Preserve offsets while ignoring braces in strings and comments. Only change
|
|
4
|
+
// the actual ReactActivity class, never a helper class later in the file.
|
|
5
|
+
function activityBody(source){
|
|
6
|
+
const code=source.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"""[\s\S]*?"""|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/g,match=>match.replace(/[^\n]/g,' '));
|
|
7
|
+
const declaration=/\bclass\s+\w+\b[^{}]*\bReactActivity\b[^{}]*\{/.exec(code);
|
|
8
|
+
if(!declaration)throw Error('Could not identify the ReactActivity class. Forward onUserLeaveHint as described in the calling guide.');
|
|
9
|
+
const start=declaration.index+declaration[0].length;let depth=1;
|
|
10
|
+
for(let i=start;i<code.length;i++){if(code[i]==='{')depth++;if(code[i]==='}'&&!--depth)return {start,end:i,code:code.slice(start,i)};}
|
|
11
|
+
throw Error('Could not locate the end of the ReactActivity class.');
|
|
12
|
+
}
|
|
13
|
+
function installPictureInPictureHook(source,language){
|
|
14
|
+
if(!['kt','java'].includes(language))throw Error('Forward Android onUserLeaveHint to RobonoCallingPictureInPicture; see the calling guide.');
|
|
15
|
+
const body=activityBody(source),content=source.slice(body.start,body.end);
|
|
16
|
+
if(content.includes(marker))return source;
|
|
17
|
+
const existing=language==='kt'?/override\s+(?:(?:public|protected)\s+)?fun\s+onUserLeaveHint\s*\(\s*\)\s*\{/:/(?:public|protected)\s+void\s+onUserLeaveHint\s*\(\s*\)\s*\{/;
|
|
18
|
+
const hook=`\n ${marker}\n com.robono.calling.CallingPictureInPicture.onUserLeaveHint(this)${language==='java'?';':''}\n`;
|
|
19
|
+
const found=existing.exec(body.code);
|
|
20
|
+
if(found){const at=body.start+found.index+found[0].length;return source.slice(0,at)+hook+source.slice(at);}
|
|
21
|
+
if(/\bonUserLeaveHint\b/.test(body.code))throw Error('A custom onUserLeaveHint needs the forwarding call described in the calling guide.');
|
|
22
|
+
const method=language==='kt'?`\n override fun onUserLeaveHint() {\n super.onUserLeaveHint()${hook} }\n`:`\n @Override protected void onUserLeaveHint() {\n super.onUserLeaveHint();${hook} }\n`;
|
|
23
|
+
return source.slice(0,body.end)+method+source.slice(body.end);
|
|
24
|
+
}
|
|
25
|
+
function withCallPictureInPicture(config){return withMainActivity(config,c=>{c.modResults.contents=installPictureInPictureHook(c.modResults.contents,c.modResults.language);return c;});}
|
|
26
|
+
module.exports={withCallPictureInPicture,installPictureInPictureHook};
|