@@ -112,11 +112,41 @@ public class CompleteWidgetActivity extends Activity {
112
112
public double homeLocationLat , homeLocationLng ;
113
113
public float droneLocationAlt , gimbalPitch , gimbalRoll , gimbalYaw , gimbalYawRelativeToAircraftHeading ;
114
114
115
+ // this holds the geoobj names count
116
+ public Dictionary names = new Hashtable ();
117
+
115
118
@ Override
116
119
protected void onCreate (Bundle savedInstanceState ) {
117
120
super .onCreate (savedInstanceState );
118
121
setContentView (R .layout .activity_default_widgets );
119
122
123
+ names .put ("Alpha" ,0 );
124
+ names .put ("Bravo" ,0 );
125
+ names .put ("Charlie" ,0 );
126
+ names .put ("Delta" ,0 );
127
+ names .put ("Echo" ,0 );
128
+ names .put ("Foxtrot" ,0 );
129
+ names .put ("Golf" ,0 );
130
+ names .put ("Hotel" ,0 );
131
+ names .put ("India" ,0 );
132
+ names .put ("Juliett" ,0 );
133
+ names .put ("Kilo" ,0 );
134
+ names .put ("Lima" ,0 );
135
+ names .put ("Mike" ,0 );
136
+ names .put ("November" ,0 );
137
+ names .put ("Oscar" ,0 );
138
+ names .put ("Papa" ,0 );
139
+ names .put ("Quebec" ,0 );
140
+ names .put ("Romeo" ,0 );
141
+ names .put ("Sierra" ,0 );
142
+ names .put ("Tango" ,0 );
143
+ names .put ("Uniform" ,0 );
144
+ names .put ("Victor" ,0 );
145
+ names .put ("Whiskey" ,0 );
146
+ names .put ("X-ray" ,0 );
147
+ names .put ("Yankee" ,0 );
148
+ names .put ("Zulu" ,0 );
149
+
120
150
height = DensityUtil .dip2px (this , 100 );
121
151
width = DensityUtil .dip2px (this , 150 );
122
152
margin = DensityUtil .dip2px (this , 12 );
@@ -292,15 +322,15 @@ public boolean onTouch(View v, MotionEvent event) {
292
322
LayoutInflater layoutInflater = (LayoutInflater ) CompleteWidgetActivity .this .getSystemService (Context .LAYOUT_INFLATER_SERVICE );
293
323
View geoObjView = layoutInflater .inflate (R .layout .geo_obj_popup , null );
294
324
295
- final String [] attitudes = new String []{"friendly " , "hostile " , "neutral " , "unknown " };
325
+ final String [] attitudes = new String []{"unknown " , "friendly " , "hostile " , "neutral " };
296
326
final String [] pickedAttitude = new String [1 ];
297
327
pickedAttitude [0 ] = attitudes [0 ];
298
328
299
329
attitudesNP = geoObjView .findViewById (R .id .attitude );
300
330
attitudesNP .setDisplayedValues (null );
301
331
attitudesNP .setMinValue (0 );
302
332
attitudesNP .setMaxValue (attitudes .length - 1 );
303
- attitudesNP .setWrapSelectorWheel (false );
333
+ // attitudesNP.setWrapSelectorWheel(false);
304
334
attitudesNP .setDisplayedValues (attitudes );
305
335
306
336
attitudesNP .setOnValueChangedListener (new NumberPicker .OnValueChangeListener () {
@@ -311,24 +341,24 @@ public void onValueChange(NumberPicker picker, final int oldVal, final int newVa
311
341
}
312
342
});
313
343
314
- final String [] names = new String []{"Alpha" ,"Bravo" ,"Charlie" ,"Delta" ,"Echo" ,"Foxtrot" ,"Golf" ,"Hotel" ,"India" ,"Juliett" ,"Kilo" ,"Lima" ,"Mike" ,"November" ,"Oscar" ,"Papa" ,"Quebec" ,"Romeo" ,"Sierra" ,"Tango" ,"Uniform" ,"Victor" ,"Whiskey" ,"X-ray" ,"Yankee" ,"Zulu" };
315
- final int [] namesPicked = {0 };
344
+ final String [] geoObjNames = new String []{"Alpha" ,"Bravo" ,"Charlie" ,"Delta" ,"Echo" ,"Foxtrot" ,"Golf" ,"Hotel" ,"India" ,"Juliett" ,"Kilo" ,"Lima" ,"Mike" ,"November" ,"Oscar" ,"Papa" ,"Quebec" ,"Romeo" ,"Sierra" ,"Tango" ,"Uniform" ,"Victor" ,"Whiskey" ,"X-ray" ,"Yankee" ,"Zulu" };
316
345
final String [] pickedName = new String [1 ];
317
- pickedName [0 ] = names [0 ];
346
+ final int [] howMany = {(int ) names .get ("Alpha" )};
347
+ pickedName [0 ] = geoObjNames [0 ];
318
348
319
349
namesNP = geoObjView .findViewById (R .id .name );
320
350
namesNP .setDisplayedValues (null );
321
351
namesNP .setMinValue (0 );
322
- namesNP .setMaxValue (names .length - 1 );
323
- namesNP .setWrapSelectorWheel (false );
324
- namesNP .setDisplayedValues (names );
352
+ namesNP .setMaxValue (geoObjNames .length - 1 );
353
+ // namesNP.setWrapSelectorWheel(false);
354
+ namesNP .setDisplayedValues (geoObjNames );
325
355
326
356
namesNP .setOnValueChangedListener (new NumberPicker .OnValueChangeListener () {
327
357
@ Override
328
358
public void onValueChange (NumberPicker picker , final int oldVal , final int newVal ) {
329
- Log . d ( TAG , String . format ( "GeoObj Name: %s" , names [newVal ])) ;
330
- pickedName [0 ] = String . format ( "%s-%d" , names [ newVal ], namesPicked [0 ]);
331
- namesPicked [0 ]++ ;
359
+ pickedName [ 0 ] = geoObjNames [newVal ];
360
+ howMany [0 ] = ( int ) names . get ( pickedName [0 ]);
361
+ Log . d ( TAG , String . format ( "GeoObj Name: %s Count: %d" , pickedName [0 ], howMany [ 0 ])) ;
332
362
}
333
363
});
334
364
@@ -367,7 +397,11 @@ public void onClick(View v) {
367
397
368
398
double [] geoObjLatLng = moveLatLng (droneLocationLat , droneLocationLng , range , droneHeading );
369
399
Log .i (TAG , String .format ("Sending geoObject at lat: %f lng: %f" , geoObjLatLng [0 ], geoObjLatLng [1 ]));
370
- new SendCotTask (CompleteWidgetActivity .this ).execute ("geoObject" , FTS_IP , FTS_APIKEY , geoObjLatLng [0 ], geoObjLatLng [1 ], pickedAttitude [0 ], pickedName [0 ], droneHeading );
400
+
401
+ // update the count for this name
402
+ names .put (pickedName [0 ], howMany [0 ]+1 );
403
+
404
+ new SendCotTask (CompleteWidgetActivity .this ).execute ("geoObject" , FTS_IP , FTS_APIKEY , geoObjLatLng [0 ], geoObjLatLng [1 ], pickedAttitude [0 ], String .format ("%s-%d" , pickedName [0 ], howMany [0 ]), droneHeading );
371
405
popupWindow .dismiss ();
372
406
}
373
407
});
0 commit comments