Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gen/

# Local configuration file (sdk path, etc)
local.properties
gradle.properties

# Eclipse project files
.classpath
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android {
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/assets/plan.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@
var CELL_FUEL = 6;
var CELL_LAST = 7;

var plan_poll_timer = setInterval(function () {loadplan()}, 1000);

// load plan from Android then display every second
function loadplan() {
function loadplan(str) {
//var str = "myplanname::::1,102,18,BOS,NAVAID--:--::::0,5,23,--:--BVY,AIRPORT::::Total 82nm --:-- 102° 10.1";
var str = AndroidPlan.getPlanData();
// split plan data encoded in ::
var plans = str.split("::::");
plan_setname(plans[0]);
Expand Down
36 changes: 14 additions & 22 deletions app/src/main/java/com/ds/avare/LocationActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import com.ds.avare.utils.OptionButton;
import com.ds.avare.utils.Tips;
import com.ds.avare.views.LocationView;
import com.ds.avare.views.LongPressedDestination;
import com.ds.avare.webinfc.WebAppMapInterface;

import java.io.File;
Expand Down Expand Up @@ -144,7 +145,7 @@ public class LocationActivity extends Activity implements Observer {
private AnimateButton mAnimateHelp;
private AnimateButton mAnimateDownload;
private AnimateButton mAnimatePref;
private String mAirportPressed;
private LongPressedDestination mDestinationPressed;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed because it's not only an airport which can be pressed...

private AlertDialog mAlertDialogDestination;
private WebAppMapInterface mInfc;

Expand Down Expand Up @@ -492,7 +493,7 @@ public void gestureCallBack(int event, LongTouchDestination data) {
* Show the popout
* Now populate the pop out weather etc.
*/
mAirportPressed = data.airport;
mDestinationPressed = new LongPressedDestination(data.destinationName, data.destinationType) ;

}
}
Expand Down Expand Up @@ -896,7 +897,7 @@ public Object callback(Object o, Object o1) {

mAlertDialogDestination.dismiss();

if (null == mAirportPressed) {
if (null == mDestinationPressed) {
return null;
}
if (mService == null) {
Expand All @@ -907,41 +908,32 @@ public Object callback(Object o, Object o1) {
/*
* A/FD
*/
if (!mAirportPressed.contains("&")) {
mService.setLastAfdAirport(mAirportPressed);
if (mDestinationPressed.getType() == Destination.BASE) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having type of a destination pressed is nice here as we select various actions base on type; this also gets rid of checking hard-coded & character

mService.setLastAfdAirport(mDestinationPressed.getName());
((MainActivity) LocationActivity.this.getParent()).showAfdTab();
}
mAirportPressed = null;
mDestinationPressed = null;
} else if (param.equals("Plate")) {
/*
* Plate
*/
if (!mAirportPressed.contains("&")) {
mService.setLastPlateAirport(mAirportPressed);
if (mDestinationPressed.getType() == Destination.BASE) {
mService.setLastPlateAirport(mDestinationPressed.getName());
mService.setLastPlateIndex(0);
((MainActivity) LocationActivity.this.getParent()).showPlatesTab();
}
mAirportPressed = null;
mDestinationPressed = null;
} else if (param.equals("+Plan")) {
String type = Destination.BASE;
if (mAirportPressed.contains("&")) {
type = Destination.GPS;
}
planTo(mAirportPressed, type);
mAirportPressed = null;
planTo(mDestinationPressed.getName(), mDestinationPressed.getType());
mDestinationPressed = null;
} else if (param.equals("->D")) {

/*
* On click, find destination that was pressed on in view
* If button pressed was a destination go there, otherwise if none, then delete current dest
*/
String dest = mAirportPressed;
mAirportPressed = null;
String type = Destination.BASE;
if (dest.contains("&")) {
type = Destination.GPS;
}
goTo(dest, type);
goTo(mDestinationPressed.getName(), mDestinationPressed.getType());
mDestinationPressed = null;
}
return null;
}
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/java/com/ds/avare/PlanActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,16 @@ public void handleMessage(Message msg) {
else if(msg.what == UNSHOW_BUSY) {
mProgressBarSearch.setVisibility(View.INVISIBLE);
}
else if(msg.what == ACTIVE) {
mActivateButton.setText(getString(R.string.Active));
}
else if(msg.what == INACTIVE) {
mActivateButton.setText(getString(R.string.Inactive));
}
else if(msg.what == ACTIVE) {
if (mActivateButton.getText().equals(getString(R.string.Inactive))) {
mActivateButton.setText(getString(R.string.Active));
}
}
else if(msg.what == INACTIVE) {
if (mActivateButton.getText().equals(getString(R.string.Active))) {
mActivateButton.setText(getString(R.string.Inactive));
}
}
else if(msg.what == MESSAGE) {
// Show an important message
DecoratedAlertDialogBuilder builder = new DecoratedAlertDialogBuilder(mContext);
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/ds/avare/storage/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class Preferences {
public static final int MAX_AREA_AIRPORTS = 20;

public static final double MIN_TOUCH_MOVEMENT_SQ_DISTANCE = 0.001;
public static final double NAVAID_TOUCH_DISTANCE = .5;

/*
* Max memory and max screen size it will support
Expand Down Expand Up @@ -1208,6 +1209,13 @@ public void setRateAskCount(int set) {
mPref.edit().putInt("rateAskLastCount", set).commit();
}

public int getWindsAloftCeiling() {
try {
return Integer.parseInt(mPref.getString(mContext.getString(R.string.WindsAloftCeiling), "39"));
} catch (Exception x) {
return 39;
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
*/
public class LongTouchDestination {

public String airport;
public String destinationName;
public String destinationType;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found having those 2 fields here is the easiest way to transit this info down the asynchronous call chain

public String info;
public String tfr;
public String mets;
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/com/ds/avare/utils/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
*/
public class Helper {

private static Calendar mCalendar = new GregorianCalendar();

// All elevation is calculated in feet
// ranges -364 to 20150 feet (hence 20150 in 3D is +z)
public static final double ALTITUDE_FT_ELEVATION_PER_PIXEL_SLOPE = 24.5276170372963 * Preferences.heightConversion;
Expand Down Expand Up @@ -691,23 +693,22 @@ public static boolean leftOfCourseLine(double brgTrue, double brgCourse) {
return true;
return false;
}

/**
*
*
*/
public static String millisToGMT(long millis) {
SimpleDateFormat df = new SimpleDateFormat("MM_dd_yyyy_hh_mm", Locale.getDefault());
df.setTimeZone(TimeZone.getTimeZone("GMT"));
return df.format(millis) + "_UTC";
}

/**
*
* @return
*/
public static long getMillisGMT() {
Calendar calendar = new GregorianCalendar();
TimeZone mTimeZone = calendar.getTimeZone();
TimeZone mTimeZone = mCalendar.getTimeZone();
int offset = mTimeZone.getOffset(System.currentTimeMillis());
return System.currentTimeMillis() - offset;
}
Expand Down
29 changes: 19 additions & 10 deletions app/src/main/java/com/ds/avare/utils/NavAidHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,34 @@ private String getNavaidLocationAsHtml(Coordinate navaidCoordinate, int navaidVa
boolean isReceived = isVorReceived(distanceToNavAid, navaidClass, altitudeReference - navaidElevation)
|| !("TLH".contains(navaidClass) || navaidClass.isEmpty());
long radial = Math.round(Helper.getMagneticHeading(p.getBearing(), navaidVariation));
return (!isReceived ? "<font color='red'>" : "")
+ String.format(Locale.getDefault(), "%03d", radial)
final String LIGHT_RED = "#ff6666", LIGHT_GREEN = "#99ff66";
return String.format(Locale.getDefault(), "%03d", radial)
+ "<font color='" + (isReceived ? LIGHT_GREEN : LIGHT_RED) + "'>"
+ Math.round(distanceToNavAid)
+ (!isReceived ? "</font>" : "")
+ "</font>"
;
}

/** format vector of navaids as a string */
public String toHtmlString(Vector<NavAid> navaids) {
String result = "";
String result = "<table>";
if (navaids != null) {
for (NavAid na : navaids) {
result += (result != "" ? "<br>" : "") // fields' order same as Chart Supplement convention
+ na.getLocationId()
+ getNavaidLocationAsHtml(na.getCoords(), na.getVariation(), na.getNavaidClass(), na.getElevation()) + " "
+ na.getFrequency()
+ (na.hasHiwas() ? "<sup>(H)</sup>" : "");
result +=
"<tr>" // fields' order same as Chart Supplement convention
+ "<td>"
+ na.getLocationId()
+ getNavaidLocationAsHtml(na.getCoords(), na.getVariation(), na.getNavaidClass(), na.getElevation())
+ "</td>"
+ "<td>&nbsp;"
+ na.getFrequency()
+ "</td>"
+ "<td>&nbsp;"
+ (na.hasHiwas() ? "HIWAS" : "")
+ "</td>"
+ "</tr>";
}
}
return result;
return result + "</table>";
}
}
127 changes: 0 additions & 127 deletions app/src/main/java/com/ds/avare/utils/WeatherHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import android.util.Pair;

import java.util.LinkedList;
import java.util.Locale;


public class WeatherHelper {
Expand Down Expand Up @@ -501,132 +500,6 @@ else if(vis >= 1) {
return output;
}

/**
* Wind decoder
* @param wind
* @return
*/
public static String decodeWind(String wind) {

if(wind.length() < 4) {
return "";
}

int dir;
int speed;
try {
dir = Integer.parseInt(wind.substring(0, 2)) * 10;
speed = Integer.parseInt(wind.substring(2, 4));
}
catch(Exception e) {
return "";
}

if(wind.length() == 4) {

if(dir == 990 && speed == 0) {
/*
* Light and variable
*/
return "000°000kt";
}
if(dir >= 510) {
dir -= 500;
speed += 100;
}

String out = String.format(Locale.getDefault(), "%03d°%03dkt", dir, speed);
return(out);
}

if(wind.length() == 7) {
String temp = wind.substring(4, 7);

if(dir == 990 && speed == 0) {
/*
* Light and variable
*/
return "000°000kt" + temp + "C";
}
if(dir >= 510) {
dir -= 500;
speed += 100;
}

String out = String.format(Locale.getDefault(), "%03d°%03dkt", dir, speed) + temp + "C";
return(out);

}

if(wind.length() == 6) {
String temp = "-" + wind.substring(4, 6);

if(dir == 990 && speed == 0) {
/*
* Light and variable
*/
return "000°000kt" + temp + "C";
}
if(dir >= 510) {
dir -= 500;
speed += 100;
}

String out = String.format(Locale.getDefault(), "%03d°%03dkt", dir, speed) + temp + "C";
return(out);
}

return "";
}

/**
* See decodeWind
* @param wind
* @return
*/
public static int decodeWindSpeed(String wind) {
String windsd = decodeWind(wind);
String w[] = windsd.split("°");
int speed = 0;
try {
speed = Integer.parseInt(w[1].split("kt")[0]);
}
catch (Exception e) {

}
return speed;
}

/**
* See decodeWind
* @param wind
* @return
*/
public static int decodeWindDir(String wind) {
String windsd = decodeWind(wind);
String w[] = windsd.split("°");
int dir = 0;
try {
dir = Integer.parseInt(w[0]);
}
catch (Exception e) {

}
return dir;
}

/**
*
* @return
*/
public static String getNamMosLegend() {
/*
* Legend
*/
return
"<a href='http://www.nws.noaa.gov/mdl/synop/namcard.php'>NAM Forecast Legend</a><br>";

}

/**
* Returns time from METAR
Expand Down
Loading