mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2025-02-01 21:47:31 +01:00
Add basic support for deprecated MyLocation feature in maps API
related to #56
This commit is contained in:
parent
b6506209a9
commit
fab75d444a
2
extern/GmsApi
vendored
2
extern/GmsApi
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 609e53a7d363183de4494600d4141b7c7cf5a692
|
Subproject commit fbe903fbcbcc27af3579c9b7b35c40b105224a01
|
@ -17,7 +17,12 @@
|
|||||||
package org.microg.gms.maps;
|
package org.microg.gms.maps;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.location.Criteria;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
import android.location.LocationListener;
|
||||||
|
import android.location.LocationManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -85,6 +90,34 @@ public class GoogleMapImpl extends IGoogleMapDelegate.Stub
|
|||||||
private IOnMarkerClickListener onMarkerClickListener;
|
private IOnMarkerClickListener onMarkerClickListener;
|
||||||
private IOnMarkerDragListener onMarkerDragListener;
|
private IOnMarkerDragListener onMarkerDragListener;
|
||||||
private IOnCameraChangeListener onCameraChangeListener;
|
private IOnCameraChangeListener onCameraChangeListener;
|
||||||
|
private IOnMyLocationChangeListener onMyLocationChangeListener;
|
||||||
|
|
||||||
|
private Criteria criteria;
|
||||||
|
private LocationListener listener = new LocationListener() {
|
||||||
|
@Override
|
||||||
|
public void onLocationChanged(Location location) {
|
||||||
|
// TODO: Actually do my location overlay
|
||||||
|
if (onMyLocationChangeListener != null && location != null) {
|
||||||
|
try {
|
||||||
|
onMyLocationChangeListener.onMyLocationChanged(ObjectWrapper.wrap(location));
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProviderEnabled(String provider) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProviderDisabled(String provider) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public GoogleMapImpl(LayoutInflater inflater, GoogleMapOptions options) {
|
public GoogleMapImpl(LayoutInflater inflater, GoogleMapOptions options) {
|
||||||
context = inflater.getContext();
|
context = inflater.getContext();
|
||||||
@ -92,6 +125,11 @@ public class GoogleMapImpl extends IGoogleMapDelegate.Stub
|
|||||||
uiSettings = new UiSettingsImpl(this);
|
uiSettings = new UiSettingsImpl(this);
|
||||||
projection = new ProjectionImpl(backendMap.getViewport());
|
projection = new ProjectionImpl(backendMap.getViewport());
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
|
criteria = new Criteria();
|
||||||
|
criteria.setAccuracy(Criteria.ACCURACY_COARSE);
|
||||||
|
criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
|
||||||
|
|
||||||
if (options != null) initFromOptions();
|
if (options != null) initFromOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,6 +417,12 @@ public class GoogleMapImpl extends IGoogleMapDelegate.Stub
|
|||||||
@Override
|
@Override
|
||||||
public void setMyLocationEnabled(boolean myLocation) throws RemoteException {
|
public void setMyLocationEnabled(boolean myLocation) throws RemoteException {
|
||||||
Log.w(TAG, "MyLocation not yet supported");
|
Log.w(TAG, "MyLocation not yet supported");
|
||||||
|
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
if (myLocation) {
|
||||||
|
locationManager.requestLocationUpdates(5000, 10, criteria, listener, Looper.getMainLooper());
|
||||||
|
} else {
|
||||||
|
locationManager.removeUpdates(listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -455,7 +499,7 @@ public class GoogleMapImpl extends IGoogleMapDelegate.Stub
|
|||||||
@Override
|
@Override
|
||||||
public void setOnMyLocationChangeListener(IOnMyLocationChangeListener listener)
|
public void setOnMyLocationChangeListener(IOnMyLocationChangeListener listener)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
this.onMyLocationChangeListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -496,7 +540,7 @@ public class GoogleMapImpl extends IGoogleMapDelegate.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocationSource(ILocationSourceDelegate locationSource) throws RemoteException {
|
public void setLocationSource(ILocationSourceDelegate locationSource) throws RemoteException {
|
||||||
|
Log.d(TAG, "setLocationSource: " + locationSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user