44import android .content .Intent ;
55import android .graphics .Point ;
66import android .os .Bundle ;
7+ import android .view .View ;
78import android .view .Window ;
8- import android .widget .Toast ;
9+ import android .widget .* ;
910import org .appspot .apprtc .VideoStreamsView ;
1011import org .webrtc .MediaStream ;
1112import org .webrtc .PeerConnectionFactory ;
@@ -15,37 +16,60 @@ public class RTCActivity extends Activity implements RTCClient.RTCListener{
1516 private static final String HOST = "http://54.214.218.3:3000/" ;
1617 private VideoStreamsView vsv ;
1718 private RTCClient client ;
19+ private EditText nameView ;
20+ private CheckBox privacySetting ;
21+ private TextView linkView ;
22+ private ToggleButton cameraFacingView ;
1823
1924 @ Override
2025 public void onCreate (Bundle savedInstanceState ) {
2126 super .onCreate (savedInstanceState );
2227 requestWindowFeature (Window .FEATURE_NO_TITLE );
28+ setContentView (R .layout .main );
29+
30+ nameView = (EditText ) findViewById (R .id .name );
31+ privacySetting = (CheckBox ) findViewById (R .id .privacy );
32+ linkView = (TextView ) findViewById (R .id .link );
33+ cameraFacingView = (ToggleButton ) findViewById (R .id .cameraFacing );
34+
35+ PeerConnectionFactory .initializeAndroidGlobals (this );
2336
2437 // Camera display view
2538 Point displaySize = new Point ();
2639 getWindowManager ().getDefaultDisplay ().getSize (displaySize );
2740 vsv = new VideoStreamsView (this , displaySize );
28- setContentView (vsv );
29-
30- PeerConnectionFactory .initializeAndroidGlobals (this );
3141
3242 client = new RTCClient (this , HOST );
43+ }
44+
45+ // button action
46+ public void stream (View view ) {
47+ setContentView (vsv );
3348
3449 // Settings
35- client .setName ("android_test" );
36- client .setCamera ("back" , "320" , "240" );
50+ client .setName (String .valueOf (nameView .getText ()));
51+ client .setPrivacy (privacySetting .isChecked ());
52+ String cameraFacing = cameraFacingView .isChecked () ? "front" : "back" ;
53+ client .setCamera (cameraFacing , "320" , "240" );
3754
3855 client .start ();
39- }
4056
41- @ Override
42- public void onCallReady (String callId ) {
4357 Intent msg = new Intent (Intent .ACTION_SEND );
44- msg .putExtra (Intent .EXTRA_TEXT , HOST + callId );
58+ msg .putExtra (Intent .EXTRA_TEXT , linkView . getText () );
4559 msg .setType ("text/plain" );
4660 startActivity (Intent .createChooser (msg , "Call someone :" ));
4761 }
4862
63+ @ Override
64+ public void onCallReady (final String callId ) {
65+ runOnUiThread (new Runnable () {
66+ @ Override
67+ public void run () {
68+ linkView .setText (HOST + callId );
69+ }
70+ });
71+ }
72+
4973 @ Override
5074 public void onStatusChanged (final String newStatus ) {
5175 runOnUiThread (new Runnable () {
0 commit comments