@@ -301,14 +301,14 @@ public void onClick(DialogInterface dialogInterface, int i) {
301301 public static void buildConfigOptionDetailsSensor (final String key , Map <String , ConfigOptionDetailsSensor > configOptionsMap , final Context context , final ShimmerDevice shimmerDevice , final ShimmerDevice shimmerDeviceClone ) {
302302 final ConfigOptionDetailsSensor cods = configOptionsMap .get (key );
303303 final CharSequence [] cs = cods .getGuiValues ();
304- String title = "" ;
304+ String title = getConfigValueLabelFromConfigLabel ( key , shimmerDeviceClone ) ;
305305 if (cods .mGuiComponentType == ConfigOptionDetails .GUI_COMPONENT_TYPE .COMBOBOX ) {
306306 Object returnedValue = shimmerDevice .getConfigValueUsingConfigLabel (key );
307307
308308 if (returnedValue != null ) {
309- int configValue = (int ) returnedValue ;
310- int itemIndex = Arrays .asList (configOptionsMap .get (key ).getConfigValues ()).indexOf (configValue );
311- title = Arrays .asList (configOptionsMap .get (key ).getGuiValues ()).get (itemIndex );
309+ // int configValue = (int) returnedValue;
310+ // int itemIndex = Arrays.asList(configOptionsMap.get(key).getConfigValues()).indexOf(configValue);
311+ // title = Arrays.asList(configOptionsMap.get(key).getGuiValues()).get(itemIndex);
312312 AlertDialog .Builder builder = new AlertDialog .Builder (context );
313313 shimmerDevice .getConfigValueUsingConfigLabel (key );
314314 builder .setTitle (title );
@@ -387,14 +387,14 @@ public static void buildConfigOptionDetailsSensor(final String key, Map<String,
387387 final ShimmerBluetoothManagerAndroid bluetoothManager ) {
388388 final ConfigOptionDetailsSensor cods = configOptionsMap .get (key );
389389 final CharSequence [] cs = cods .getGuiValues ();
390- String title = "" ;
390+ String title = getConfigValueLabelFromConfigLabel ( key , shimmerDeviceClone ) ;
391391 if (cods .mGuiComponentType == ConfigOptionDetails .GUI_COMPONENT_TYPE .COMBOBOX ) {
392392 Object returnedValue = shimmerDevice .getConfigValueUsingConfigLabel (key );
393393
394394 if (returnedValue != null ) {
395- int configValue = (int ) returnedValue ;
396- int itemIndex = Arrays .asList (configOptionsMap .get (key ).getConfigValues ()).indexOf (configValue );
397- title = Arrays .asList (configOptionsMap .get (key ).getGuiValues ()).get (itemIndex );
395+ // int configValue = (int) returnedValue;
396+ // int itemIndex = Arrays.asList(configOptionsMap.get(key).getConfigValues()).indexOf(configValue);
397+ // title = Arrays.asList(configOptionsMap.get(key).getGuiValues()).get(itemIndex);
398398 AlertDialog .Builder builder = new AlertDialog .Builder (context );
399399 shimmerDevice .getConfigValueUsingConfigLabel (key );
400400 builder .setTitle (title );
@@ -464,14 +464,14 @@ public static void buildConfigOptionDetailsSensor(final String key, Map<String,
464464 final ShimmerDialogConfigurations shimmerDialogConfigurations ) {
465465 final ConfigOptionDetailsSensor cods = configOptionsMap .get (key );
466466 final CharSequence [] cs = cods .getGuiValues ();
467- String title = "" ;
467+ String title = getConfigValueLabelFromConfigLabel ( key , shimmerDeviceClone ) ;
468468 if (cods .mGuiComponentType == ConfigOptionDetails .GUI_COMPONENT_TYPE .COMBOBOX ) {
469469 Object returnedValue = shimmerDeviceClone .getConfigValueUsingConfigLabel (key );
470470
471471 if (returnedValue != null ) {
472- int configValue = (int ) returnedValue ;
473- int itemIndex = Arrays .asList (configOptionsMap .get (key ).getConfigValues ()).indexOf (configValue );
474- title = Arrays .asList (configOptionsMap .get (key ).getGuiValues ()).get (itemIndex );
472+ // int configValue = (int) returnedValue;
473+ // int itemIndex = Arrays.asList(configOptionsMap.get(key).getConfigValues()).indexOf(configValue);
474+ // title = Arrays.asList(configOptionsMap.get(key).getGuiValues()).get(itemIndex);
475475 AlertDialog .Builder builder = new AlertDialog .Builder (context );
476476 shimmerDeviceClone .getConfigValueUsingConfigLabel (key );
477477 builder .setTitle (title );
@@ -536,6 +536,30 @@ public void writeConfigToShimmer(ShimmerDevice clone, ShimmerBluetoothManagerAnd
536536
537537 }
538538
539+ private static String getConfigValueLabelFromConfigLabel (String label , ShimmerDevice cloneDevice ){
540+ ConfigOptionDetailsSensor cods = cloneDevice .getConfigOptionsMap ().get (label );
541+ int currentConfigInt = (int ) cloneDevice .getConfigValueUsingConfigLabel (label );
542+ int index = -1 ;
543+ Integer [] values = cods .getConfigValues ();
544+ String [] valueLabels = cods .getGuiValues ();
545+ for (int i =0 ;i <values .length ;i ++){
546+ if (currentConfigInt ==values [i ]){
547+ index =i ;
548+ }
549+ }
550+ if (index ==-1 ){
551+ System .out .println ();
552+ return "" ;
553+ }
554+ return valueLabels [index ];
555+ }
556+
557+ private static int getConfigValueIntFromConfigGuiIndex (int configGuiIndex , String currentConfigKey , ShimmerDevice cloneDevice ) {
558+ ConfigOptionDetailsSensor cods = cloneDevice .getConfigOptionsMap ().get (currentConfigKey );
559+ Integer [] values = cods .getConfigValues ();
560+ return values [configGuiIndex ];
561+ }
562+
539563 //Additional variables for custom signals and filtered signals for the SelectSensorPlot dialog
540564 static protected List <String []> mAdditionalSignalsList = null ;
541565 static protected List <String []> mFilteredSignalsList = null ;
0 commit comments