Geocoding up and running
This commit is contained in:
parent
68833c0cef
commit
a79141c0d1
|
@ -54,12 +54,13 @@ LOCAL_MODULE_TAGS := optional
|
|||
LOCAL_RESOURCE_DIR := $(addprefix $(LOCAL_PATH)/, $(res_dir))
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
# Remove LocationProvider V1 as it does not work with gms package name
|
||||
LOCAL_SRC_FILES := $(filter-out src/org/microg/nlp/location/LocationProviderV1.java, $(LOCAL_SRC_FILES))
|
||||
LOCAL_SRC_FILES := $(filter-out src/org/microg/nlp/location/LocationServiceV1.java, $(LOCAL_SRC_FILES))
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := framework com.android.location.provider
|
||||
|
||||
# Include compat v9 files if necassary
|
||||
ifeq ($(shell [ $(PLATFORM_SDK_VERSION) -ge 17 ] && echo true), true)
|
||||
LOCAL_JAVA_LIBRARIES += UnifiedNlpCompatV9
|
||||
endif
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := UnifiedNlpApi android-support-v4 android-support-v7-appcompat
|
||||
LOCAL_PACKAGE_NAME := NetworkLocation
|
||||
LOCAL_SDK_VERSION := current
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import org.microg.nlp.geocode.GeocodeService;
|
||||
import org.microg.nlp.location.LocationService;
|
||||
|
||||
public class PackageReceiver extends BroadcastReceiver {
|
||||
|
@ -14,5 +15,6 @@ public class PackageReceiver extends BroadcastReceiver {
|
|||
Log.d(TAG, "Intent received: " + intent);
|
||||
Log.d(TAG, "Reloading location service...");
|
||||
LocationService.reloadLocationService(context);
|
||||
GeocodeService.reloadLocationService(context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,18 @@ class BackendFuser {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
for (BackendHelper backendHelper : backendHelpers) {
|
||||
backendHelper.bind();
|
||||
}
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
for (BackendHelper backendHelper : backendHelpers) {
|
||||
backendHelper.unbind();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Address> getFromLocation(double latitude, double longitude, int maxResults,
|
||||
String locale) {
|
||||
|
|
|
@ -47,6 +47,10 @@ class GeocodeProviderV1 extends GeocodeProvider implements org.microg.nlp.geocod
|
|||
|
||||
@Override
|
||||
public void reload() {
|
||||
if (backendFuser != null) {
|
||||
backendFuser.unbind();
|
||||
}
|
||||
backendFuser = new BackendFuser(context);
|
||||
backendFuser.bind();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
package org.microg.nlp.geocode;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import org.microg.nlp.ProviderService;
|
||||
|
||||
import static org.microg.nlp.api.NlpApiConstants.ACTION_RELOAD_SETTINGS;
|
||||
|
||||
public abstract class GeocodeService extends ProviderService<GeocodeProvider> {
|
||||
public static void reloadLocationService(Context context) {
|
||||
Intent intent = new Intent(ACTION_RELOAD_SETTINGS);
|
||||
intent.setClass(context, GeocodeServiceV1.class);
|
||||
context.startService(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an GeocodeService. Invoked by your subclass's constructor.
|
||||
*
|
||||
|
|
|
@ -15,7 +15,7 @@ public abstract class LocationService extends ProviderService<LocationProvider>
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
intent.setClass(context, LocationServiceV2.class);
|
||||
} else {
|
||||
// TODO
|
||||
intent.setClass(context, LocationServiceV1.class);
|
||||
}
|
||||
context.startService(intent);
|
||||
}
|
||||
|
|
|
@ -129,7 +129,6 @@ public abstract class AbstractBackendConfigFragment extends Fragment {
|
|||
updateAddButton();
|
||||
resetAdapter();
|
||||
saveActiveBackends(activeBackends);
|
||||
LocationService.reloadLocationService(getActivity());
|
||||
}
|
||||
|
||||
public static String serviceInfosToBackendString(List<ServiceInfo> backends) {
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.content.pm.ResolveInfo;
|
|||
import android.content.pm.ServiceInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import org.microg.nlp.Preferences;
|
||||
import org.microg.nlp.geocode.GeocodeService;
|
||||
import org.microg.nlp.location.LocationService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -36,5 +38,6 @@ public class GeocodeBackendConfigFragment extends AbstractBackendConfigFragment
|
|||
@Override
|
||||
protected void saveActiveBackends(List<ServiceInfo> activeBackends) {
|
||||
new Preferences(getActivity()).setGeocoderBackends(serviceInfosToBackendString(activeBackends));
|
||||
GeocodeService.reloadLocationService(getActivity());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.microg.nlp.ui;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import org.microg.nlp.Preferences;
|
||||
import org.microg.nlp.location.LocationService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -31,6 +32,7 @@ public class LocationBackendConfigFragment extends AbstractBackendConfigFragment
|
|||
protected void saveActiveBackends(List<ServiceInfo> activeBackends) {
|
||||
new Preferences(getActivity())
|
||||
.setLocationBackends(serviceInfosToBackendString(activeBackends));
|
||||
LocationService.reloadLocationService(getActivity());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue