Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a9c609323 | ||
|
|
48e7fe5d04 |
BIN
DroneAppController.rar
Normal file
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$USER_HOME$/Documentos/android/DroneAppController" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
||||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$USER_HOME$/Documents/android/DroneAppController" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android-gradle" name="Android-Gradle">
|
||||
<configuration>
|
||||
|
||||
@ -25,12 +25,9 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ControllerActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:label="@string/title_activity_main" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".CalibrationActivity"
|
||||
android:label="@string/title_activity_calibration" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ListOfDrones"
|
||||
android:label="@string/title_activity_list_of_drones" >
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
package pt.isep.mei.simov.droneappcontroller;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
/**
|
||||
* Created by almeida on 23-12-2014.
|
||||
*/
|
||||
|
||||
public class CalibrationActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_calibration);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_calibration, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
package pt.isep.mei.simov.droneappcontroller;
|
||||
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.jivesoftware.smack.AccountManager;
|
||||
import org.jivesoftware.smack.ConnectionConfiguration;
|
||||
@ -10,11 +9,7 @@ import org.jivesoftware.smack.RosterEntry;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import java.lang.InterruptedException;
|
||||
import java.lang.Runnable;
|
||||
import java.lang.String;
|
||||
import java.lang.System;
|
||||
import java.lang.Thread;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@ -26,6 +21,11 @@ public class Connection {
|
||||
String HOST = "aalmeid.ddns.net";
|
||||
int PORT = 5222;
|
||||
String SERVICE = "xmppserver";
|
||||
|
||||
/*String HOST = "sibacsimovisep2014.noip.me";
|
||||
int PORT = 5222;
|
||||
String SERVICE = "sibacsimovisep2014";*/
|
||||
|
||||
String USERNAME = "";
|
||||
String PASSWORD = "";
|
||||
|
||||
@ -104,6 +104,11 @@ public class Connection {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean closeConnection(){
|
||||
connection.disconnect();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean createAccount (String username, String password){
|
||||
try {
|
||||
AccountManager accountManager = connection.getAccountManager();
|
||||
|
||||
@ -2,15 +2,22 @@ package pt.isep.mei.simov.droneappcontroller;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
@ -21,31 +28,68 @@ import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by almeida on 18-12-2014.
|
||||
*/
|
||||
|
||||
public class ControllerActivity extends Activity {
|
||||
public class ControllerActivity extends Activity implements SensorEventListener {
|
||||
private SensorManager sensorManager;
|
||||
private String to;
|
||||
private XMPPConnection connection = Connection.getConnection();
|
||||
private ArrayList<String> messages = new ArrayList<String>();
|
||||
private int speed;
|
||||
private TextView tv;
|
||||
private Switch onOff;
|
||||
private Switch expertmode;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_controller);
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
|
||||
Button left = (Button) findViewById(R.id.buttonLeft);
|
||||
Button right = (Button) findViewById(R.id.buttonRight);
|
||||
Button up = (Button) findViewById(R.id.buttonUp);
|
||||
Button down = (Button) findViewById(R.id.buttonDown);
|
||||
Button acelerate = (Button) findViewById(R.id.buttonAcelerate);
|
||||
Button breake = (Button) findViewById(R.id.buttonBreak);
|
||||
Button on_off = (Button) findViewById(R.id.buttonOnOff);
|
||||
Button calibration = (Button) findViewById(R.id.buttonCallibration);
|
||||
Button desacelarate = (Button) findViewById(R.id.buttonBreak);
|
||||
|
||||
sensorManager=(SensorManager)getSystemService(SENSOR_SERVICE);
|
||||
|
||||
sensorManager.registerListener(this,
|
||||
sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
|
||||
SensorManager.SENSOR_DELAY_GAME);
|
||||
|
||||
tv = (TextView) findViewById(R.id.tv);
|
||||
|
||||
onOff = (Switch) findViewById(R.id.onOff);
|
||||
|
||||
|
||||
|
||||
onOff.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
senMessage("v-"+100);
|
||||
senMessage("v-"+30);
|
||||
speed = 30;
|
||||
} else {
|
||||
senMessage("v-" + 0);
|
||||
speed = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expertmode = (Switch) findViewById(R.id.expertmode);
|
||||
|
||||
expertmode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!onOff.isChecked()) {
|
||||
expertmode.setChecked(false);
|
||||
Toast.makeText(getApplicationContext(), R.string.turnOn,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Bundle b = getIntent().getExtras();
|
||||
to = b.getString("to");
|
||||
@ -55,128 +99,136 @@ public class ControllerActivity extends Activity {
|
||||
left.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(getApplicationContext(), "left pressed!",
|
||||
if(onOff.isChecked()) {
|
||||
senMessage("e");
|
||||
}else{
|
||||
Toast.makeText(getApplicationContext(), R.string.turnOn,
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
senMessage("left");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
right.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(getApplicationContext(), "right pressed!",
|
||||
if (onOff.isChecked()) {
|
||||
senMessage("d");
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), R.string.turnOn,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
senMessage("rigth");
|
||||
/*acelerate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onOff.isChecked()) {
|
||||
if (speed < 91) {
|
||||
speed = speed + 10;
|
||||
senMessage("v-" + speed);
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), R.string.turnOn,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});*/
|
||||
|
||||
acelerate.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (onOff.isChecked()) {
|
||||
if (speed < 100) {
|
||||
speed = speed + 1;
|
||||
senMessage("v-" + speed);
|
||||
tv.setText(speed+"/100");
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), R.string.turnOn,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
/*desacelarate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(onOff.isChecked()) {
|
||||
if(speed > 9) {
|
||||
speed = speed - 10;
|
||||
senMessage("v-" + speed);
|
||||
}
|
||||
}else{
|
||||
Toast.makeText(getApplicationContext(), R.string.turnOn,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});*/
|
||||
|
||||
desacelarate.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (onOff.isChecked()) {
|
||||
if (speed > 0) {
|
||||
speed = speed - 1;
|
||||
senMessage("v-" + speed);
|
||||
tv.setText(speed+"/100");
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), R.string.turnOn,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
up.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(getApplicationContext(), "up pressed!",
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
if (onOff.isChecked()) {
|
||||
senMessage("up");
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), R.string.turnOn,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
down.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(getApplicationContext(), "down pressed!",
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
if (onOff.isChecked()) {
|
||||
senMessage("down");
|
||||
}
|
||||
});
|
||||
|
||||
acelerate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(getApplicationContext(), "acelerate pressed!",
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), R.string.turnOn,
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
senMessage("acelerate");
|
||||
}
|
||||
});
|
||||
|
||||
breake.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(getApplicationContext(), "break pressed!",
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
senMessage("break");
|
||||
}
|
||||
});
|
||||
|
||||
on_off.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Toast.makeText(getApplicationContext(), "on_off pressed!",
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
senMessage("On/Off");
|
||||
}
|
||||
});
|
||||
|
||||
calibration.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(v.getContext());
|
||||
|
||||
// set title
|
||||
alertDialogBuilder.setTitle("Expert Mode");
|
||||
|
||||
// set dialog message
|
||||
alertDialogBuilder
|
||||
.setMessage("Atention: Expert Mode")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,int id) {
|
||||
// if this button is clicked, close
|
||||
// current activity
|
||||
Intent i = new Intent(getApplicationContext(), CalibrationActivity.class);
|
||||
startActivity(i);
|
||||
}
|
||||
})
|
||||
.setNegativeButton("No",new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,int id) {
|
||||
// if this button is clicked, just close
|
||||
// the dialog box and do nothing
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
// create alert dialog
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
||||
// show it
|
||||
alertDialog.show();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void senMessage(String message) {
|
||||
Message msg = new Message(to, Message.Type.chat);
|
||||
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
|
||||
|
||||
msg.setBody(message);
|
||||
if (connection != null) {
|
||||
if (!(networkInfo != null && networkInfo.isConnected())) {
|
||||
Toast.makeText(getApplicationContext(), R.string.droneConnection, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}else{
|
||||
connection.sendPacket(msg);
|
||||
messages.add(connection.getUser() + ":");
|
||||
messages.add(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setConnection(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
|
||||
System.out.println ("connection"+connection);
|
||||
if (connection != null) {
|
||||
// Add a packet listener to get messages sent to us
|
||||
PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
|
||||
connection.addPacketListener(new PacketListener() {
|
||||
@Override
|
||||
@ -185,34 +237,41 @@ public class ControllerActivity extends Activity {
|
||||
if (message.getBody() != null) {
|
||||
String fromName = StringUtils.parseBareAddress(message.getFrom());
|
||||
Log.i("XMPPChatDemoActivity ", " Text Recieved " + message.getBody() + " from " + fromName);
|
||||
messages.add(fromName + ":");
|
||||
messages.add(message.getBody());
|
||||
}
|
||||
}
|
||||
}, filter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
return true;
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
|
||||
if(event.sensor.getType()==Sensor.TYPE_ACCELEROMETER){
|
||||
|
||||
// assign directions
|
||||
float x=event.values[0];
|
||||
float y=event.values[1];
|
||||
|
||||
if (expertmode.isChecked() && onOff.isChecked()) {
|
||||
if(x > 8){
|
||||
if (speed > 0) {
|
||||
speed = speed - 1;
|
||||
senMessage("v-" + speed);
|
||||
tv.setText(speed + "/100");
|
||||
}
|
||||
} else if(x < 2) {
|
||||
if (speed < 100) {
|
||||
speed = speed + 1;
|
||||
senMessage("v-" + speed);
|
||||
tv.setText(speed+"/100");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,17 @@
|
||||
package pt.isep.mei.simov.droneappcontroller;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
|
||||
@ -36,16 +39,17 @@ public class ListOfDrones extends Activity {
|
||||
String user = b.getString("id");
|
||||
String passwd = b.getString("passwd");
|
||||
|
||||
Connection c = new Connection(user,passwd);
|
||||
try {
|
||||
Connection c = new Connection(user, passwd);
|
||||
users = c.getUsers();
|
||||
connection = c.getConnection();
|
||||
|
||||
|
||||
listView = (ListView) findViewById( R.id.listOfDrones );
|
||||
listView = (ListView) findViewById(R.id.listOfDrones);
|
||||
listAdapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.simplerow);
|
||||
listView.setAdapter( listAdapter );
|
||||
listView.setAdapter(listAdapter);
|
||||
|
||||
for (int i = 0; i < users.size(); i++){
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
listAdapter.add(users.get(i).toString());
|
||||
}
|
||||
|
||||
@ -53,11 +57,25 @@ public class ListOfDrones extends Activity {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
|
||||
|
||||
if (connection != null) {
|
||||
if (!(networkInfo != null && networkInfo.isConnected())) {
|
||||
Toast.makeText(getApplicationContext(), R.string.internetConnection, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}else{
|
||||
Intent i = new Intent(getApplicationContext(), ControllerActivity.class);
|
||||
i.putExtra("to", listAdapter.getItem(position));
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
Log.e("Authentication Problem", "Some problem with your account", e);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package pt.isep.mei.simov.droneappcontroller;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
@ -37,7 +35,7 @@ public class LoginActivity extends Activity {
|
||||
Log.i("XMPP", "Credencials: " + email + " and " + passwd);
|
||||
|
||||
if (email.equals("") || passwd.equals("")) {
|
||||
Toast.makeText(this, "Por favor preencha os campos de autenticação",
|
||||
Toast.makeText(this, R.string.autField,
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
@ -45,10 +43,9 @@ public class LoginActivity extends Activity {
|
||||
|
||||
if (!(networkInfo != null && networkInfo.isConnected()))
|
||||
{
|
||||
Toast.makeText(getApplicationContext(), "Não existe conexão à internet. Por favor, ligue o acesso à internet", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getApplicationContext(), R.string.internetConnection, Toast.LENGTH_SHORT).show();
|
||||
} else{
|
||||
|
||||
Intent i=new Intent(this,ListOfDrones.class);
|
||||
Intent i = new Intent(this, ListOfDrones.class);
|
||||
i.putExtra("id", email);
|
||||
i.putExtra("passwd", passwd);
|
||||
this.startActivity(i);
|
||||
@ -56,8 +53,8 @@ public class LoginActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
public void registerData (View vw) {
|
||||
/*public void registerData (View vw) {
|
||||
Intent i = new Intent(this, RegisterActivity.class);
|
||||
startActivity(i);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@ -1,17 +1,12 @@
|
||||
package pt.isep.mei.simov.droneappcontroller;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.jivesoftware.smack.ConnectionConfiguration;
|
||||
|
||||
/**
|
||||
* Created by almeida on 18-12-2014.
|
||||
*/
|
||||
@ -30,7 +25,7 @@ public class RegisterActivity extends Activity {
|
||||
buttonReg.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Connection c = new Connection("admin","adminpassword"); //este user não existe, o registo não está a funcionar com esta conta.
|
||||
Connection c = new Connection("user","passwd");
|
||||
if (c.createAccount(username.getText().toString(), passwd.getText().toString())){
|
||||
Toast.makeText(getApplicationContext(), "Registration completed!",
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
||||
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 13 KiB |
@ -1,12 +0,0 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="simov.dei.isep.pt.droneappcontrol.CallibrationActivity">
|
||||
|
||||
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</RelativeLayout>
|
||||
@ -9,23 +9,7 @@
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="On / Off"
|
||||
android:id="@+id/buttonOnOff"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Expert Mode"
|
||||
android:id="@+id/buttonCallibration"
|
||||
android:layout_below="@+id/buttonOnOff"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Left"
|
||||
android:text="<"
|
||||
android:id="@+id/buttonLeft"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
@ -34,7 +18,7 @@
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Acelerate"
|
||||
android:text="∧"
|
||||
android:id="@+id/buttonAcelerate"
|
||||
android:layout_above="@+id/buttonBreak"
|
||||
android:layout_toRightOf="@+id/buttonLeft"
|
||||
@ -43,7 +27,7 @@
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Break"
|
||||
android:text="V"
|
||||
android:id="@+id/buttonBreak"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toRightOf="@+id/buttonLeft"
|
||||
@ -54,7 +38,7 @@
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Right"
|
||||
android:text=">"
|
||||
android:id="@+id/buttonRight"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toRightOf="@+id/buttonBreak"
|
||||
@ -78,4 +62,34 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="30/100"
|
||||
android:id="@+id/tv"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignLeft="@+id/buttonAcelerate"
|
||||
android:layout_alignStart="@+id/buttonAcelerate"
|
||||
android:layout_alignRight="@+id/buttonAcelerate"
|
||||
android:layout_alignEnd="@+id/buttonAcelerate" />
|
||||
|
||||
<Switch
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/onOff"
|
||||
android:id="@+id/onOff"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<Switch
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/expert"
|
||||
android:id="@+id/expertmode"
|
||||
android:layout_below="@+id/onOff"
|
||||
android:layout_alignRight="@+id/onOff"
|
||||
android:layout_alignEnd="@+id/onOff"
|
||||
android:layout_marginTop="26dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="@drawable/back"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<ListView android:layout_width="fill_parent"
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:background="@drawable/back"
|
||||
@ -40,7 +41,7 @@
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="JabberID"
|
||||
android:text="Drone ID"
|
||||
android:textColor="#372c24" />
|
||||
|
||||
<EditText
|
||||
@ -81,7 +82,7 @@
|
||||
android:layout_marginTop="34dp"
|
||||
android:onClick="postData"
|
||||
android:text="Login" />
|
||||
|
||||
<!--
|
||||
<Button
|
||||
android:id="@+id/btnRegister"
|
||||
android:layout_width="fill_parent"
|
||||
@ -91,4 +92,5 @@
|
||||
android:layout_below="@+id/btnLogin"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
-->
|
||||
</RelativeLayout>
|
||||
@ -1,8 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/rowTextView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#336633"
|
||||
android:padding="10dp"
|
||||
android:textSize="20sp" >
|
||||
</TextView>
|
||||
|
||||
<!--
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5dip" >
|
||||
<LinearLayout
|
||||
android:id="@+id/thumbnail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginRight="5dip"
|
||||
android:padding="3dip" >
|
||||
<ImageView
|
||||
android:id="@+id/list_image"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:layout_width="60dip"
|
||||
android:layout_height="60dip"
|
||||
android:src="@drawable/ic_launcher" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/rowTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="75dip"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingBottom ="10dip"
|
||||
android:textColor="#040404"
|
||||
android:textSize="25dip"
|
||||
android:textStyle="bold"
|
||||
android:typeface="sans" />
|
||||
</RelativeLayout> -->
|
||||
@ -1,7 +1,7 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="pt.isep.mei.simov.droneappcontroller.CalibrationActivity">
|
||||
tools:context="pt.isep.mei.simov.droneappcontroller.ExpertMode">
|
||||
<item android:id="@+id/action_settings" android:title="@string/action_settings"
|
||||
android:orderInCategory="100" app:showAsAction="never" />
|
||||
</menu>
|
||||
|
||||
@ -8,5 +8,15 @@
|
||||
<string name="title_activity_main">Controlo</string>
|
||||
<string name="title_activity_calibration">Calibração</string>
|
||||
<string name="title_activity_list_of_drones">Lista de drones</string>
|
||||
<string name="expertMode">Atenção: Activar o modo avançado?</string>
|
||||
<string name="expert">Modo avançado</string>
|
||||
<string name="autField">Por favor preencha os campos de autenticação</string>
|
||||
<string name="internetConnection">Não existe conexão à internet. Por favor, ligue o acesso à internet</string>
|
||||
<string name="droneConnection">Não existe conexão ao drone.</string>
|
||||
<string name="autFailed">Início de sessão falhou. Por favor, tente novamente</string>
|
||||
<string name="turnOn">Por favor, ligue o drone</string>
|
||||
<string name="onOff">Ligar/Desligar</string>
|
||||
<string name="yes">Sim</string>
|
||||
<string name="no">Não</string>
|
||||
|
||||
</resources>
|
||||
@ -5,8 +5,17 @@
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="title_activity_register">Register</string>
|
||||
<string name="title_activity_main">Controlo</string>
|
||||
<string name="title_activity_calibration">Calibration Activity</string>
|
||||
<string name="title_activity_main">Control</string>
|
||||
<string name="title_activity_list_of_drones">List Of Drones</string>
|
||||
<string name="expertMode">Attention: You wanto to enable the Expert Mode?</string>
|
||||
<string name="expert">Expert Mode</string>
|
||||
<string name="autField">Please, use your login credentials</string>
|
||||
<string name="internetConnection">Network problem. Please, turn on your access to the Internet</string>
|
||||
<string name="droneConnection">Drone connection network problem.</string>
|
||||
<string name="autFailed">Autentication failed. Please, try again</string>
|
||||
<string name="turnOn">Please, turn on the drone!</string>
|
||||
<string name="onOff">On/Off</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
|
||||
</resources>
|
||||
|
||||