mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-04-10 02:02:21 +02:00
Cleaner editor interface
This commit is contained in:
parent
1a4db33328
commit
caeaa0169f
@ -8,4 +8,4 @@
|
|||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=Google Inc.:Google APIs:11
|
target=Google Inc.:Google APIs:10
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<ListView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/object_list"></ListView>
|
<Spinner android:layout_alignParentTop="true" android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/object_list_filter"></Spinner>
|
||||||
|
<ListView android:id="@+id/object_list" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_below="@+id/spinner1" android:layout_alignLeft="@+id/spinner1" android:layout_alignRight="@+id/spinner1"></ListView>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<TextView android:layout_height="wrap_content" android:text="ObjectEditor: " android:id="@+id/object_edit_title" android:layout_alignParentTop="true" android:layout_width="wrap_content" android:layout_centerHorizontal="true" android:textStyle="bold"></TextView>
|
<org.openpilot.androidgcs.ObjectEditView android:layout_height="wrap_content" android:text="ObjectEditor: " android:id="@+id/object_edit_view" android:layout_alignParentTop="true" android:layout_width="wrap_content" android:layout_centerHorizontal="true" android:textStyle="bold"></org.openpilot.androidgcs.ObjectEditView>
|
||||||
<TextView android:text="" android:id="@+id/object_edit_name" android:layout_toRightOf="@+id/object_edit_title" android:layout_alignTop="@+id/textView1" android:layout_alignBottom="@+id/textView1" android:layout_height="wrap_content" android:layout_width="50dip"></TextView>
|
<Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentBottom="true" android:id="@+id/object_edit_send_button" android:text="@string/send_button"></Button>
|
||||||
<LinearLayout android:id="@+id/object_edit_fields" android:layout_height="match_parent" android:layout_width="match_parent" android:layout_alignParentBottom="true" android:orientation="vertical"></LinearLayout>
|
<Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/object_edit_save_button" android:text="@string/save_button" android:layout_toRightOf="@+id/object_edit_send_button" android:layout_alignTop="@+id/object_edit_send_button" android:layout_alignBottom="@+id/object_edit_send_button"></Button>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
6
androidgcs/res/layout/object_editor.xml
Normal file
6
androidgcs/res/layout/object_editor.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
</LinearLayout>
|
@ -21,4 +21,7 @@
|
|||||||
<string name="cardinal_south">S</string>
|
<string name="cardinal_south">S</string>
|
||||||
<string name="cardinal_west">W</string>
|
<string name="cardinal_west">W</string>
|
||||||
<string name="connected">Connected</string>
|
<string name="connected">Connected</string>
|
||||||
|
<string name="update_button">Update</string>
|
||||||
|
<string name="save_button">Save</string>
|
||||||
|
<string name="send_button">Send</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -74,7 +74,8 @@ public class OPTelemetryService extends Service {
|
|||||||
Toast.makeText(getApplicationContext(), "Attempting connection", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), "Attempting connection", Toast.LENGTH_SHORT).show();
|
||||||
terminate = false;
|
terminate = false;
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(OPTelemetryService.this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(OPTelemetryService.this);
|
||||||
int connection_type = Integer.decode(prefs.getString("connection_type", ""));
|
//int connection_type = Integer.decode(prefs.getString("connection_type", ""));
|
||||||
|
int connection_type = 1;
|
||||||
switch(connection_type) {
|
switch(connection_type) {
|
||||||
case 0: // No connection
|
case 0: // No connection
|
||||||
return;
|
return;
|
||||||
@ -128,7 +129,7 @@ public class OPTelemetryService extends Service {
|
|||||||
mServiceHandler = new ServiceHandler(mServiceLooper);
|
mServiceHandler = new ServiceHandler(mServiceLooper);
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(OPTelemetryService.this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(OPTelemetryService.this);
|
||||||
if(prefs.getBoolean("autoconnect", false)) {
|
if(prefs.getBoolean("autoconnect", false) || true) {
|
||||||
Toast.makeText(getApplicationContext(), "Should auto connect", Toast.LENGTH_SHORT);
|
Toast.makeText(getApplicationContext(), "Should auto connect", Toast.LENGTH_SHORT);
|
||||||
Message msg = mServiceHandler.obtainMessage();
|
Message msg = mServiceHandler.obtainMessage();
|
||||||
msg.arg1 = MSG_CONNECT;
|
msg.arg1 = MSG_CONNECT;
|
||||||
|
@ -17,6 +17,7 @@ import android.view.View;
|
|||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.Spinner;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
|
||||||
@ -46,6 +47,8 @@ public class ObjectBrowser extends ObjectManagerActivity implements OnSharedPref
|
|||||||
setContentView(R.layout.object_browser);
|
setContentView(R.layout.object_browser);
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
Spinner objectFilter = (Spinner) findViewById(R.id.object_list_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
114
androidgcs/src/org/openpilot/androidgcs/ObjectEditView.java
Normal file
114
androidgcs/src/org/openpilot/androidgcs/ObjectEditView.java
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
package org.openpilot.androidgcs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
|
import org.openpilot.uavtalk.UAVObjectField;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class ObjectEditView extends LinearLayout {
|
||||||
|
|
||||||
|
TextView objectName;
|
||||||
|
List<View> fields;
|
||||||
|
|
||||||
|
public ObjectEditView(Context context) {
|
||||||
|
super(context);
|
||||||
|
initObjectEditView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectEditView(Context context, AttributeSet ats, int defaultStyle) {
|
||||||
|
super(context, ats);
|
||||||
|
initObjectEditView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectEditView(Context context, AttributeSet ats) {
|
||||||
|
super(context, ats);
|
||||||
|
initObjectEditView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initObjectEditView() {
|
||||||
|
// Set orientation of layout to vertical
|
||||||
|
setOrientation(LinearLayout.VERTICAL);
|
||||||
|
|
||||||
|
objectName = new TextView(getContext());
|
||||||
|
objectName.setText("");
|
||||||
|
objectName.setTextSize(14);
|
||||||
|
|
||||||
|
// Lay them out in the compound control.
|
||||||
|
int lHeight = LayoutParams.WRAP_CONTENT;
|
||||||
|
int lWidth = LayoutParams.FILL_PARENT;
|
||||||
|
addView(objectName, new LinearLayout.LayoutParams(lWidth, lHeight));
|
||||||
|
|
||||||
|
fields = new ArrayList<View>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
objectName.setText(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addField(UAVObjectField field) {
|
||||||
|
if(field.getNumElements() == 1) {
|
||||||
|
FieldValue fieldView = new FieldValue(getContext());
|
||||||
|
fieldView.setName(field.getName());
|
||||||
|
if(field.isNumeric()) {
|
||||||
|
fieldView.setValue(new Double(field.getDouble()).toString());
|
||||||
|
} else {
|
||||||
|
fieldView.setValue(field.getValue().toString());
|
||||||
|
}
|
||||||
|
fields.add(fieldView);
|
||||||
|
addView(fieldView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ListIterator<String> names = field.getElementNames().listIterator();
|
||||||
|
int i = 0;
|
||||||
|
while(names.hasNext()) {
|
||||||
|
FieldValue fieldView = new FieldValue(getContext());
|
||||||
|
fieldView.setName(field.getName() + "-" + names.next());
|
||||||
|
if(field.isNumeric()) {
|
||||||
|
fieldView.setValue(new Double(field.getDouble(i)).toString());
|
||||||
|
} else {
|
||||||
|
fieldView.setValue(field.getValue(i).toString());
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
fields.add(fieldView);
|
||||||
|
addView(fieldView, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FieldValue extends LinearLayout {
|
||||||
|
|
||||||
|
TextView fieldName;
|
||||||
|
EditText fieldValue;
|
||||||
|
|
||||||
|
public FieldValue(Context context) {
|
||||||
|
super(context);
|
||||||
|
setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
|
||||||
|
fieldName = new TextView(getContext());
|
||||||
|
fieldValue = new EditText(getContext());
|
||||||
|
|
||||||
|
// Lay them out in the compound control.
|
||||||
|
addView(fieldName, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));
|
||||||
|
fieldValue.setWidth(300);
|
||||||
|
addView(fieldValue, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
fieldName.setText(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
fieldValue.setText(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -7,8 +7,6 @@ import org.openpilot.uavtalk.UAVObject;
|
|||||||
import org.openpilot.uavtalk.UAVObjectField;
|
import org.openpilot.uavtalk.UAVObjectField;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class ObjectEditor extends ObjectManagerActivity {
|
public class ObjectEditor extends ObjectManagerActivity {
|
||||||
@ -35,17 +33,13 @@ public class ObjectEditor extends ObjectManagerActivity {
|
|||||||
UAVObject obj = objMngr.getObject(objectID, instID);
|
UAVObject obj = objMngr.getObject(objectID, instID);
|
||||||
Toast.makeText(getApplicationContext(), obj.toString(), Toast.LENGTH_SHORT);
|
Toast.makeText(getApplicationContext(), obj.toString(), Toast.LENGTH_SHORT);
|
||||||
|
|
||||||
TextView objectName = (TextView) findViewById(R.id.object_edit_name);
|
ObjectEditView editView = (ObjectEditView) findViewById(R.id.object_edit_view);
|
||||||
objectName.setText(obj.getName());
|
editView.setName(obj.getName());
|
||||||
|
|
||||||
LinearLayout fieldViewList = (LinearLayout) findViewById(R.id.object_edit_fields);
|
|
||||||
List<UAVObjectField> fields = obj.getFields();
|
List<UAVObjectField> fields = obj.getFields();
|
||||||
ListIterator<UAVObjectField> li = fields.listIterator();
|
ListIterator<UAVObjectField> li = fields.listIterator();
|
||||||
while(li.hasNext()) {
|
while(li.hasNext()) {
|
||||||
UAVObjectField field = li.next();
|
editView.addField(li.next());
|
||||||
TextView fieldName = new TextView(this);
|
|
||||||
fieldName.setText(field.getName());
|
|
||||||
fieldViewList.addView(fieldName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user