Skip to content

Commit

Permalink
## 4.6.0.1
Browse files Browse the repository at this point in the history
* Bug Fixes
  * handle the case where the RerouteDialog can throw an IllegalStateException (playstore)
  * follow the altitude unit preference for the display and entry of the height in viewshed screens
  * encode and decode unicode representation for the basic XML escaped values so invalid characters in the preferences file will not cause issues (xml values that would need to be escaped)
  * correctly pad with zeros and only return the number if it is negative
  • Loading branch information
takdeveloper committed Apr 7, 2023
1 parent 9c9c6ee commit ded2cdc
Show file tree
Hide file tree
Showing 16 changed files with 235 additions and 60 deletions.
8 changes: 8 additions & 0 deletions VERSION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Version History

## 4.6.0.1

* Bug Fixes
* handle the case where the RerouteDialog can throw an IllegalStateException (playstore)
* follow the altitude unit preference for the display and entry of the height in viewshed screens
* encode and decode unicode representation for the basic XML escaped values so invalid characters in the preferences file will not cause issues (xml values that would need to be escaped)
* correctly pad with zeros and only return the number if it is negative

## 4.6.0.0

* Feature Additions
Expand Down
2 changes: 1 addition & 1 deletion atak/ATAK/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ buildscript {
apply from: '../../gradle/versions.gradle', to: project

ext.ATAK_VERSION = "4.6.0"
ext.ATAK_VERSION_SUBMINOR = ".0"
ext.ATAK_VERSION_SUBMINOR = ".1"

ext.isDevKitEnabled = { ->
return getProperty('takRepoMavenUrl', null) != null &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,15 @@ public void setActive(boolean active) {
}

/**
* Pad a number by the specified number of places.
* Pad a positive number by the specified number of places. If the
* number is negative - just return the same number.
* @param value the number of places
* @return 0 padded number.
*/
public static String pad3(int value) {
if (value < 0)
return Integer.toString(value);

if (value < 9)
return "00" + value;
else if (value < 99)
Expand Down Expand Up @@ -1371,6 +1375,8 @@ public void _updateLinkInfo() {
if (v > 180)
v = -(360 - v);

if (v < 0) v+=360;

bearingString = pad3(v);

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

package com.atakmap.android.elev;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
Expand All @@ -14,10 +11,12 @@
import com.atakmap.android.maps.MapOverlayManager;
import com.atakmap.android.maps.MapView;
import com.atakmap.android.overlay.MapOverlayRenderer;

import com.atakmap.coremap.maps.coords.GeoCalculations;
import com.atakmap.coremap.maps.coords.GeoPoint.AltitudeReference;
import com.atakmap.coremap.maps.coords.GeoPoint;
import com.atakmap.coremap.maps.coords.GeoPoint.AltitudeReference;

import java.util.ArrayList;
import java.util.HashMap;

public class ViewShedReceiver extends BroadcastReceiver {

Expand Down Expand Up @@ -104,7 +103,7 @@ public class ViewShedReceiver extends BroadcastReceiver {
public static final String VIEWSHED_PREFERENCE_CIRCULAR_VIEWSHED = "viewshed_prefs_circular_viewshed";
public static final String VIEWSHED_PREFERENCE_RADIUS_KEY = "viewshed_prefs_radius";

public static final String VIEWSHED_PREFERENCE_HEIGHT_ABOVE_KEY = "viewshed_prefs_height_above";
public static final String VIEWSHED_PREFERENCE_HEIGHT_ABOVE_KEY = "viewshed_prefs_height_above_meters";

public static final String VIEWSHED_LINE_UID_SEPERATOR = "*";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1819,8 +1819,8 @@ private void setupRerouteButton() {
final RoutePlannerManager routePlannerManager = ((RouteMapComponent) mc)
.getRoutePlannerManager();

// No route planners - remove button if it exists
if (routePlannerManager.getCount() == 0) {
// No reroute capable route planners - hide the button
if (routePlannerManager.getReroutePlanners().size() == 0) {
removeRerouteButton();
return;
}
Expand Down Expand Up @@ -1860,8 +1860,8 @@ private void setupRerouteButton() {
public void onMapWidgetPress(MapWidget widget, MotionEvent event) {

// Make sure there are route planners available
if (routePlannerManager.getCount() == 0) {
// No route planners - hide the button
if (routePlannerManager.getReroutePlanners().size() == 0) {
// No reroute capable route planners - hide the button
// XXX - Ideally we'd hide the button when the last planner
// is unregistered but there's no hook for this...
removeRerouteButton();
Expand All @@ -1871,7 +1871,15 @@ public void onMapWidgetPress(MapWidget widget, MotionEvent event) {
}

if (rerouteButton.getState() == REROUTE_BUTTON_OFF) {
showRerouteDialog(routePlannerManager);
try {
// showRerouteDialog can throw an IllegalStateException
// handle it by removing the reroute button and toasting
showRerouteDialog(routePlannerManager);
} catch (Exception e) {
removeRerouteButton();
Toast.makeText(_context, R.string.bloodhound_no_planners,
Toast.LENGTH_LONG).show();
}
} else if (rerouteButton.getState() == REROUTE_BUTTON_ON) {
rerouteButton.setIcon(rerouteInactiveIcon);
rerouteButton.setState(REROUTE_BUTTON_OFF);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package com.atakmap.android.viewshed;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -60,12 +61,15 @@
import com.atakmap.android.util.SimpleSeekBarChangeListener;
import com.atakmap.app.R;
import com.atakmap.coremap.conversions.ConversionFactors;
import com.atakmap.coremap.conversions.Span;
import com.atakmap.coremap.locale.LocaleUtil;
import com.atakmap.coremap.log.Log;
import com.atakmap.coremap.maps.conversion.EGM96;
import com.atakmap.coremap.maps.coords.GeoPoint;
import com.atakmap.coremap.maps.coords.GeoPoint.AltitudeReference;
import com.atakmap.map.elevation.ElevationManager;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
Expand Down Expand Up @@ -95,7 +99,7 @@ public class ViewshedDropDownReceiver extends DropDownReceiver implements
private boolean viewshedListShowing = false;

private final HashMap<String, Double> radiusMap = new HashMap<>();
private final HashMap<String, Integer> heightMap = new HashMap<>();
private final HashMap<String, Float> heightMap = new HashMap<>();
private final HashMap<String, Integer> intensityMap = new HashMap<>();
private final HashMap<String, GeoPoint> refPointMap = new HashMap<>();

Expand Down Expand Up @@ -176,6 +180,7 @@ public void run() {
}
}
});
prefs.registerOnSharedPreferenceChangeListener(prefChanged);
}

@Override
Expand Down Expand Up @@ -207,6 +212,7 @@ public void run() {

@Override
public void disposeImpl() {
prefs.unregisterOnSharedPreferenceChangeListener(prefChanged);
}

@Override
Expand Down Expand Up @@ -303,6 +309,8 @@ public View createTabContent(String tag) {
showHideHeatmapCB.setChecked(
ElevationOverlaysMapComponent.isHeatMapVisible());
}


showDropDown(tabHost, FIVE_TWELFTHS_WIDTH, FULL_HEIGHT, FULL_WIDTH,
HALF_HEIGHT);
setRetain(true);
Expand Down Expand Up @@ -799,10 +807,9 @@ public void afterTextChanged(Editable s) {

//the altitude editText
altitudeET = vsView.findViewById(R.id.altitude_et);
final int heightAboveMarker = prefs.getInt(
ViewShedReceiver.VIEWSHED_PREFERENCE_HEIGHT_ABOVE_KEY,
5);
altitudeET.setText(Integer.toString(heightAboveMarker));
setFtMLabel(altitudeET);
setAltitudeFromPreference();


altitudeET.addTextChangedListener(new AfterTextChangedWatcher() {
@Override
Expand Down Expand Up @@ -1341,7 +1348,10 @@ public void onPointChanged(final PointMapItem m) {
title = m.getMetaString("callsign", "");
}

final String msltext = EGM96.formatMSL(m.getPoint());



final String msltext = formatMSL(m.getPoint());

getMapView().post(new Runnable() {
@Override
Expand Down Expand Up @@ -1410,7 +1420,7 @@ public void run() {
title = m.getMetaString("callsign", "");
}

final String msltext = EGM96.formatMSL(m.getPoint());
final String msltext = formatMSL(m.getPoint());

getMapView().post(new Runnable() {
@Override
Expand Down Expand Up @@ -1615,24 +1625,29 @@ public void showViewshed(final PointMapItem vsdMarker) {

GeoPoint refPoint = vsdMarker.getPoint();

int heightAboveGround = 0;
float heightAboveGround = 0;
if (altitudeET.getText().length() > 0) {
try {
heightAboveGround = Integer.parseInt(altitudeET.getText()
heightAboveGround = Float.parseFloat(altitudeET.getText()
.toString());
} catch (Exception e) {
return;
}

Span span = getSpan();
if (span == Span.FOOT) {
heightAboveGround *= ConversionFactors.FEET_TO_METERS;
}

// for storage the unit will always need to be meters
prefs.edit()
.putInt(ViewShedReceiver.VIEWSHED_PREFERENCE_HEIGHT_ABOVE_KEY,
.putFloat(ViewShedReceiver.VIEWSHED_PREFERENCE_HEIGHT_ABOVE_KEY,
heightAboveGround)
.apply();
heightMap.put(vsdMarker.getUID(), heightAboveGround);

}

heightAboveGround *= ConversionFactors.FEET_TO_METERS;

//get the marker alt in AGL
double markerAltAGL = 0;
if (!vsdMarker.getType().equalsIgnoreCase("vsd-marker")) {
Expand Down Expand Up @@ -1735,27 +1750,37 @@ private void changeViewshed(PointMapItem vsdMarker) {

final String uid = vsdMarker.getUID();

double radius = radiusMap.get(uid);
int intensity = intensityMap.get(uid);
int heightAboveGround = heightMap.get(uid);
Double radius = radiusMap.get(uid);
if (radius == null) return;

Integer intensity = intensityMap.get(uid);
if (intensity == null) return;

Float heightAboveGround = heightMap.get(uid);
if (heightAboveGround == null) return;

GeoPoint refPoint = refPointMap.get(uid);
final String msltext = EGM96.formatMSL(vsdMarker.getPoint());
final String msltext = formatMSL(vsdMarker.getPoint());

//Updates the text boxes
markerInfoTV.setText(vsdMarker.getTitle());
viewshedDtedTV.setText(msltext);
String height = String.valueOf(heightAboveGround);

radiusET.setText(String.valueOf(radius));
altitudeET.setText(height);


prefs.edit()
.putInt(ViewShedReceiver.VIEWSHED_PREFERENCE_HEIGHT_ABOVE_KEY,
heightAboveGround)
.putFloat(ViewShedReceiver.VIEWSHED_PREFERENCE_HEIGHT_ABOVE_KEY,
(float) (double)heightAboveGround)
.apply();

setAltitudeFromPreference();

intensityPercentageET.setText(String.valueOf(intensity));
intensitySeek.setProgress(intensity);
prefs.edit()
.putInt(ViewShedReceiver.VIEWSHED_PREFERENCE_RADIUS_KEY,
(int) radius)
(int) (double)radius)
.apply();

ElevationOverlaysMapComponent.setHeatMapVisible(false);
Expand Down Expand Up @@ -1966,4 +1991,90 @@ private void updateGenEnabled(boolean enabled) {
contourGenButton.setEnabled(enabled);
}
}

private String formatMSL(GeoPoint point) {
Span altUnits = getSpan();
return EGM96.formatMSL(point, altUnits);
}

/**
* This method is being added in so take care of the heavy lift of changing
* the value from ft to meters for the Height Above Marker. The EditText
* for entering the value should be passed. This can all be removed when the
* field is labeled.
*/
private void setFtMLabel(EditText et) {
Span altUnits = getSpan();
final String ftunit = et.getContext().getString(R.string.ft);
final String munit = et.getContext().getString(R.string.meter_abbreviation);

String unit;
if (altUnits.equals(Span.FOOT)) {
unit = ftunit;
} else {
unit = munit;
}
ViewGroup vg = (ViewGroup) et.getParent();
int numChildren = vg.getChildCount();
for (int i = 0; i < numChildren; ++i) {
View v = vg.getChildAt(i);
if (v instanceof TextView) {
String s = ((TextView) v).getText().toString();
if (s.equals(ftunit) || s.equals(munit)) {
((TextView) v).setText(unit);
}
}
}

}

private Span getSpan() {
Span altUnits;
switch (Integer
.parseInt(prefs.getString("alt_unit_pref", "0"))) {
case 0:
altUnits = Span.FOOT;
break;
case 1:
altUnits = Span.METER;
break;
default: // default to feet
altUnits = Span.FOOT;
break;
}
return altUnits;
}

private void setAltitudeFromPreference() {
float heightAboveMarker = prefs.getFloat(
ViewShedReceiver.VIEWSHED_PREFERENCE_HEIGHT_ABOVE_KEY,
(float)(5 * ConversionFactors.FEET_TO_METERS));

// for display purposes only
if (getSpan() == Span.FOOT) {
heightAboveMarker *= ConversionFactors.METERS_TO_FEET;
}
DecimalFormat _two = LocaleUtil.getDecimalFormat("0.00");
altitudeET.setText(_two.format(heightAboveMarker));
}


private SharedPreferences.OnSharedPreferenceChangeListener prefChanged = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

if (key == null)
return;

if (key.equals("alt_unit_pref") && altitudeET != null) {
((Activity)getMapView().getContext()).runOnUiThread(new Runnable() {
@Override
public void run() {
setFtMLabel(altitudeET);
setAltitudeFromPreference();
}
});
}
}
};
}
Loading

0 comments on commit ded2cdc

Please sign in to comment.