Skip to content
Snippets Groups Projects
Commit 6bafaf1e authored by Aylen Ricca's avatar Aylen Ricca
Browse files

getting ip dialog

parent 30a1ef2c
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ public class Server {
public static final int SERVERPORT = 5555;
public Server() {
public Server(String serverIp) {
clientSocket = null;
try {
serverSocket = new ServerSocket(SERVERPORT);
......@@ -44,6 +44,15 @@ public class Server {
}
}
public void SendData() {
try {
serverSocket.close();
clientSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public void Stop() {
try {
serverSocket.close();
......
......@@ -8,18 +8,27 @@ import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;
import uy.edu.chesstrack.communication.Server;
import uy.edu.fing.chesstrack.modulovision.Adquisicion;
import uy.edu.fing.chesstrack.modulovision.Calibracion;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.media.AudioManager;
import android.media.ToneGenerator;
import android.os.Bundle;
import android.text.Editable;
import android.text.method.KeyListener;
import android.util.Log;
import android.view.KeyEvent;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class ChessTrackActivity extends Activity implements CvCameraViewListener {
......@@ -30,6 +39,8 @@ public class ChessTrackActivity extends Activity implements CvCameraViewListener
private Adquisicion adq;
private Calibracion calibrar;
private Button btnCalibrar;
private Server ServidorCommunication;
private EditText text;
//TODO es chancho pero ver luego
private Mat frame;
......@@ -71,7 +82,6 @@ public class ChessTrackActivity extends Activity implements CvCameraViewListener
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraView.setCvCameraViewListener(this);
try {
isUsed = false;
isCalibrada =false;
addListenerOnButton();
......@@ -80,8 +90,35 @@ public class ChessTrackActivity extends Activity implements CvCameraViewListener
e.printStackTrace();
}
getIp();
}
public void getIp(){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Communication Setup");
alert.setMessage("Set server ip");
// Set an EditText view to get user input
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Editable value = input.getText();
Log.i(TAG,"INPUT=" + value.toString());
ServidorCommunication = new Server(value.toString());
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// no server communication
}
});
alert.show();
}
public void addListenerOnButton() {
btnCalibrar = (Button) findViewById(R.id.btn_calibrar);
......@@ -111,7 +148,6 @@ public class ChessTrackActivity extends Activity implements CvCameraViewListener
}
});
}
......@@ -130,6 +166,7 @@ public class ChessTrackActivity extends Activity implements CvCameraViewListener
if (mOpenCvCameraView != null) {
mOpenCvCameraView.disableView();
}
this.ServidorCommunication.Stop();
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment