Compare commits

..

2 Commits

Author SHA1 Message Date
andre-almeid
2a9c609323 new layout and some changes in advanced mode 2015-01-05 17:31:30 +00:00
João Gonçalves
48e7fe5d04 Alteração 2015-01-02 16:46:40 +00:00
26 changed files with 333 additions and 412 deletions

View File

@ -1,6 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
## [0.0.1] - 2019-05-07
### Added
- migration from github to gitlab

View File

@ -1,92 +0,0 @@
# Contributing
When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.
Please note we have a code of conduct, please follow it in all your interactions with the project.
## Pull Request Process
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
build.
2. Update the README.md with details of changes to the interface, this includes new environment
variables, exposed ports, useful file locations and container parameters.
3. Increase the version numbers in any examples files and the README.md to the new version that this
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
do not have permission to do that, you may request the second reviewer to merge it for you.
## Code of Conduct
### Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
### Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
### Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
### Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
### Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
### Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

BIN
DroneAppController.rar Normal file

Binary file not shown.

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle"> <facet type="android-gradle" name="Android-Gradle">
<configuration> <configuration>

View File

@ -25,12 +25,9 @@
</activity> </activity>
<activity <activity
android:name=".ControllerActivity" android:name=".ControllerActivity"
android:screenOrientation="landscape"
android:label="@string/title_activity_main" > android:label="@string/title_activity_main" >
</activity> </activity>
<activity
android:name=".CalibrationActivity"
android:label="@string/title_activity_calibration" >
</activity>
<activity <activity
android:name=".ListOfDrones" android:name=".ListOfDrones"
android:label="@string/title_activity_list_of_drones" > android:label="@string/title_activity_list_of_drones" >

View File

@ -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);
}
}

View File

@ -1,7 +1,6 @@
package pt.isep.mei.simov.droneappcontroller; package pt.isep.mei.simov.droneappcontroller;
import android.util.Log; import android.util.Log;
import android.widget.Toast;
import org.jivesoftware.smack.AccountManager; import org.jivesoftware.smack.AccountManager;
import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.ConnectionConfiguration;
@ -10,11 +9,7 @@ import org.jivesoftware.smack.RosterEntry;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Presence; 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.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
@ -26,6 +21,11 @@ public class Connection {
String HOST = "aalmeid.ddns.net"; String HOST = "aalmeid.ddns.net";
int PORT = 5222; int PORT = 5222;
String SERVICE = "xmppserver"; String SERVICE = "xmppserver";
/*String HOST = "sibacsimovisep2014.noip.me";
int PORT = 5222;
String SERVICE = "sibacsimovisep2014";*/
String USERNAME = ""; String USERNAME = "";
String PASSWORD = ""; String PASSWORD = "";
@ -104,6 +104,11 @@ public class Connection {
} }
} }
private boolean closeConnection(){
connection.disconnect();
return true;
}
public boolean createAccount (String username, String password){ public boolean createAccount (String username, String password){
try { try {
AccountManager accountManager = connection.getAccountManager(); AccountManager accountManager = connection.getAccountManager();

View File

@ -2,15 +2,22 @@ package pt.isep.mei.simov.droneappcontroller;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.hardware.Sensor;
import android.content.pm.ActivityInfo; 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.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.MotionEvent;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.jivesoftware.smack.PacketListener; 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.packet.Packet;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
import java.util.ArrayList;
/** /**
* Created by almeida on 18-12-2014. * 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 String to;
private XMPPConnection connection = Connection.getConnection(); 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_controller); setContentView(R.layout.activity_controller);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Button left = (Button) findViewById(R.id.buttonLeft); Button left = (Button) findViewById(R.id.buttonLeft);
Button right = (Button) findViewById(R.id.buttonRight); Button right = (Button) findViewById(R.id.buttonRight);
Button up = (Button) findViewById(R.id.buttonUp); Button up = (Button) findViewById(R.id.buttonUp);
Button down = (Button) findViewById(R.id.buttonDown); Button down = (Button) findViewById(R.id.buttonDown);
Button acelerate = (Button) findViewById(R.id.buttonAcelerate); Button acelerate = (Button) findViewById(R.id.buttonAcelerate);
Button breake = (Button) findViewById(R.id.buttonBreak); Button desacelarate = (Button) findViewById(R.id.buttonBreak);
Button on_off = (Button) findViewById(R.id.buttonOnOff);
Button calibration = (Button) findViewById(R.id.buttonCallibration); 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(); Bundle b = getIntent().getExtras();
to = b.getString("to"); to = b.getString("to");
@ -55,128 +99,136 @@ public class ControllerActivity extends Activity {
left.setOnClickListener(new View.OnClickListener() { left.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Toast.makeText(getApplicationContext(), "left pressed!", if(onOff.isChecked()) {
Toast.LENGTH_LONG).show(); senMessage("e");
}else{
senMessage("left"); Toast.makeText(getApplicationContext(), R.string.turnOn,
Toast.LENGTH_LONG).show();
}
} }
}); });
right.setOnClickListener(new View.OnClickListener() { right.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Toast.makeText(getApplicationContext(), "right pressed!", if (onOff.isChecked()) {
Toast.LENGTH_LONG).show(); 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() { up.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Toast.makeText(getApplicationContext(), "up pressed!", if (onOff.isChecked()) {
Toast.LENGTH_LONG).show(); senMessage("up");
} else {
senMessage("up"); Toast.makeText(getApplicationContext(), R.string.turnOn,
Toast.LENGTH_LONG).show();
}
} }
}); });
down.setOnClickListener(new View.OnClickListener() { down.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Toast.makeText(getApplicationContext(), "down pressed!", if (onOff.isChecked()) {
Toast.LENGTH_LONG).show(); senMessage("down");
} else {
senMessage("down"); Toast.makeText(getApplicationContext(), R.string.turnOn,
} Toast.LENGTH_LONG).show();
}); }
acelerate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "acelerate pressed!",
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) { public void senMessage(String message) {
Message msg = new Message(to, Message.Type.chat); Message msg = new Message(to, Message.Type.chat);
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
msg.setBody(message); msg.setBody(message);
if (connection != null) { if (connection != null) {
connection.sendPacket(msg); if (!(networkInfo != null && networkInfo.isConnected())) {
messages.add(connection.getUser() + ":"); Toast.makeText(getApplicationContext(), R.string.droneConnection, Toast.LENGTH_SHORT).show();
messages.add(message); finish();
}else{
connection.sendPacket(msg);
}
} }
} }
public void setConnection(XMPPConnection connection) { public void setConnection(XMPPConnection connection) {
this.connection = connection; this.connection = connection;
System.out.println ("connection"+connection);
if (connection != null) { if (connection != null) {
// Add a packet listener to get messages sent to us
PacketFilter filter = new MessageTypeFilter(Message.Type.chat); PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
connection.addPacketListener(new PacketListener() { connection.addPacketListener(new PacketListener() {
@Override @Override
@ -185,34 +237,41 @@ public class ControllerActivity extends Activity {
if (message.getBody() != null) { if (message.getBody() != null) {
String fromName = StringUtils.parseBareAddress(message.getFrom()); String fromName = StringUtils.parseBareAddress(message.getFrom());
Log.i("XMPPChatDemoActivity ", " Text Recieved " + message.getBody() + " from " + fromName); Log.i("XMPPChatDemoActivity ", " Text Recieved " + message.getBody() + " from " + fromName);
messages.add(fromName + ":");
messages.add(message.getBody());
} }
} }
}, filter); }, filter);
} }
} }
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public void onSensorChanged(SensorEvent event) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu); if(event.sensor.getType()==Sensor.TYPE_ACCELEROMETER){
return true;
// 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 @Override
public boolean onOptionsItemSelected(MenuItem item) { public void onAccuracyChanged(Sensor sensor, int accuracy) {
// 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);
} }
} }

View File

@ -1,14 +1,17 @@
package pt.isep.mei.simov.droneappcontroller; package pt.isep.mei.simov.droneappcontroller;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.util.Log;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
@ -36,28 +39,43 @@ public class ListOfDrones extends Activity {
String user = b.getString("id"); String user = b.getString("id");
String passwd = b.getString("passwd"); String passwd = b.getString("passwd");
Connection c = new Connection(user,passwd); try {
users = c.getUsers(); Connection c = new Connection(user, passwd);
connection = c.getConnection(); 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); 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()); listAdapter.add(users.get(i).toString());
}
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(getApplicationContext(), ControllerActivity.class);
i.putExtra("to", listAdapter.getItem(position));
startActivity(i);
} }
});
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@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();
}
} }
} }

View File

@ -1,13 +1,11 @@
package pt.isep.mei.simov.droneappcontroller; package pt.isep.mei.simov.droneappcontroller;
import android.os.Bundle;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.EditText; import android.widget.EditText;
@ -37,7 +35,7 @@ public class LoginActivity extends Activity {
Log.i("XMPP", "Credencials: " + email + " and " + passwd); Log.i("XMPP", "Credencials: " + email + " and " + passwd);
if (email.equals("") || passwd.equals("")) { 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(); Toast.LENGTH_LONG).show();
} else { } else {
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
@ -45,10 +43,9 @@ public class LoginActivity extends Activity {
if (!(networkInfo != null && networkInfo.isConnected())) 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{ } else{
Intent i = new Intent(this, ListOfDrones.class);
Intent i=new Intent(this,ListOfDrones.class);
i.putExtra("id", email); i.putExtra("id", email);
i.putExtra("passwd", passwd); i.putExtra("passwd", passwd);
this.startActivity(i); 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); Intent i = new Intent(this, RegisterActivity.class);
startActivity(i); startActivity(i);
} }*/
} }

View File

@ -1,17 +1,12 @@
package pt.isep.mei.simov.droneappcontroller; package pt.isep.mei.simov.droneappcontroller;
import android.app.Activity; import android.app.Activity;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import org.jivesoftware.smack.ConnectionConfiguration;
/** /**
* Created by almeida on 18-12-2014. * Created by almeida on 18-12-2014.
*/ */
@ -30,7 +25,7 @@ public class RegisterActivity extends Activity {
buttonReg.setOnClickListener(new View.OnClickListener() { buttonReg.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { 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())){ if (c.createAccount(username.getText().toString(), passwd.getText().toString())){
Toast.makeText(getApplicationContext(), "Registration completed!", Toast.makeText(getApplicationContext(), "Registration completed!",
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -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>

View File

@ -9,23 +9,7 @@
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="On / Off" android:text="&lt;"
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:id="@+id/buttonLeft" android:id="@+id/buttonLeft"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
@ -34,7 +18,7 @@
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Acelerate" android:text=""
android:id="@+id/buttonAcelerate" android:id="@+id/buttonAcelerate"
android:layout_above="@+id/buttonBreak" android:layout_above="@+id/buttonBreak"
android:layout_toRightOf="@+id/buttonLeft" android:layout_toRightOf="@+id/buttonLeft"
@ -43,7 +27,7 @@
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Break" android:text="V"
android:id="@+id/buttonBreak" android:id="@+id/buttonBreak"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/buttonLeft" android:layout_toRightOf="@+id/buttonLeft"
@ -54,7 +38,7 @@
<Button <Button
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Right" android:text=">"
android:id="@+id/buttonRight" android:id="@+id/buttonRight"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/buttonBreak" android:layout_toRightOf="@+id/buttonBreak"
@ -78,4 +62,34 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentEnd="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> </RelativeLayout>

View File

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:background="@drawable/back"
android:layout_height="fill_parent"> android:layout_height="fill_parent">
<ListView android:layout_width="fill_parent" <ListView android:layout_width="fill_parent"

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/back" android:background="@drawable/back"
@ -40,7 +41,7 @@
<TextView <TextView
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="JabberID" android:text="Drone ID"
android:textColor="#372c24" /> android:textColor="#372c24" />
<EditText <EditText
@ -81,7 +82,7 @@
android:layout_marginTop="34dp" android:layout_marginTop="34dp"
android:onClick="postData" android:onClick="postData"
android:text="Login" /> android:text="Login" />
<!--
<Button <Button
android:id="@+id/btnRegister" android:id="@+id/btnRegister"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -91,4 +92,5 @@
android:layout_below="@+id/btnLogin" android:layout_below="@+id/btnLogin"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" /> android:layout_alignParentStart="true" />
-->
</RelativeLayout> </RelativeLayout>

View File

@ -1,8 +1,44 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowTextView" android:id="@+id/rowTextView"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="#336633"
android:padding="10dp" android:padding="10dp"
android:textSize="20sp" > android:textSize="20sp" >
</TextView> </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> -->

View File

@ -1,7 +1,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" 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" <item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" /> android:orderInCategory="100" app:showAsAction="never" />
</menu> </menu>

View File

@ -8,5 +8,15 @@
<string name="title_activity_main">Controlo</string> <string name="title_activity_main">Controlo</string>
<string name="title_activity_calibration">Calibração</string> <string name="title_activity_calibration">Calibração</string>
<string name="title_activity_list_of_drones">Lista de drones</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> </resources>

View File

@ -5,8 +5,17 @@
<string name="hello_world">Hello world!</string> <string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<string name="title_activity_register">Register</string> <string name="title_activity_register">Register</string>
<string name="title_activity_main">Controlo</string> <string name="title_activity_main">Control</string>
<string name="title_activity_calibration">Calibration Activity</string>
<string name="title_activity_list_of_drones">List Of Drones</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> </resources>

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2019, André Almeida dev@andrealmeida.net
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,48 +0,0 @@
# Drone controller app android
![Version](https://img.shields.io/badge/version-0.0.1-success.svg)
Drone contoller via app android and XMPP server.
## Getting Started
You need have an XMPP Server to communicate the messages for the drone, a Raspberry Pi to construct your middleware (maybe in python) and eletronic skills.
### Prerequisites
* [Android Studio](https://developer.android.com/studio/);
* [XMPP Server](https://xmpp.org/software/servers.html);
* [Python](https://www.python.org);
### Installing
Install android studio and XMPP Server.
After that, compile your app and set the address for your server:
### Final Result
[![Watch the video](https://i.imgur.com/vKb2F1B.png)](https://vimeo.com/116756682)
## Built With
* [Android Studio](https://developer.android.com/studio/);
* [XMPP Server](https://xmpp.org/software/servers.html);
* [Python](https://www.python.org);
## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on my code of conduct, and the process for submitting pull requests to me.
## Versioning
I use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://gitlab.andrealmeida.net/public_projects/DroneController/tags).
## Authors
[![Author](https://img.shields.io/badge/Author-André%20Almeida-blue.svg)](https://andrealmeida.net)
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details