use of android.webkit.JavascriptInterface in project Gadgetbridge by Freeyourgadget.
the class JSInterface method getAppStoredPreset.
@JavascriptInterface
public String getAppStoredPreset() {
try {
File destDir = PebbleUtils.getPbwCacheDir();
File configurationFile = new File(destDir, this.mUuid.toString() + "_preset.json");
if (configurationFile.exists()) {
return FileUtils.getStringFromFile(configurationFile);
}
} catch (IOException e) {
GB.toast("Error reading presets", Toast.LENGTH_LONG, GB.ERROR);
LOG.warn("Error reading presets", e);
}
return null;
}
use of android.webkit.JavascriptInterface in project Gadgetbridge by Freeyourgadget.
the class JSInterface method getCurrentPosition.
@JavascriptInterface
public String getCurrentPosition() {
if (!isLocationEnabledForWatchApp()) {
return "";
}
// we need to override this because the coarse location is not enough for the android webview, we should add the permission for fine location.
JSONObject geoPosition = new JSONObject();
JSONObject coords = new JSONObject();
try {
CurrentPosition currentPosition = new CurrentPosition();
geoPosition.put("timestamp", currentPosition.timestamp);
coords.put("latitude", currentPosition.getLatitude());
coords.put("longitude", currentPosition.getLongitude());
coords.put("accuracy", currentPosition.accuracy);
coords.put("altitude", currentPosition.altitude);
coords.put("speed", currentPosition.speed);
geoPosition.put("coords", coords);
} catch (JSONException e) {
LOG.warn(e.getMessage());
}
LOG.info("WEBVIEW - geo position" + geoPosition.toString());
return geoPosition.toString();
}
Aggregations