From 828a713da1c201f8a1fb5dd5bcd5f35ce9bcfb26 Mon Sep 17 00:00:00 2001 From: JuRoot Date: Sun, 9 Jan 2022 11:31:43 +0100 Subject: [PATCH] fix #357 Locus integration not working - bump Locus API library on Gradle from 0.2.7 to 0.9.45 - removed `Location` initializer with string (no longer supported) - changed LAPI dependencies in files to newer version + required refactor of corresponding code - changed `Location.java` inits with only `TAG` string resource (obsolete) - changed `Location.Accuracy` (removed support) to horizontal accuracy - removed dependency on locus api when loading cartridges (never fully implemented) --- build.gradle | 2 +- .../whereyougo/geo/location/Location.java | 12 ++-- .../geo/location/LocationState.java | 12 ++-- .../activity/CartridgeDetailsActivity.java | 4 +- .../gui/activity/GuidingActivity.java | 10 +-- .../whereyougo/gui/activity/MainActivity.java | 26 ++------ .../gui/activity/SatelliteActivity.java | 10 +-- .../gui/dialog/ChooseCartridgeDialog.java | 4 +- .../whereyougo/gui/extension/DataInfo.java | 10 +-- .../android/whereyougo/guide/ZoneGuide.java | 9 ++- .../maps/utils/LocusMapDataProvider.java | 66 ++++++++++--------- .../whereyougo/maps/utils/MapHelper.java | 25 +++---- .../whereyougo/openwig/WLocationService.java | 10 +-- .../preferences/PreferenceValues.java | 10 +-- .../android/whereyougo/utils/UtilsFormat.java | 20 +++--- 15 files changed, 108 insertions(+), 122 deletions(-) diff --git a/build.gradle b/build.gradle index 9d13f7802..bcbdeb253 100644 --- a/build.gradle +++ b/build.gradle @@ -103,7 +103,7 @@ dependencies { // Locus Maps integration //noinspection GradleDependency - implementation 'com.asamm:locus-api-android:0.2.7' + implementation 'com.asamm:locus-api-android:0.9.45' // openwig@cgeo implementation 'com.github.cgeo:openwig:1.0.0' diff --git a/src/main/java/menion/android/whereyougo/geo/location/Location.java b/src/main/java/menion/android/whereyougo/geo/location/Location.java index 78a98de6c..e17bef25c 100644 --- a/src/main/java/menion/android/whereyougo/geo/location/Location.java +++ b/src/main/java/menion/android/whereyougo/geo/location/Location.java @@ -7,10 +7,10 @@ public Location() { } public Location(android.location.Location loc) { - this(loc.getProvider(), loc.getLatitude(), loc.getLongitude()); + this(loc.getLatitude(), loc.getLongitude()); setTime(loc.getTime()); if (loc.hasAccuracy()) { - setAccuracy(loc.getAccuracy()); + setAccuracyHor(loc.getAccuracy()); } if (loc.hasAltitude()) { setAltitude(loc.getAltitude()); @@ -27,12 +27,8 @@ public Location(Location loc) { super(loc); } - public Location(String provider) { - super(provider); - } - - public Location(String provider, double lat, double lon) { - super(provider, lat, lon); + public Location(double lat, double lon) { + super(lat, lon); } @Override diff --git a/src/main/java/menion/android/whereyougo/geo/location/LocationState.java b/src/main/java/menion/android/whereyougo/geo/location/LocationState.java index 5321cf806..0f041f89c 100644 --- a/src/main/java/menion/android/whereyougo/geo/location/LocationState.java +++ b/src/main/java/menion/android/whereyougo/geo/location/LocationState.java @@ -1,17 +1,17 @@ /* * This file is part of WhereYouGo. - * + * * WhereYouGo is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * WhereYouGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along with WhereYouGo. If not, * see . - * + * * Copyright (C) 2012 Menion */ @@ -147,7 +147,7 @@ public static Location getLastKnownLocation(Activity activity) { public static Location getLocation() { if (location == null) - return new Location(TAG); + return new Location(); return new Location(location); } @@ -331,7 +331,7 @@ static void onLocationChanged(Location location) { // if first location from Network, and new from GPS but with worst precision, do not set if (LocationState.location.getProvider().equals(LocationManager.NETWORK_PROVIDER) && location.getProvider().equals(LocationManager.GPS_PROVIDER) - && (LocationState.location.getAccuracy() * 3) < location.getAccuracy()) { + && (LocationState.location.getAccuracyHor() * 3) < location.getAccuracyHor()) { return; } diff --git a/src/main/java/menion/android/whereyougo/gui/activity/CartridgeDetailsActivity.java b/src/main/java/menion/android/whereyougo/gui/activity/CartridgeDetailsActivity.java index b80645623..0e3eb4f9c 100644 --- a/src/main/java/menion/android/whereyougo/gui/activity/CartridgeDetailsActivity.java +++ b/src/main/java/menion/android/whereyougo/gui/activity/CartridgeDetailsActivity.java @@ -74,7 +74,7 @@ public void onCreate(Bundle savedInstanceState) { TextView tvDistance = (TextView) findViewById(R.id.layoutDetailsTextViewDistance); - Location loc = new Location(TAG); + Location loc = new Location(); loc.setLatitude(MainActivity.cartridgeFile.latitude); loc.setLongitude(MainActivity.cartridgeFile.longitude); @@ -92,7 +92,7 @@ public void onCreate(Bundle savedInstanceState) { MainActivity.startSelectedCartridge(false); return true; }, null, null, getString(R.string.navigate), (dialog, v, btn) -> { - Location loc1 = new Location(TAG); + Location loc1 = new Location(); loc1.setLatitude(MainActivity.cartridgeFile.latitude); loc1.setLongitude(MainActivity.cartridgeFile.longitude); Guide guide = new Guide(MainActivity.cartridgeFile.name, loc1); diff --git a/src/main/java/menion/android/whereyougo/gui/activity/GuidingActivity.java b/src/main/java/menion/android/whereyougo/gui/activity/GuidingActivity.java index 3e017eff5..4c06a7fa7 100644 --- a/src/main/java/menion/android/whereyougo/gui/activity/GuidingActivity.java +++ b/src/main/java/menion/android/whereyougo/gui/activity/GuidingActivity.java @@ -1,17 +1,17 @@ /* * This file is part of WhereYouGo. - * + * * WhereYouGo is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * WhereYouGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along with WhereYouGo. If not, * see . - * + * * Copyright (C) 2012 Menion */ @@ -132,7 +132,7 @@ public void onOrientationChanged(float azimuth, float pitch, float roll) { viewLat.setText(UtilsFormat.formatLatitude(loc.getLatitude())); viewLon.setText(UtilsFormat.formatLongitude(loc.getLongitude())); viewAlt.setText(UtilsFormat.formatAltitude(loc.getAltitude(), true)); - viewAcc.setText(UtilsFormat.formatDistance((double) loc.getAccuracy(), false)); + viewAcc.setText(UtilsFormat.formatDistance((double) loc.getAccuracyHor(), false)); viewSpeed.setText(UtilsFormat.formatSpeed(loc.getSpeed(), false)); repaint(); diff --git a/src/main/java/menion/android/whereyougo/gui/activity/MainActivity.java b/src/main/java/menion/android/whereyougo/gui/activity/MainActivity.java index 291860701..8ed2cd5cf 100644 --- a/src/main/java/menion/android/whereyougo/gui/activity/MainActivity.java +++ b/src/main/java/menion/android/whereyougo/gui/activity/MainActivity.java @@ -1,17 +1,17 @@ /* * This file is part of WhereYouGo. - * + * * WhereYouGo is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * WhereYouGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along with WhereYouGo. If not, * see . - * + * * Copyright (C) 2012 Menion */ @@ -49,7 +49,8 @@ import cz.matejcik.openwig.Engine; import cz.matejcik.openwig.formats.CartridgeFile; import locus.api.objects.extra.Location; -import locus.api.objects.extra.Waypoint; + +//import locus.api.objects.extra.Waypoint; import menion.android.whereyougo.MainApplication; import menion.android.whereyougo.R; @@ -179,9 +180,6 @@ public static void refreshCartridges() { File[] files = FileSystem.getFiles(FileSystem.ROOT, "gwc"); cartridgeFiles = new Vector<>(); - // add cartridges to map - ArrayList wpts = new ArrayList<>(); - File actualFile = null; if (files != null) { for (File file : files) { @@ -190,26 +188,14 @@ public static void refreshCartridges() { CartridgeFile cart = CartridgeFile.read(new WSeekableFile(file), new WSaveFile(file)); if (cart != null) { cart.filename = file.getAbsolutePath(); - - Location loc = new Location(TAG); - loc.setLatitude(cart.latitude); - loc.setLongitude(cart.longitude); - Waypoint waypoint = new Waypoint(cart.name, loc); - cartridgeFiles.add(cart); - wpts.add(waypoint); } } catch (Exception e) { Logger.w(TAG, "refreshCartridge(), file:" + actualFile + ", e:" + e.toString()); ManagerNotify.toastShortMessage(Locale.getString(R.string.invalid_cartridge, actualFile.getName())); - // file.delete(); } } } - - if (wpts.size() > 0) { - // TODO add items on map - } } public static void openCartridge(final CartridgeFile cartridgeFile) { diff --git a/src/main/java/menion/android/whereyougo/gui/activity/SatelliteActivity.java b/src/main/java/menion/android/whereyougo/gui/activity/SatelliteActivity.java index 28e8442d2..dd0bf60e6 100644 --- a/src/main/java/menion/android/whereyougo/gui/activity/SatelliteActivity.java +++ b/src/main/java/menion/android/whereyougo/gui/activity/SatelliteActivity.java @@ -1,17 +1,17 @@ /* * This file is part of WhereYouGo. - * + * * WhereYouGo is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * WhereYouGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along with WhereYouGo. If not, * see . - * + * * Copyright (C) 2012 Menion */ @@ -162,7 +162,7 @@ public void run() { ((TextView) findViewById(R.id.text_view_altitude)).setText(UtilsFormat.formatAltitude( location.getAltitude(), true)); ((TextView) findViewById(R.id.text_view_accuracy)).setText(UtilsFormat.formatDistance( - location.getAccuracy(), false)); + location.getAccuracyHor(), false)); ((TextView) findViewById(R.id.text_view_speed)).setText(UtilsFormat.formatSpeed( location.getSpeed(), false)); ((TextView) findViewById(R.id.text_view_declination)).setText(UtilsFormat diff --git a/src/main/java/menion/android/whereyougo/gui/dialog/ChooseCartridgeDialog.java b/src/main/java/menion/android/whereyougo/gui/dialog/ChooseCartridgeDialog.java index 83f28080d..d8572c0f9 100644 --- a/src/main/java/menion/android/whereyougo/gui/dialog/ChooseCartridgeDialog.java +++ b/src/main/java/menion/android/whereyougo/gui/dialog/ChooseCartridgeDialog.java @@ -50,8 +50,8 @@ public Dialog createDialog(Bundle savedInstanceState) { try { // sort cartridges final Location actLoc = LocationState.getLocation(); - final Location loc1 = new Location(TAG); - final Location loc2 = new Location(TAG); + final Location loc1 = new Location(); + final Location loc2 = new Location(); Collections.sort(cartridgeFiles, (object1, object2) -> { loc1.setLatitude(object1.latitude); loc1.setLongitude(object1.longitude); diff --git a/src/main/java/menion/android/whereyougo/gui/extension/DataInfo.java b/src/main/java/menion/android/whereyougo/gui/extension/DataInfo.java index f2752b574..c607407ca 100644 --- a/src/main/java/menion/android/whereyougo/gui/extension/DataInfo.java +++ b/src/main/java/menion/android/whereyougo/gui/extension/DataInfo.java @@ -1,17 +1,17 @@ /* * This file is part of WhereYouGo. - * + * * WhereYouGo is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * WhereYouGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along with WhereYouGo. If not, * see . - * + * * Copyright (C) 2012 Menion */ @@ -175,7 +175,7 @@ public DataInfo setImageRight(Bitmap image) { } public Location getLocation() { - Location loc = new Location(TAG); + Location loc = new Location(); loc.setLatitude(value01); loc.setLongitude(value02); return loc; diff --git a/src/main/java/menion/android/whereyougo/guide/ZoneGuide.java b/src/main/java/menion/android/whereyougo/guide/ZoneGuide.java index 92e4caf1a..5abefec3a 100644 --- a/src/main/java/menion/android/whereyougo/guide/ZoneGuide.java +++ b/src/main/java/menion/android/whereyougo/guide/ZoneGuide.java @@ -12,8 +12,7 @@ public class ZoneGuide extends Guide { private boolean mAlreadyEntered = false; public ZoneGuide(Zone zone) { - super(zone.name, new Location("Guidance: " + zone.name, zone.bbCenter.latitude, - zone.bbCenter.longitude)); + super(zone.name, new Location(zone.bbCenter.latitude, zone.bbCenter.longitude)); mZone = zone; mAlreadyEntered = false; } @@ -21,14 +20,14 @@ public ZoneGuide(Zone zone) { /* * public void actualizeState(Location location) { super.actualizeState(location); if * (mAlreadyEntered == false && mZone.contain == Zone.INSIDE) { mAlreadyEntered = true; - * + * * // issue #54 - acoustical switch (Preferences.GUIDING_WAYPOINT_SOUND) { case * PreferenceValues.VALUE_GUIDING_WAYPOINT_SOUND_INCREASE_CLOSER: case * PreferenceValues.VALUE_GUIDING_WAYPOINT_SOUND_BEEP_ON_DISTANCE: playSingleBeep(); break; case * PreferenceValues.VALUE_GUIDING_WAYPOINT_SOUND_CUSTOM_SOUND: playCustomSound(); break; } - * + * * // issue #54 - visual //ManagerNotify.toastShortMessage(R.string.guidance_zone_entered); - * + * * // issue #54 - vibration Vibrator v = (Vibrator) * A.getMain().getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(50); } } */ diff --git a/src/main/java/menion/android/whereyougo/maps/utils/LocusMapDataProvider.java b/src/main/java/menion/android/whereyougo/maps/utils/LocusMapDataProvider.java index 373eaaeaa..9daaf94e2 100644 --- a/src/main/java/menion/android/whereyougo/maps/utils/LocusMapDataProvider.java +++ b/src/main/java/menion/android/whereyougo/maps/utils/LocusMapDataProvider.java @@ -1,14 +1,14 @@ /* * Copyright 2013, 2014 biylda - * + * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along with this program. If not, * see . */ @@ -24,14 +24,13 @@ import cz.matejcik.openwig.EventTable; import cz.matejcik.openwig.Zone; import cz.matejcik.openwig.formats.CartridgeFile; -import locus.api.android.objects.PackWaypoints; -import locus.api.objects.extra.ExtraData; -import locus.api.objects.extra.ExtraStyle; -import locus.api.objects.extra.ExtraStyle.LineStyle.ColorStyle; -import locus.api.objects.extra.ExtraStyle.LineStyle.Units; +import locus.api.android.objects.PackPoints; +import locus.api.objects.extra.GeoDataExtra; +import locus.api.objects.styles.GeoDataStyle; +import locus.api.objects.styles.LineStyle; import locus.api.objects.extra.Location; -import locus.api.objects.extra.Track; -import locus.api.objects.extra.Waypoint; +import locus.api.objects.geoData.Track; +import locus.api.objects.geoData.Point; import menion.android.whereyougo.gui.activity.MainActivity; import menion.android.whereyougo.gui.activity.wherigo.DetailsActivity; import menion.android.whereyougo.gui.utils.UtilsWherigo; @@ -39,11 +38,11 @@ public class LocusMapDataProvider implements MapDataProvider { private static LocusMapDataProvider instance = null; private ArrayList tracks = null; - private final PackWaypoints pack; + private final PackPoints pack; private LocusMapDataProvider() { tracks = new ArrayList<>(); - pack = new PackWaypoints("WhereYouGo"); + pack = new PackPoints("WhereYouGo"); } public static LocusMapDataProvider getInstance() { @@ -74,13 +73,13 @@ public void addCartridges(Vector cartridges) { } // construct waypoint - Location loc = new Location("WhereYouGo"); + Location loc = new Location(); loc.setLatitude(cartridge.latitude); loc.setLongitude(cartridge.longitude); - Waypoint wpt = new Waypoint(cartridge.name, loc); - wpt.addParameter(ExtraData.PAR_DESCRIPTION, cartridge.description); - wpt.addUrl(cartridge.url); - pack.addWaypoint(wpt); + Point wpt = new Point(cartridge.name, loc); + wpt.addParameter(GeoDataExtra.PAR_DESCRIPTION, cartridge.description); + wpt.addParameterUrl(cartridge.url); + pack.addPoint(wpt); } } @@ -89,30 +88,34 @@ public void addOther(EventTable et, boolean mark) { return; Location loc = UtilsWherigo.extractLocation(et); - pack.addWaypoint(new Waypoint(et.name, loc)); + pack.addPoint(new Point(et.name, loc)); } public void addZone(Zone z, boolean mark) { if (z == null || !z.isLocated() || !z.isVisible()) return; - ArrayList locs = new ArrayList<>(); + ArrayList locations = new ArrayList<>(); for (int i = 0; i < z.points.length; i++) { - Location loc = new Location(""); - loc.setLatitude(z.points[i].latitude); - loc.setLongitude(z.points[i].longitude); - locs.add(loc); + Location location = new Location(); + location.setLatitude(z.points[i].latitude); + location.setLongitude(z.points[i].longitude); + locations.add(location); } - if (locs.size() >= 3) - locs.add(locs.get(0)); + if (locations.size() >= 3) + locations.add(locations.get(0)); Track track = new Track(); - ExtraStyle style = new ExtraStyle(); - style.setLineStyle(ColorStyle.SIMPLE, Color.MAGENTA, 2.0f, Units.PIXELS); - track.styleNormal = style; - track.setPoints(locs); + LineStyle lineStyle = new LineStyle(); + lineStyle.setColoring(LineStyle.Coloring.SIMPLE); + lineStyle.setColorBase(Color.MAGENTA); + lineStyle.setWidth(2.0f); + lineStyle.setUnits(LineStyle.Units.PIXELS); + GeoDataStyle geoDataStyle = new GeoDataStyle(); + geoDataStyle.setLineStyle(lineStyle); + track.setStyleNormal(geoDataStyle); + track.setPoints(locations); track.setName(z.name); - tracks.add(track); } @@ -131,10 +134,9 @@ public void addZones(Vector zones, EventTable mark) { public void clear() { tracks.clear(); - pack.reset(); } - public PackWaypoints getPoints() { + public PackPoints getPoints() { return pack; } diff --git a/src/main/java/menion/android/whereyougo/maps/utils/MapHelper.java b/src/main/java/menion/android/whereyougo/maps/utils/MapHelper.java index 85c44b7c6..d8833abb8 100644 --- a/src/main/java/menion/android/whereyougo/maps/utils/MapHelper.java +++ b/src/main/java/menion/android/whereyougo/maps/utils/MapHelper.java @@ -1,14 +1,14 @@ /* * Copyright 2013, 2014 biylda - * + * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along with this program. If not, * see . */ @@ -18,13 +18,16 @@ import android.app.Activity; import android.content.Intent; +import cz.matejcik.openwig.Action; import cz.matejcik.openwig.EventTable; -import locus.api.android.ActionDisplay.ExtraAction; +import locus.api.android.ActionDisplayVarious.ExtraAction; import locus.api.android.ActionDisplayPoints; import locus.api.android.ActionDisplayTracks; -import locus.api.android.ActionTools; +import locus.api.android.ActionBasics; import locus.api.android.utils.LocusUtils; import locus.api.android.utils.exceptions.RequiredVersionMissingException; +import locus.api.objects.extra.Location; +import locus.api.objects.geoData.Point; import menion.android.whereyougo.gui.activity.MainActivity; import menion.android.whereyougo.gui.utils.UtilsWherigo; import menion.android.whereyougo.maps.mapsforge.MapsforgeActivity; @@ -73,16 +76,16 @@ public static void vectorMap(Activity activity, EventTable et) { public static void locusMap(Activity activity, EventTable et) { LocusMapDataProvider mdp = LocusMapDataProvider.getInstance(); try { - ActionDisplayPoints.sendPack(activity, mdp.getPoints(), ExtraAction.NONE); - ActionDisplayTracks.sendTracks(activity, mdp.getTracks(), ExtraAction.CENTER); + ActionDisplayPoints.INSTANCE.sendPack(activity, mdp.getPoints(), ExtraAction.NONE); + ActionDisplayTracks.INSTANCE.sendTracks(activity, mdp.getTracks(), ExtraAction.CENTER); if (et != null && et.isLocated()) { - locus.api.objects.extra.Location loc = UtilsWherigo.extractLocation(et); - locus.api.objects.extra.Waypoint wpt = new locus.api.objects.extra.Waypoint(et.name, loc); - ActionTools.actionStartGuiding(activity, wpt); + Location loc = UtilsWherigo.extractLocation(et); + Point wpt = new Point(et.name, loc); + ActionBasics.INSTANCE.actionStartGuiding(activity, wpt); } } catch (RequiredVersionMissingException e) { Logger.e(activity.toString(), "MapHelper.showMap() - missing locus version", e); - LocusUtils.callInstallLocus(activity); + LocusUtils.INSTANCE.callInstallLocus(activity); } catch (Exception e) { Logger.e(activity.toString(), "MapHelper.showMap() - unknown locus problem", e); } diff --git a/src/main/java/menion/android/whereyougo/openwig/WLocationService.java b/src/main/java/menion/android/whereyougo/openwig/WLocationService.java index a502f540e..7548f2b31 100644 --- a/src/main/java/menion/android/whereyougo/openwig/WLocationService.java +++ b/src/main/java/menion/android/whereyougo/openwig/WLocationService.java @@ -1,17 +1,17 @@ /* * This file is part of WhereYouGo. - * + * * WhereYouGo is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * WhereYouGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along with WhereYouGo. If not, * see . - * + * * Copyright (C) 2012 Menion */ @@ -50,7 +50,7 @@ public double getLongitude() { } public double getPrecision() { - return LocationState.getLocation().getAccuracy(); + return LocationState.getLocation().getAccuracyHor(); } public int getState() { diff --git a/src/main/java/menion/android/whereyougo/preferences/PreferenceValues.java b/src/main/java/menion/android/whereyougo/preferences/PreferenceValues.java index 2c138a893..f3a46392f 100644 --- a/src/main/java/menion/android/whereyougo/preferences/PreferenceValues.java +++ b/src/main/java/menion/android/whereyougo/preferences/PreferenceValues.java @@ -1,17 +1,17 @@ /* * This file is part of WhereYouGo. - * + * * WhereYouGo is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * WhereYouGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along with WhereYouGo. If not, * see . - * + * * Copyright (C) 2012 Menion */ @@ -203,7 +203,7 @@ public static String getLanguageCode() { } public static Location getLastKnownLocation() { - Location lastKnownLocation = new Location(TAG); + Location lastKnownLocation = new Location(); lastKnownLocation.setLatitude(Preferences.getDecimalPreference(R.string.pref_KEY_F_LAST_KNOWN_LOCATION_LATITUDE)); lastKnownLocation.setLongitude(Preferences.getDecimalPreference(R.string.pref_KEY_F_LAST_KNOWN_LOCATION_LONGITUDE)); lastKnownLocation.setAltitude(Preferences.getDecimalPreference(R.string.pref_KEY_F_LAST_KNOWN_LOCATION_ALTITUDE)); diff --git a/src/main/java/menion/android/whereyougo/utils/UtilsFormat.java b/src/main/java/menion/android/whereyougo/utils/UtilsFormat.java index 08a63004f..f3ee9eabd 100644 --- a/src/main/java/menion/android/whereyougo/utils/UtilsFormat.java +++ b/src/main/java/menion/android/whereyougo/utils/UtilsFormat.java @@ -1,17 +1,17 @@ /* * This file is part of WhereYouGo. - * + * * WhereYouGo is free software: you can redistribute it and/or modify it under the terms of the GNU * General Public License as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * WhereYouGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License along with WhereYouGo. If not, * see . - * + * * Copyright (C) 2012 Menion */ @@ -41,27 +41,27 @@ public class UtilsFormat { private static final SimpleDateFormat datetimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static String formatAltitude(double altitude, boolean addUnits) { - return locus.api.android.utils.UtilsFormat.formatAltitude(Preferences.FORMAT_ALTITUDE, altitude, addUnits); + return locus.api.android.utils.UtilsFormat.INSTANCE.formatAltitude(Preferences.FORMAT_ALTITUDE, altitude, addUnits); } public static String formatAngle(double angle) { - return locus.api.android.utils.UtilsFormat.formatAngle(Preferences.FORMAT_ANGLE, (float) ((angle % 360) + 360) % 360, false, 0); + return locus.api.android.utils.UtilsFormat.INSTANCE.formatAngle(Preferences.FORMAT_ANGLE, (float) ((angle % 360) + 360) % 360, false, 0); } public static String formatSpeed(double speed, boolean withoutUnits) { - return locus.api.android.utils.UtilsFormat.formatSpeed(Preferences.FORMAT_SPEED, speed, withoutUnits); + return locus.api.android.utils.UtilsFormat.INSTANCE.formatSpeed(Preferences.FORMAT_SPEED, speed, withoutUnits); } public static String formatDistance(double dist, boolean withoutUnits) { - return locus.api.android.utils.UtilsFormat.formatDistance(Preferences.FORMAT_LENGTH, dist, withoutUnits); + return locus.api.android.utils.UtilsFormat.INSTANCE.formatDistance(Preferences.FORMAT_LENGTH, dist, withoutUnits); } public static String formatDouble(double value, int precision) { - return locus.api.android.utils.UtilsFormat.formatDouble(value, precision); + return locus.api.android.utils.UtilsFormat.INSTANCE.formatDouble(value, precision); } public static String formatDouble(double value, int precision, int minlen) { - return locus.api.android.utils.UtilsFormat.formatDouble(value, precision, minlen); + return locus.api.android.utils.UtilsFormat.INSTANCE.formatDouble(value, precision, minlen); } public static String addZeros(String text, int count) {