altosui: When flashing to TeleDongle or TeleBT, match any .ihx file
authorKeith Packard <keithp@keithp.com>
Mon, 9 Dec 2013 05:07:17 +0000 (21:07 -0800)
committerKeith Packard <keithp@keithp.com>
Mon, 9 Dec 2013 05:07:17 +0000 (21:07 -0800)
Let the user pick any .ihx file when using a device which can only be
used as a pair programmer. Note that 'telemetrum' can be either, and
we'll assume that it's a self-programmed device (v2) for now.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosFlashUI.java

index 5ec5ea8a2bc49a645640a05d8b3d2c1e09afa0a8..e305d458a171fa388aa0ee2c1cfcfc286f1c9f63 100644 (file)
@@ -69,9 +69,18 @@ public class AltosFlashUI
        };
 
        private boolean is_pair_programmed() {
-               String  name = file.getName();
-               for (int i = 0; i < pair_programmed.length; i++) {
-                       if (name.startsWith(pair_programmed[i]))
+
+               if (file != null) {
+                       String  name = file.getName();
+                       for (int i = 0; i < pair_programmed.length; i++) {
+                               if (name.startsWith(pair_programmed[i]))
+                                       return true;
+                       }
+               }
+               if (device != null) {
+                       if (!device.matchProduct(AltosLib.product_altusmetrum) &&
+                           (device.matchProduct(AltosLib.product_teledongle) ||
+                            device.matchProduct(AltosLib.product_telebt)))
                                return true;
                }
                return false;
@@ -223,7 +232,7 @@ public class AltosFlashUI
                hexfile_chooser.addChoosableFileFilter(ihx_filter);
                hexfile_chooser.setFileFilter(ihx_filter);
                
-               if (!device.matchProduct(AltosLib.product_altusmetrum)) {
+               if (!is_pair_programmed() && !device.matchProduct(AltosLib.product_altusmetrum)) {
                        for (int i = 0; i < filters.length; i++) {
                                if (device != null && device.matchProduct(filters[i].product))
                                        hexfile_chooser.setFileFilter(filters[i]);