Skip to content

Commit

Permalink
Coding style: consistency, formatting, naming
Browse files Browse the repository at this point in the history
  • Loading branch information
lyubomir committed May 7, 2018

Verified

This commit was signed with the committer’s verified signature.
EtiennePelletier Étienne Pelletier
1 parent b777322 commit 6a0de0d
Showing 5 changed files with 110 additions and 108 deletions.
28 changes: 15 additions & 13 deletions android/sdk/src/main/java/org/jitsi/meet/sdk/ExternalAPIModule.java
Original file line number Diff line number Diff line change
@@ -112,28 +112,30 @@ public String getName() {
}

/**
* The internal processing for the conference URL set on
* a {@link JitsiMeetView} instance.
* The internal processing for the URL of the current conference set on the
* associated {@link JitsiMeetView}.
*
* @param eventName the name of the external API event to be processed.
* @param eventName the name of the external API event to be processed
* @param eventData the details/specifics of the event to process determined
* by/associated with the specified {@code eventName}.
* @param view the {@link JitsiMeetView} instance.
* @param url the "url" attribute value retrieved from the "data" carried by
* the event.
*/
private void maybeSetConferenceUrlOnTheView(
String eventName, JitsiMeetView view, String url)
{
private void maybeSetViewURL(
String eventName,
ReadableMap eventData,
JitsiMeetView view) {
switch(eventName) {
case "CONFERENCE_WILL_JOIN":
view.setCurrentConferenceUrl(url);
view.setURL(eventData.getString("url"));
break;

case "CONFERENCE_FAILED":
case "CONFERENCE_WILL_LEAVE":
case "LOAD_CONFIG_ERROR":
// Abandon the conference only if it's for the current URL
if (url != null && url.equals(view.getCurrentConferenceUrl())) {
view.setCurrentConferenceUrl(null);
String url = eventData.getString("url");

if (url != null && url.equals(view.getURL())) {
view.setURL(null);
}
break;
}
@@ -158,7 +160,7 @@ public void sendEvent(String name, ReadableMap data, String scope) {
return;
}

maybeSetConferenceUrlOnTheView(name, view, data.getString("url"));
maybeSetViewURL(name, data, view);

JitsiMeetViewListener listener = view.getListener();

70 changes: 36 additions & 34 deletions android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetView.java
Original file line number Diff line number Diff line change
@@ -204,15 +204,6 @@ && loadURLStringInViews(uri.toString())) {
}
}

/**
* Stores the current conference URL. Will have a value when the app is in
* a conference.
*
* Currently one thread writes and one thread reads, so it should be fine to
* have this field volatile without additional synchronization.
*/
private volatile String conferenceUrl;

/**
* The default base {@code URL} used to join a conference when a partial URL
* (e.g. a room name only) is specified to {@link #loadURLString(String)} or
@@ -252,6 +243,13 @@ && loadURLStringInViews(uri.toString())) {
*/
private ReactRootView reactRootView;

/**
* The URL of the current conference.
*/
// XXX Currently, one thread writes and one thread reads, so it should be
// fine to have this field volatile without additional synchronization.
private volatile String url;

/**
* Whether the Welcome page is enabled.
*/
@@ -291,16 +289,6 @@ public void dispose() {
}
}

/**
* Retrieves the current conferences URL.
*
* @return a string with conference URL if the view is currently in
* a conference or {@code null} otherwise.
*/
public String getCurrentConferenceUrl() {
return conferenceUrl;
}

/**
* Gets the default base {@code URL} used to join a conference when a
* partial URL (e.g. a room name only) is specified to
@@ -352,6 +340,19 @@ public boolean getPictureInPictureEnabled() {
|| pictureInPictureEnabled.booleanValue());
}

/**
* Gets the URL of the current conference.
*
* XXX The method is meant for internal purposes only at the time of this
* writing because there is no equivalent API on iOS.
*
* @return the URL {@code String} of the current conference if any;
* otherwise, {@code null}.
*/
String getURL() {
return url;
}

/**
* Gets whether the Welcome page is enabled. If {@code true}, the Welcome
* page is rendered when this {@code JitsiMeetView} is not at a URL
@@ -477,17 +478,16 @@ public void loadURLString(@Nullable String urlString) {
* page.
*/
public void onUserLeaveHint() {
if (getPictureInPictureEnabled() && conferenceUrl != null) {
if (getPictureInPictureEnabled() && getURL() != null) {
PictureInPictureModule pipModule
= ReactInstanceManagerHolder.getNativeModule(
PictureInPictureModule.class);

if (pipModule != null) {
try {
pipModule.enterPictureInPicture();
} catch (RuntimeException exc) {
Log.e(
TAG, "onUserLeaveHint: failed to enter PiP mode", exc);
} catch (RuntimeException re) {
Log.e(TAG, "onUserLeaveHint: failed to enter PiP mode", re);
}
}
}
@@ -530,17 +530,6 @@ public void onWindowFocusChanged(boolean hasFocus) {
}
}

/**
* Sets the current conference URL.
*
* @param conferenceUrl a string with new conference URL to set if the view
* is entering the conference or {@code null} if the view is no longer in
* the conference.
*/
void setCurrentConferenceUrl(String conferenceUrl) {
this.conferenceUrl = conferenceUrl;
}

/**
* Sets the default base {@code URL} used to join a conference when a
* partial URL (e.g. a room name only) is specified to
@@ -577,6 +566,19 @@ public void setPictureInPictureEnabled(boolean pictureInPictureEnabled) {
this.pictureInPictureEnabled = Boolean.valueOf(pictureInPictureEnabled);
}

/**
* Sets the URL of the current conference.
*
* XXX The method is meant for internal purposes only. It does not
* {@code loadURL}, it merely remembers the specified URL.
*
* @param url the URL {@code String} which to be set as the URL of the
* current conference.
*/
void setURL(String url) {
this.url = url;
}

/**
* Sets whether the Welcome page is enabled. Must be called before
* {@link #loadURL(URL)} for it to take effect.
70 changes: 35 additions & 35 deletions react/features/welcome/components/VideoSwitch.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
// @flow

import React, { Component } from 'react';
import {
Switch,
TouchableWithoutFeedback,
View
} from 'react-native';
import { Switch, TouchableWithoutFeedback, View } from 'react-native';
import { connect } from 'react-redux';

import { translate } from '../../base/i18n';
import { updateProfile } from '../../base/profile';
import { Header, Text } from '../../base/react';

import styles, {
SWITCH_THUMB_COLOR,
SWITCH_UNDER_COLOR
} from './styles';
import styles, { SWITCH_THUMB_COLOR, SWITCH_UNDER_COLOR } from './styles';

/**
* The type of the React {@code Component} props of {@link VideoSwitch}.
*/
type Props = {

/**
* The Redux dispatch functions.
* The redux {@code dispatch} function.
*/
dispatch: Function,

@@ -29,28 +26,31 @@ type Props = {
t: Function,

/**
* The current profile settings from Redux.
* The current profile settings from redux.
*/
_profile: Object
};

/**
* Renders the audio-video switch on the welcome screen.
* Renders the "Video <-> Voice" switch on the {@code WelcomePage}.
*/
class VideoSwitch extends Component<Props> {
/**
* Constructor of the component.
* Initializes a new {@code VideoSwitch} instance.
*
* @inheritdoc
*/
constructor(props) {
super(props);

// Bind event handlers so they are only bound once per instance.
this._onStartAudioOnlyChange = this._onStartAudioOnlyChange.bind(this);
this._onStartAudioOnlyFalse = this._onStartAudioOnlyChangeFn(false);
this._onStartAudioOnlyTrue = this._onStartAudioOnlyChangeFn(true);
}

/**
* Implements React Component's render.
* Implements React's {@link Component#render}.
*
* @inheritdoc
*/
@@ -61,10 +61,8 @@ class VideoSwitch extends Component<Props> {
return (
<View style = { styles.audioVideoSwitchContainer }>
<TouchableWithoutFeedback
onPress = {
this._onStartAudioOnlyChangeFn(false)
} >
<Text style = { textStyle } >
onPress = { this._onStartAudioOnlyFalse }>
<Text style = { textStyle }>
{ t('welcomepage.audioVideoSwitch.video') }
</Text>
</TouchableWithoutFeedback>
@@ -75,30 +73,16 @@ class VideoSwitch extends Component<Props> {
thumbTintColor = { SWITCH_THUMB_COLOR }
value = { _profile.startAudioOnly } />
<TouchableWithoutFeedback
onPress = {
this._onStartAudioOnlyChangeFn(true)
} >
<Text style = { textStyle } >
onPress = { this._onStartAudioOnlyTrue }>
<Text style = { textStyle }>
{ t('welcomepage.audioVideoSwitch.audio') }
</Text>
</TouchableWithoutFeedback>
</View>
);
}

/**
* Creates a function that forwards the startAudioOnly changes to the
* function that handles it.
*
* @private
* @param {boolean} startAudioOnly - The new startAudioOnly value.
* @returns {void}
*/
_onStartAudioOnlyChangeFn(startAudioOnly) {
return () => this._onStartAudioOnlyChange(startAudioOnly);
}

_onStartAudioOnlyChange: boolean => void
_onStartAudioOnlyChange: boolean => void;

/**
* Handles the audio-video switch changes.
@@ -115,6 +99,22 @@ class VideoSwitch extends Component<Props> {
startAudioOnly
}));
}

/**
* Creates a function that forwards the {@code startAudioOnly} changes to
* the function that handles it.
*
* @private
* @param {boolean} startAudioOnly - The new {@code startAudioOnly} value.
* @returns {void}
*/
_onStartAudioOnlyChangeFn(startAudioOnly) {
return () => this._onStartAudioOnlyChange(startAudioOnly);
}

_onStartAudioOnlyFalse: boolean => void;

_onStartAudioOnlyTrue: boolean => void;
}

/**
37 changes: 17 additions & 20 deletions react/features/welcome/components/WelcomePage.native.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import { connect } from 'react-redux';
import { translate } from '../../base/i18n';
import { Icon } from '../../base/font-icons';
import { MEDIA_TYPE } from '../../base/media';
import { LoadingIndicator, Header, Text } from '../../base/react';
import { Header, LoadingIndicator, Text } from '../../base/react';
import { ColorPalette } from '../../base/styles';
import {
createDesiredLocalTracks,
@@ -24,9 +24,7 @@ import { SettingsView } from '../../settings';
import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
import { setSideBarVisible } from '../actions';
import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
import styles, {
PLACEHOLDER_TEXT_COLOR
} from './styles';
import styles, { PLACEHOLDER_TEXT_COLOR } from './styles';
import VideoSwitch from './VideoSwitch';
import WelcomePageLists from './WelcomePageLists';
import WelcomePageSideBar from './WelcomePageSideBar';
@@ -155,22 +153,23 @@ class WelcomePage extends AbstractWelcomePage {
*/
_onFieldFocusChange(focused) {
return () => {
if (focused) {
this.setState({
focused
&& this.setState({
_fieldFocused: true
});
}

Animated.timing(this.state.hintBoxAnimation, {
duration: 300,
toValue: focused ? 1 : 0
}).start(animationState => {
if (animationState.finished && !focused) {
this.setState({
_fieldFocused: false
});
}
});
Animated.timing(
this.state.hintBoxAnimation,
{
duration: 300,
toValue: focused ? 1 : 0
})
.start(animationState =>
animationState.finished
&& !focused
&& this.setState({
_fieldFocused: false
}));
};
}

@@ -256,9 +255,7 @@ class WelcomePage extends AbstractWelcomePage {
buttonDisabled ? styles.buttonDisabled : null
] }
underlayColor = { ColorPalette.white }>
{
children
}
{ children }
</TouchableHighlight>
);
}
Loading

0 comments on commit 6a0de0d

Please sign in to comment.