Skip to content

Commit f5d0a0d

Browse files
committed
Fixes #181: Quick cleanup of code for BETA2 release
1 parent 20275e8 commit f5d0a0d

File tree

8 files changed

+150
-489
lines changed

8 files changed

+150
-489
lines changed

Examples/restcomm-messenger/app/src/main/java/com/telestax/restcomm_messenger/CallActivity.java

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
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 [email protected].
20+
*
21+
*/
22+
123
package com.telestax.restcomm_messenger;
224

325
import android.app.Activity;
@@ -30,7 +52,7 @@
3052
import org.webrtc.VideoTrack;
3153

3254
public class CallActivity extends Activity implements RCConnectionListener, View.OnClickListener,
33-
CompoundButton.OnCheckedChangeListener, AudioManager.OnAudioFocusChangeListener {
55+
CompoundButton.OnCheckedChangeListener {
3456

3557
private GLSurfaceView videoView;
3658
private VideoRenderer.Callbacks localRender = null;
@@ -65,8 +87,6 @@ public class CallActivity extends Activity implements RCConnectionListener, View
6587
CheckBox cbMuted;
6688
Button btnHangup;
6789
Button btnAnswer, btnAnswerAudio;
68-
//Button btnDecline;
69-
//Button btnCancel;
7090

7191
@Override
7292
protected void onCreate(Bundle savedInstanceState) {
@@ -93,10 +113,6 @@ protected void onCreate(Bundle savedInstanceState) {
93113
btnAnswer.setOnClickListener(this);
94114
btnAnswerAudio = (Button)findViewById(R.id.button_answer_audio);
95115
btnAnswerAudio.setOnClickListener(this);
96-
//btnDecline = (Button)findViewById(R.id.button_decline);
97-
//btnDecline.setOnClickListener(this);
98-
//btnCancel = (Button)findViewById(R.id.button_cancel);
99-
//btnCancel.setOnClickListener(this);
100116
cbMuted = (CheckBox)findViewById(R.id.checkbox_muted);
101117
cbMuted.setOnCheckedChangeListener(this);
102118
cbMuted.setEnabled(false);
@@ -343,41 +359,11 @@ public void onReceiveRemoteVideo(RCConnection connection, VideoTrack videoTrack)
343359
VideoRendererGui.update(remoteRender,
344360
REMOTE_X, REMOTE_Y,
345361
REMOTE_WIDTH, REMOTE_HEIGHT, scalingType, false);
346-
//if (iceConnected) {
347-
VideoRendererGui.update(localRender,
348-
LOCAL_X_CONNECTED, LOCAL_Y_CONNECTED,
349-
LOCAL_WIDTH_CONNECTED, LOCAL_HEIGHT_CONNECTED,
350-
VideoRendererGui.ScalingType.SCALE_ASPECT_FIT, true);
351-
/*
352-
} else {
353-
VideoRendererGui.update(localRender,
354-
LOCAL_X_CONNECTING, LOCAL_Y_CONNECTING,
355-
LOCAL_WIDTH_CONNECTING, LOCAL_HEIGHT_CONNECTING, scalingType, true);
356-
}
357-
*/
358-
}
359-
}
360-
361-
// Callbacks for auio focus change events
362-
public void onAudioFocusChange(int focusChange)
363-
{
364-
Log.i(TAG, "onAudioFocusChange: " + focusChange);
365-
/*
366-
if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT) {
367-
// Pause playback
368-
}
369-
else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) {
370-
// Resume playback or raise it back to normal if we were ducked
371-
}
372-
else if (focusChange == AudioManager.AUDIOFOCUS_LOSS) {
373-
//am.unregisterMediaButtonEventReceiver(RemoteControlReceiver);
374-
audio.abandonAudioFocus(this);
375-
// Stop playback
376-
}
377-
else if (focusChange == AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) {
378-
// Lower the volume
362+
VideoRendererGui.update(localRender,
363+
LOCAL_X_CONNECTED, LOCAL_Y_CONNECTED,
364+
LOCAL_WIDTH_CONNECTED, LOCAL_HEIGHT_CONNECTED,
365+
VideoRendererGui.ScalingType.SCALE_ASPECT_FIT, true);
379366
}
380-
*/
381367
}
382368

383369
// Helpers

Examples/restcomm-messenger/app/src/main/java/com/telestax/restcomm_messenger/MainActivity.java

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
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 [email protected].
20+
*
21+
*/
22+
123
package com.telestax.restcomm_messenger;
224

325
import android.app.Activity;
@@ -7,7 +29,6 @@
729
import android.content.SharedPreferences;
830
import android.content.res.Configuration;
931
import android.media.MediaPlayer;
10-
import android.net.wifi.WifiManager;
1132
import android.os.Bundle;
1233
import android.preference.PreferenceManager;
1334
import android.view.Menu;
@@ -117,7 +138,6 @@ protected void onResume() {
117138
}
118139
// The activity has become visible (it is now "resumed").
119140
Log.i(TAG, "%% onResume");
120-
Intent intent = getIntent();
121141
}
122142

123143
@Override
@@ -157,22 +177,15 @@ public void onPrepared(MediaPlayer mp)
157177
// UI Events
158178
public void onClick(View view) {
159179
if (view.getId() == R.id.button_dial || view.getId() == R.id.button_dial_audio) {
160-
//WifiManager wifi = (WifiManager) getSystemService(WIFI_SERVICE);
161-
//if (wifi.isWifiEnabled()) {
162-
Intent intent = new Intent(this, CallActivity.class);
163-
intent.setAction(RCDevice.OUTGOING_CALL);
164-
intent.putExtra(RCDevice.EXTRA_DID, txtUri.getText().toString());
165-
if (view.getId() == R.id.button_dial_audio) {
166-
intent.putExtra(RCDevice.EXTRA_VIDEO_ENABLED, false);
167-
}
168-
else {
169-
intent.putExtra(RCDevice.EXTRA_VIDEO_ENABLED, true);
170-
}
171-
startActivityForResult(intent, CONNECTION_REQUEST);
172-
//}
173-
//else {
174-
// showOkAlert("No Connectivity", "No network connectivity");
175-
//}
180+
Intent intent = new Intent(this, CallActivity.class);
181+
intent.setAction(RCDevice.OUTGOING_CALL);
182+
intent.putExtra(RCDevice.EXTRA_DID, txtUri.getText().toString());
183+
if (view.getId() == R.id.button_dial_audio) {
184+
intent.putExtra(RCDevice.EXTRA_VIDEO_ENABLED, false);
185+
} else {
186+
intent.putExtra(RCDevice.EXTRA_VIDEO_ENABLED, true);
187+
}
188+
startActivityForResult(intent, CONNECTION_REQUEST);
176189
}
177190
else if (view.getId() == R.id.button_register) {
178191
if (!device.updateParams(params)) {
@@ -181,16 +194,10 @@ else if (view.getId() == R.id.button_register) {
181194

182195
}
183196
else if (view.getId() == R.id.button_message) {
184-
//WifiManager wifi = (WifiManager) getSystemService(WIFI_SERVICE);
185-
//if (wifi.isWifiEnabled()) {
186-
Intent intent = new Intent(this, MessageActivity.class);
187-
intent.setAction(RCDevice.OPEN_MESSAGE_SCREEN);
188-
intent.putExtra(RCDevice.EXTRA_DID, txtUri.getText().toString());
189-
startActivity(intent);
190-
//}
191-
//else {
192-
// showOkAlert("No Connectivity", "No network connectivity");
193-
//}
197+
Intent intent = new Intent(this, MessageActivity.class);
198+
intent.setAction(RCDevice.OPEN_MESSAGE_SCREEN);
199+
intent.putExtra(RCDevice.EXTRA_DID, txtUri.getText().toString());
200+
startActivity(intent);
194201
}
195202
else if (view.getId() == R.id.button_listen) {
196203
device.listen();

Examples/restcomm-messenger/app/src/main/java/com/telestax/restcomm_messenger/MessageActivity.java

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
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 [email protected].
20+
*
21+
*/
22+
123
package com.telestax.restcomm_messenger;
224

325
import android.app.AlertDialog;
4-
import android.content.Context;
526
import android.content.DialogInterface;
627
import android.content.Intent;
7-
import android.media.AudioManager;
828
import android.app.Activity;
9-
import android.media.AudioManager.OnAudioFocusChangeListener;
10-
import android.media.MediaPlayer;
1129
import android.os.Bundle;
1230
import android.text.method.ScrollingMovementMethod;
1331
import android.util.Log;
@@ -33,8 +51,6 @@ public class MessageActivity extends Activity implements View.OnClickListener {
3351
Button btnSend;
3452
EditText txtMessage;
3553
TextView txtWall;
36-
//MediaPlayer messagePlayer;
37-
//AudioManager audioManager;
3854

3955
@Override
4056
protected void onCreate(Bundle savedInstanceState) {
@@ -50,13 +66,6 @@ protected void onCreate(Bundle savedInstanceState) {
5066
txtMessage = (EditText)findViewById(R.id.text_message);
5167
txtMessage.setOnClickListener(this);
5268

53-
/*
54-
// volume control should be by default 'music' which will control the ringing sounds and 'voice call' when within a call
55-
setVolumeControlStream(AudioManager.STREAM_MUSIC);
56-
messagePlayer = MediaPlayer.create(getApplicationContext(), R.raw.message);
57-
messagePlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
58-
audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
59-
*/
6069
}
6170

6271
// We 've set MessageActivity to be 'singleTop' on the manifest to be able to receive messages while already open, without instantiating
@@ -91,13 +100,6 @@ public void onResume()
91100
params.put("username", username);
92101

93102
txtWall.append(shortname + ": " + message + "\n\n");
94-
95-
/*
96-
int result = audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
97-
if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
98-
messagePlayer.start();
99-
}
100-
*/
101103
}
102104
}
103105

@@ -109,13 +111,6 @@ public void onClick(View view) {
109111
if (device.sendMessage(txtMessage.getText().toString(), sendParams)) {
110112
// also output the message in the wall
111113
txtWall.append("Me: " + txtMessage.getText().toString() + "\n\n");
112-
113-
/*
114-
int result = audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
115-
if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
116-
messagePlayer.start();
117-
}
118-
*/
119114
txtMessage.setText("");
120115
}
121116
else {
@@ -146,16 +141,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
146141
return super.onOptionsItemSelected(item);
147142
}
148143

149-
/*
150-
public void handleIncomingMessage(RCDevice device, String message, HashMap<String, String> parameters)
151-
{
152-
Log.i(TAG, "Message arrived: " + message);
153-
154-
// put new text on the bottom
155-
txtWall.append(parameters.get("username") + ": " + message + "\n");
156-
}
157-
*/
158-
159144
@Override
160145
protected void onPause() {
161146
super.onPause();
@@ -175,7 +160,6 @@ private void showOkAlert(final String title, final String detail) {
175160
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
176161
public void onClick(DialogInterface dialog, int which) {
177162
dialog.dismiss();
178-
//finish();
179163
}
180164
});
181165
alertDialog.show();

restcomm.android.client.sdk/src/main/java/org/mobicents/restcomm/android/client/sdk/RCClient.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public static void initialize(Context context, final RCInitListener listener)
114114
listener.onInitialized();
115115

116116
/*
117+
TODO: this would probably make more sense at some point
117118
Handler mainHandler = new Handler(RCClient.getInstance().context.getMainLooper());
118119
Runnable myRunnable = new Runnable() {
119120
@Override
@@ -141,8 +142,8 @@ public static void shutdown()
141142
// remove the reference so that RCDevice instance is removed
142143
list.clear();
143144
list = null;
144-
// TODO: keep in mind that once this block is left device can be claimed by GC.
145-
// Need to make sure that shutdown() will finish its job synchronously
145+
// Need to make sure that shutdown() will finish its job synchronously.
146+
// Keep in mind that once this block is left device can be claimed by GC
146147
device.shutdown();
147148
}
148149
else {
@@ -179,7 +180,6 @@ public static RCDevice createDevice(HashMap<String, Object> parameters, RCDevice
179180
if (list.size() == 0) {
180181
RCDevice device = new RCDevice(parameters, deviceListener);
181182
list.add(device);
182-
//initialized = true;
183183
}
184184
else {
185185
Log.e(TAG, "Device already exists, so we 're returning this one");
@@ -206,11 +206,13 @@ public static ArrayList<RCDevice> listDevices()
206206
}
207207

208208
/*
209+
// TODO: implement
209210
public static void setLogLevel(int level)
210211
{
211212
212213
}
213214
215+
// TODO: implement
214216
public static String getVersion()
215217
{
216218
return "";

0 commit comments

Comments
 (0)