Skip to content

Commit bdd383a

Browse files
author
Antonis Tsakiridis
committed
Fixed #394: Bring helloworld sample App up to date with latest SDK changes
1 parent 8f66921 commit bdd383a

File tree

8 files changed

+147
-74
lines changed

8 files changed

+147
-74
lines changed

Examples/restcomm-helloworld/.idea/gradle.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/restcomm-helloworld/.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/restcomm-helloworld/.idea/modules.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/restcomm-helloworld/app/app.iml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@
6464
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
6565
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
6666
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
67-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
68-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
69-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
70-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
71-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
72-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
73-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
74-
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
7567
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
7668
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
7769
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
@@ -80,23 +72,31 @@
8072
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
8173
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
8274
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
75+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
76+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
77+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
78+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
79+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
80+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
81+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
82+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
8383
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
8484
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
8585
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
8686
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
8787
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
8888
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
89-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/24.2.0/jars" />
90-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/24.2.0/jars" />
89+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/24.2.1/jars" />
90+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/24.2.1/jars" />
9191
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/24.2.0/jars" />
9292
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/24.2.0/jars" />
93-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-compat/24.2.0/jars" />
94-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-ui/24.2.0/jars" />
95-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-utils/24.2.0/jars" />
96-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-fragment/24.2.0/jars" />
97-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-media-compat/24.2.0/jars" />
98-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/24.2.0/jars" />
99-
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/24.2.0/jars" />
93+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-compat/24.2.1/jars" />
94+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-ui/24.2.1/jars" />
95+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-core-utils/24.2.1/jars" />
96+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-fragment/24.2.1/jars" />
97+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-media-compat/24.2.1/jars" />
98+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/24.2.1/jars" />
99+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/24.2.1/jars" />
100100
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
101101
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-classes" />
102102
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-runtime-classes" />
@@ -117,24 +117,24 @@
117117
</content>
118118
<orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" />
119119
<orderEntry type="sourceFolder" forTests="false" />
120-
<orderEntry type="library" exported="" name="support-media-compat-24.2.0" level="project" />
120+
<orderEntry type="library" exported="" name="support-v4-24.2.1" level="project" />
121+
<orderEntry type="library" exported="" name="support-compat-24.2.1" level="project" />
122+
<orderEntry type="library" exported="" name="support-media-compat-24.2.1" level="project" />
123+
<orderEntry type="library" exported="" name="animated-vector-drawable-24.2.1" level="project" />
124+
<orderEntry type="library" exported="" name="support-fragment-24.2.1" level="project" />
121125
<orderEntry type="library" exported="" name="recyclerview-v7-24.2.0" level="project" />
122126
<orderEntry type="library" exported="" name="android-jain-sip-ri-1.2.293" level="project" />
123-
<orderEntry type="library" exported="" name="support-compat-24.2.0" level="project" />
124-
<orderEntry type="library" exported="" name="support-v4-24.2.0" level="project" />
125-
<orderEntry type="library" exported="" name="support-core-ui-24.2.0" level="project" />
127+
<orderEntry type="library" exported="" name="support-core-ui-24.2.1" level="project" />
126128
<orderEntry type="library" exported="" name="core-1.54.0.0" level="project" />
127-
<orderEntry type="library" exported="" name="support-core-utils-24.2.0" level="project" />
128-
<orderEntry type="library" exported="" name="appcompat-v7-24.2.0" level="project" />
129-
<orderEntry type="library" exported="" name="support-fragment-24.2.0" level="project" />
130-
<orderEntry type="library" exported="" name="support-annotations-24.2.0" level="project" />
131-
<orderEntry type="library" exported="" name="support-vector-drawable-24.2.0" level="project" />
132-
<orderEntry type="library" exported="" name="animated-vector-drawable-24.2.0" level="project" />
129+
<orderEntry type="library" exported="" name="appcompat-v7-24.2.1" level="project" />
130+
<orderEntry type="library" exported="" name="support-vector-drawable-24.2.1" level="project" />
131+
<orderEntry type="library" exported="" name="support-core-utils-24.2.1" level="project" />
132+
<orderEntry type="library" exported="" name="support-annotations-24.2.1" level="project" />
133133
<orderEntry type="library" exported="" name="design-24.2.0" level="project" />
134134
<orderEntry type="library" exported="" name="prov-1.54.0.0" level="project" />
135135
<orderEntry type="library" exported="" name="pkix-1.54.0.0" level="project" />
136136
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
137137
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
138-
<orderEntry type="module" module-name="restcomm.android.client.sdk" exported="" />
138+
<orderEntry type="module" module-name="restcomm.android.sdk" exported="" />
139139
</component>
140140
</module>

Examples/restcomm-helloworld/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ android {
2222
dependencies {
2323
compile fileTree(dir: 'libs', include: ['*.jar'])
2424
testCompile 'junit:junit:4.12'
25-
compile project(':restcomm.android.client.sdk')
25+
compile project(':restcomm.android.sdk')
2626
compile 'com.android.support:appcompat-v7:24.2.0'
2727
compile 'com.android.support:design:24.2.0'
2828
compile 'com.android.support:support-v4:24.2.0'

Examples/restcomm-helloworld/app/src/main/java/com/telestax/restcomm_helloworld/MainActivity.java

Lines changed: 108 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
1+
/*
2+
* TeleStax, Open Source Cloud Communications
3+
* Copyright 2011-2015, Telestax Inc and individual contributors
4+
* by the @authors tag.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* under the terms of the GNU Affero General Public License as
8+
* published by the Free Software Foundation; either version 3 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Affero General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>
18+
*
19+
* For questions related to commercial use licensing, please contact sales@telestax.com.
20+
*
21+
*/
22+
123
package com.telestax.restcomm_helloworld;
224

325
//import android.support.v7.app.ActionBarActivity;
426

527
import android.Manifest;
628
import android.app.Activity;
29+
import android.content.ComponentName;
30+
import android.content.Context;
731
import android.content.Intent;
32+
import android.content.ServiceConnection;
833
import android.content.pm.PackageManager;
34+
import android.graphics.drawable.ColorDrawable;
935
import android.opengl.GLSurfaceView;
1036
import android.os.Bundle;
37+
import android.os.IBinder;
1138
import android.support.v4.app.ActivityCompat;
1239
import android.view.Menu;
1340
import android.view.MenuItem;
@@ -23,19 +50,22 @@
2350
import java.util.HashMap;
2451
import java.util.ListIterator;
2552

26-
import org.mobicents.restcomm.android.client.sdk.RCClient;
27-
import org.mobicents.restcomm.android.client.sdk.RCConnection;
28-
import org.mobicents.restcomm.android.client.sdk.RCConnectionListener;
29-
import org.mobicents.restcomm.android.client.sdk.RCDevice;
30-
import org.mobicents.restcomm.android.client.sdk.RCDeviceListener;
31-
import org.mobicents.restcomm.android.client.sdk.RCPresenceEvent;
53+
import org.restcomm.android.sdk.RCClient;
54+
import org.restcomm.android.sdk.RCConnection;
55+
import org.restcomm.android.sdk.RCConnectionListener;
56+
import org.restcomm.android.sdk.RCDevice;
57+
import org.restcomm.android.sdk.RCDeviceListener;
58+
import org.restcomm.android.sdk.RCPresenceEvent;
3259
import org.webrtc.VideoRenderer;
3360
import org.webrtc.VideoRendererGui;
3461
import org.webrtc.VideoTrack;
3562

36-
public class MainActivity extends Activity implements RCDeviceListener, RCConnectionListener, OnClickListener {
63+
public class MainActivity extends Activity implements RCDeviceListener, RCConnectionListener, OnClickListener,
64+
ServiceConnection {
3765

3866
private RCDevice device;
67+
boolean serviceBound = false;
68+
3969
private RCConnection connection, pendingConnection;
4070
private HashMap<String, Object> params;
4171
private static final String TAG = "MainActivity";
@@ -71,53 +101,95 @@ protected void onCreate(Bundle savedInstanceState)
71101
btnDial.setOnClickListener(this);
72102
btnHangup = (Button) findViewById(R.id.button_hangup);
73103
btnHangup.setOnClickListener(this);
104+
}
74105

75-
// Initialized Restcomm Client SDK entities
76-
RCClient.setLogLevel(Log.VERBOSE);
77-
RCClient.initialize(getApplicationContext(), new RCClient.RCInitListener() {
78-
public void onInitialized()
79-
{
80-
Log.i(TAG, "RCClient initialized");
81-
}
106+
@Override
107+
protected void onStart()
108+
{
109+
super.onStart();
110+
// The activity is about to become visible.
111+
Log.i(TAG, "%% onStart");
82112

83-
public void onError(Exception exception)
84-
{
85-
Log.e(TAG, "RCClient initialization error");
86-
}
87-
});
113+
bindService(new Intent(this, RCDevice.class), this, Context.BIND_AUTO_CREATE);
114+
}
88115

89-
params = new HashMap<String, Object>();
90-
// update the IP address to your Restcomm instance
91-
params.put(RCDevice.ParameterKeys.SIGNALING_DOMAIN, "");
92-
params.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "android-sdk");
93-
params.put(RCDevice.ParameterKeys.SIGNALING_PASSWORD, "1234");
94-
params.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, "https://service.xirsys.com/ice");
95-
params.put(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME, "atsakiridis");
96-
params.put(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD, "4e89a09e-bf6f-11e5-a15c-69ffdcc2b8a7");
97-
params.put(RCDevice.ParameterKeys.MEDIA_TURN_ENABLED, true);
98-
device = RCClient.createDevice(params, this);
99-
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
100-
// we don't have a separate activity for the calls and messages, so let's use the same intent both for calls and messages
101-
device.setPendingIntents(intent, intent);
116+
@Override
117+
protected void onStop()
118+
{
119+
super.onStop();
120+
// The activity is no longer visible (it is now "stopped")
121+
Log.i(TAG, "%% onStop");
122+
123+
// Unbind from the service
124+
if (serviceBound) {
125+
//device.detach();
126+
unbindService(this);
127+
serviceBound = false;
128+
}
102129
}
103130

131+
104132
@Override
105133
protected void onDestroy()
106134
{
107135
super.onDestroy();
108136
// The activity is about to be destroyed.
109137
Log.i(TAG, "%% onDestroy");
138+
device.release();
139+
/*
110140
RCClient.shutdown();
111141
device = null;
142+
*/
112143
}
113144

114-
/*
115-
private void videoContextReady()
145+
// Callbacks for service binding, passed to bindService()
146+
@Override
147+
public void onServiceConnected(ComponentName className, IBinder service)
116148
{
117-
videoReady = true;
149+
Log.i(TAG, "%% onServiceConnected");
150+
// We've bound to LocalService, cast the IBinder and get LocalService instance
151+
RCDevice.RCDeviceBinder binder = (RCDevice.RCDeviceBinder) service;
152+
device = binder.getService();
153+
154+
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
155+
156+
HashMap<String, Object> params = new HashMap<String, Object>();
157+
// we don't have a separate activity for the calls and messages, so let's use the same intent both for calls and messages
158+
params.put(RCDevice.ParameterKeys.INTENT_INCOMING_CALL, intent);
159+
params.put(RCDevice.ParameterKeys.INTENT_INCOMING_MESSAGE, intent);
160+
params.put(RCDevice.ParameterKeys.SIGNALING_DOMAIN, "");
161+
params.put(RCDevice.ParameterKeys.SIGNALING_USERNAME, "android-sdk");
162+
params.put(RCDevice.ParameterKeys.SIGNALING_PASSWORD, "1234");
163+
params.put(RCDevice.ParameterKeys.MEDIA_ICE_URL, "https://service.xirsys.com/ice");
164+
params.put(RCDevice.ParameterKeys.MEDIA_ICE_USERNAME, "atsakiridis");
165+
params.put(RCDevice.ParameterKeys.MEDIA_ICE_PASSWORD, "4e89a09e-bf6f-11e5-a15c-69ffdcc2b8a7");
166+
params.put(RCDevice.ParameterKeys.MEDIA_TURN_ENABLED, true);
167+
//params.put(RCDevice.ParameterKeys.SIGNALING_SECURE_ENABLED, prefs.getBoolean(RCDevice.ParameterKeys.SIGNALING_SECURE_ENABLED, false));
168+
169+
// The SDK provides the user with default sounds for calling, ringing, busy (declined) and message, but the user can override them
170+
// by providing their own resource files (i.e. .wav, .mp3, etc) at res/raw passing them with Resource IDs like R.raw.user_provided_calling_sound
171+
//params.put(RCDevice.ParameterKeys.RESOURCE_SOUND_CALLING, R.raw.user_provided_calling_sound);
172+
//params.put(RCDevice.ParameterKeys.RESOURCE_SOUND_RINGING, R.raw.user_provided_ringing_sound);
173+
//params.put(RCDevice.ParameterKeys.RESOURCE_SOUND_DECLINED, R.raw.user_provided_declined_sound);
174+
//params.put(RCDevice.ParameterKeys.RESOURCE_SOUND_MESSAGE, R.raw.user_provided_message_sound);
175+
176+
// This is for debugging purposes, not for release builds
177+
//params.put(RCDevice.ParameterKeys.SIGNALING_JAIN_SIP_LOGGING_ENABLED, prefs.getBoolean(RCDevice.ParameterKeys.SIGNALING_JAIN_SIP_LOGGING_ENABLED, true));
178+
179+
if (!device.isInitialized()) {
180+
device.initialize(getApplicationContext(), params, this);
181+
device.setLogLevel(Log.VERBOSE);
182+
}
183+
184+
serviceBound = true;
118185
}
119-
*/
120186

187+
@Override
188+
public void onServiceDisconnected(ComponentName arg0)
189+
{
190+
Log.i(TAG, "%% onServiceDisconnected");
191+
serviceBound = false;
192+
}
121193
@Override
122194
public boolean onCreateOptionsMenu(Menu menu)
123195
{

0 commit comments

Comments
 (0)