-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPROVE] Disable Jitsi native module on Android (#4708)
* temp: disable jitsi on android * update props and subscription * add open intent * add request permissions * disable react-native-jitsi-meet on android and separate implementations * fix ios * fix import alias * revert android manifest indentation * add catch to method * return comment * remove is iOS * fix queries * remove unused data * webview audio * fix android permissions * fix audio android * change how to open jitsi app * remove loading * update close logic
- Loading branch information
1 parent
52a9336
commit ab29723
Showing
13 changed files
with
174 additions
and
51 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import React from 'react'; | ||
import { BackHandler, NativeEventSubscription } from 'react-native'; | ||
import BackgroundTimer from 'react-native-background-timer'; | ||
import { isAppInstalled, openAppWithUri } from 'react-native-send-intent'; | ||
import WebView from 'react-native-webview'; | ||
import { WebViewMessage, WebViewNavigation } from 'react-native-webview/lib/WebViewTypes'; | ||
|
||
import { IBaseScreen } from '../definitions'; | ||
import { events, logEvent } from '../lib/methods/helpers/log'; | ||
import { Services } from '../lib/services'; | ||
import { ChatsStackParamList } from '../stacks/types'; | ||
import { withTheme } from '../theme'; | ||
|
||
const JITSI_INTENT = 'org.jitsi.meet'; | ||
|
||
type TJitsiMeetViewProps = IBaseScreen<ChatsStackParamList, 'JitsiMeetView'>; | ||
|
||
class JitsiMeetView extends React.Component<TJitsiMeetViewProps> { | ||
private rid: string; | ||
private url: string; | ||
private videoConf: boolean; | ||
private jitsiTimeout: number | null; | ||
private backHandler!: NativeEventSubscription; | ||
|
||
constructor(props: TJitsiMeetViewProps) { | ||
super(props); | ||
this.rid = props.route.params?.rid; | ||
this.url = props.route.params?.url; | ||
this.videoConf = !!props.route.params?.videoConf; | ||
this.jitsiTimeout = null; | ||
} | ||
|
||
componentDidMount() { | ||
const { route, navigation } = this.props; | ||
isAppInstalled(JITSI_INTENT) | ||
.then(function (isInstalled) { | ||
if (isInstalled) { | ||
const callUrl = route.params.url.replace(/^https?:\/\//, '').split('#')[0]; | ||
openAppWithUri(`intent://${callUrl}#Intent;scheme=${JITSI_INTENT};package=${JITSI_INTENT};end`) | ||
.then(() => navigation.pop()) | ||
.catch(() => {}); | ||
} | ||
}) | ||
.catch(() => {}); | ||
this.onConferenceJoined(); | ||
this.backHandler = BackHandler.addEventListener('hardwareBackPress', () => true); | ||
} | ||
|
||
componentWillUnmount() { | ||
logEvent(this.videoConf ? events.LIVECHAT_VIDEOCONF_TERMINATE : events.JM_CONFERENCE_TERMINATE); | ||
if (this.jitsiTimeout && !this.videoConf) { | ||
BackgroundTimer.clearInterval(this.jitsiTimeout); | ||
this.jitsiTimeout = null; | ||
BackgroundTimer.stopBackgroundTimer(); | ||
} | ||
this.backHandler.remove(); | ||
} | ||
|
||
// Jitsi Update Timeout needs to be called every 10 seconds to make sure | ||
// call is not ended and is available to web users. | ||
onConferenceJoined = () => { | ||
logEvent(this.videoConf ? events.LIVECHAT_VIDEOCONF_JOIN : events.JM_CONFERENCE_JOIN); | ||
if (this.rid && !this.videoConf) { | ||
Services.updateJitsiTimeout(this.rid).catch((e: unknown) => console.log(e)); | ||
if (this.jitsiTimeout) { | ||
BackgroundTimer.clearInterval(this.jitsiTimeout); | ||
BackgroundTimer.stopBackgroundTimer(); | ||
this.jitsiTimeout = null; | ||
} | ||
this.jitsiTimeout = BackgroundTimer.setInterval(() => { | ||
Services.updateJitsiTimeout(this.rid).catch((e: unknown) => console.log(e)); | ||
}, 10000); | ||
} | ||
}; | ||
|
||
onNavigationStateChange = (webViewState: WebViewNavigation | WebViewMessage) => { | ||
const { navigation, route } = this.props; | ||
const jitsiRoomId = route.params.url | ||
?.split(/^https?:\/\//)[1] | ||
?.split('#')[0] | ||
?.split('/')[1]; | ||
if ((jitsiRoomId && !webViewState.url.includes(jitsiRoomId)) || webViewState.url.includes('close')) { | ||
navigation.pop(); | ||
} | ||
}; | ||
|
||
render() { | ||
return ( | ||
<WebView | ||
source={{ uri: `${this.url}&config.disableDeepLinking=true` }} | ||
onMessage={({ nativeEvent }) => this.onNavigationStateChange(nativeEvent)} | ||
onNavigationStateChange={this.onNavigationStateChange} | ||
style={{ flex: 1 }} | ||
javaScriptEnabled | ||
domStorageEnabled | ||
mediaPlaybackRequiresUserAction={false} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
export default withTheme(JitsiMeetView); |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react'; | ||
|
||
declare const JitsiMeetView: React.SFC<>; | ||
|
||
export default JitsiMeetView; |
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