Skip to content

Commit

Permalink
[RN] Consistency in Jitsi Meet SDK for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
lyubomir committed Jun 9, 2017
1 parent 84463d8 commit 9046618
Show file tree
Hide file tree
Showing 12 changed files with 221 additions and 197 deletions.
95 changes: 48 additions & 47 deletions android/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
# Jitsi Meet for Android
# Jitsi Meet SDK for Android

This directory contains the source code for Jitsi Meet for Android (the
application) and the Jitsi Meet SDK for Android.
This directory contains the source code of the Jitsi Meet app and the Jitsi Meet
SDK for Android.

## Jitsi Meet SDK

Jitsi Meet SDK is an Android library which embodies the Jitsi Meet experience,
gift-wrapped so other applications can use it. Example use:
Jitsi Meet SDK is an Android library which embodies the whole Jitsi Meet
experience and makes it reusable by third-party apps.

To get started, extends your `android.app.Activity` from
`org.jitsi.meet.sdk.JitsiMeetActivity`:

```java
package org.jitsi.example;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import org.jitsi.meet.sdk.JitsiMeetActivity;

public class MainActivity extends JitsiMeetActivity {
}
```

import org.jitsi.meet.sdk.*;
Alternatively, you can use the `org.jitsi.meet.sdk.JitsiMeetView` class which
extends `android.view.View`:

```java
package org.jitsi.example;

public class CustomActivity extends AppCompatActivity {
private JitsiMeetView jitsiMeetView;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import org.jitsi.meet.sdk.JitsiMeetView;

public class MainActivity extends AppCompatActivity {
private JitsiMeetView view;

@Override
public void onBackPressed() {
Expand All @@ -32,56 +46,44 @@ public class CustomActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

jitsiMeetView = new JitsiMeetView(this);
jitsiMeetView.loadURL(null);
view = new JitsiMeetView(this);
view.loadURL(null);

setContentView(jitsiMeetView);
}

@Override
public void onNewIntent(Intent intent) {
JitsiMeetView.onNewIntent(intent);
setContentView(view);
}

@Override
protected void onDestroy() {
super.onDestroy();

JitsiMeetView.onHostDestroy(this);
}

@Override
public void onNewIntent(Intent intent) {
JitsiMeetView.onNewIntent(intent);
}

@Override
protected void onPause() {
super.onPause();

JitsiMeetView.onHostPause(this);
}

@Override
protected void onResume() {
super.onResume();

JitsiMeetView.onHostResume(this);
}

}
```

Alternatively, you can use the `JitsiMeetBaseActivity` class, which already has
all activity lifecycle methods hooked up:

```java
package org.jitsi.example;

import org.jitsi.meet.sdk.*;


public class MainActivity extends JitsiMeetBaseActivity {
}

```

### JitsiMeetBaseActivity
### JitsiMeetActivity

This class encapsulates a high level API in the form of an Android activity
which displays a single `JitsiMeetView` views.
This class encapsulates a high level API in the form of an Android `Activity`
which displays a single `JitsiMeetView`.

#### loadURL(url)

Expand All @@ -91,16 +93,16 @@ See JitsiMeetView.loadURL.
### JitsiMeetView

The `JitsiMeetView` class is the core of Jitsi Meet SDK. It's designed to
display a Jitsi Meet conference view (or a welcome page).
display a Jitsi Meet conference (or a welcome page).

#### getListener()

Returns the `JitsiMeetView.Listener` instance attached to the view.

#### loadURL(url)

Loads the given URL and joins the conference which is being pointed to. If null,
it will load the welcome page.
Loads the given URL and joins the room. If `null` is specified, the welcome page
is displayed instead.

#### setListener(listener)

Expand All @@ -110,8 +112,8 @@ interface) on the view.
#### onBackPressed()

Helper method which should be called from the activity's `onBackPressed` method.
If this function returns `true` it means the action was handled and thus no
extra processing is required, otherwise the application should call the parent's
If this function returns `true`, it means the action was handled and thus no
extra processing is required; otherwise the app should call the parent's
`onBackPressed` method.

This is a static method.
Expand All @@ -136,16 +138,16 @@ This is a static method.

#### onNewIntent(intent)

Helper method for integrating the *deep linking* functionality. If your
application's activity is launched in "singleTask" mode this method should
be called from the activity's `onNewIntent` method.
Helper method for integrating the *deep linking* functionality. If your app's
activity is launched in "singleTask" mode this method should be called from the
activity's `onNewIntent` method.

This is a static method.

#### Listener

JitsiMeetView.Listener provides an interface applications can implement in order
to get notified about the state of the Jitsi Meet conference.
JitsiMeetView.Listener provides an interface apps can implement in order to get
notified about the state of the Jitsi Meet conference.

##### onConferenceFailed

Expand Down Expand Up @@ -178,4 +180,3 @@ The `data` HashMap contains a "url" key with the conference URL.
Called before a conference is left.

The `data` HashMap contains a "url" key with the conference URL.

1 change: 0 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apply plugin: 'com.android.application'


android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
Expand Down
21 changes: 11 additions & 10 deletions android/app/src/main/java/org/jitsi/meet/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@

package org.jitsi.meet;

import org.jitsi.meet.sdk.JitsiMeetBaseActivity;

import org.jitsi.meet.sdk.JitsiMeetActivity;

/**
* The one and only Activity that Jitsi Meet (the app) needs. The activity is launched in
* "singleTask" mode, so it will be created upon application initialization and there will be
* a single instance of it. Further attempts at launching the application once it was already
* launched will result in <tt>onNewIntent</tt> being called.
* The one and only {@link Activity} that the Jitsi Meet app needs. The
* {@code Activity} is launched in {@code singleTask} mode, so it will be
* created upon application initialization and there will be a single instance
* of it. Further attempts at launching the application once it was already
* launched will result in {@link Activity#onNewIntent(Intent)} being called.
*
* This Activity inherits from JitsiMeetBaseActivity without adding anything to it. It merely exists to
* keep the React Native CLI working, since it always tries to launch an activity called
* "MainActivity" when doing "react-native run-android".
* This {@code Activity} extends {@link JitsiMeetActivity} without adding
* anything to it. It exists to merely keep the React Native CLI working, since
* the latter always tries to launch an {@code Activity} named
* {@code MainActivity} when doing {@code react-native run-android}.
*/
public class MainActivity extends JitsiMeetBaseActivity {
public class MainActivity extends JitsiMeetActivity {
}
8 changes: 5 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
// Top-level build file where you can add configuration options common to all
// sub-projects/modules.

buildscript {
repositories {
Expand All @@ -8,7 +9,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:2.2.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// in the individual module build.gradle files.
}
}

Expand All @@ -17,7 +18,8 @@ allprojects {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
// All of React Native (JS, Obj-C sources, Android binaries) is
// installed from npm.
url "$rootDir/../node_modules/react-native/android"
}
}
Expand Down
24 changes: 16 additions & 8 deletions android/sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ gradle.projectsEvaluated {
def buildNameCapitalized = "${buildType.name.capitalize()}"
def bundlePath = "${buildDir}/intermediates/bundles/${buildType.name}"

// Bundle fonts in react-native-vector-icons
// Bundle fonts in react-native-vector-icons.
//

def currentFontTask = tasks.create(name: "${buildType.name}CopyFonts", type: Copy) {
Expand All @@ -63,35 +63,43 @@ gradle.projectsEvaluated {
runBefore("processUniversal${buildNameCapitalized}Resources", currentFontTask)
runBefore("process${buildNameCapitalized}Resources", currentFontTask)

// Bundle JavaScript and React resources
// Bundle JavaScript and React resources.
// (adapted from react-native/react.gradle)
//

// React js bundle directories
// React JS bundle directories
def jsBundleDir = file("${bundlePath}/assets")
def resourcesDir = file("${bundlePath}/res/merged")
def jsBundleFile = file("${jsBundleDir}/index.android.bundle")

// Bundle task name for variant
// Bundle task name for variant.
def bundleJsAndAssetsTaskName = "bundle${buildNameCapitalized}JsAndAssets"

def currentBundleTask = tasks.create(
name: bundleJsAndAssetsTaskName,
type: Exec) {

// Set up inputs and outputs so gradle can cache the result
// Set up inputs and outputs so gradle can cache the result.
def reactRoot = file("${projectDir}/../../")
inputs.files fileTree(dir: reactRoot, excludes: ["android/**", "ios/**"])
outputs.dir jsBundleDir
outputs.dir resourcesDir

// Set up the call to the react-native cli
// Set up the call to the react-native cli.
workingDir reactRoot

// Create JS bundle
def devEnabled = !buildNameCapitalized.toLowerCase().contains("release")
commandLine("node", "node_modules/react-native/local-cli/cli.js", "bundle", "--platform", "android", "--dev", "${devEnabled}",
"--reset-cache", "--entry-file", "index.android.js", "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir)
commandLine(
"node",
"node_modules/react-native/local-cli/cli.js",
"bundle",
"--assets-dest", resourcesDir,
"--bundle-output", jsBundleFile,
"--dev", "${devEnabled}",
"--entry-file", "index.android.js",
"--platform", "android",
"--reset-cache")

// TODO: disable task in Debug mode?
}
Expand Down
Loading

0 comments on commit 9046618

Please sign in to comment.