diff --git a/androidgcs/AndroidManifest.xml b/androidgcs/AndroidManifest.xml
index a791d0fbb..fe8c6ae9a 100644
--- a/androidgcs/AndroidManifest.xml
+++ b/androidgcs/AndroidManifest.xml
@@ -26,6 +26,7 @@
+
diff --git a/androidgcs/Doc/.AndroidArchitecture.txt.swp b/androidgcs/Doc/.AndroidArchitecture.txt.swp
deleted file mode 100644
index 167a07252..000000000
Binary files a/androidgcs/Doc/.AndroidArchitecture.txt.swp and /dev/null differ
diff --git a/androidgcs/res/layout/main.xml b/androidgcs/res/layout/object_browser.xml
similarity index 100%
rename from androidgcs/res/layout/main.xml
rename to androidgcs/res/layout/object_browser.xml
diff --git a/androidgcs/res/layout/object_edit.xml b/androidgcs/res/layout/object_edit.xml
new file mode 100644
index 000000000..62a482be9
--- /dev/null
+++ b/androidgcs/res/layout/object_edit.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/androidgcs/src/org/openpilot/androidgcs/ObjectBrowser.java b/androidgcs/src/org/openpilot/androidgcs/ObjectBrowser.java
index f3cc56d47..df2d114a4 100644
--- a/androidgcs/src/org/openpilot/androidgcs/ObjectBrowser.java
+++ b/androidgcs/src/org/openpilot/androidgcs/ObjectBrowser.java
@@ -9,25 +9,16 @@ import java.util.Observer;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.database.DataSetObserver;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Adapter;
+import android.widget.AdapterView;
import android.widget.ArrayAdapter;
-import android.widget.ExpandableListAdapter;
-import android.widget.ExpandableListView;
import android.widget.ListView;
-import android.widget.SimpleAdapter;
-import android.widget.SimpleExpandableListAdapter;
-import android.widget.TextView;
import android.widget.Toast;
+import android.widget.AdapterView.OnItemClickListener;
import org.openpilot.uavtalk.UAVDataObject;
import org.openpilot.uavtalk.UAVObject;
@@ -38,6 +29,7 @@ public class ObjectBrowser extends ObjectManagerActivity implements OnSharedPref
boolean connected;
SharedPreferences prefs;
ArrayAdapter adapter;
+ List allObjects;
final Handler uavobjHandler = new Handler();
final Runnable updateText = new Runnable() {
@@ -51,7 +43,7 @@ public class ObjectBrowser extends ObjectManagerActivity implements OnSharedPref
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
+ setContentView(R.layout.object_browser);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this);
}
@@ -60,18 +52,32 @@ public class ObjectBrowser extends ObjectManagerActivity implements OnSharedPref
void onOPConnected() {
Toast.makeText(this,"Telemetry estabilished",Toast.LENGTH_SHORT);
Log.d(TAG, "onOPConnected()");
-
+
List> allobjects = objMngr.getDataObjects();
- List linearized = new ArrayList();
+ allObjects = new ArrayList();
ListIterator> li = allobjects.listIterator();
while(li.hasNext()) {
- linearized.addAll(li.next());
+ allObjects.addAll(li.next());
}
-
- adapter = new ArrayAdapter(this,R.layout.object_view, linearized);
+
+ adapter = new ArrayAdapter(this,R.layout.object_view, allObjects);
ListView objects = (ListView) findViewById(R.id.object_list);
objects.setAdapter(adapter);
+ objects.setOnItemClickListener(new OnItemClickListener() {
+ public void onItemClick(AdapterView> parent, View view,
+ int position, long id) {
+ /*Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
+ Toast.LENGTH_SHORT).show();*/
+ Intent intent = new Intent(ObjectBrowser.this, ObjectEditor.class);
+ intent.putExtra("org.openpilot.androidgcs.ObjectName", allObjects.get(position).getName());
+ intent.putExtra("org.openpilot.androidgcs.ObjectId", allObjects.get(position).getObjID());
+ intent.putExtra("org.openpilot.androidgcs.InstId", allObjects.get(position).getInstID());
+ startActivity(intent);
+ }
+ });
+
+
UAVObject obj = objMngr.getObject("SystemStats");
if(obj != null)
obj.addUpdatedObserver(new Observer() {
@@ -81,7 +87,7 @@ public class ObjectBrowser extends ObjectManagerActivity implements OnSharedPref
});
}
-
+
public void update() {
adapter.notifyDataSetChanged();
}
@@ -89,6 +95,6 @@ public class ObjectBrowser extends ObjectManagerActivity implements OnSharedPref
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
// TODO Auto-generated method stub
-
+
}
}
diff --git a/androidgcs/src/org/openpilot/androidgcs/ObjectEditor.java b/androidgcs/src/org/openpilot/androidgcs/ObjectEditor.java
new file mode 100644
index 000000000..33d0e2f8e
--- /dev/null
+++ b/androidgcs/src/org/openpilot/androidgcs/ObjectEditor.java
@@ -0,0 +1,52 @@
+package org.openpilot.androidgcs;
+
+import java.util.List;
+import java.util.ListIterator;
+
+import org.openpilot.uavtalk.UAVObject;
+import org.openpilot.uavtalk.UAVObjectField;
+
+import android.os.Bundle;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class ObjectEditor extends ObjectManagerActivity {
+
+ String objectName;
+ int objectID;
+ int instID;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.object_edit);
+
+ System.out.println("Started. Intent:" + getIntent());
+ Bundle extras = getIntent().getExtras();
+ if(extras != null){
+ objectName = extras.getString("org.openpilot.androidgcs.ObjectName");
+ objectID = extras.getInt("org.openpilot.androidgcs.ObjectId");
+ instID = extras.getInt("org.openpilot.androidgcs.InstId");
+ }
+ }
+
+ public void onOPConnected() {
+ UAVObject obj = objMngr.getObject(objectID, instID);
+ Toast.makeText(getApplicationContext(), obj.toString(), Toast.LENGTH_SHORT);
+
+ TextView objectName = (TextView) findViewById(R.id.object_edit_name);
+ objectName.setText(obj.getName());
+
+ LinearLayout fieldViewList = (LinearLayout) findViewById(R.id.object_edit_fields);
+ List fields = obj.getFields();
+ ListIterator li = fields.listIterator();
+ while(li.hasNext()) {
+ UAVObjectField field = li.next();
+ TextView fieldName = new TextView(this);
+ fieldName.setText(field.getName());
+ fieldViewList.addView(fieldName);
+ }
+ }
+
+}
diff --git a/androidgcs/src/org/openpilot/androidgcs/ObjectManagerActivity.java b/androidgcs/src/org/openpilot/androidgcs/ObjectManagerActivity.java
index d91946b92..5027d4d24 100644
--- a/androidgcs/src/org/openpilot/androidgcs/ObjectManagerActivity.java
+++ b/androidgcs/src/org/openpilot/androidgcs/ObjectManagerActivity.java
@@ -21,7 +21,7 @@ import android.view.MenuItem;
public abstract class ObjectManagerActivity extends Activity {
private final String TAG = "ObjectManagerActivity";
- private static int LOGLEVEL = 2;
+ private static int LOGLEVEL = 0;
// private static boolean WARN = LOGLEVEL > 1;
private static boolean DEBUG = LOGLEVEL > 0;
@@ -106,19 +106,38 @@ public abstract class ObjectManagerActivity extends Activity {
Intent intent = new Intent(this, OPTelemetryService.class);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}
+
+ public void onBind() {
+
+ }
/** Defines callbacks for service binding, passed to bindService() */
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName arg0, IBinder service) {
// We've bound to LocalService, cast the IBinder and attempt to open a connection
if (DEBUG) Log.d(TAG,"Service bound");
- binder = (LocalBinder) service;
+ mBound = true;
+ binder = (LocalBinder) service;
+
+ if(binder.isConnected()) {
+ TelemTask task;
+ if((task = binder.getTelemTask(0)) != null) {
+ objMngr = task.getObjectManager();
+ mConnected = true;
+ onOPConnected();
+ }
+
+ }
}
public void onServiceDisconnected(ComponentName name) {
mBound = false;
+ binder = null;
mConnected = false;
objMngr = null;
+ objMngr = null;
+ mConnected = false;
+ onOPDisconnected();
}
};
}