summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/Piztor/res/drawable/bottom_img.pngbin525331 -> 0 bytes
-rw-r--r--client/Piztor/res/drawable/data.jpgbin0 -> 686402 bytes
-rw-r--r--client/Piztor/res/drawable/piztor.pngbin0 -> 3245 bytes
-rw-r--r--client/Piztor/res/layout/activity_gather.xml8
-rw-r--r--client/Piztor/res/layout/activity_init.xml24
-rw-r--r--client/Piztor/res/layout/activity_login.xml141
-rw-r--r--client/Piztor/res/layout/activity_main.xml12
-rw-r--r--client/Piztor/res/layout/activity_settings.xml244
-rw-r--r--client/Piztor/res/layout/new_login.xml54
-rw-r--r--client/Piztor/src/com/macaroon/piztor/MultiTouchListener.java102
-rw-r--r--server/piztor/server.py68
11 files changed, 405 insertions, 248 deletions
diff --git a/client/Piztor/res/drawable/bottom_img.png b/client/Piztor/res/drawable/bottom_img.png
deleted file mode 100644
index 2725ea8..0000000
--- a/client/Piztor/res/drawable/bottom_img.png
+++ /dev/null
Binary files differ
diff --git a/client/Piztor/res/drawable/data.jpg b/client/Piztor/res/drawable/data.jpg
new file mode 100644
index 0000000..f549ec7
--- /dev/null
+++ b/client/Piztor/res/drawable/data.jpg
Binary files differ
diff --git a/client/Piztor/res/drawable/piztor.png b/client/Piztor/res/drawable/piztor.png
new file mode 100644
index 0000000..7b6698a
--- /dev/null
+++ b/client/Piztor/res/drawable/piztor.png
Binary files differ
diff --git a/client/Piztor/res/layout/activity_gather.xml b/client/Piztor/res/layout/activity_gather.xml
index f887cf0..9bc7ea4 100644
--- a/client/Piztor/res/layout/activity_gather.xml
+++ b/client/Piztor/res/layout/activity_gather.xml
@@ -20,4 +20,12 @@
>
<include layout="@layout/gather_footbar"></include>
</LinearLayout>
+ <ImageView
+ android:id="@+id/activity_mapview"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_below="@+id/gather_timer_layout"
+ android:layout_above="@+id/gather_footbar_layout"
+ android:scaleType="matrix"
+ android:src="@drawable/data"/>
</RelativeLayout>
diff --git a/client/Piztor/res/layout/activity_init.xml b/client/Piztor/res/layout/activity_init.xml
index 43e6253..aa9cf66 100644
--- a/client/Piztor/res/layout/activity_init.xml
+++ b/client/Piztor/res/layout/activity_init.xml
@@ -1,16 +1,16 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
+<?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:paddingBottom="@dimen/activity_vertical_margin"
- android:paddingLeft="@dimen/activity_horizontal_margin"
- android:paddingRight="@dimen/activity_horizontal_margin"
- android:paddingTop="@dimen/activity_vertical_margin"
- tools:context=".InitAct" >
+ android:orientation="vertical"
+ android:id="@+id/init_layout"
+ android:background="@android:color/black">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/hello_world" />
+ <ImageView
+ android:id="@+id/init_img"
+ android:layout_width="180dip"
+ android:layout_height="400dip"
+ android:src="@drawable/title_logo"
+ android:layout_gravity="center" />
-</RelativeLayout>
+</LinearLayout>
diff --git a/client/Piztor/res/layout/activity_login.xml b/client/Piztor/res/layout/activity_login.xml
index cd2d34c..b1f2f5b 100644
--- a/client/Piztor/res/layout/activity_login.xml
+++ b/client/Piztor/res/layout/activity_login.xml
@@ -1,11 +1,13 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="fill_parent"
- android:background="@android:color/black"
- android:orientation="vertical">
-
-<LinearLayout
+<RelativeLayout
+ android:orientation="vertical"
+ android:id="@+id/login_layout"
+ android:background="@android:color/black"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/black"
@@ -18,75 +20,62 @@
android:layout_height="240dp"
android:layout_gravity="center_horizontal"
android:src="@drawable/title_logo" />
+ </LinearLayout>
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
+ <LinearLayout
android:orientation="vertical"
- android:layout_gravity="center">
-
- <TableLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <TableRow
- android:layout_marginBottom="15dp"
- android:layout_marginTop="15dp">
- <TextView
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="0.25"
- android:gravity="right"
- android:id="@+id/user_id_text"
- android:text="User ID"
- android:textColor="@android:color/white"
- />
-
- <EditText
- android:layout_width="0dp"
- android:layout_weight="0.75"
- android:id="@+id/user_id"
- android:textColor="@android:color/black"
- android:singleLine="true"/>
- <requestFocus/>
- </TableRow>
-
- <TableRow>
- <TextView
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="0.25"
- android:gravity="right"
- android:id="@+id/user_pass_text"
- android:text="Password"
- android:textColor="@android:color/black"
- />
-
- <EditText
- android:layout_width="0dp"
- android:layout_weight="0.75"
- android:id="@+id/user_pass"
- android:password="true"
- android:textColor="@android:color/black"
- android:singleLine="true"/>
- </TableRow>
- </TableLayout>
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:orientation="vertical"
- >
- <Button
- android:id="@+id/login_btn_login"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:text="Login"
- android:textColor="@android:color/white" />
+ android:id="@+id/user_layout"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="220.0dip"
+ android:layout_marginLeft="28.0dip"
+ android:layout_marginRight="28.0dip">
+ <EditText
+ android:textSize="16.0sp"
+ android:textColor="@android:color/white"
+ android:textColorHint="#ff666666"
+ android:id="@+id/user_id"
+ android:background="#00ffffff"
+ android:paddingLeft="12.0dip"
+ android:layout_width="fill_parent"
+ android:layout_height="44.0dip"
+ android:hint="account" android:maxLines="1"
+ android:maxLength="16"/>
+ <View
+ android:background="#ffc0c3c4"
+ android:layout_width="fill_parent"
+ android:layout_height="1.0px"
+ android:layout_marginLeft="1.0px"
+ android:layout_marginRight="1.0px" />
+ <EditText
+ android:textSize="16.0sp"
+ android:textColor="@android:color/white"
+ android:textColorHint="#ff666666"
+ android:gravity="center_vertical"
+ android:id="@+id/user_pass"
+ android:background="#00ffffff"
+ android:paddingLeft="12.0dip"
+ android:layout_width="fill_parent"
+ android:layout_height="44.0dip"
+ android:hint="password"
+ android:maxLines="1"
+ android:maxLength="16"
+ android:inputType="textPassword" />
</LinearLayout>
+
-</LinearLayout>
-</RelativeLayout>
+ <Button
+ android:textSize="18.0sp"
+ android:textColor="#ff333333"
+ android:gravity="center"
+ android:id="@+id/login_btn_login"
+ android:paddingTop="5.0dip"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="28.0dip"
+ android:layout_marginTop="12.0dip"
+ android:layout_marginRight="28.0dip"
+ android:text="login"
+ android:layout_below="@id/user_layout" />
+
+</RelativeLayout> \ No newline at end of file
diff --git a/client/Piztor/res/layout/activity_main.xml b/client/Piztor/res/layout/activity_main.xml
index b2b61ac..a36f8b5 100644
--- a/client/Piztor/res/layout/activity_main.xml
+++ b/client/Piztor/res/layout/activity_main.xml
@@ -12,6 +12,7 @@
>
<include layout="@layout/main_headbar"/>
</RelativeLayout>
+
<LinearLayout
android:id="@+id/main_footbar_layout"
android:layout_width="wrap_content"
@@ -20,4 +21,13 @@
>
<include layout="@layout/main_footbar"/>
</LinearLayout>
-</RelativeLayout>
+
+ <ImageView
+ android:id="@+id/main_mapview"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_below="@+id/main_headbar_layout"
+ android:layout_above="@+id/main_footbar_layout"
+ android:scaleType="matrix"
+ android:src="@drawable/data"/>
+</RelativeLayout> \ No newline at end of file
diff --git a/client/Piztor/res/layout/activity_settings.xml b/client/Piztor/res/layout/activity_settings.xml
index 8ce051f..05c849b 100644
--- a/client/Piztor/res/layout/activity_settings.xml
+++ b/client/Piztor/res/layout/activity_settings.xml
@@ -2,7 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:background="@drawable/topbar_background"
+ android:background="@android:color/black"
android:orientation="horizontal" >
<RelativeLayout
@@ -15,33 +15,34 @@
</RelativeLayout>
<LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="match_parent"
- android:layout_marginTop="48dip"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/settings_GPSrefreshrate_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="GPS refresh rate"
- android:layout_gravity="center"
- android:layout_marginTop="10dip"
- android:textSize="20dip"
- android:textColor="@android:color/white" />
-
- <SeekBar
- android:id="@+id/settings_GPSrefreshrate"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
-
- <!-- LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="48dip"
+ android:orientation="vertical" >
+
+ <TextView
+ android:id="@+id/settings_GPSrefreshrate_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:layout_marginTop="10dip"
+ android:text="GPS refresh rate"
+ android:textColor="@android:color/white"
+ android:textSize="20dip" />
+
+ <SeekBar
+ android:id="@+id/settings_GPSrefreshrate"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <!--
+ LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
- -->
- <!-- TextView
+ -->
+ <!--
+ TextView
android:id="@+id/GPS_min_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -49,101 +50,116 @@
android:layout_marginLeft="10dip"
android:text="1s"
android:textSize="10dip"
- android:textColor="@android:color/white"/-->
+ android:textColor="@android:color/white"/
+ -->
- <!--TextView
+
+ <!--
+ TextView
android:id="@+id/GPS_max_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="30s"
android:textColor="@android:color/white"
- android:textSize="10dip" /-->
-
- <!-- /LinearLayout --> <!-- end of gps text -->
-
- <ImageView
- android:id="@+id/settings_seperator1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/horizontal_line" />
+ android:textSize="10dip" /
+ -->
+
+
+ <!-- /LinearLayout -->
+ <!-- end of gps text -->
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1.0px"
+ android:layout_marginLeft="1.0px"
+ android:layout_marginRight="1.0px"
+ android:background="#ffc0c3c4" />
+
+ <LinearLayout
+ android:id="@+id/settings_sex_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dip" >
+
+ <TextView
+ android:id="@+id/settings_sex_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dip"
+ android:text="@string/show_sex"
+ android:textColor="@android:color/white"
+ android:textSize="20dip" />
+
+ <CheckBox
+ android:id="@+id/settings_show_male"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/male"
+ android:textColor="@android:color/white" />
+
+ <CheckBox
+ android:id="@+id/settings_show_female"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/female"
+ android:textColor="@android:color/white" />
+ </LinearLayout>
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1.0px"
+ android:layout_marginLeft="1.0px"
+ android:layout_marginRight="1.0px"
+ android:background="#ffc0c3c4" />
+
+ <LinearLayout
+ android:id="@+id/settings_team_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="10dip" >
+
+ <TextView
+ android:id="@+id/settings_team_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="10dip"
+ android:text="@string/show_team"
+ android:textColor="@android:color/white"
+ android:textSize="20dip" />
+
+ <RadioButton
+ android:id="@+id/settings_team_mine"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/mine"
+ android:textColor="@android:color/white"
+ android:textSize="20dip" />
+
+ <RadioButton
+ android:id="@+id/settings_team_all"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/all"
+ android:textColor="@android:color/white"
+ android:textSize="20dip" />
+ </LinearLayout>
+
+ <View
+ android:layout_width="fill_parent"
+ android:layout_height="1.0px"
+ android:layout_marginLeft="1.0px"
+ android:layout_marginRight="1.0px"
+ android:background="#ffc0c3c4" />
+
+ <Button
+ android:id="@+id/button1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.00"
+ android:layout_marginTop="100dip"
+ android:text="Logout" />
+
+ </LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/settings_sex_layout"
- android:layout_marginTop="10dip">
-
- <TextView
- android:id="@+id/settings_sex_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10dip"
- android:textSize="20dip"
- android:textColor="@android:color/white"
- android:text="@string/show_sex" />
-
- <CheckBox
- android:id="@+id/settings_show_male"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/male"
- android:textColor="@android:color/white"/>
-
-
- <CheckBox
- android:id="@+id/settings_show_female"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/female"
- android:textColor="@android:color/white"/>
-
- </LinearLayout>
-
- <ImageView
- android:id="@+id/settings_seperator2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/horizontal_line" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/settings_team_layout"
- android:layout_marginTop="10dip">
-
- <TextView
- android:id="@+id/settings_team_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10dip"
- android:textSize="20dip"
- android:textColor="@android:color/white"
- android:text="@string/show_team" />
-
- <RadioButton
- android:id="@+id/settings_team_mine"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/mine"
- android:textSize="20dip"
- android:textColor="@android:color/white"/>
-
- <RadioButton
- android:id="@+id/settings_team_all"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/all"
- android:textSize="20dip"
- android:textColor="@android:color/white"/>
-
- </LinearLayout>
-
- <ImageView
- android:id="@+id/settings_seperator3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/horizontal_line" />
-
- </LinearLayout>
</RelativeLayout>
diff --git a/client/Piztor/res/layout/new_login.xml b/client/Piztor/res/layout/new_login.xml
new file mode 100644
index 0000000..36d3eec
--- /dev/null
+++ b/client/Piztor/res/layout/new_login.xml
@@ -0,0 +1,54 @@
+<RelativeLayout
+ android:orientation="vertical"
+ android:id="@+id/login_layout"
+ android:background="@android:color/black"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@android:color/black"
+ android:gravity="center_horizontal"
+ android:orientation="vertical" >
+
+ <ImageView
+ android:id="@+id/main_headbar_img"
+ android:layout_width="180dp"
+ android:layout_height="240dp"
+ android:layout_gravity="center_horizontal"
+ android:src="@drawable/title_logo" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:id="@+id/user_layout"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="220.0dip"
+ android:layout_marginLeft="28.0dip"
+ android:layout_marginRight="28.0dip">
+ <EditText android:textSize="16.0sp" android:textColor="#ff1d1d1d" android:textColorHint="#ff666666" android:id="@+id/user_id" android:background="#00ffffff" android:paddingLeft="12.0dip" android:layout_width="fill_parent" android:layout_height="44.0dip" android:hint="account" android:maxLines="1" android:maxLength="16" android:inputType="number"/>
+ <View android:background="#ffc0c3c4" android:layout_width="fill_parent" android:layout_height="1.0px" android:layout_marginLeft="1.0px" android:layout_marginRight="1.0px" />
+ <EditText android:textSize="16.0sp" android:textColor="#ff1d1d1d" android:textColorHint="#ff666666" android:gravity="center_vertical" android:id="@+id/user_pass" android:background="#00ffffff" android:paddingLeft="12.0dip" android:layout_width="fill_parent" android:layout_height="44.0dip" android:hint="password" android:maxLines="1" android:maxLength="16" android:inputType="textPassword" />
+ </LinearLayout>
+
+
+ <Button
+ android:textSize="18.0sp"
+ android:textColor="#ff333333"
+ android:gravity="center"
+ android:id="@+id/login_btn_login"
+ android:background="@android:color/white"
+ android:paddingTop="5.0dip"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="28.0dip"
+ android:layout_marginTop="12.0dip"
+ android:layout_marginRight="28.0dip"
+ android:text="login"
+ android:layout_below="@id/user_layout" />
+
+</RelativeLayout> \ No newline at end of file
diff --git a/client/Piztor/src/com/macaroon/piztor/MultiTouchListener.java b/client/Piztor/src/com/macaroon/piztor/MultiTouchListener.java
new file mode 100644
index 0000000..2bd379d
--- /dev/null
+++ b/client/Piztor/src/com/macaroon/piztor/MultiTouchListener.java
@@ -0,0 +1,102 @@
+package com.macaroon.piztor;
+
+import android.app.Activity;
+import android.graphics.Matrix;
+import android.graphics.PointF;
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.util.FloatMath;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnTouchListener;
+import android.view.GestureDetector;
+import android.view.GestureDetector.SimpleOnGestureListener;
+import android.widget.ImageView;
+
+public class MultiTouchListener implements OnTouchListener {
+
+ private Matrix matrix = new Matrix();
+ private Matrix preMatrix = new Matrix();
+
+ private static final int NONE = 0;
+ private static final int DRAG = 1;
+ private static final int ZOOM = 2;
+ private int mode = NONE;
+
+ private PointF start = new PointF();
+ private PointF mid = new PointF();
+ private float preDis = 1f;
+ private float d = 0f;
+ private float newRot = 0f;
+ private float[] values;
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ float[] values = new float[9];
+ matrix.getValues(values);
+ //System.out.println("1111111"+values[1]);
+ //Log.d("Touch", "onTouch.......");
+ ImageView view = (ImageView) v;
+ switch (event.getAction() & MotionEvent.ACTION_MASK) {
+ case MotionEvent.ACTION_DOWN:
+ //Log.d("Touch", "ACTION_DOWN");
+ preMatrix.set(matrix);
+ start.set(event.getX(), event.getY());
+ mode = DRAG;
+ break;
+ case MotionEvent.ACTION_POINTER_DOWN:
+ //Log.d("Touch", "ACTION_POINTER_DOWN");
+ preDis = spacing(event);
+ if(preDis > 10f) {
+ preMatrix.set(matrix);
+ midPoint(mid, event);
+ mode = ZOOM;
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ //Log.d("Touch", "ACTION_UP");
+ case MotionEvent.ACTION_POINTER_UP:
+ //Log.d("Touch", "ACTION_POINTER_UP");
+ mode = NONE;
+ break;
+ case MotionEvent.ACTION_MOVE:
+ //Log.d("Touch", "ACTION_MOVE");
+ if(mode == DRAG) {
+ //Log.d("Touch", "Draging");
+ matrix.set(preMatrix);
+ float dx = event.getX() - start.x;
+ float dy = event.getY() - start.y;
+ matrix.postTranslate(dx, dy);
+ } else if (mode == ZOOM) {
+ //Log.d("Touch","Zooming");
+ float newDis = spacing(event);
+ if (newDis > 10f) {
+ matrix.set(preMatrix);
+ float scale = (newDis / preDis);
+ matrix.postScale(scale,scale,mid.x,mid.y);
+ //System.out.println("ssssssssssssssssss" + scale);
+ }
+ }
+ break;
+ }
+ matrix.getValues(values);
+ //System.out.println("222222"+values[1]);
+ view.setImageMatrix(matrix);
+ matrix.getValues(values);
+ //System.out.println("333333"+values[1]);
+ return true;
+ }
+
+ private float spacing(MotionEvent event) {
+ float x = event.getX(0) - event.getX(1);
+ float y = event.getY(0) - event.getY(1);
+ return FloatMath.sqrt(x * x + y * y);
+ }
+
+ private void midPoint(PointF point, MotionEvent event) {
+ float x = event.getX(0) + event.getY(1);
+ float y = event.getY(0) + event.getY(1);
+ point.set(x / 2, y / 2);
+ }
+}
diff --git a/server/piztor/server.py b/server/piztor/server.py
index 725fc5b..5d2382d 100644
--- a/server/piztor/server.py
+++ b/server/piztor/server.py
@@ -18,12 +18,6 @@ from model import *
def get_hex(data):
return "".join([hex(ord(c))[2:].zfill(2) for c in data])
-def print_datagram(data):
- print "=================================="
- print "Received datagram:"
- print get_hex(data)
- print "=================================="
-
db_path = "piztor.sqlite"
FORMAT = "%(asctime)-15s %(message)s"
logging.basicConfig(format = FORMAT)
@@ -93,13 +87,21 @@ class RequestHandler(object):
class UserAuthHandler(RequestHandler):
- _user_auth_response_size = \
+ _response_size = \
_SectionSize.LENGTH + \
_SectionSize.OPT_ID + \
_SectionSize.STATUS + \
_SectionSize.USER_ID + \
_SectionSize.USER_TOKEN
+ _failed_response = \
+ struct.pack("!LBBL32s", _response_size,
+ _OptCode.user_auth,
+ _StatusCode.failure,
+ 0,
+ bytes('\x00' * 32))
+
+
def handle(self, tr_data):
logger.info("Reading auth data...")
pos = -1
@@ -122,12 +124,7 @@ class UserAuthHandler(RequestHandler):
.filter(UserModel.username == username).one()
except NoResultFound:
logger.info("No such user: {0}".format(username))
- return struct.pack("!LBBL32s", UserAuthHandler \
- ._user_auth_response_size,
- _OptCode.user_auth,
- _StatusCode.failure,
- 0,
- bytes('\x00' * 32))
+ return UserAuthHandler._failed_response
except MultipleResultsFound:
raise DBCorruptedError()
@@ -137,33 +134,22 @@ class UserAuthHandler(RequestHandler):
raise DBCorruptedError()
if not uauth.check_password(password):
logger.info("Incorrect password: {0}".format(password))
- return struct.pack("!LBBL32s", UserAuthHandler \
- ._user_auth_response_size,
- _OptCode.user_auth,
- _StatusCode.failure,
- 0,
- bytes('\x00' * 32))
+ return UserAuthHandler._failed_response
else:
logger.info("Logged in sucessfully: {0}".format(username))
uauth.regen_token()
session.commit()
- print "new token generated: " + get_hex(uauth.token)
- return struct.pack("!LBBL32s", UserAuthHandler \
- ._user_auth_response_size,
- _OptCode.user_auth,
- _StatusCode.sucess,
- user.id,
- uauth.token)
+ logger.info("new token generated: " + get_hex(uauth.token))
+ return struct.pack("!LBBL32s", UserAuthHandler._response_size,
+ _OptCode.user_auth,
+ _StatusCode.sucess,
+ user.id,
+ uauth.token)
class LocationUpdateHandler(RequestHandler):
-# _location_update_size = \
-# _SectionSize.AUTH_HEAD + \
-# _SectionSize.LATITUDE + \
-# _SectionSize.LONGITUDE
-
- _location_update_response_size = \
+ _response_size = \
_SectionSize.LENGTH + \
_SectionSize.OPT_ID + \
_SectionSize.STATUS
@@ -189,8 +175,7 @@ class LocationUpdateHandler(RequestHandler):
# Authentication failure
if uauth is None:
logger.warning("Authentication failure")
- return struct.pack("!LBB", LocationUpdateHandler \
- ._location_update_response_size,
+ return struct.pack("!LBB", LocationUpdateHandler._response_size,
_OptCode.location_update,
_StatusCode.failure)
@@ -200,19 +185,14 @@ class LocationUpdateHandler(RequestHandler):
session.commit()
logger.info("Location is updated sucessfully")
- return struct.pack("!LBB", LocationUpdateHandler \
- ._location_update_response_size,
+ return struct.pack("!LBB", LocationUpdateHandler._response_size,
_OptCode.location_update,
_StatusCode.sucess)
class LocationRequestHandler(RequestHandler):
-# _location_request_size = \
-# _SectionSize.AUTH_HEAD + \
-# _SectionSize.GROUP_ID
-
@classmethod
- def _location_request_response_size(cls, item_num):
+ def _response_size(cls, item_num):
return _SectionSize.LENGTH + \
_SectionSize.OPT_ID + \
_SectionSize.STATUS + \
@@ -239,15 +219,14 @@ class LocationRequestHandler(RequestHandler):
# Auth failure
if uauth is None:
logger.warning("Authentication failure")
- return struct.pack("!LBB", LocationRequestHandler \
- ._location_request_response_size(0),
+ return struct.pack("!LBB", LocationRequestHandler._response_size(0),
_OptCode.location_request,
_StatusCode.failure)
ulist = session.query(UserModel).filter(UserModel.gid == gid).all()
reply = struct.pack(
"!LBB",
- LocationRequestHandler._location_request_response_size(len(ulist)),
+ LocationRequestHandler._response_size(len(ulist)),
_OptCode.location_request,
_StatusCode.sucess)
@@ -276,7 +255,6 @@ class UserInfoRequestHandler(RequestHandler):
_OptCode.user_info_request,
_StatusCode.failure)
-
_code_map = {0x00 : ('gid', pack_int),
0x01 : ('sex', pack_bool)}