diff options
author | Teddy <ted.sybil@gmail.com> | 2013-08-26 17:33:55 +0800 |
---|---|---|
committer | Teddy <ted.sybil@gmail.com> | 2013-08-26 17:33:55 +0800 |
commit | cf77f61bff7822b35020f2877ca4e6e683981be1 (patch) | |
tree | c7904cda1d81ef8a5dc8b196a7d8e9d360b58d40 | |
parent | eb303ea6f1f6aa3e9a0cd4b00ef3fda6b06f0027 (diff) | |
parent | 92c5473740f45883c719002d4bc47236c669f51e (diff) |
Merge branch 'master' of github.com:Determinant/piztor
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 Binary files differdeleted file mode 100644 index 2725ea8..0000000 --- a/client/Piztor/res/drawable/bottom_img.png +++ /dev/null diff --git a/client/Piztor/res/drawable/data.jpg b/client/Piztor/res/drawable/data.jpg Binary files differnew file mode 100644 index 0000000..f549ec7 --- /dev/null +++ b/client/Piztor/res/drawable/data.jpg diff --git a/client/Piztor/res/drawable/piztor.png b/client/Piztor/res/drawable/piztor.png Binary files differnew file mode 100644 index 0000000..7b6698a --- /dev/null +++ b/client/Piztor/res/drawable/piztor.png 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) { |