SWADroid/SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/GetLocation.java
Javier Bueno López ab0898c571 Indoor Location new module (#287)
* Adding icons and text for manage location

* Adding manage location to main menu

* Adding class to manage location

* Adding view layout to manage location

* Share location switch created

* Basic listener added to switch

* Moving manage location to users menu

* Adding icons and text for manage location

* Adding manage location to main menu

* Adding class to manage location

* Adding view layout to manage location

* Share location switch created

* Basic listener added to switch

* Moving manage location to users menu

* Adding elements to indoor_location view

* Improving indoor_location with default text

* Logic to calculate distance

* Trying to connect to the API.

* Adding model to location distance

* Changing textview to listview

* Making request to MacStore API to get location of Mac

* Search user menu

* New designs manage location activity

* Connecting to swad api

* Connection to swad api working

* Location history showing up in activity

* Adding button and user code to find user

* Sorting locations and saving only one

* Implementing GetLastLocation API method

* Adding location preferences translations

* Adding translations to location menu toast

* Return without error from searching user

* Removing warning

* Adding translations

* Changing permissions

* Changing module name

* Making location serializable

* Changing deprecated implementation

* Cleaning code and refactoring deprecated classes

* Changing location name in menu

* Scanning all wifi networks

* Hiding white activities

* Showing more information in each location

* Fixing bug when searching user

* Fixing available networks sort

* Using roomCode instead of institutionCode

* Changes scheduling tasks

* Deleting dependencies

* Deleting useless import

* Getting correct mac

* Requesting permissions to user

* LocationTimeStamp inherits from Location

* Using new variable to soap object

* Setting const defaultValue

* Extracting common lines on update location click

* Extracting common lines on activity result

* Update SWADroid/src/main/res/values/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values-es/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Using functions to reduce code

* Update SWADroid/src/main/res/values/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/GetLastLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/model/UserFilter.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/GetLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/GetLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/GetLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/IndoorLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/IndoorLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/IndoorLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/IndoorLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/IndoorLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/IndoorLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/IndoorLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/IndoorLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/IndoorLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Constant moved to class level

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/SendCurrentLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/SendCurrentLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/indoorlocation/SendCurrentLocation.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/modules/messages/SearchUsers.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values-es/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values-es/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values-es/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values-es/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values-es/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values-es/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values-es/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/values/strings.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Adding dependency to preferences

* Changing indoor location title text

* Showing text when no location is found

* Allow always location option

* Adding new button to show mac

* Find mac button added and working

* Stopping scheduler when user can't be located

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/model/LocationTimeStamp.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/model/LocationTimeStamp.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/java/es/ugr/swad/swadroid/model/LocationTimeStamp.java

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update SWADroid/src/main/res/xml/preferences.xml

Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>

* Update material version to 1.2.1

* Updating plugin

* Fixing API permissions

* Update gradle/wrapper/gradle-wrapper.properties

* Minor code style improvements

* Fix IndexOutOfBoundsException

* Add default locale to SimpleDateFormat

* Use complete Gradle distribution

* Update authors

* Update CHANGELOG

* Remove unused import

* Minor code style improvements

Co-authored-by: javibl8@correo.ugr.es <javier.bueno@jitkey.com>
Co-authored-by: Juan Miguel Boyero Corral <juanmi1982@gmail.com>
2020-10-14 19:50:20 +02:00

121 lines
3.9 KiB
Java

package es.ugr.swad.swadroid.modules.indoorlocation;
import android.content.Intent;
import android.os.Bundle;
import org.ksoap2.serialization.SoapObject;
import es.ugr.swad.swadroid.Constants;
import es.ugr.swad.swadroid.model.Location;
import es.ugr.swad.swadroid.modules.Module;
import es.ugr.swad.swadroid.modules.login.Login;
import es.ugr.swad.swadroid.webservices.SOAPClient;
public class GetLocation extends Module {
/**
* Physical address of AP
*/
private String mac;
/**
* Distance to AP
*/
private double distance;
/**
* Default distance
*/
private final double defaultDistance = 500;
/**
* Location related to mac
*/
private Location location;
/**
* Messages tag name for Logcat
*/
private static final String TAG = Constants.APP_TAG + " GetLocation";
@Override
protected void runConnection() {
super.runConnection();
if (!isConnected) {
setResult(RESULT_CANCELED);
finish();
}
}
/* (non-Javadoc)
* @see android.app.Activity#onCreate()
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setMETHOD_NAME("getLocation");
getSupportActionBar().hide();
}
/* (non-Javadoc)
* @see android.app.Activity#onStart()
*/
@Override
protected void onStart() {
super.onStart();
mac = getIntent().getStringExtra("mac");
distance = getIntent().getDoubleExtra("distance", defaultDistance);
connect();
}
@Override
protected void requestService() throws Exception {
createRequest(SOAPClient.CLIENT_TYPE);
addParam("wsKey", Login.getLoggedUser().getWsKey());
addParam("MAC", mac);
sendRequest(Location.class, true);
if (result != null) {
SoapObject soap = (SoapObject) result;
soap = (SoapObject)soap.getProperty(0);
int roomCode = Integer.parseInt(soap.getProperty("roomCode").toString());
if (roomCode != -1) {
int institutionCode = Integer.parseInt(soap.getProperty("institutionCode").toString());
String institutionShortName = soap.getProperty("institutionShortName").toString();
String institutionFullName = soap.getProperty("institutionShortName").toString();
int centerCode = Integer.parseInt(soap.getProperty("centerCode").toString());
String centerShortName = soap.getProperty("centerShortName").toString();
String centerFullName = soap.getProperty("centerFullName").toString();
int buildingCode = Integer.parseInt(soap.getProperty("buildingCode").toString());
String buildingShortName = soap.getProperty("buildingShortName").toString();
String buildingFullName = soap.getProperty("buildingFullName").toString();
int floor = Integer.parseInt(soap.getProperty("floor").toString());
String roomShortName = soap.getProperty("roomShortName").toString();
String roomFullName = soap.getProperty("roomFullName").toString();
location = new Location(institutionCode, institutionShortName, institutionFullName,
centerCode, centerShortName, centerFullName, buildingCode, buildingShortName, buildingFullName,
floor, roomCode, roomShortName, roomFullName);
} else {
location = null;
}
}
Intent intent = new Intent();
intent.putExtra("location", location);
intent.putExtra("distance", distance);
setResult(RESULT_OK, intent);
}
@Override
protected void connect() {
startConnection();
}
@Override
protected void postConnect() {
finish();
}
@Override
protected void onError() {
}
}