Skip to content

Commit 9868e79

Browse files
committed
1.3 update the geoobject dropper to increment the counts correctly
1 parent e9bfef3 commit 9868e79

File tree

6 files changed

+60
-23
lines changed

6 files changed

+60
-23
lines changed

app/src/main/java/org/FreeTak/FreeTAKUAS/CompleteWidgetActivity.java

+46-12
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,41 @@ public class CompleteWidgetActivity extends Activity {
112112
public double homeLocationLat, homeLocationLng;
113113
public float droneLocationAlt, gimbalPitch, gimbalRoll, gimbalYaw, gimbalYawRelativeToAircraftHeading;
114114

115+
// this holds the geoobj names count
116+
public Dictionary names = new Hashtable();
117+
115118
@Override
116119
protected void onCreate(Bundle savedInstanceState) {
117120
super.onCreate(savedInstanceState);
118121
setContentView(R.layout.activity_default_widgets);
119122

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+
120150
height = DensityUtil.dip2px(this, 100);
121151
width = DensityUtil.dip2px(this, 150);
122152
margin = DensityUtil.dip2px(this, 12);
@@ -292,15 +322,15 @@ public boolean onTouch(View v, MotionEvent event) {
292322
LayoutInflater layoutInflater = (LayoutInflater) CompleteWidgetActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
293323
View geoObjView = layoutInflater.inflate(R.layout.geo_obj_popup, null);
294324

295-
final String[] attitudes = new String[]{"friendly", "hostile", "neutral", "unknown"};
325+
final String[] attitudes = new String[]{"unknown", "friendly", "hostile", "neutral"};
296326
final String[] pickedAttitude = new String[1];
297327
pickedAttitude[0] = attitudes[0];
298328

299329
attitudesNP = geoObjView.findViewById(R.id.attitude);
300330
attitudesNP.setDisplayedValues(null);
301331
attitudesNP.setMinValue(0);
302332
attitudesNP.setMaxValue(attitudes.length - 1);
303-
attitudesNP.setWrapSelectorWheel(false);
333+
//attitudesNP.setWrapSelectorWheel(false);
304334
attitudesNP.setDisplayedValues(attitudes);
305335

306336
attitudesNP.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@@ -311,24 +341,24 @@ public void onValueChange(NumberPicker picker, final int oldVal, final int newVa
311341
}
312342
});
313343

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"};
316345
final String[] pickedName = new String[1];
317-
pickedName[0] = names[0];
346+
final int[] howMany = {(int) names.get("Alpha")};
347+
pickedName[0] = geoObjNames[0];
318348

319349
namesNP = geoObjView.findViewById(R.id.name);
320350
namesNP.setDisplayedValues(null);
321351
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);
325355

326356
namesNP.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
327357
@Override
328358
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]));
332362
}
333363
});
334364

@@ -367,7 +397,11 @@ public void onClick(View v) {
367397

368398
double[] geoObjLatLng = moveLatLng(droneLocationLat, droneLocationLng, range, droneHeading);
369399
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);
371405
popupWindow.dismiss();
372406
}
373407
});

app/src/main/java/org/FreeTak/FreeTAKUAS/MainActivity.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ protected void onCreate(Bundle savedInstanceState) {
177177
TextView versionText = (TextView) findViewById(R.id.app_version);
178178
versionText.setText(R.string.app_version);
179179
FtsIpEditText = (EditText) findViewById(R.id.edittext_fts_ip);
180-
FtsIpEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_FTS_IP, "172.30.254.237:19023"));
180+
//FtsIpEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_FTS_IP, "172.30.254.237:19023"));
181+
FtsIpEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_FTS_IP, ""));
181182
FtsIpEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
182183
@Override
183184
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
@@ -218,7 +219,8 @@ public void afterTextChanged(Editable s) {
218219
}
219220
});
220221
FtsApiEditText = (EditText) findViewById(R.id.edittext_fts_apikey);
221-
FtsApiEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_FTS_API, "apikey123"));
222+
//FtsApiEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_FTS_API, "apikey123"));
223+
FtsApiEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_FTS_API, ""));
222224
FtsApiEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
223225
@Override
224226
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
@@ -259,7 +261,8 @@ public void afterTextChanged(Editable s) {
259261
}
260262
});
261263
RtmpIpEditText = (EditText) findViewById(R.id.edittext_rtmp_ip);
262-
RtmpIpEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_RTMP_IP, "172.30.254.237:1935"));
264+
//RtmpIpEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_RTMP_IP, "172.30.254.237:1935"));
265+
RtmpIpEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_RTMP_IP, ""));
263266
RtmpIpEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
264267
@Override
265268
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
@@ -300,7 +303,8 @@ public void afterTextChanged(Editable s) {
300303
}
301304
});
302305
DroneNameEditText = (EditText) findViewById(R.id.edittext_drone_name);
303-
DroneNameEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_DRONE_NAME, "djcombo"));
306+
//DroneNameEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_DRONE_NAME, "djcombo"));
307+
DroneNameEditText.setText(PreferenceManager.getDefaultSharedPreferences(this).getString(LAST_USED_DRONE_NAME, ""));
304308
DroneNameEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
305309
@Override
306310
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

app/src/main/java/org/FreeTak/FreeTAKUAS/SendCotTask.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected String doInBackground(Object... data) {
8282
range = Math.abs(range);
8383
jsonObject.put("Range", String.valueOf(range));
8484

85-
double fov = Math.abs(2 * (tan(Math.toRadians(gimbalPitch)/2) * range));
85+
double fov = Math.abs(5.25 * (tan(Math.toRadians(gimbalPitch)/2) * range));
8686
jsonObject.put("FieldOfView", String.valueOf(fov));
8787

8888
if (parent.getDroneSPI() == null) {

app/src/main/res/layout/activity_main.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
android:layout_column="0"
5757
android:layout_margin="10dp"
5858
android:background="@color/gray"
59-
android:digits="0123456789.:\n"
59+
android:digits="0123456789.:"
6060
android:gravity="center"
6161
android:hint="@string/fts_ip"
6262
android:imeOptions="actionDone"
@@ -74,7 +74,7 @@
7474
android:layout_column="0"
7575
android:layout_margin="10dp"
7676
android:background="@color/gray"
77-
android:digits="0123456789.:\n"
77+
android:digits="0123456789.:"
7878
android:gravity="center"
7979
android:hint="@string/rtmp_ip"
8080
android:imeOptions="actionDone"

app/src/main/res/layout/geo_obj_popup.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
android:layout_width="wrap_content"
99
android:layout_height="wrap_content"
1010
android:text="Send GeoObject CoT"
11-
android:textSize="30dp"
1211
android:layout_marginBottom="10dp"
1312
android:textColor="@color/red"/>
1413

@@ -28,7 +27,7 @@
2827

2928
<NumberPicker
3029
android:id="@+id/attitude"
31-
android:layout_width="130dp"
30+
android:layout_width="135dp"
3231
android:layout_height="wrap_content"
3332
android:layout_below="@id/attitude_text"
3433
/>
@@ -59,7 +58,7 @@
5958

6059
<NumberPicker
6160
android:id="@+id/name"
62-
android:layout_width="130dp"
61+
android:layout_width="135dp"
6362
android:layout_height="wrap_content"
6463
android:layout_below="@id/name_text"
6564
/>

app/src/main/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<resources>
22
<string name="app_name">FreeTAK UAS</string>
3-
<string name="app_version">FreeTAK UAS version 1.1</string>
3+
<string name="app_version">FreeTAK UAS version 1.3</string>
44
<string name="uas_button_disabled">UAS [NOT READY]</string>
55
<string name="uas_button_enabled">UAS [READY]</string>
66
<string name="select_all">Select All</string>

0 commit comments

Comments
 (0)