ilabs-flir 2.3.5 → 2.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,6 +10,7 @@ import com.facebook.react.bridge.WritableMap
|
|
|
10
10
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
11
11
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
12
12
|
import com.flir.thermalsdk.live.Identity
|
|
13
|
+
import com.flir.thermalsdk.image.Palette
|
|
13
14
|
import com.flir.thermalsdk.image.PaletteManager
|
|
14
15
|
import java.io.File
|
|
15
16
|
import java.io.FileOutputStream
|
|
@@ -463,24 +464,31 @@ object FlirManager {
|
|
|
463
464
|
Log.d(TAG, "Updated Var.cool to $shaderIdx via reflection (raw=$rawIdx)")
|
|
464
465
|
|
|
465
466
|
// If we are in FLIR mode, also notify the SDK palette using the official SDK palette list
|
|
466
|
-
var sdkPalettes: List
|
|
467
|
+
var sdkPalettes: List<*>? = null
|
|
467
468
|
try {
|
|
468
469
|
sdkPalettes = PaletteManager.getDefaultPalettes()
|
|
469
470
|
} catch (t: Throwable) {
|
|
470
471
|
try {
|
|
471
472
|
val altClazz = Class.forName("com.flir.thermalsdk.image.palettes.PaletteManager")
|
|
472
473
|
val method = altClazz.getMethod("getDefaultPalettes")
|
|
473
|
-
sdkPalettes = method.invoke(null) as? List
|
|
474
|
+
sdkPalettes = method.invoke(null) as? List<*>
|
|
474
475
|
} catch (t2: Throwable) {
|
|
475
476
|
Log.w(TAG, "Palette discovery failed in updateAcol", t2)
|
|
476
477
|
}
|
|
477
478
|
}
|
|
478
479
|
|
|
479
|
-
|
|
480
|
-
|
|
480
|
+
val currentPalettes = sdkPalettes
|
|
481
|
+
if (currentPalettes != null && currentPalettes.isNotEmpty()) {
|
|
482
|
+
val paletteNames = currentPalettes.map { p ->
|
|
483
|
+
try {
|
|
484
|
+
p?.let { it::class.java.getMethod("getName").invoke(it) as? String } ?: p?.toString() ?: ""
|
|
485
|
+
} catch (e: Exception) {
|
|
486
|
+
p?.toString() ?: ""
|
|
487
|
+
}
|
|
488
|
+
}
|
|
481
489
|
Log.d(TAG, "True FLIR Palettes: $paletteNames")
|
|
482
490
|
|
|
483
|
-
val maxEff =
|
|
491
|
+
val maxEff = currentPalettes.size
|
|
484
492
|
val paletteIdx = rawIdx % maxEff
|
|
485
493
|
val safeIdx = if (paletteIdx < 0) paletteIdx + maxEff else paletteIdx
|
|
486
494
|
|
|
@@ -501,7 +509,7 @@ object FlirManager {
|
|
|
501
509
|
fun generatePaletteIcons(context: Context): List<Map<String, String>> {
|
|
502
510
|
val results = mutableListOf<Map<String, String>>()
|
|
503
511
|
try {
|
|
504
|
-
var rawPalettes: List
|
|
512
|
+
var rawPalettes: List<*>? = null
|
|
505
513
|
try {
|
|
506
514
|
rawPalettes = PaletteManager.getDefaultPalettes()
|
|
507
515
|
} catch (t: Throwable) {
|
|
@@ -509,22 +517,27 @@ object FlirManager {
|
|
|
509
517
|
try {
|
|
510
518
|
val altClazz = Class.forName("com.flir.thermalsdk.image.palettes.PaletteManager")
|
|
511
519
|
val method = altClazz.getMethod("getDefaultPalettes")
|
|
512
|
-
rawPalettes = method.invoke(null) as? List
|
|
520
|
+
rawPalettes = method.invoke(null) as? List<*>
|
|
513
521
|
} catch (t2: Throwable) {
|
|
514
522
|
Log.e(TAG, "Alternative package search also failed in icon generation", t2)
|
|
515
523
|
}
|
|
516
524
|
}
|
|
517
525
|
|
|
518
|
-
|
|
526
|
+
val currentPalettes = rawPalettes
|
|
527
|
+
if (currentPalettes == null) {
|
|
519
528
|
Log.e(TAG, "Failed to retrieve any palettes from SDK")
|
|
520
529
|
return emptyList()
|
|
521
530
|
}
|
|
522
531
|
|
|
523
|
-
val palettes =
|
|
532
|
+
val palettes = currentPalettes.toMutableList()
|
|
524
533
|
|
|
525
534
|
// Reorder: Move WhiteHot/Gray to the front
|
|
526
|
-
val grayIdx = palettes.indexOfFirst {
|
|
527
|
-
|
|
535
|
+
val grayIdx = palettes.indexOfFirst { p ->
|
|
536
|
+
val name = try {
|
|
537
|
+
p?.let { it::class.java.getMethod("getName").invoke(it) as? String } ?: p?.toString() ?: ""
|
|
538
|
+
} catch (e: Exception) { p?.toString() ?: "" }
|
|
539
|
+
|
|
540
|
+
name.equals("WhiteHot", ignoreCase = true) || name.equals("Gray", ignoreCase = true) || name.contains("gray", ignoreCase = true)
|
|
528
541
|
}
|
|
529
542
|
if (grayIdx > 0) {
|
|
530
543
|
val gray = palettes.removeAt(grayIdx)
|
|
@@ -535,17 +548,21 @@ object FlirManager {
|
|
|
535
548
|
if (!dir.exists()) dir.mkdirs()
|
|
536
549
|
|
|
537
550
|
for (palette in palettes) {
|
|
538
|
-
val
|
|
551
|
+
val name = try {
|
|
552
|
+
palette?.let { it::class.java.getMethod("getName").invoke(it) as? String } ?: palette?.toString() ?: "unknown"
|
|
553
|
+
} catch (e: Exception) { palette?.toString() ?: "unknown" }
|
|
554
|
+
|
|
555
|
+
val iconFile = File(dir, "${name.lowercase()}.png")
|
|
539
556
|
if (!iconFile.exists()) {
|
|
540
557
|
try {
|
|
541
558
|
// Common method names for palette preview in FLIR SDK: getBitmap(), getIcon()
|
|
542
559
|
val bitmap = try {
|
|
543
|
-
val m = palette.
|
|
544
|
-
m
|
|
560
|
+
val m = palette?.let { it::class.java.getMethod("getBitmap") }
|
|
561
|
+
m?.invoke(palette) as? Bitmap
|
|
545
562
|
} catch (e: Exception) {
|
|
546
563
|
try {
|
|
547
|
-
val m = palette.
|
|
548
|
-
m
|
|
564
|
+
val m = palette?.let { it::class.java.getMethod("getIcon") }
|
|
565
|
+
m?.invoke(palette) as? Bitmap
|
|
549
566
|
} catch (e2: Exception) { null }
|
|
550
567
|
}
|
|
551
568
|
|
|
@@ -555,11 +572,11 @@ object FlirManager {
|
|
|
555
572
|
}
|
|
556
573
|
}
|
|
557
574
|
} catch (e: Exception) {
|
|
558
|
-
Log.w(TAG, "Failed to save icon for $
|
|
575
|
+
Log.w(TAG, "Failed to save icon for $name: ${e.message}")
|
|
559
576
|
}
|
|
560
577
|
}
|
|
561
578
|
results.add(mapOf(
|
|
562
|
-
"name" to
|
|
579
|
+
"name" to name,
|
|
563
580
|
"uri" to if (iconFile.exists()) "file://${iconFile.absolutePath}" else ""
|
|
564
581
|
))
|
|
565
582
|
}
|
|
@@ -376,7 +376,7 @@ public class FlirSdkManager {
|
|
|
376
376
|
try {
|
|
377
377
|
Palette palette = null;
|
|
378
378
|
// 1. Try to get default palettes list safely
|
|
379
|
-
List
|
|
379
|
+
List<?> sdkPalettes = null;
|
|
380
380
|
try {
|
|
381
381
|
sdkPalettes = PaletteManager.getDefaultPalettes();
|
|
382
382
|
} catch (Throwable t) {
|
|
@@ -385,7 +385,7 @@ public class FlirSdkManager {
|
|
|
385
385
|
try {
|
|
386
386
|
Class<?> altClazz = Class.forName("com.flir.thermalsdk.image.palettes.PaletteManager");
|
|
387
387
|
java.lang.reflect.Method method = altClazz.getMethod("getDefaultPalettes");
|
|
388
|
-
sdkPalettes = (List
|
|
388
|
+
sdkPalettes = (List<?>) method.invoke(null);
|
|
389
389
|
Log.i(TAG, "Successfully retrieved palettes using alternative package");
|
|
390
390
|
} catch (Throwable t2) {
|
|
391
391
|
Log.e(TAG, "Alternative PaletteManager search also failed", t2);
|
|
@@ -393,9 +393,16 @@ public class FlirSdkManager {
|
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
if (sdkPalettes != null) {
|
|
396
|
-
for (
|
|
397
|
-
|
|
398
|
-
|
|
396
|
+
for (Object p : sdkPalettes) {
|
|
397
|
+
String pName = "";
|
|
398
|
+
try {
|
|
399
|
+
pName = (String) p.getClass().getMethod("getName").invoke(p);
|
|
400
|
+
} catch (Exception e) {
|
|
401
|
+
pName = p.toString();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (pName != null && pName.equalsIgnoreCase(paletteToApply)) {
|
|
405
|
+
palette = (Palette) p;
|
|
399
406
|
break;
|
|
400
407
|
}
|
|
401
408
|
}
|