You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
implement LocationManager and orientation sensor using libportal
This commit is contained in:
@@ -12,4 +12,12 @@ public class Criteria {
|
||||
public static final int ACCURACY_HIGH = 3;
|
||||
|
||||
public void setAccuracy(int accuracy) {}
|
||||
|
||||
public void setAltitudeRequired(boolean required) {}
|
||||
|
||||
public void setBearingRequired(boolean required) {}
|
||||
|
||||
public void setCostAllowed(boolean allowed) {}
|
||||
|
||||
public void setPowerRequirement(int powerRequirement) {}
|
||||
}
|
||||
|
||||
27
src/api-impl/android/location/Location.java
Normal file
27
src/api-impl/android/location/Location.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package android.location;
|
||||
|
||||
public class Location {
|
||||
|
||||
private double latitude;
|
||||
private double longitude;
|
||||
private double bearing;
|
||||
|
||||
public Location (double latitude, double longitude, double bearing) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.bearing = bearing;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public double getBearing() {
|
||||
return bearing;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
package android.location;
|
||||
|
||||
public interface LocationListener {
|
||||
|
||||
public void onLocationChanged(Location location);
|
||||
|
||||
}
|
||||
|
||||
31
src/api-impl/android/location/LocationManager.java
Normal file
31
src/api-impl/android/location/LocationManager.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package android.location;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class LocationManager {
|
||||
|
||||
static Set<LocationListener> listeners = new HashSet<>();
|
||||
|
||||
public String getBestProvider(Criteria criteria, boolean enabledOnly) {
|
||||
return "xdgportal";
|
||||
}
|
||||
|
||||
public Location getLastKnownLocation(String provider) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void requestLocationUpdates (String provider, long minTimeMs, float minDistanceM, LocationListener listener) {
|
||||
listeners.add(listener);
|
||||
nativeGetLocation();
|
||||
}
|
||||
|
||||
private native void nativeGetLocation();
|
||||
|
||||
private static void locationUpdated(double latitude, double longitude, double heading) {
|
||||
for (LocationListener locationListener : listeners) {
|
||||
locationListener.onLocationChanged(new Location(latitude, longitude, heading));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user