From 238ddde1ffdb8521d06519306cfb76271ae552b9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 12 May 2014 22:47:55 -0700 Subject: [PATCH] atosui: Hide Callsign and RSSI tabs for devices without a radio When doing Monitor Idle with EasyMini, it's nice to not put fields on the screen which won't ever have useful data in them. Signed-off-by: Keith Packard --- altosui/AltosFlightStatus.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index c6d75420..b467bbde 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -39,6 +39,11 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay value.setFont(Altos.status_font); } + void setVisible(boolean visible) { + label.setVisible(visible); + value.setVisible(visible); + } + public FlightValue (GridBagLayout layout, int x, String text) { GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); @@ -66,6 +71,10 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay class Call extends FlightValue { void show(AltosState state, AltosListenerState listener_state) { value.setText(state.callsign); + if (state.callsign == null) + setVisible(false); + else + setVisible(true); } public Call (GridBagLayout layout, int x) { super (layout, x, "Callsign"); @@ -116,6 +125,10 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay class RSSI extends FlightValue { void show(AltosState state, AltosListenerState listener_state) { value.setText(String.format("%d", state.rssi())); + if (state.rssi == AltosLib.MISSING) + setVisible(false); + else + setVisible(true); } public RSSI (GridBagLayout layout, int x) { super (layout, x, "RSSI"); -- 2.30.2