-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize functions and callbacks. Documentation completed. Library added in bintray.
- Loading branch information
Showing
41 changed files
with
851 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,148 @@ | ||
# Privacy Aware Location Service Library | ||
[](https://bintray.com/bestog/pals/pals/_latestVersion) | ||
[](https://github.com/bestog/pals-lib/tree/master) | ||
|
||
__Privacy Aware Location Service Library for Android -- MLS, OpenCellID, OpenBMap and OpenWLANMap__ | ||
|
||
GPS is the most common approach to locate a smartphone-user. The GPS location is determined in Android by Google services. Google stores user profiles about their movement. Thus privacy is not protected! | ||
The GPS localization is realized in Android through a Google service. Google can thereby save user profiles and track the movements of the user. This library prevents the localization on Google interface and uses only free-usable anonymous location-services. | ||
Data on the surrounding wireless networks and cell towers are sent to the location-service. As a result, you get the calculated approximate GPS location of the user. | ||
|
||
This library uses location-services to treat the data anonymous. These can be add to your project as a library. | ||
_Be clever and keep your private data anonymous!_ | ||
|
||
__Pull Requests are welcome!__ | ||
__Pull-Requests are allowed and encouraged!__ | ||
|
||
## Getting Started | ||
1. Download the [latest version](https://github.com/bestog/pals-lib/releases) from GitHub | ||
2. Copy the `palslib.jar` file in your `/libs/`-directory | ||
3. Add this library to your dependencies | ||
4. Ready! | ||
|
||
__Maven__ | ||
``` | ||
<dependency> | ||
<groupId>com.bestog.pals</groupId> | ||
<artifactId>pals</artifactId> | ||
<version>2.0</version> | ||
<type>pom</type> | ||
</dependency> | ||
``` | ||
|
||
__Gradle__ | ||
``` | ||
compile 'com.bestog.pals:pals:2.0' | ||
``` | ||
|
||
## Usage | ||
__Permissions (AndroidManifest)__ | ||
``` | ||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | ||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> | ||
<uses-permission android:name="android.permission.INTERNET"/> | ||
// Only for submit-request | ||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> | ||
``` | ||
|
||
__Basics__ | ||
```java | ||
// Initialize Pals | ||
Pals pals = new Pals(Context ctx); | ||
|
||
Pals pals = new Pals(context); | ||
// Enable Provider | ||
pals.enableProvider(LocationProvider.PROVIDER_MOZILLA); | ||
pals.enableProvider(LocationProvider.PROVIDER_OPENBMAP); | ||
... | ||
|
||
// Request | ||
``` | ||
__Request__ | ||
A request that returns the current approximate position of the user as a result. | ||
```java | ||
pals.request(new IRequest() { | ||
@Override | ||
public void onComplete(GeoResult result, boolean valid) { | ||
// Result - Example ----------------- | ||
// double lat = result.getLatitude(); | ||
// double lon = result.getLongitude(); | ||
// int lat = result.getAccuracy(); | ||
// boolean validRequest = valid; | ||
// Result - Example ----------------- | ||
double lat = result.getLatitude(); | ||
double lon = result.getLongitude(); | ||
int acc = result.getAccuracy(); | ||
boolean validRequest = valid; | ||
// ---- YOUR CODE ------------------ | ||
} | ||
}); | ||
``` | ||
__Submit__ | ||
To guarantee accurate position of a user, the database of location-services with new data needs to be filled. | ||
Help us with it and collect new data! | ||
```java | ||
pals.submit(new ISubmit() { | ||
@Override | ||
public void onComplete(boolean valid) { | ||
// Result - Example ----------- | ||
boolean validSubmit = valid; | ||
// ---- YOUR CODE ------------ | ||
} | ||
}); | ||
``` | ||
|
||
## Provider | ||
|
||
__Mozilla Location Service__ | ||
`LocationProvider.PROVIDER_MOZILLA` | ||
[+] Request | ||
[+] Submit | ||
|
||
__OpenBMap__ | ||
`LocationProvider.PROVIDER_OPENBMAP` | ||
[+] Request | ||
[-] Submit | ||
|
||
`LocationProvider.PROVIDER_GOOGLE` | ||
|
||
__OpenCellID__ | ||
`LocationProvider.PROVIDER_OPENCELLID` | ||
[+] Request | ||
[-] Submit | ||
|
||
__OpenMap__ | ||
`LocationProvider.PROVIDER_OPENMAP` | ||
[+] Request | ||
[-] Submit | ||
|
||
__Google Geolocation__ | ||
`LocationProvider.PROVIDER_GOOGLE` | ||
[+] Request | ||
[-] Submit | ||
|
||
## Functions | ||
|
||
#### enableProvider | ||
Enable a provider for the geolocation. | ||
Enable a location-provider for the geolocation. | ||
```java | ||
enableProvider(String provider); | ||
void enableProvider(String provider); | ||
``` | ||
|
||
#### disableProvider | ||
Disable a provider for the geolocation. | ||
Disable a location-provider for the geolocation. | ||
```java | ||
disableProvider(String provider); | ||
void disableProvider(String provider); | ||
``` | ||
|
||
#### enabledProvider | ||
Get all enabled location-provider as a comma-seperated string | ||
```java | ||
String enabledProvider(); | ||
``` | ||
|
||
#### request | ||
Executes a request and sends at the end the result to the listener. | ||
```java | ||
request(IRequest listener); | ||
void request(IRequest listener); | ||
``` | ||
|
||
#### submit | ||
Executes a submit, collect data from current position and send to a location-provider. | ||
```java | ||
void submit(ISubmit listener); | ||
``` | ||
|
||
#### isProviderEnabled | ||
Is LocationProvider enabled? | ||
Is the specific location-provider enabled? | ||
```java | ||
isProviderEnabled(String provider); | ||
boolean isProviderEnabled(String provider); | ||
``` | ||
|
||
#### setTrilaterateAlg | ||
Set a specific algorithm for the calculation | ||
```java | ||
void setTrilaterateAlg(String alg); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,25 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.2" | ||
|
||
defaultConfig { | ||
applicationId "com.bestog.palssample" | ||
minSdkVersion 11 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
lintOptions { | ||
abortOnError false | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
} | ||
|
||
task deleteOldJar(type: Delete) { | ||
delete 'release/AndroidPlugin.jar' | ||
compile project(':pals') | ||
compile 'com.android.support:appcompat-v7:23.4.0' | ||
} | ||
|
||
task exportJar(type: Copy) { | ||
from('build/intermediates/bundles/release/') | ||
into('release/') | ||
include('classes.jar') | ||
rename('classes.jar', 'palslib.jar') | ||
} | ||
|
||
exportJar.dependsOn(deleteOldJar, build) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.bestog.palssample; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.widget.TextView; | ||
|
||
import com.bestog.pals.Pals; | ||
import com.bestog.pals.interfaces.IRequest; | ||
import com.bestog.pals.interfaces.ISubmit; | ||
import com.bestog.pals.provider.LocationProvider; | ||
import com.bestog.pals.utils.GeoResult; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
private Pals pals; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
pals = new Pals(this); | ||
pals.enableProvider(LocationProvider.PROVIDER_MOZILLA); | ||
pals.enableProvider(LocationProvider.PROVIDER_OPENBMAP); | ||
pals.enableProvider(LocationProvider.PROVIDER_GOOGLE); | ||
pals.enableProvider(LocationProvider.PROVIDER_OPENMAP); | ||
process(); | ||
} | ||
|
||
private void process() { | ||
final TextView resultat = (TextView) findViewById(R.id.result); | ||
if (resultat != null) { | ||
resultat.setText(""); | ||
} | ||
pals.request(new IRequest() { | ||
@Override | ||
public void onComplete(GeoResult result, boolean valid) { | ||
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy - HH:mm:ss", Locale.GERMAN); | ||
String out = String.format("Lat: %1$s\nLon: %2$s\nAcc: %3$s\n\nTime: %4$s", result.getLatitude(), result.getLongitude(), result.getAccuracy(), sdf.format(new Date())); | ||
if (resultat != null) { | ||
resultat.setText(out); | ||
} | ||
} | ||
}); | ||
final TextView submit = (TextView) findViewById(R.id.submit); | ||
pals.submit(new ISubmit() { | ||
@Override | ||
public void onComplete(boolean valid) { | ||
if (submit != null) { | ||
submit.setText((valid) ? "Submit success" : "Submit error"); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
getMenuInflater().inflate(R.menu.main, menu); | ||
return super.onCreateOptionsMenu(menu); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
switch (item.getItemId()) { | ||
case R.id.refresh: | ||
process(); | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.