Skip to content

Commit

Permalink
fix #357 Locus integration not working
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
sk-juroot committed Jan 9, 2022
1 parent 9740c5d commit 828a713
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 122 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
*
* Copyright (C) 2012 Menion <[email protected]>
*/

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
*
* Copyright (C) 2012 Menion <[email protected]>
*/

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
*
* Copyright (C) 2012 Menion <[email protected]>
*/

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -179,9 +180,6 @@ public static void refreshCartridges() {
File[] files = FileSystem.getFiles(FileSystem.ROOT, "gwc");
cartridgeFiles = new Vector<>();

// add cartridges to map
ArrayList<Waypoint> wpts = new ArrayList<>();

File actualFile = null;
if (files != null) {
for (File file : files) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
*
* Copyright (C) 2012 Menion <[email protected]>
*/

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
*
* Copyright (C) 2012 Menion <[email protected]>
*/

Expand Down Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/menion/android/whereyougo/guide/ZoneGuide.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ 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;
}

/*
* 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); } }
*/
Expand Down
Loading

0 comments on commit 828a713

Please sign in to comment.