summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorTeddy <[email protected]>2013-08-26 17:33:55 +0800
committerTeddy <[email protected]>2013-08-26 17:33:55 +0800
commitcf77f61bff7822b35020f2877ca4e6e683981be1 (patch)
treec7904cda1d81ef8a5dc8b196a7d8e9d360b58d40 /client
parenteb303ea6f1f6aa3e9a0cd4b00ef3fda6b06f0027 (diff)
parent92c5473740f45883c719002d4bc47236c669f51e (diff)
Merge branch 'master' of github.com:Determinant/piztor
Diffstat (limited to 'client')
-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/AppMgr.java21
-rw-r--r--client/Piztor/src/com/macaroon/piztor/InitAct.java1
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Login.java8
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Main.java15
-rw-r--r--client/Piztor/src/com/macaroon/piztor/MultiTouchListener.java102
-rw-r--r--client/Piztor/src/com/macaroon/piztor/ReqUserinfo.java11
-rw-r--r--client/Piztor/src/com/macaroon/piztor/ResUserinfo.java41
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Settings.java2
-rw-r--r--client/Piztor/src/com/macaroon/piztor/SocketClient.java30
-rw-r--r--client/Piztor/src/com/macaroon/piztor/Transam.java54
-rw-r--r--client/Piztor/src/com/macaroon/piztor/UserInfo.java3
20 files changed, 488 insertions, 283 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/AppMgr.java b/client/Piztor/src/com/macaroon/piztor/AppMgr.java
index 2e5e2b3..e86bf3e 100644
--- a/client/Piztor/src/com/macaroon/piztor/AppMgr.java
+++ b/client/Piztor/src/com/macaroon/piztor/AppMgr.java
@@ -9,22 +9,23 @@ import android.os.Handler;
@SuppressLint("UseSparseArrays")
public class AppMgr {
// Status
- public enum ActivityStatus{
+ public enum ActivityStatus {
create, start, resume, restart, stop, pause, destroy
- }
+ }
+
static ActivityStatus status;
static PiztorAct nowAct;
- //TODO fix
+ // TODO fix
static Handler fromTransam, fromGPS;
static Transam transam = null;
static Tracker tracker = null;
static Thread tTransam, tGPS;
- //Event
-
+ // Event
+
final static int noToken = 101;
final static int loginSuccess = 102;
-
-
+ final static int errorToken = 103;
+ final static int hasToken = 104;
static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
static void setStatus(ActivityStatus st) {
@@ -39,6 +40,8 @@ public class AppMgr {
else if (mp.get(nowAct.getClass()) == null)
System.out.println("second");
i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ if (event == errorToken)
+ UserInfo.token = null;
nowAct.startActivity(i);
}
@@ -84,6 +87,10 @@ public class AppMgr {
addStatus(Main.class);
addTransition(InitAct.class, noToken, Login.class);
addTransition(Login.class, loginSuccess, Main.class);
+ addTransition(Main.class, errorToken, Login.class);
+ addTransition(Settings.class, errorToken, Login.class);
+ addTransition(InitAct.class, hasToken, Main.class);
+ addTransition(InitAct.class, errorToken, Login.class);
}
}
diff --git a/client/Piztor/src/com/macaroon/piztor/InitAct.java b/client/Piztor/src/com/macaroon/piztor/InitAct.java
index bd4f5f4..7eba1e3 100644
--- a/client/Piztor/src/com/macaroon/piztor/InitAct.java
+++ b/client/Piztor/src/com/macaroon/piztor/InitAct.java
@@ -22,6 +22,7 @@ public class InitAct extends PiztorAct {
AppMgr.trigger(AppMgr.noToken);
else {
//TODO jump to main
+ AppMgr.trigger(AppMgr.hasToken);
}
}
diff --git a/client/Piztor/src/com/macaroon/piztor/Login.java b/client/Piztor/src/com/macaroon/piztor/Login.java
index d095d1c..4ddd603 100644
--- a/client/Piztor/src/com/macaroon/piztor/Login.java
+++ b/client/Piztor/src/com/macaroon/piztor/Login.java
@@ -20,13 +20,15 @@ public class Login extends PiztorAct {
Handler hand = new Handler() {
@Override
public void handleMessage(Message m) {
- System.out.println(m.what);
+ System.out.println("receive what : " + m.what);
if (m.what == 0) {
ResLogin res = (ResLogin) m.obj;
UserInfo.token = res.t;
+ UserInfo.id = res.uid;
UserInfo.username = edtUser.getText().toString();
+ System.out.println(res.s + " :!!! " + res.t);
actMgr.trigger(AppMgr.loginSuccess);
- } else if (m.what == 101) {
+ } else {
actMgr.trigger(loginFailed);
}
}
@@ -51,7 +53,7 @@ public class Login extends PiztorAct {
String pass = edtPass.getText().toString();
long nowtime = System.currentTimeMillis();
System.out.println(user + " : " + pass + "\n");
- AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 10000));
}
@Override
diff --git a/client/Piztor/src/com/macaroon/piztor/Main.java b/client/Piztor/src/com/macaroon/piztor/Main.java
index 17a8b1e..573c753 100644
--- a/client/Piztor/src/com/macaroon/piztor/Main.java
+++ b/client/Piztor/src/com/macaroon/piztor/Main.java
@@ -49,8 +49,10 @@ public class Main extends PiztorAct {
ResUpdate update = (ResUpdate) m.obj;
if (update.t == 0)
System.out.println("update success");
- else
+ else {
System.out.println("update failed");
+ actMgr.trigger(AppMgr.errorToken);
+ }
break;
case 2:
ResLocation location = (ResLocation) m.obj;
@@ -64,14 +66,17 @@ public class Main extends PiztorAct {
} else {
System.out
.println("resquest for location must be wrong!!!");
+ actMgr.trigger(AppMgr.errorToken);
}
break;
case 3:
ResUserinfo r = (ResUserinfo) m.obj;
if (r.s == 0) {
- System.out.println(r.id + " " + r.sex + " " + r.groupId);
+ System.out.println("id : " + r.uid + " sex : " + r.sex
+ + " group : " + r.gid);
} else {
System.out.println("reqest for userInfo must be wrong!!!");
+ actMgr.trigger(AppMgr.errorToken);
}
break;
default:
@@ -110,6 +115,12 @@ public class Main extends PiztorAct {
@Override
void enter(int e) {
System.out.println("enter start status!!!!");
+ if (e == ActMgr.Create) {
+ AppMgr.transam.send(new ReqUserinfo(UserInfo.token,
+ UserInfo.username, UserInfo.id, System
+ .currentTimeMillis(), 5000));
+ }
+
if (e == TimerFlush) {
ReqLocation r = new ReqLocation(UserInfo.token,
UserInfo.username, 1, System.currentTimeMillis(), 1000);
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/client/Piztor/src/com/macaroon/piztor/ReqUserinfo.java b/client/Piztor/src/com/macaroon/piztor/ReqUserinfo.java
index 9ae0cb5..77bcf84 100644
--- a/client/Piztor/src/com/macaroon/piztor/ReqUserinfo.java
+++ b/client/Piztor/src/com/macaroon/piztor/ReqUserinfo.java
@@ -4,11 +4,12 @@ package com.macaroon.piztor;
// Ask user info //
//--------------------------------------//
-public class ReqUserinfo extends Req {
- int uid; // user id
-
- ReqUserinfo(String token, String name, int id, long time, long alive) {
- super(3, token, name, time, alive); // for type 3
+public class ReqUserinfo extends Req{
+ int uid; //user id
+
+
+ ReqUserinfo(String token,String name,int id,long time,long alive){
+ super(3,token,name,time,alive); //for type 3
uid = id;
}
} \ No newline at end of file
diff --git a/client/Piztor/src/com/macaroon/piztor/ResUserinfo.java b/client/Piztor/src/com/macaroon/piztor/ResUserinfo.java
index abd5e62..ed981b4 100644
--- a/client/Piztor/src/com/macaroon/piztor/ResUserinfo.java
+++ b/client/Piztor/src/com/macaroon/piztor/ResUserinfo.java
@@ -1,21 +1,20 @@
-package com.macaroon.piztor;
-
-import java.util.Vector;
-
-//--------------------------------------//
-// Respond to User Info //
-//--------------------------------------//
-
-public class ResUserinfo extends Res{
- int sex; //1 for male, 0 for female
- int groupId;
- int id;
-
-
- Vector<RUserinfo> l; //user info
-
- ResUserinfo(int status,Vector<RUserinfo> userinfo){
- super(3,status); //for type 3
- l = userinfo;
- }
-}
+package com.macaroon.piztor;
+
+
+//--------------------------------------//
+// Respond to User Info //
+//--------------------------------------//
+
+public class ResUserinfo extends Res{
+ int uid; //userid
+ int gid; //groupid
+ int sex; //type 0 for female,type 1 for male
+
+
+ ResUserinfo(int status,int u,int g,int s){
+ super(3,status); //for type 3
+ uid = u;
+ gid = g;
+ sex =s;
+ }
+} \ No newline at end of file
diff --git a/client/Piztor/src/com/macaroon/piztor/Settings.java b/client/Piztor/src/com/macaroon/piztor/Settings.java
index 292a112..94c6a94 100644
--- a/client/Piztor/src/com/macaroon/piztor/Settings.java
+++ b/client/Piztor/src/com/macaroon/piztor/Settings.java
@@ -4,7 +4,7 @@ import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
-public class Settings extends Activity {
+public class Settings extends PiztorAct {
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/client/Piztor/src/com/macaroon/piztor/SocketClient.java b/client/Piztor/src/com/macaroon/piztor/SocketClient.java
index 3bc7ef3..812de05 100644
--- a/client/Piztor/src/com/macaroon/piztor/SocketClient.java
+++ b/client/Piztor/src/com/macaroon/piztor/SocketClient.java
@@ -5,9 +5,9 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
+import java.util.Locale;
import java.util.Vector;
-import android.annotation.SuppressLint;
import android.os.Handler;
import android.os.Message;
@@ -36,12 +36,13 @@ public class SocketClient {
ReqLogin rau = (ReqLogin) req;
String id = rau.user;
String pa = rau.pass;
- len = 4+1+id.length()+1+pa.length();
+ len = 4+1+id.length()+1+pa.length()+1;
out.writeInt(len);
out.writeByte(tmp);
out.writeBytes(id);
out.writeByte(0);
out.writeBytes(pa);
+ out.writeByte(0);
break;
case 1:
ReqUpdate rup = (ReqUpdate) req;
@@ -136,29 +137,25 @@ public class SocketClient {
break;
case 3:
int status3 = in.readUnsignedByte();
- Vector<RUserinfo> tmpu = new Vector<RUserinfo>();
+ outlen-=6;
+ ReqUserinfo rus = (ReqUserinfo) req;
+ int u = rus.uid;
+ int g = 0,s = 0;
while(outlen>0){
- RUserinfo r;
int typ = in.readUnsignedByte();
outlen-=1;
switch(typ){
case 0:
- int gid = in.readInt();
- in.readByte();
- r = new RKeyGroupID(gid);
- outlen-=5;
- tmpu.add(r);
+ g = in.readInt();
+ outlen-=4;
break;
case 1:
- boolean s = in.readBoolean();
- in.readByte();
- r = new RKeyGender(s);
- outlen-=2;
- tmpu.add(r);
+ s = in.readByte();
+ outlen-=1;
break;
}
}
- ResUserinfo resus = new ResUserinfo(status3,tmpu);
+ ResUserinfo resus = new ResUserinfo(status3,u,g,s);
msg.obj = resus;
msg.what = 3;
recall.sendMessage(msg);
@@ -179,12 +176,11 @@ public class SocketClient {
}
}
- @SuppressLint("DefaultLocale")
private static byte[] hexStringToBytes(String hexString) {
if (hexString == null || hexString.equals("")) {
return null;
}
- hexString = hexString.toUpperCase();
+ hexString = hexString.toUpperCase(Locale.CHINA);
int length = hexString.length() / 2;
char[] hexChars = hexString.toCharArray();
byte[] d = new byte[length];
diff --git a/client/Piztor/src/com/macaroon/piztor/Transam.java b/client/Piztor/src/com/macaroon/piztor/Transam.java
index 481a676..fae9252 100644
--- a/client/Piztor/src/com/macaroon/piztor/Transam.java
+++ b/client/Piztor/src/com/macaroon/piztor/Transam.java
@@ -24,11 +24,7 @@ import android.os.Message;
// //
// ----------I'm the division line-------- //
// //
-// 100 for timeOut //
-// 101 for conection failed //
-// 102 for reconnect //
-// 103 for IOexception //
-// 104 for UnknownHostException //
+// -1 for Exceptions //
// //
// ----------I'm the division line-------- //
// //
@@ -46,9 +42,7 @@ import android.os.Message;
// getlocation -- status & entrynumber & data //
// entry -- userid & latitude & longitude //
// //
-// getuserinfo -- status & RUserinfo(base class) //
-// 0 RKeyGroupID -- groupid //
-// 1 RKeyGender -- gender //
+// getuserinfo -- status & uid & gid & gender //
// //
// status -- 0 for success //
// 1 for failed/invalid //
@@ -77,7 +71,6 @@ public class Transam implements Runnable {
reqtask = new LinkedList<Req>();
}
-
public void send(Req r){
reqtask.offer(r);
@@ -100,8 +93,9 @@ public class Transam implements Runnable {
req = reqtask.poll();
if(req.time + req.alive < System.currentTimeMillis()){ //time out!
Message ret = new Message();
- ret.obj = "Time out!";
- ret.what = 100;
+ TimeOutException t = new TimeOutException();
+ ret.obj = t;
+ ret.what = -1;
recall.sendMessage(ret);
}
else{ //run the request
@@ -113,7 +107,7 @@ public class Transam implements Runnable {
thread.start();
timer = new Timer();
TimerTask task = new Timertk();
- timer.schedule(task, 2000, 2000);
+ timer.schedule(task, 20000, 20000);
}
}
}
@@ -138,14 +132,14 @@ public class Transam implements Runnable {
} catch (UnknownHostException e) {
e.printStackTrace();
Message msg = new Message();
- msg.obj = "UnknownHostException";
- msg.what = 104;
+ msg.obj = e;
+ msg.what = -1;
recall.sendMessage(msg);
} catch (IOException e) {
e.printStackTrace();
Message msg = new Message();
- msg.obj = "IOException";
- msg.what = 103;
+ msg.obj = e;
+ msg.what = -1;
recall.sendMessage(msg);
}
@@ -161,6 +155,7 @@ public class Transam implements Runnable {
break;
case 2:
final thd t = new thd();
+ thread.interrupt();
thread = new Thread(t);
thread.start();
break;
@@ -173,17 +168,14 @@ public class Transam implements Runnable {
public void run() {
if (flag == false && cnt > 0) {
cnt--;
- Message msg = new Message();
- msg.obj = "Reconnect for rest " + cnt + " times";
- msg.what = 102;
- recall.sendMessage(msg);
Message m = new Message();
- msg.what = 2;
+ m.what = 2;
handler.sendMessage(m);
} else if (cnt == 0) {
Message msg = new Message();
- msg.obj = "connecting failed";
- msg.what = 101;
+ ConnectFailedException c = new ConnectFailedException();
+ msg.obj = c;
+ msg.what = -1;
recall.sendMessage(msg);
timer.cancel();
} else if (flag == true) {
@@ -192,4 +184,20 @@ public class Transam implements Runnable {
}
}
};
+
+ class ConnectFailedException extends Exception{
+ private static final long serialVersionUID = 101L;
+ public ConnectFailedException() {
+ super();
+ }
+ }
+
+ class TimeOutException extends Exception{
+ private static final long serialVersionUID = 102L;
+ public TimeOutException() {
+ super();
+ }
+
+ }
+
} \ No newline at end of file
diff --git a/client/Piztor/src/com/macaroon/piztor/UserInfo.java b/client/Piztor/src/com/macaroon/piztor/UserInfo.java
index 3d163d5..63f413e 100644
--- a/client/Piztor/src/com/macaroon/piztor/UserInfo.java
+++ b/client/Piztor/src/com/macaroon/piztor/UserInfo.java
@@ -2,7 +2,8 @@ package com.macaroon.piztor;
public class UserInfo {
static String ip = "69.85.86.42";
- static int port = 9990;
+ static int port = 2222;
static String token = null;
static String username = null;
+ static int id = -1;
}