]> rtime.felk.cvut.cz Git - orte.git/commitdiff
ROBOT_DEMO: minor changes to UI
authorMartin Vajnar <martin.vajnar@gmail.com>
Wed, 28 Aug 2013 18:16:59 +0000 (20:16 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Mon, 23 Sep 2013 09:06:28 +0000 (11:06 +0200)
orte/Robot_Demo/gen/org/ocera/orte/demo/R.java
orte/Robot_Demo/res/layout/about_dialog.xml
orte/Robot_Demo/res/layout/managers_view.xml
orte/Robot_Demo/res/layout/status_dialog.xml
orte/Robot_Demo/res/menu/activity_main.xml
orte/Robot_Demo/src/org/ocera/orte/demo/HokuyoView.java
orte/Robot_Demo/src/org/ocera/orte/demo/MainActivity.java

index cc2ab9503259409fa37c0ba2834d0a72cd79d719..81bf7ef4c36bbe1eb9189443d9168a2ea5b6218d 100644 (file)
@@ -16,32 +16,34 @@ public final class R {
         public static final int logo_flamingos=0x7f020002;
     }
     public static final class id {
-        public static final int about=0x7f070018;
-        public static final int crane=0x7f070015;
-        public static final int editText1=0x7f070008;
-        public static final int editText2=0x7f07000b;
-        public static final int editText3=0x7f07000e;
-        public static final int editText4=0x7f070011;
-        public static final int exit=0x7f070019;
-        public static final int hokuyo=0x7f070014;
+        public static final int about=0x7f07001a;
+        public static final int crane=0x7f070017;
+        public static final int editText1=0x7f07000a;
+        public static final int editText2=0x7f07000d;
+        public static final int editText3=0x7f070010;
+        public static final int editText4=0x7f070013;
+        public static final int exit=0x7f07001b;
+        public static final int hokuyo=0x7f070016;
         public static final int hokuyo_view=0x7f070004;
         public static final int hokuyo_view_bg=0x7f070003;
         public static final int imageView1=0x7f070001;
-        public static final int magnet=0x7f070016;
-        public static final int managers=0x7f070005;
-        public static final int ownIP=0x7f070006;
+        public static final int magnet=0x7f070018;
+        public static final int managers=0x7f070006;
+        public static final int ownIP=0x7f070007;
         public static final int scrollView1=0x7f070000;
-        public static final int speed=0x7f070012;
-        public static final int speed_mon=0x7f070013;
-        public static final int tableRow1=0x7f070007;
-        public static final int tableRow2=0x7f070009;
-        public static final int tableRow3=0x7f07000c;
-        public static final int tableRow4=0x7f07000f;
+        public static final int scrollView2=0x7f070005;
+        public static final int scrollView3=0x7f070008;
+        public static final int speed=0x7f070014;
+        public static final int speed_mon=0x7f070015;
+        public static final int tableRow1=0x7f070009;
+        public static final int tableRow2=0x7f07000b;
+        public static final int tableRow3=0x7f07000e;
+        public static final int tableRow4=0x7f070011;
         public static final int textView1=0x7f070002;
-        public static final int textView2=0x7f07000a;
-        public static final int textView3=0x7f07000d;
-        public static final int textView4=0x7f070010;
-        public static final int voltage=0x7f070017;
+        public static final int textView2=0x7f07000c;
+        public static final int textView3=0x7f07000f;
+        public static final int textView4=0x7f070012;
+        public static final int voltage=0x7f070019;
     }
     public static final class layout {
         public static final int about_dialog=0x7f030000;
index da2bca634919092d6287cde8eab336be6434da00..27d4f9e52052427561bed944f9d2bc090054bb47 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/scrollView1"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
     android:scrollbars="vertical" >
     
        <LinearLayout
index 8eab0a79901fea901e156eb090459810a615fae0..9bcf66f3875bf919b46679a734896fb862dbd5a4 100644 (file)
@@ -1,23 +1,33 @@
 <?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"
-    android:gravity="center"
-    android:orientation="vertical" >
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/scrollView2"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:layout_gravity="center_horizontal"
+    android:scrollbars="vertical" >
+    
+       <LinearLayout
+           android:layout_width="fill_parent"
+           android:layout_height="wrap_content"
+           android:layout_gravity="center_horizontal"
+           android:orientation="vertical" >
+       
+           <EditText
+               android:id="@+id/managers"
+               android:layout_width="fill_parent"
+               android:layout_height="fill_parent"
+               android:ems="10"
+               android:inputType="textMultiLine" >
+       
+               <requestFocus />
+           </EditText>
+       
+           <TextView
+               android:id="@+id/ownIP"
+               android:gravity="center_horizontal"
+               android:layout_width="fill_parent"
+               android:layout_height="fill_parent" />
+       
+       </LinearLayout>
 
-    <EditText
-        android:id="@+id/managers"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:ems="10"
-        android:inputType="textMultiLine" >
-
-        <requestFocus />
-    </EditText>
-
-    <TextView
-        android:id="@+id/ownIP"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content" />
-
-</LinearLayout>
+</ScrollView>
\ No newline at end of file
index e9454c69ab13dea68e7369269507094f10ffdfb1..bc2be6083f99be3e310f9113ff9ffa948d0a7dc6 100644 (file)
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/scrollView3"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:layout_gravity="center"
-    android:gravity="center"
-    android:orientation="vertical" >
-
-    <TableLayout
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center"
-        android:gravity="center" >
-
-        <TableRow
-            android:id="@+id/tableRow1"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent" >
-
-            <TextView
-                android:id="@+id/textView1"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:text="3.3V" />
-
-            <EditText
-                android:id="@+id/editText1"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:clickable="false"
-                android:focusable="false"
-                android:focusableInTouchMode="false"
-                android:minWidth="70dp" />
-
-        </TableRow>
-
-        <TableRow
-            android:id="@+id/tableRow2"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent" >
-
-            <TextView
-                android:id="@+id/textView2"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:text="5V" />
-
-            <EditText
-                android:id="@+id/editText2"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:clickable="false"
-                android:focusable="false"
-                android:focusableInTouchMode="false"
-                android:minWidth="70dp" />
-
-        </TableRow>
-
-        <TableRow
-            android:id="@+id/tableRow3"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent" >
-
-            <TextView
-                android:id="@+id/textView3"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:text="8V" />
-
-            <EditText
-                android:id="@+id/editText3"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:clickable="false"
-                android:focusable="false"
-                android:focusableInTouchMode="false"
-                android:minWidth="70dp" />
-
-        </TableRow>
-
-        <TableRow
-            android:id="@+id/tableRow4"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent" >
-
-            <TextView
-                android:id="@+id/textView4"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:text="BAT" />
-
-            <EditText
-                android:id="@+id/editText4"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:clickable="false"
-                android:focusable="false"
-                android:focusableInTouchMode="false"
-                android:minWidth="70dp" />
-
-        </TableRow>
-
-    </TableLayout>
-
-</LinearLayout>
+    android:scrollbars="vertical" >
+    
+       <LinearLayout
+           android:layout_width="wrap_content"
+           android:layout_height="wrap_content"
+           android:layout_gravity="center"
+           android:gravity="center"
+           android:orientation="vertical" >
+       
+           <TableLayout
+               android:layout_width="wrap_content"
+               android:layout_height="wrap_content"
+               android:layout_gravity="center"
+               android:gravity="center" >
+       
+               <TableRow
+                   android:id="@+id/tableRow1"
+                   android:layout_width="match_parent"
+                   android:layout_height="match_parent" >
+       
+                   <TextView
+                       android:id="@+id/textView1"
+                       android:layout_width="match_parent"
+                       android:layout_height="match_parent"
+                       android:text="3.3V" />
+       
+                   <EditText
+                       android:id="@+id/editText1"
+                       android:layout_width="match_parent"
+                       android:layout_height="match_parent"
+                       android:clickable="false"
+                       android:focusable="false"
+                       android:focusableInTouchMode="false"
+                       android:inputType="numberDecimal"
+                       android:minWidth="90sp" />
+       
+               </TableRow>
+       
+               <TableRow
+                   android:id="@+id/tableRow2"
+                   android:layout_width="match_parent"
+                   android:layout_height="match_parent" >
+       
+                   <TextView
+                       android:id="@+id/textView2"
+                       android:layout_width="match_parent"
+                       android:layout_height="match_parent"
+                       android:text="5V" />
+       
+                   <EditText
+                       android:id="@+id/editText2"
+                       android:layout_width="match_parent"
+                       android:layout_height="match_parent"
+                       android:clickable="false"
+                       android:focusable="false"
+                       android:focusableInTouchMode="false"
+                       android:inputType="numberDecimal"
+                       android:minWidth="90sp" />
+       
+               </TableRow>
+       
+               <TableRow
+                   android:id="@+id/tableRow3"
+                   android:layout_width="match_parent"
+                   android:layout_height="match_parent" >
+       
+                   <TextView
+                       android:id="@+id/textView3"
+                       android:layout_width="match_parent"
+                       android:layout_height="match_parent"
+                       android:text="8V" />
+       
+                   <EditText
+                       android:id="@+id/editText3"
+                       android:layout_width="match_parent"
+                       android:layout_height="match_parent"
+                       android:clickable="false"
+                       android:focusable="false"
+                       android:focusableInTouchMode="false"
+                                       android:inputType="numberDecimal"
+                       android:minWidth="90sp" />
+       
+               </TableRow>
+       
+               <TableRow
+                   android:id="@+id/tableRow4"
+                   android:layout_width="match_parent"
+                   android:layout_height="match_parent" >
+       
+                   <TextView
+                       android:id="@+id/textView4"
+                       android:layout_width="match_parent"
+                       android:layout_height="match_parent"
+                       android:text="BAT" />
+       
+                   <EditText
+                       android:id="@+id/editText4"
+                       android:layout_width="match_parent"
+                       android:layout_height="match_parent"
+                       android:clickable="false"
+                       android:focusable="false"
+                       android:focusableInTouchMode="false"
+                       android:inputType="numberDecimal"
+                       android:minWidth="90sp" />
+       
+               </TableRow>
+       
+           </TableLayout>
+       
+       </LinearLayout>
+
+</ScrollView>
\ No newline at end of file
index 793a6c00ed8c1bae48396ea3d911c347481e2880..db290e5b3a11591cdd086bae2d736f78f5a9a952 100644 (file)
     </item>
     
     <item android:id="@+id/crane"
-        android:title="Crane up"
+        android:title="Crane: up"
         android:orderInCategory="4"
         android:showAsAction="never">
     </item>
     
     <item android:id="@+id/magnet"
-        android:title="Magnet on"
+        android:title="Magnet"
         android:orderInCategory="5"
+        android:checkable="true"
         android:showAsAction="never">
     </item>
 
index d79eee0a0c393c70b21e8e2bf48087a0a89fa306..b786adb3cbff5dd2121bb285e86f56b8ce75fae7 100644 (file)
@@ -149,7 +149,7 @@ public class HokuyoView extends View {
                x = (temp[0]-y)/0.30;
 
                speedCo[1] = -y;
-               speedCo[0] = speedCo[1]>0 ? -x : x;
+               speedCo[0] = x;
        }
        
        public void run(boolean run) {
index 644e01afd5767bb59a34f8727036318bf2f8eb68..04bf53f4a6a7f55268aef8e2748cb253dae732ff 100644 (file)
@@ -7,6 +7,7 @@ import android.app.Activity;
 import android.app.AlertDialog;
 import android.content.Context;
 import android.content.DialogInterface;
+import android.content.DialogInterface.OnDismissListener;
 import android.content.SharedPreferences;
 import android.content.pm.ActivityInfo;
 import android.hardware.Sensor;
@@ -151,7 +152,6 @@ public class MainActivity extends Activity {
         }
     }
        
-       @SuppressWarnings("deprecation")
        @Override
     public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -172,19 +172,19 @@ public class MainActivity extends Activity {
                AlertDialog.Builder voltageBuilder = new AlertDialog.Builder(this);
                LayoutInflater inflater = getLayoutInflater();
                View voltageView = inflater.inflate(R.layout.status_dialog, null);
-               voltageBuilder.setCancelable(false);
                voltageBuilder.setView(voltageView);
-               voltageBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
+               voltageBuilder.setPositiveButton("OK",null);
+               voltageBuilder.setTitle("Voltages");
+               voltageDialog = voltageBuilder.create();
+               voltageDialog.setOnDismissListener(new OnDismissListener(){
                        @Override
-                       public void onClick(DialogInterface dialog, int which) {
+                       public void onDismiss(DialogInterface arg0) {
                                voltageDialog.dismiss();
                                pwr_voltage.cancel();
                                mWakeLock.release();
                                mWifiLock.release();
                        }
                });
-               voltageBuilder.setTitle("Voltages");
-               voltageDialog = voltageBuilder.create();
                voltage33 = (EditText)voltageView.findViewById(R.id.editText1);
                voltage50 = (EditText)voltageView.findViewById(R.id.editText2);
                voltage80 = (EditText)voltageView.findViewById(R.id.editText3);
@@ -202,14 +202,12 @@ public class MainActivity extends Activity {
                managersField = (EditText)managersView.findViewById(R.id.managers);
                managersField.setText(mgrs);
                
-               managersBuilder.setCancelable(false);
                managersBuilder.setView(managersView);
                managersBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                                SharedPreferences.Editor editor = prefs.edit();
                                mgrs = managersField.getText().toString();
-                               System.out.println(mgrs);
                                editor.putString("managers", mgrs);
                                editor.commit();
                                
@@ -217,12 +215,19 @@ public class MainActivity extends Activity {
                                        manager.destroy();
                                manager = new Manager(mgrs);
                                
-                               wifiInfoTask.cancel(false);
                                managersDialog.dismiss();
                        }
                });
+               managersBuilder.setNeutralButton("Cancel", null);
                managersBuilder.setTitle("Set fellow managers");
                managersDialog = managersBuilder.create();
+               managersDialog.setOnDismissListener(new OnDismissListener() {
+                       @Override
+                       public void onDismiss(DialogInterface arg0) {
+                               managersField.setText(mgrs);
+                               wifiInfoTask.cancel(false);
+                       }
+               });
                
         mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
         mGravity = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
@@ -311,21 +316,23 @@ public class MainActivity extends Activity {
                                mWifiLock.release();
                        }
                }
-               else if (item.getTitle().equals("Crane up")) {
-                       crane_cmd.send(0x100);
-                       item.setTitle("Crane down");
-               }
-               else if (item.getTitle().equals("Crane down")) {
+               else if (item.getTitle().equals("Crane: up")) {
                        crane_cmd.send(0x190);
-                       item.setTitle("Crane up");
+                       item.setTitle("Crane: down");
                }
-               else if (item.getTitle().equals("Magnet on")) {
-                       magnet_cmd.send(1);
-                       item.setTitle("Magnet off");                    
+               else if (item.getTitle().equals("Crane: down")) {
+                       crane_cmd.send(0x100);
+                       item.setTitle("Crane: up");
                }
-               else if (item.getTitle().equals("Magnet off")) {
-                       magnet_cmd.send(0);
-                       item.setTitle("Magnet on");                     
+               else if (item.getTitle().equals("Magnet")) {
+                       if (!item.isChecked()) {
+                               magnet_cmd.send(1);
+                               item.setChecked(true);
+                       }
+                       else {
+                               magnet_cmd.send(0);
+                               item.setChecked(false); 
+                       }
                }
                else if (item.getTitle().equals("Voltage monitor")) {
                        mWakeLock.acquire();