Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added dejavu and nominatim backends, added logging #250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
}

compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 11
targetCompatibility = 11
}
}

Expand Down
16 changes: 12 additions & 4 deletions api/src/main/java/org/microg/nlp/api/AbstractBackendService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public IBinder onBind(Intent intent) {
/**
* Called after a connection was setup
*/
protected void onOpen() {
public void onOpen() {

}

Expand All @@ -34,17 +34,25 @@ protected void onClose() {

}

protected Intent getInitIntent() {
public Intent getInitIntent() {
return null;
}

@SuppressWarnings("SameReturnValue")
protected Intent getSettingsIntent() {
public Intent getSettingsIntent() {
return null;
}

@SuppressWarnings("SameReturnValue")
protected Intent getAboutIntent() {
public Intent getAboutIntent() {
return null;
}

public String getBackendName() {
return null;
}

public String getDescription() {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void disconnect() {
* address should be localized in
* @see android.location.Geocoder#getFromLocation(double, double, int)
*/
protected abstract List<Address> getFromLocation(double latitude, double longitude, int maxResults, String locale);
public abstract List<Address> getFromLocation(double latitude, double longitude, int maxResults, String locale);

protected List<Address> getFromLocation(double latitude, double longitude, int maxResults, String locale, Bundle options) {
return getFromLocation(latitude, longitude, maxResults, locale);
Expand All @@ -47,7 +47,7 @@ protected List<Address> getFromLocation(double latitude, double longitude, int m
* address should be localized in
* @see android.location.Geocoder#getFromLocationName(String, int, double, double, double, double)
*/
protected abstract List<Address> getFromLocationName(String locationName, int maxResults, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, double upperRightLongitude, String locale);
public abstract List<Address> getFromLocationName(String locationName, int maxResults, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, double upperRightLongitude, String locale);


protected List<Address> getFromLocationName(String locationName, int maxResults, double lowerLeftLatitude, double lowerLeftLongitude, double upperRightLatitude, double upperRightLongitude, String locale, Bundle options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public synchronized void removeHelpers() {
}

@Override
protected synchronized void onOpen() {
public synchronized void onOpen() {
for (AbstractBackendHelper helper : helpers) {
helper.onOpen();
}
Expand All @@ -60,15 +60,15 @@ protected synchronized void onClose() {
}

@Override
protected synchronized Location update() {
public synchronized Location update() {
for (AbstractBackendHelper helper : helpers) {
helper.onUpdate();
}
return null;
}

@Override
protected Intent getInitIntent() {
public Intent getInitIntent() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Consider permissions
List<String> perms = new LinkedList<>();
Expand Down
12 changes: 10 additions & 2 deletions api/src/main/java/org/microg/nlp/api/LocationBackendService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@SuppressWarnings({"WeakerAccess", "unused"})
public abstract class LocationBackendService extends AbstractBackendService {

private LocationCallback callback;
public LocationCallback callback;
private Location waiting;

/**
Expand All @@ -28,7 +28,7 @@ public abstract class LocationBackendService extends AbstractBackendService {
* @return a new {@link android.location.Location} instance or null if not available.
*/
@SuppressWarnings("SameReturnValue")
protected Location update() {
public Location update() {
return null;
}

Expand Down Expand Up @@ -108,6 +108,14 @@ public Intent getInitIntent() {
return LocationBackendService.this.getInitIntent();
}

public String getBackendName() {
return LocationBackendService.this.getBackendName();
}

public String getDescription() {
return LocationBackendService.this.getDescription();
}

@Override
public Intent getSettingsIntent() {
return LocationBackendService.this.getSettingsIntent();
Expand Down
1 change: 1 addition & 0 deletions app-dejavu/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
38 changes: 38 additions & 0 deletions app-dejavu/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 33
defaultConfig {
minSdkVersion 14
targetSdkVersion 33
versionCode 32
versionName "1.1.23"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
encoding "UTF-8"
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

packagingOptions {
exclude 'META-INF/*'
}
}

dependencies {
implementation project(':api')

testImplementation 'junit:junit:4.13'
testImplementation 'org.mockito:mockito-core:3.5.10'

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.6.0'
}
25 changes: 25 additions & 0 deletions app-dejavu/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/tfitch/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
35 changes: 35 additions & 0 deletions app-dejavu/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.microg.nlp.backend.dejavu">

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<application
android:supportsRtl="true">

<activity android:name=".ui.MainActivity"
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>

<service
android:name="org.microg.nlp.backend.dejavu.BackendService"
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="org.microg.nlp.LOCATION_BACKEND" />
</intent-filter>
<meta-data
android:name="org.microg.nlp.BACKEND_SUMMARY"
android:value="@string/summary" />
</service>
</application>

</manifest>
Loading