Skip to content

Commit edc1ae1

Browse files
committed
Fixes #94: Avoid passing video view and preferences from the activity to SDK. Fixes #95: Various trivial fixes
1 parent f9db352 commit edc1ae1

File tree

7 files changed

+106
-147
lines changed

7 files changed

+106
-147
lines changed

Examples/restcomm-messenger/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
android:configChanges="orientation|screenSize|keyboardHidden"
2222
android:label="@string/app_name"
2323
android:launchMode="singleTask"
24-
android:screenOrientation="fullUser" > <!-- "portrait" > -->
24+
android:screenOrientation="portrait" >
2525
<intent-filter>
2626
<action android:name="android.intent.action.MAIN" />
2727

@@ -35,8 +35,8 @@
3535
<activity
3636
android:name=".CallActivity"
3737
android:label="@string/title_activity_call"
38-
android:screenOrientation="fullUser"
39-
android:configChanges="orientation|screenSize" >
38+
android:screenOrientation="portrait"
39+
android:configChanges="orientation|screenSize|keyboardHidden" >
4040
</activity>
4141

4242
</application>

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

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import android.widget.Button;
2222
import android.widget.CheckBox;
2323
import android.widget.CompoundButton;
24+
import android.widget.LinearLayout;
25+
import android.widget.RelativeLayout;
2426

2527
import org.mobicents.restcomm.android.client.sdk.RCClient;
2628
import org.mobicents.restcomm.android.client.sdk.RCConnection;
@@ -35,26 +37,24 @@
3537
public class CallActivity extends Activity implements RCConnectionListener, View.OnClickListener,
3638
CompoundButton.OnCheckedChangeListener, AudioManager.OnAudioFocusChangeListener {
3739

38-
private GLSurfaceView videoView;
40+
//private GLSurfaceView videoView;
3941
private RCConnection connection, pendingConnection;
4042
SharedPreferences prefs;
4143
private static final String TAG = "CallActivity";
4244
private HashMap<String, String> connectParams = new HashMap<String, String>();
4345
private RCDevice device;
46+
private RelativeLayout parentLayout;
4447
MediaPlayer ringingPlayer;
4548
MediaPlayer callingPlayer;
4649
AudioManager audioManager;
50+
final String TAG_LOCAL_VIDEO_VIEW = "local-video-view";
4751

4852
CheckBox cbMuted;
4953
Button btnHangup;
5054
Button btnAnswer;
5155
Button btnDecline;
5256
Button btnCancel;
5357

54-
String incomingCallDid = "";
55-
// TODO: remove those when the API is structured properlu
56-
// String incomingCallSdp = "";
57-
5858
@Override
5959
protected void onCreate(Bundle savedInstanceState) {
6060
super.onCreate(savedInstanceState);
@@ -85,7 +85,8 @@ protected void onCreate(Bundle savedInstanceState) {
8585
btnCancel.setOnClickListener(this);
8686
cbMuted = (CheckBox)findViewById(R.id.checkbox_muted);
8787
cbMuted.setOnCheckedChangeListener(this);
88-
videoView = (GLSurfaceView) findViewById(R.id.glview_call);
88+
parentLayout = (RelativeLayout) findViewById(R.id.layout_video_call);
89+
//videoView = (GLSurfaceView) findViewById(R.id.glview_call);
8990

9091
audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
9192
// volume control should be by default 'music' which will control the ringing sounds and 'voice call' when within a call
@@ -108,7 +109,7 @@ protected void onCreate(Bundle savedInstanceState) {
108109
final Intent intent = getIntent();
109110
if (intent.getAction() == RCDevice.OUTGOING_CALL) {
110111
connectParams.put("username", intent.getStringExtra(RCDevice.EXTRA_DID));
111-
connection = device.connect(connectParams, this, videoView, prefs);
112+
connection = device.connect(connectParams, this);
112113

113114
if (connection == null) {
114115
Log.e(TAG, "Error: error connecting");
@@ -121,21 +122,15 @@ protected void onCreate(Bundle savedInstanceState) {
121122
ringingPlayer.start();
122123
}
123124
pendingConnection = device.incomingConnection;
124-
pendingConnection.updateListener(this);
125-
pendingConnection.setupWebrtcForIncomingCall(videoView, prefs);
125+
pendingConnection.listenerReady(this);
126126

127127
// the number from which we got the call
128-
incomingCallDid = intent.getStringExtra(RCDevice.EXTRA_DID);
129-
//incomingCallSdp = intent.getStringExtra(RCDevice.EXTRA_SDP);
128+
String incomingCallDid = intent.getStringExtra(RCDevice.EXTRA_DID);
130129
}
131130
}
132131

133132
// UI Events
134133
public void onClick(View view) {
135-
if (view.getId() == R.id.glview_call) {
136-
//connection = device.connect(connectParams, this, videoView, prefs);
137-
}
138-
139134
if (view.getId() == R.id.button_hangup) {
140135
if (connection == null) {
141136
Log.e(TAG, "Error: not connected");
@@ -148,8 +143,8 @@ public void onClick(View view) {
148143
} else if (view.getId() == R.id.button_answer) {
149144
if (pendingConnection != null) {
150145
pendingConnection.accept();
151-
//pendingConnection.answerCall(incomingCallDid, incomingCallSdp);
152146
connection = this.pendingConnection;
147+
pendingConnection = null;
153148
ringingPlayer.pause();
154149
// Abandon audio focus when playback complete
155150
audioManager.abandonAudioFocus(this);
@@ -161,6 +156,7 @@ public void onClick(View view) {
161156
ringingPlayer.pause();
162157
// Abandon audio focus when playback complete
163158
audioManager.abandonAudioFocus(this);
159+
finish();
164160
}
165161
} else if (view.getId() == R.id.button_cancel) {
166162
if (connection == null) {
@@ -173,6 +169,7 @@ public void onClick(View view) {
173169
callingPlayer.pause();
174170
// Abandon audio focus when playback complete
175171
audioManager.abandonAudioFocus(this);
172+
finish();
176173
}
177174
}
178175
}
@@ -202,7 +199,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
202199
@Override
203200
public void onResume() {
204201
super.onResume();
205-
videoView.onResume();
202+
//videoView.onResume();
206203
/*
207204
activityRunning = true;
208205
if (peerConnectionClient != null) {
@@ -256,6 +253,8 @@ public void onCancelled(RCConnection connection) {
256253

257254
this.connection = null;
258255
pendingConnection = null;
256+
257+
finish();
259258
}
260259

261260
public void onDeclined(RCConnection connection) {
@@ -267,6 +266,8 @@ public void onDeclined(RCConnection connection) {
267266

268267
this.connection = null;
269268
pendingConnection = null;
269+
270+
finish();
270271
}
271272

272273
public void onDisconnected(RCConnection connection, int errorCode, String errorText) {
@@ -290,6 +291,17 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
290291
}
291292
}
292293

294+
public void onReceiveLocalVideo(RCConnection connection, GLSurfaceView videoView) {
295+
if (videoView != null) {
296+
//show media on screen
297+
videoView.setTag(TAG_LOCAL_VIDEO_VIEW);
298+
if (parentLayout.findViewWithTag(TAG_LOCAL_VIDEO_VIEW) != null) {
299+
parentLayout.removeView(videoView);
300+
}
301+
parentLayout.addView(videoView, 0);
302+
}
303+
}
304+
293305
// Callbacks for auio focus change events
294306
public void onAudioFocusChange(int focusChange)
295307
{

Examples/restcomm-messenger/app/src/main/res/layout/activity_call.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<RelativeLayout
4+
android:id="@+id/layout_video_call"
45
xmlns:android="http://schemas.android.com/apk/res/android"
56
xmlns:tools="http://schemas.android.com/tools"
67
android:layout_width="match_parent"
78
android:layout_height="match_parent">
8-
9+
<!--
910
<android.opengl.GLSurfaceView
1011
android:id="@+id/glview_call"
1112
android:layout_width="match_parent"
1213
android:layout_height="match_parent" />
14+
-->
1315

1416
<!--
1517
<FrameLayout

Examples/restcomm-messenger/app/src/main/res/layout/activity_main.xml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
android:layout_height="wrap_content"
1111
android:text="Dial"
1212
android:id="@+id/button_dial"
13-
android:layout_alignBottom="@+id/text_uri"
14-
android:layout_alignRight="@+id/button_send"
15-
android:layout_alignEnd="@+id/button_send" />
13+
android:layout_below="@+id/text_uri"
14+
android:layout_alignEnd="@+id/button_send"
15+
android:layout_alignParentStart="true" />
1616
<!--
1717
<Button
1818
android:layout_width="wrap_content"
@@ -30,12 +30,9 @@
3030
android:layout_height="wrap_content"
3131
android:text="Register"
3232
android:id="@+id/button_register"
33-
android:layout_below="@+id/text_message"
34-
android:layout_alignParentLeft="true"
33+
android:layout_alignParentBottom="true"
3534
android:layout_alignParentStart="true"
36-
android:layout_marginTop="30dp"
37-
android:layout_alignRight="@+id/button_send"
38-
android:layout_alignEnd="@+id/button_send" />
35+
android:layout_alignParentEnd="true" />
3936
<!--
4037
<Button
4138
android:layout_width="wrap_content"
@@ -73,9 +70,9 @@
7370
android:layout_height="wrap_content"
7471
android:text="Send"
7572
android:id="@+id/button_send"
76-
android:layout_alignBottom="@+id/text_message"
77-
android:layout_alignParentRight="true"
78-
android:layout_alignParentEnd="true" />
73+
android:layout_below="@+id/text_message"
74+
android:layout_alignParentEnd="true"
75+
android:layout_alignParentStart="true" />
7976

8077
<EditText
8178
android:layout_width="wrap_content"
@@ -86,7 +83,7 @@
8683
android:layout_alignParentStart="true"
8784
android:layout_toStartOf="@+id/button_send"
8885
android:layout_marginTop="10dp"
89-
android:layout_toLeftOf="@+id/button_send" />
86+
android:layout_alignEnd="@+id/button_send" />
9087

9188
<EditText
9289
android:layout_width="wrap_content"
@@ -99,7 +96,7 @@
9996
android:layout_alignParentStart="true"
10097
android:layout_marginTop="25dp"
10198
android:layout_toStartOf="@+id/button_send"
102-
android:layout_toLeftOf="@+id/button_send" />
99+
android:layout_alignParentEnd="true" />
103100

104101
<EditText
105102
android:layout_width="wrap_content"

0 commit comments

Comments
 (0)