Skip to content

Commit

Permalink
Updates for 1.3.6 Release (#191)
Browse files Browse the repository at this point in the history
* Update versions

* Get access token and server from local.properties for quickstart

* Update video invite to use local.properties for idk-starter server

* Update dependencies for latest android gradle plugin

* Fix video invite build config

* Update bintray link

* Small readme change

* Address feedback

* Remove download badge
  • Loading branch information
Aaron Alaniz authored Nov 1, 2017
1 parent 158a8c3 commit 6aa976c
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 60 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[ ![Download](https://api.bintray.com/packages/twilio/releases/video-android/images/download.svg) ](https://bintray.com/twilio/releases/video-android/1.3.5)
[![Javadoc](https://img.shields.io/badge/javadoc-OK-blue.svg)](https://media.twiliocdn.com/sdk/android/video/latest/docs/)

> NOTE: These sample applications use the Twilio Video 1.x APIs. For examples using our 2.x APIs, please see the [2.0](https://github.com/twilio/video-quickstart-android/tree/2.0) branch.
Expand Down Expand Up @@ -27,8 +26,12 @@ To get started with the Quickstart application follow these steps:
2. Type in an identity and click on "Generate Access Token" from the [Testing Tools page](https://www.twilio.com/console/video/runtime/testing-tools).
<img width="700px" src="images/quickstart/generate_access_token.png"/>

3. Paste the Access Token into the VideoActivity.java.
<img width="700px" src="images/quickstart/activity_access_token.png"/>
3. Add the access token string copied from the console to a variable named `TWILIO_ACCESS_TOKEN`
in your **local.properties** file.

```
TWILIO_ACCESS_TOKEN=abcdef0123456789
```

4. Run the quickstart app on an Android device or Android emulator.

Expand Down Expand Up @@ -326,7 +329,16 @@ be shown once - make sure to save this in a secure location.

If you run your video chat application on an Android device, you'll need to provide an externally accessible URL for the app. The [ngrok](https://ngrok.com/) tool creates a publicly accessible URL that you can use to send HTTP/HTTPS traffic to a server running on your localhost. Use HTTPS to make web connections that retrieve a Twilio access token.

When you get a URL from ngrok, go ahead and update VideoActivity.java with the new URL. At the very bottom is the retrieveAccessTokenfromServer() method. If you go down this path, be sure to follow the directions in the comments in the initializeTwilioSdk() method at the top of the source file - you will need to comment out everything under "OPTION 1" and uncomment the one line under "OPTION 2". You will also need to update the code if your ngrok URL changes.
When you get a URL from ngrok, go ahead and update **local.properties**. Reference the following
snippet.

```
# Insert the URL from ngrok
ACCESS_TOKEN_SERVER=http://localhost:3000
# Inform quickstart you want to use a token server
USE_TOKEN_SERVER=true
```

## More Documentation

Expand Down
31 changes: 22 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,46 @@
buildscript {
ext.versions = [
'compileSdk': 26,
'buildTools': '26.0.1',
'buildTools': '26.0.2',
'minSdk': 16,
'targetSdk': 26,
'supportLibrary': '26.1.0',
'firebase': '10.0.1',
'retrofit': '2.0.0-beta4',
'okhttp': '3.6.0',
'ion': '2.1.7',
'videoAndroid': '1.3.5'
'videoAndroid': '1.3.6'
]
ext.getSecretProperty = { key, defaultValue ->
def value = System.getenv(key);

if (value == null) {
Properties properties = new Properties()
if (project.rootProject.file('local.properties').exists()) {
properties.load(project.rootProject.file('local.properties').newDataInputStream())
value = properties.getProperty(key)
}
}

if (value == null) {
value = defaultValue
}

return value;
}
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.0'
}
}

allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
8 changes: 4 additions & 4 deletions exampleAdvancedCameraCapturer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ android {
}

dependencies {
testCompile 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'

compile "com.twilio:video-android:${versions.videoAndroid}"
compile "com.android.support:appcompat-v7:${versions.supportLibrary}"
compile "com.android.support:design:${versions.supportLibrary}"
implementation "com.twilio:video-android:${versions.videoAndroid}"
implementation "com.android.support:appcompat-v7:${versions.supportLibrary}"
implementation "com.android.support:design:${versions.supportLibrary}"
}
8 changes: 4 additions & 4 deletions exampleCustomVideoCapturer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ android {
}

dependencies {
testCompile 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'

compile "com.twilio:video-android:${versions.videoAndroid}"
compile "com.android.support:appcompat-v7:${versions.supportLibrary}"
compile "com.android.support:design:${versions.supportLibrary}"
implementation "com.twilio:video-android:${versions.videoAndroid}"
implementation "com.android.support:appcompat-v7:${versions.supportLibrary}"
implementation "com.android.support:design:${versions.supportLibrary}"
}
8 changes: 4 additions & 4 deletions exampleCustomVideoRenderer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ android {
}

dependencies {
testCompile 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'

compile "com.twilio:video-android:${versions.videoAndroid}"
compile "com.android.support:appcompat-v7:${versions.supportLibrary}"
compile "com.android.support:design:${versions.supportLibrary}"
implementation "com.twilio:video-android:${versions.videoAndroid}"
implementation "com.android.support:appcompat-v7:${versions.supportLibrary}"
implementation "com.android.support:design:${versions.supportLibrary}"
}
8 changes: 4 additions & 4 deletions exampleScreenCapturer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ android {
}

dependencies {
testCompile 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'

compile "com.twilio:video-android:${versions.videoAndroid}"
compile "com.android.support:appcompat-v7:${versions.supportLibrary}"
compile "com.android.support:design:${versions.supportLibrary}"
implementation "com.twilio:video-android:${versions.videoAndroid}"
implementation "com.android.support:appcompat-v7:${versions.supportLibrary}"
implementation "com.android.support:design:${versions.supportLibrary}"
}
2 changes: 1 addition & 1 deletion exampleVideoInvite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ Using ngrok type `ngrok http 3000`

### <a name="bullet5"></a>5. Run the application

Update the `TWILIO_SDK_STARTER_SERVER_URL` in `VideoInviteActivity.java` with the url provided by ngrok and run the example
Update the `TWILIO_SDK_STARTER_SERVER_URL` in `local.properties` with the url provided by ngrok and run the example
on at least two devices. Once both devices are registered use one of the devices to connect to a room.
The other device should receive a push notification alerting them to join the room.
23 changes: 13 additions & 10 deletions exampleVideoInvite/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ android {

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

buildConfigField("String",
"TWILIO_SDK_STARTER_SERVER_URL",
"\"${getSecretProperty("TWILIO_SDK_STARTER_SERVER_URL", "TWILIO_SDK_STARTER_SERVER_URL")}\"")
}

buildTypes {
Expand All @@ -29,19 +32,19 @@ android {
}

dependencies {
testCompile 'junit:junit:4.12'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
testImplementation 'junit:junit:4.12'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})

compile "com.twilio:video-android:${versions.videoAndroid}"
compile "com.google.firebase:firebase-messaging:${versions.firebase}"
compile "com.squareup.retrofit2:retrofit:${versions.retrofit}"
compile "com.squareup.retrofit2:converter-jackson:${versions.retrofit}"
compile "com.squareup.okhttp3:logging-interceptor:${versions.okhttp}"
compile "com.koushikdutta.ion:ion:${versions.ion}"
compile "com.android.support:appcompat-v7:${versions.supportLibrary}"
compile "com.android.support:design:${versions.supportLibrary}"
implementation "com.twilio:video-android:${versions.videoAndroid}"
implementation "com.google.firebase:firebase-messaging:${versions.firebase}"
implementation "com.squareup.retrofit2:retrofit:${versions.retrofit}"
implementation "com.squareup.retrofit2:converter-jackson:${versions.retrofit}"
implementation "com.squareup.okhttp3:logging-interceptor:${versions.okhttp}"
implementation "com.koushikdutta.ion:ion:${versions.ion}"
implementation "com.android.support:appcompat-v7:${versions.supportLibrary}"
implementation "com.android.support:design:${versions.supportLibrary}"
}

apply plugin: 'com.google.gms.google-services'
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public class VideoInviteActivity extends AppCompatActivity {
* At the moment, the sdk-starter project that is compliant with this project is only available
* in Java and can be found here: https://github.com/TwilioDevEd/sdk-starter-java
*/
public static final String TWILIO_SDK_STARTER_SERVER_URL = "YOUR_TWILIO_SDK_STARTER_SERVER_URL";
public static final String TWILIO_SDK_STARTER_SERVER_URL =
BuildConfig.TWILIO_SDK_STARTER_SERVER_URL;

/*
* The tag used to notify others when this identity is connecting to a Video room.
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Mar 06 09:55:05 CST 2017
#Tue Oct 31 10:10:40 CDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 15 additions & 5 deletions quickstart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ android {
targetSdkVersion versions.targetSdk
versionCode 1
versionName "1.0"

buildConfigField("String",
"TWILIO_ACCESS_TOKEN",
"\"${getSecretProperty("TWILIO_ACCESS_TOKEN", "TWILIO_ACCESS_TOKEN")}\"")
buildConfigField("String",
"TWILIO_ACCESS_TOKEN_SERVER",
"\"${getSecretProperty("TWILIO_ACCESS_TOKEN_SERVER", "http://localhost:3000")}\"")
buildConfigField("boolean",
"USE_TOKEN_SERVER",
"${getSecretProperty("USE_TOKEN_SERVER", false)}")
}

buildTypes {
Expand Down Expand Up @@ -39,10 +49,10 @@ android {
}

dependencies {
testCompile 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'

compile "com.twilio:video-android:${versions.videoAndroid}"
compile "com.koushikdutta.ion:ion:${versions.ion}"
compile "com.android.support:appcompat-v7:${versions.supportLibrary}"
compile "com.android.support:design:${versions.supportLibrary}"
implementation "com.twilio:video-android:${versions.videoAndroid}"
implementation "com.koushikdutta.ion:ion:${versions.ion}"
implementation "com.android.support:appcompat-v7:${versions.supportLibrary}"
implementation "com.android.support:design:${versions.supportLibrary}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.twilio.video.Video;
import com.twilio.video.VideoRenderer;
import com.twilio.video.TwilioException;
import com.twilio.video.quickstart.BuildConfig;
import com.twilio.video.quickstart.R;
import com.twilio.video.quickstart.dialog.Dialog;
import com.twilio.video.AudioTrack;
Expand All @@ -47,6 +48,7 @@
import com.twilio.video.quickstart.util.CameraCapturerCompat;

import java.util.Collections;
import java.util.UUID;

import static com.twilio.video.quickstart.R.drawable.ic_phonelink_ring_white_24dp;
import static com.twilio.video.quickstart.R.drawable.ic_volume_up_white_24dp;
Expand All @@ -58,7 +60,8 @@ public class VideoActivity extends AppCompatActivity {
/*
* You must provide a Twilio Access Token to connect to the Video service
*/
private static final String TWILIO_ACCESS_TOKEN = "TWILIO_ACCESS_TOKEN";
private static final String TWILIO_ACCESS_TOKEN = BuildConfig.TWILIO_ACCESS_TOKEN;
private static final String ACCESS_TOKEN_SERVER = BuildConfig.TWILIO_ACCESS_TOKEN_SERVER;

/*
* Access token used to connect. This field will be set either from the console generated token
Expand Down Expand Up @@ -294,12 +297,23 @@ private CameraSource getAvailableCameraSource() {
}

private void setAccessToken() {
// OPTION 1- Generate an access token from the getting started portal
// https://www.twilio.com/console/video/dev-tools/testing-tools
this.accessToken = TWILIO_ACCESS_TOKEN;

// OPTION 2- Retrieve an access token from your own web app
// retrieveAccessTokenfromServer();
if (!BuildConfig.USE_TOKEN_SERVER) {
/*
* OPTION 1 - Generate an access token from the getting started portal
* https://www.twilio.com/console/video/dev-tools/testing-tools and add
* the variable TWILIO_ACCESS_TOKEN setting it equal to the access token
* string in your local.properties file.
*/
this.accessToken = TWILIO_ACCESS_TOKEN;
} else {
/*
* OPTION 2 - Retrieve an access token from your own web app.
* Add the variable ACCESS_TOKEN_SERVER assigning it to the url of your
* token server and the variable USE_TOKEN_SERVER=true to your
* local.properties file.
*/
retrieveAccessTokenfromServer();
}
}

private void connectToRoom(String roomName) {
Expand Down Expand Up @@ -672,13 +686,14 @@ public void onClick(View v) {

private void retrieveAccessTokenfromServer() {
Ion.with(this)
.load("http://localhost:8000/token.php")
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
.load(String.format("%s?identity=%s", ACCESS_TOKEN_SERVER,
UUID.randomUUID().toString()))
.asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
public void onCompleted(Exception e, String token) {
if (e == null) {
VideoActivity.this.accessToken = result.get("token").getAsString();
VideoActivity.this.accessToken = token;
} else {
Toast.makeText(VideoActivity.this,
R.string.error_retrieving_access_token, Toast.LENGTH_LONG)
Expand Down

0 comments on commit 6aa976c

Please sign in to comment.