summaryrefslogtreecommitdiff
path: root/client/.metadata/.plugins/org.eclipse.core.resources
diff options
context:
space:
mode:
authorgoblin911 <[email protected]>2013-08-25 21:18:19 +0800
committergoblin911 <[email protected]>2013-08-25 21:18:19 +0800
commit0e687f12bd2653adb55ea002b39292678366c525 (patch)
tree0ad073ec8ff2ed2716adf23a679184c38df582a1 /client/.metadata/.plugins/org.eclipse.core.resources
parent2efdc2f20f0306791ced5ec78a1acddfaf086f42 (diff)
...
Diffstat (limited to 'client/.metadata/.plugins/org.eclipse.core.resources')
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/0/b08b1b0b560d00131719b896d543f08c45
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/1/907f38e9220d00131a9bb9bc5a5e61714
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/1/e0fccb09380d00131249f322b63acde896
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/1/f02df33e860d00131719b896d543f08c31
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/12/201d72d3760d00131719b896d543f08c178
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/13/6046c8d2670d00131719b896d543f08c91
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/15/80676cae330d00131249f322b63acde857
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/16/30f189812c0d00131249f322b63acde833
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/16/c03b1eb7550d00131719b896d543f08c68
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/17/8029226c800d00131719b896d543f08c15
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/17/b039f5b4330d00131249f322b63acde859
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/18/00a5e084260d00131a9bb9bc5a5e617168
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/19/b01e7ce6220d00131a9bb9bc5a5e61710
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/19/b06a41ee310d00131249f322b63acde881
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/1b/1001f39b220d00131a9bb9bc5a5e617117
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/1b/e052bedc670d00131719b896d543f08c91
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/1c/0084ccf2240d00131a9bb9bc5a5e61718
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/1c/c097adfa670d00131719b896d543f08c91
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/1f/305dce064c0d00131719b896d543f08c103
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/2/c0e1f0e53a0d00131524a793807f338e85
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/22/20302442660d00131719b896d543f08c82
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/22/b0553560360d00131249f322b63acde872
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/24/40a1e7d3340d00131249f322b63acde863
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/24/602725f7320d00131249f322b63acde89
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/25/60c3225c250d00131a9bb9bc5a5e617190
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/25/703b1352250d00131a9bb9bc5a5e617190
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/25/e0a3222e250d00131a9bb9bc5a5e617191
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/26/10fa1d9f550d00131719b896d543f08c241
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/26/60c51154370d00131249f322b63acde870
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/27/20fe519b7a0d00131719b896d543f08c196
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/27/8062fc9c690d00131719b896d543f08c115
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/27/b0ff1ddf650d00131719b896d543f08c66
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/28/005bf7374c0d00131719b896d543f08c103
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/28/a00c947d310d00131249f322b63acde8133
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/28/e0fe6e7a310d00131249f322b63acde876
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/2b/90dd627f4f0d00131719b896d543f08c42
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/2b/e0b1b2b86a0d00131719b896d543f08c137
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/10589e1d530d00131719b896d543f08c33
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/b0547e04360d00131249f322b63acde870
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/d03e1c612c0d00131249f322b63acde830
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/2e/80cdc91d560d00131719b896d543f08c45
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/3/b0bdfe23320d00131249f322b63acde881
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/30/909951c6530d00131719b896d543f08c42
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/31/50f2612d2d0d00131249f322b63acde835
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/32/00f713722c0d00131249f322b63acde832
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/33/00c793445a0d00131719b896d543f08c104
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/34/b0a7c7dc250d00131a9bb9bc5a5e617164
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/34/c0f6cc4a530d00131719b896d543f08c37
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/35/4093eb606b0d00131719b896d543f08c149
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/36/90c1e030690d00131719b896d543f08c110
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/36/d038f44e800d00131719b896d543f08c89
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/38/003d32e92d0d00131249f322b63acde874
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/50c1a310570d00131719b896d543f08c49
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70725e2b330d00131249f322b63acde884
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/c06b1bbd810d00131719b896d543f08c23
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/3b/908be6833c0d00131524a793807f338e90
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/3c/e05994772c0d00131249f322b63acde832
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/00def6177b0d00131719b896d543f08c196
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/1089ba593d0d00131524a793807f338e35
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/70b085c6280d00131249f322b63acde869
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/3f/20d16da8790d00131719b896d543f08c191
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4/208b4473550d00131719b896d543f08c69
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4/d06a2613260d00131a9bb9bc5a5e617171
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/40/d0cd94022e0d00131249f322b63acde876
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/41/c042e3c3810d00131719b896d543f08c23
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/42/202de8244f0d00131719b896d543f08c42
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/43/d08732c36a0d00131719b896d543f08c137
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/43/e05e9ddd800d00131719b896d543f08c22
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/44/00604d29230d00131a9bb9bc5a5e61716
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/44/50b1dc18530d00131719b896d543f08c23
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/44/b0ce412f550d00131719b896d543f08c241
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/48/f02ec265260d00131a9bb9bc5a5e617171
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/49/10547e20330d00131249f322b63acde883
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/49/d0e63f99550d00131719b896d543f08c241
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4a/2006f95e2b0d00131249f322b63acde814
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4b/60e6bdcd310d00131249f322b63acde834
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/10fd771f320d00131249f322b63acde881
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/2088d09b260d00131a9bb9bc5a5e617122
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/30e8770c260d00131a9bb9bc5a5e617171
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/d04b30d8520d00131719b896d543f08c62
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/40eb8393390d00131524a793807f338e85
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/5025c807320d00131249f322b63acde882
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/60e7a753340d00131249f322b63acde858
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/709e4dd5770d00131719b896d543f08c193
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/d078d3c5670d00131719b896d543f08c87
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/4f/20629bba350d00131249f322b63acde866
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/5/c09802f4810d00131719b896d543f08c28
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/51/1058bc287a0d00131719b896d543f08c195
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/51/d01e0d2c7c0d00131719b896d543f08c202
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/51/e043216f2c0d00131249f322b63acde831
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/52/80fa1082370d00131249f322b63acde880
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/52/908340203a0d00131524a793807f338e101
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/52/b0f7e5f4300d00131249f322b63acde8133
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/53/20300883550d00131719b896d543f08c67
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/53/a06c6384500d00131719b896d543f08c92
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/53/b0d150cf4d0d00131719b896d543f08c149
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/54/105bdc86800d00131719b896d543f08c19
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/55/c0697f702b0d00131249f322b63acde815
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/56/70ea45fe4b0d00131719b896d543f08c102
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/56/e0d3f982370d00131249f322b63acde896
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/58/c0259769680d00131719b896d543f08c92
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/59/604165f5520d00131719b896d543f08c62
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/59/b0dfede04f0d00131719b896d543f08c21
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/5a/1067b967520d00131719b896d543f08c62
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/5a/20289dc1250d00131a9bb9bc5a5e617162
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/5b/a01d01234f0d00131719b896d543f08c42
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/5b/b09b88be520d00131719b896d543f08c62
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/5c/40ac8a2a760d00131719b896d543f08c174
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/5c/a0a26974330d00131249f322b63acde853
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/10ddd0bd550d00131719b896d543f08c68
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/b06ac273760d00131719b896d543f08c174
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/5e/5026feaa340d00131249f322b63acde861
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/5f/40817ce9810d00131719b896d543f08c28
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/6/509d88ee670d00131719b896d543f08c91
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/60/c0fbac51760d00131719b896d543f08c173
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/61/503835816a0d00131719b896d543f08c116
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/62/f050f6cd300d00131249f322b63acde8132
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/65/10afe9c2560d00131719b896d543f08c68
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/65/7015966a370d00131249f322b63acde883
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/65/c008735d330d00131249f322b63acde8134
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/66/108b1d6a2c0d00131249f322b63acde872
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/67/7089926a2b0d00131249f322b63acde813
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/67/80e1a600230d00131a9bb9bc5a5e61715
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/6b/40af41ee250d00131a9bb9bc5a5e617169
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/6b/50c980702b0d00131249f322b63acde815
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/6c/e0cb25df390d00131524a793807f338e99
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/6d/30ed916a2b0d00131249f322b63acde813
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/6e/a03ae288270d00131050e648e11def2a28
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/6f/0020dd3c560d00131719b896d543f08c47
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7/102ad2cb800d00131719b896d543f08c20
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7/10a4d736550d00131719b896d543f08c241
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7/806200684f0d00131719b896d543f08c42
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7/b00ff61a380d00131249f322b63acde897
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7/f0c8a1b1330d00131249f322b63acde858
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7/f0e31801750d00131719b896d543f08c160
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/70/501f63f7750d00131719b896d543f08c168
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/70/803f3d632b0d00131249f322b63acde816
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/70/c00737b35b0d00131719b896d543f08c53
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/70/e041e862500d00131719b896d543f08c92
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/71/3084ff9b220d00131a9bb9bc5a5e61713
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/71/b0d73212550d00131719b896d543f08c67
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/72/40aa3d7d680d00131719b896d543f08c109
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/72/7046908d340d00131249f322b63acde861
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/72/b0a7a169550d00131719b896d543f08c240
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/73/006fa23d5a0d00131719b896d543f08c104
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/73/c01d2030760d00131719b896d543f08c173
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/73/c08e77fb780d00131719b896d543f08c192
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/74/40c025d4770d00131719b896d543f08c182
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/74/80e6f54e800d00131719b896d543f08c106
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/74/901b4f2c550d00131719b896d543f08c241
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/75/601f31e7390d00131524a793807f338e99
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/75/b047617e310d00131249f322b63acde8132
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/76/207ce70b330d00131249f322b63acde882
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/76/608e011f4f0d00131719b896d543f08c42
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/77/e09023cf310d00131249f322b63acde835
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/77/f09da14b290d00131249f322b63acde830
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/78/d014d7fc220d00131a9bb9bc5a5e61710
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/79/2065267c2c0d00131249f322b63acde833
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/79/90c475984b0d00131719b896d543f08c63
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7a/906f6f46800d00131719b896d543f08c9
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7b/5015928e500d00131719b896d543f08c42
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7b/b0d770546b0d00131719b896d543f08c151
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7c/f0024b04260d00131a9bb9bc5a5e617171
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7c/f0272c32560d00131719b896d543f08c46
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7d/10fd3cab810d00131719b896d543f08c23
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7d/e021b37a330d00131249f322b63acde854
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7e/00390e21280d00131249f322b63acde829
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7e/a0c4a019530d00131719b896d543f08c33
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/7f/5045a039260d00131a9bb9bc5a5e617171
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8/208ac81c560d00131719b896d543f08c45
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8/40515524760d00131719b896d543f08c173
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8/c064fb4e800d00131719b896d543f08c8
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/80/706d105f250d00131a9bb9bc5a5e617190
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/80/9080b2de4d0d00131719b896d543f08c107
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/81/10091b6d2b0d00131249f322b63acde818
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/81/60af4207370d00131249f322b63acde863
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/81/d0e51ef7320d00131249f322b63acde831
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/82/70f000a8770d00131719b896d543f08c178
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/82/909cd18d310d00131249f322b63acde8133
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/84/30d53cf3280d00131249f322b63acde869
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/84/700a3adf290d00131249f322b63acde831
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/84/901e3ac8250d00131a9bb9bc5a5e617164
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/84/c01bf7ee550d00131719b896d543f08c67
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/84/c080c339520d00131719b896d543f08c241
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/86/90090791270d00131050e648e11def2a22
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/86/b0ac05a2810d00131719b896d543f08c23
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/87/201980b5760d00131719b896d543f08c176
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/87/5019e3b3260d00131a9bb9bc5a5e617128
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/87/50ba72af3b0d00131524a793807f338e7
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/87/d0e225b3310d00131249f322b63acde880
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/88/50d41de3290d00131249f322b63acde830
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/88/a0228599540d00131719b896d543f08c87
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/88/a0b797df250d00131a9bb9bc5a5e617169
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/89/0029672d5a0d00131719b896d543f08c34
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8a/c0860fa32d0d00131249f322b63acde872
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8b/908f0c6a360d00131249f322b63acde872
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8b/d056c37d2d0d00131249f322b63acde836
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8c/10eb0b46390d00131524a793807f338e84
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8c/e09a6d15560d00131719b896d543f08c45
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/10e89b06370d00131249f322b63acde863
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/80e1dd33540d00131719b896d543f08c85
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/a08e799e530d00131719b896d543f08c37
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/a0b8e0b1310d00131249f322b63acde878
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/b05c6824790d00131719b896d543f08c192
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8e/b08854886b0d00131719b896d543f08c149
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8f/e0acc70a360d00131249f322b63acde872
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/8f/f0503e632b0d00131249f322b63acde816
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/9/80eaba674e0d00131719b896d543f08c10
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/9/d0125955810d00131719b896d543f08c23
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/90/00e09e727b0d00131719b896d543f08c198
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/90/2028ee04230d00131a9bb9bc5a5e617110
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/90/d01af94e800d00131719b896d543f08c205
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/92/90d0196d2b0d00131249f322b63acde818
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/95/6090f2e14d0d00131719b896d543f08c29
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/95/d0e2b9652c0d00131249f322b63acde830
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/96/00f46dd44f0d00131719b896d543f08c19
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/96/7099eaee250d00131a9bb9bc5a5e617171
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/96/d045188a780d00131719b896d543f08c191
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/97/b0d85224540d00131719b896d543f08c42
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/97/b0e93a1f560d00131719b896d543f08c46
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/98/90d9c0a3260d00131a9bb9bc5a5e617128
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/98/c0bccf492c0d00131249f322b63acde85
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/98/d01ce77a780d00131719b896d543f08c192
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/99/502b88e7810d00131719b896d543f08c28
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/99/603b4d34230d00131a9bb9bc5a5e617110
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/99/70ce9093370d00131249f322b63acde896
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/9b/90a9ae62770d00131719b896d543f08c181
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/9c/606048dc370d00131249f322b63acde896
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/9d/1036ff9b220d00131a9bb9bc5a5e61712
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/9d/3091338f6b0d00131719b896d543f08c156
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/9e/80db2574360d00131249f322b63acde872
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/90356481800d00131719b896d543f08c15
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/a064e6d0330d00131249f322b63acde858
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/f04144582b0d00131249f322b63acde816
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a/40b9ebd22d0d00131249f322b63acde873
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/70559b0a250d00131a9bb9bc5a5e617116
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/90d4db88800d00131719b896d543f08c19
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/e0b88562370d00131249f322b63acde871
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a2/308cf16f2c0d00131249f322b63acde832
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a2/50ad9b0a560d00131719b896d543f08c43
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a3/f02825fc2d0d00131249f322b63acde874
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a6/a016c8c14f0d00131719b896d543f08c20
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a7/a0893aae550d00131719b896d543f08c68
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a8/20fcf44e800d00131719b896d543f08c32
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a8/80a9829d690d00131719b896d543f08c116
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/100cbe75540d00131719b896d543f08c86
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/409f33a52d0d00131249f322b63acde872
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/e083aa57340d00131249f322b63acde860
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/aa/1010278f550d00131719b896d543f08c241
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/aa/a0a35aa1550d00131719b896d543f08c242
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ab/608c6879260d00131a9bb9bc5a5e617169
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ac/00248cbd360d00131249f322b63acde871
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ae/30296b52560d00131719b896d543f08c47
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ae/c0defd575a0d00131719b896d543f08c68
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/af/30d4b2674e0d00131719b896d543f08c35
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/7084ef6a550d00131719b896d543f08c241
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/c09fb905760d00131719b896d543f08c171
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/d04f2b58380d00131249f322b63acde899
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/00a1a652550d00131719b896d543f08c240
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/00b0df34260d00131a9bb9bc5a5e617171
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/806ea1b54f0d00131719b896d543f08c19
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/a0011e00530d00131719b896d543f08c22
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b3/005ecbdb800d00131719b896d543f08c20
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/d054deff370d00131249f322b63acde896
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/e0f38c9f260d00131a9bb9bc5a5e617127
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/f0db4c2f390d00131524a793807f338e84
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b6/907c20d0330d00131249f322b63acde858
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b7/00d0ee3f5a0d00131719b896d543f08c104
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b7/7017f2e32d0d00131249f322b63acde874
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/b9/002a6f89770d00131719b896d543f08c178
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/bd/90228f69800d00131719b896d543f08c8
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/a0e7485e390d00131524a793807f338e84
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/b07e9999380d00131249f322b63acde834
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/c0281dde290d00131249f322b63acde831
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c/20533453360d00131249f322b63acde872
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c/c0b909df780d00131719b896d543f08c62
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c1/70c31bc4770d00131719b896d543f08c180
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c1/90049d68370d00131249f322b63acde884
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c2/305132042e0d00131249f322b63acde877
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c2/905743582b0d00131249f322b63acde816
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c3/c02b54e56a0d00131719b896d543f08c137
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c3/e083ea64370d00131249f322b63acde885
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c4/80454f67500d00131719b896d543f08c92
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c4/a02a68e4550d00131719b896d543f08c66
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c5/b0f3fcc27c0d00131719b896d543f08c204
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c8/b082216a2c0d00131249f322b63acde831
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/c9/406dedec4e0d00131719b896d543f08c41
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/20f3b0b5340d00131249f322b63acde862
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/90266484690d00131719b896d543f08c114
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/a02a83fc310d00131249f322b63acde880
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/d0283431550d00131719b896d543f08c241
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/cb/30fcab3d6b0d00131719b896d543f08c137
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/30d547d6300d00131249f322b63acde8132
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/40540cea780d00131719b896d543f08c65
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/a06019c6550d00131719b896d543f08c66
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/b0cf5a29320d00131249f322b63acde881
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/e0b44c18280d00131249f322b63acde829
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ce/400f0022790d00131719b896d543f08c65
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/509df39b220d00131a9bb9bc5a5e61715
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/80bdfc51360d00131249f322b63acde872
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/80e32f683a0d00131524a793807f338e85
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/b0399970330d00131249f322b63acde848
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/d1/e0493fd6550d00131719b896d543f08c64
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/d2/80c7346a770d00131719b896d543f08c181
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/d3/d07246a16a0d00131719b896d543f08c128
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/d4/b08e74497f0d00131719b896d543f08c7
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/d6/70651b8c4f0d00131719b896d543f08c42
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/d7/50a452ea310d00131249f322b63acde880
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/d7/50d6caf2240d00131a9bb9bc5a5e617127
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/d8/90a207514b0d00131719b896d543f08c101
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/d8/f0ae11884d0d00131719b896d543f08c16
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/d9/b0831880280d00131249f322b63acde869
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/d9/c0cdd6df780d00131719b896d543f08c64
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/da/b0c3a5433d0d00131524a793807f338e35
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/db/50df9b974b0d00131719b896d543f08c63
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/dd/600b7a0f780d00131719b896d543f08c192
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/dd/c0b636965b0d00131719b896d543f08c106
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/de/20eb032c3c0d00131524a793807f338e100
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/de/a03d00d2760d00131719b896d543f08c177
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/de/f01bbbba310d00131249f322b63acde879
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/df/406bf637390d00131524a793807f338e84
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/e/d06a5fb7520d00131719b896d543f08c241
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/e0/40e5bce9370d00131249f322b63acde898
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/306f6f46360d00131249f322b63acde872
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/9017fa5e2b0d00131249f322b63acde814
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/b01fa77a4e0d00131719b896d543f08c16
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/005a5d292d0d00131249f322b63acde833
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/4039c9d3330d00131249f322b63acde858
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/d0880974550d00131719b896d543f08c68
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/e6/20fcf772310d00131249f322b63acde8133
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/e7/00e5c3933a0d00131524a793807f338e22
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/e9/201bd58e370d00131249f322b63acde895
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/0041c861520d00131719b896d543f08c64
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/50149cac330d00131249f322b63acde854
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/50fcb17a260d00131a9bb9bc5a5e617169
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ed/d0b50c637c0d00131719b896d543f08c203
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/800bef37290d00131249f322b63acde873
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/8094037e770d00131719b896d543f08c181
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/e062b6d0520d00131719b896d543f08c62
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f/702f615d280d00131249f322b63acde868
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f/c043e2232c0d00131249f322b63acde829
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f0/a000529a350d00131249f322b63acde863
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/00249bf3370d00131249f322b63acde898
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/e068ac2a250d00131a9bb9bc5a5e617190
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/e0f0dd782c0d00131249f322b63acde831
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f2/101fed70800d00131719b896d543f08c15
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f4/a087fd4e800d00131719b896d543f08c8
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f4/a0da18d74d0d00131719b896d543f08c133
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/50b3bf00680d00131719b896d543f08c91
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/c0432fca650d00131719b896d543f08c56
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/f009dded390d00131524a793807f338e100
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/f0f9d74b5a0d00131719b896d543f08c51
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f7/404fa93a860d00131719b896d543f08c30
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f8/10ed0356660d00131719b896d543f08c86
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f8/60faee49750d00131719b896d543f08c159
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f9/40812ada6a0d00131719b896d543f08c137
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/f9/e06a5470670d00131719b896d543f08c86
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fa/f0caef03230d00131a9bb9bc5a5e61715
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/10233142530d00131719b896d543f08c33
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/10a53b2a7a0d00131719b896d543f08c197
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/901006312c0d00131249f322b63acde80
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/d0859c9d370d00131249f322b63acde896
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/d0f7938e550d00131719b896d543f08c240
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/e0d4eed4300d00131249f322b63acde8133
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fc/f05e84f54e0d00131719b896d543f08c42
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/50c48d3c520d00131719b896d543f08c64
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/7081acc66c0d00131719b896d543f08c154
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/90b04d264f0d00131719b896d543f08c42
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fe/4015f3cd330d00131249f322b63acde858
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.history/fe/c09a68a94b0d00131719b896d543f08c63
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/5f/properties.indexbin0 -> 430 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/62/properties.indexbin0 -> 639 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/66/properties.indexbin0 -> 167 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/cd/properties.indexbin0 -> 162 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/d6/history.indexbin0 -> 631 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/d6/properties.indexbin0 -> 1953 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/de/history.indexbin0 -> 224 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/de/properties.indexbin0 -> 410 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/eb/properties.indexbin0 -> 158 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/ee/properties.indexbin0 -> 158 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/af/history.indexbin0 -> 94 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/e4/81/32/ea/history.indexbin0 -> 8568 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/e4/history.indexbin0 -> 76 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/history.indexbin0 -> 413 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/properties.indexbin0 -> 1048 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.markersbin0 -> 3779 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.markers.snapbin0 -> 42350 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.syncinfo.snapbin0 -> 688 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version1
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.indexbin0 -> 234 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version1
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snapbin0 -> 715 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.root/7.treebin0 -> 9558 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resourcesbin0 -> 18176 bytes
-rw-r--r--client/.metadata/.plugins/org.eclipse.core.resources/.snapbin0 -> 32995 bytes
395 files changed, 29518 insertions, 0 deletions
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/0/b08b1b0b560d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/0/b08b1b0b560d00131719b896d543f08c
new file mode 100644
index 0000000..02e3800
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/0/b08b1b0b560d00131719b896d543f08c
@@ -0,0 +1,45 @@
+package com.macaroon.piztor;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ Location l = (Location) m.objl
+ ReqUpdate r = new ReqUpdate(UserInfo.token, , longitude, time, alive)
+ AppMgr.transam.send();
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/1/907f38e9220d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1/907f38e9220d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..44f93d4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1/907f38e9220d00131a9bb9bc5a5e6171
@@ -0,0 +1,4 @@
+
+class Exception {
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/1/e0fccb09380d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1/e0fccb09380d00131249f322b63acde8
new file mode 100644
index 0000000..633f742
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1/e0fccb09380d00131249f322b63acde8
@@ -0,0 +1,96 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/1/f02df33e860d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1/f02df33e860d00131719b896d543f08c
new file mode 100644
index 0000000..0c5fcbc
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1/f02df33e860d00131719b896d543f08c
@@ -0,0 +1,31 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import java.util.HashMap;
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+ static int myGroup = -1;
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+
+ static HashMap<Integer, Group> mp;
+
+ @SuppressLint("UseSparseArrays")
+ static void init() {
+ mp = new HashMap<Integer, Group>();
+ mp = new Spa
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/12/201d72d3760d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/12/201d72d3760d00131719b896d543f08c
new file mode 100644
index 0000000..4406dc1
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/12/201d72d3760d00131719b896d543f08c
@@ -0,0 +1,178 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " " + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0) System.out.println("update success");
+ else System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/13/6046c8d2670d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/13/6046c8d2670d00131719b896d543f08c
new file mode 100644
index 0000000..c3a9bbe
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/13/6046c8d2670d00131719b896d543f08c
@@ -0,0 +1,91 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/15/80676cae330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/15/80676cae330d00131249f322b63acde8
new file mode 100644
index 0000000..a3b8c65
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/15/80676cae330d00131249f322b63acde8
@@ -0,0 +1,57 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ boolean sendMessage(Message m) {
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/16/30f189812c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/16/30f189812c0d00131249f322b63acde8
new file mode 100644
index 0000000..5d2cc7c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/16/30f189812c0d00131249f322b63acde8
@@ -0,0 +1,33 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else {
+ //TODO
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/16/c03b1eb7550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/16/c03b1eb7550d00131719b896d543f08c
new file mode 100644
index 0000000..b653442
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/16/c03b1eb7550d00131719b896d543f08c
@@ -0,0 +1,68 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.location.Location;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/17/8029226c800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/17/8029226c800d00131719b896d543f08c
new file mode 100644
index 0000000..16bf50d
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/17/8029226c800d00131719b896d543f08c
@@ -0,0 +1,15 @@
+package com.macaroon.piztor;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+
+ static class UserInfo {
+ double lat, lon;
+ }
+
+ static class Group {
+
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/17/b039f5b4330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/17/b039f5b4330d00131249f322b63acde8
new file mode 100644
index 0000000..3058eb2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/17/b039f5b4330d00131249f322b63acde8
@@ -0,0 +1,59 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public
+ boolean sendMessage(Message m) {
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/18/00a5e084260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/18/00a5e084260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..270ce20
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/18/00a5e084260d00131a9bb9bc5a5e6171
@@ -0,0 +1,68 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int hasToken = 1;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, hasToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/19/b01e7ce6220d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/19/b01e7ce6220d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/19/b01e7ce6220d00131a9bb9bc5a5e6171
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/19/b06a41ee310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/19/b06a41ee310d00131249f322b63acde8
new file mode 100644
index 0000000..6c0b0eb
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/19/b06a41ee310d00131249f322b63acde8
@@ -0,0 +1,81 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static Transam transam = null;
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+
+ new Thread(transam).run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/1b/1001f39b220d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1b/1001f39b220d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..ae72ba5
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1b/1001f39b220d00131a9bb9bc5a5e6171
@@ -0,0 +1,17 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ </application>
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/1b/e052bedc670d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1b/e052bedc670d00131719b896d543f08c
new file mode 100644
index 0000000..c3a9bbe
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1b/e052bedc670d00131719b896d543f08c
@@ -0,0 +1,91 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/1c/0084ccf2240d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1c/0084ccf2240d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..a88b749
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1c/0084ccf2240d00131a9bb9bc5a5e6171
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">Piztor</string>
+ <string name="action_settings">Settings</string>
+ <string name="hello_world">Hello world!</string>
+
+</resources>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/1c/c097adfa670d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1c/c097adfa670d00131719b896d543f08c
new file mode 100644
index 0000000..6966e0f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1c/c097adfa670d00131719b896d543f08c
@@ -0,0 +1,91 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[2];
+ r[0] = new StartStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/1f/305dce064c0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1f/305dce064c0d00131719b896d543f08c
new file mode 100644
index 0000000..4f16d24
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/1f/305dce064c0d00131719b896d543f08c
@@ -0,0 +1,103 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ cout.println(m.what);
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ System.out.println(user + " : " + pass + "\n");
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/2/c0e1f0e53a0d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2/c0e1f0e53a0d00131524a793807f338e
new file mode 100644
index 0000000..71415fe
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2/c0e1f0e53a0d00131524a793807f338e
@@ -0,0 +1,85 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ //fromGPS = new Handler();
+ tTransam = new Thread(transam);
+ tTransam.run();
+ System.out.println("!!!!!!");
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/22/20302442660d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/22/20302442660d00131719b896d543f08c
new file mode 100644
index 0000000..5dd8ba4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/22/20302442660d00131719b896d543f08c
@@ -0,0 +1,82 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/22/b0553560360d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/22/b0553560360d00131249f322b63acde8
new file mode 100644
index 0000000..12a937e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/22/b0553560360d00131249f322b63acde8
@@ -0,0 +1,72 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/24/40a1e7d3340d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/24/40a1e7d3340d00131249f322b63acde8
new file mode 100644
index 0000000..c8f52ad
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/24/40a1e7d3340d00131249f322b63acde8
@@ -0,0 +1,63 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ }
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/24/602725f7320d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/24/602725f7320d00131249f322b63acde8
new file mode 100644
index 0000000..0b8f112
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/24/602725f7320d00131249f322b63acde8
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">Piztor</string>
+ <string name="action_settings">Settings</string>
+ <string name="hello_world">Hello world!</string>
+ <string name="title_activity_login">Login</string>
+
+</resources>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/25/60c3225c250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/25/60c3225c250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..e0a3278
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/25/60c3225c250d00131a9bb9bc5a5e6171
@@ -0,0 +1,90 @@
+<?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
+ 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
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ 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: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/white"
+ />
+
+ <EditText
+ android:layout_width="0dp"
+ android:layout_weight="0.75"
+ android:id="@+id/user_pass"
+ android:password="true"
+ 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" />
+ </LinearLayout>
+
+</LinearLayout>
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/25/703b1352250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/25/703b1352250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..629f1c1
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/25/703b1352250d00131a9bb9bc5a5e6171
@@ -0,0 +1,90 @@
+<?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
+ 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
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ 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: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/white"
+ />
+
+ <EditText
+ android:layout_width="0dp"
+ android:layout_weight="0.75"
+ android:id="@+id/user_pass"
+ android:password="true"
+ 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" />
+ </LinearLayout>
+
+</LinearLayout>
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/25/e0a3222e250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/25/e0a3222e250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..809994b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/25/e0a3222e250d00131a9bb9bc5a5e6171
@@ -0,0 +1,91 @@
+<?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
+ 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
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ 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: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/white"
+ />
+
+ <EditText
+ android:layout_width="0dp"
+ android:layout_weight="0.75"
+ android:id="@+id/user_pass"
+ android:password="true"
+ 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" />
+ </LinearLayout>
+
+</LinearLayout>
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/26/10fa1d9f550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/26/10fa1d9f550d00131719b896d543f08c
new file mode 100644
index 0000000..742b99a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/26/10fa1d9f550d00131719b896d543f08c
@@ -0,0 +1,241 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public Location getLocation() {
+ try {
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ return location;
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/26/60c51154370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/26/60c51154370d00131249f322b63acde8
new file mode 100644
index 0000000..aa5d479
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/26/60c51154370d00131249f322b63acde8
@@ -0,0 +1,70 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/27/20fe519b7a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/27/20fe519b7a0d00131719b896d543f08c
new file mode 100644
index 0000000..c43caef
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/27/20fe519b7a0d00131719b896d543f08c
@@ -0,0 +1,196 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == TimerFlush) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1, System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ autodate.schedule(new AutoUpdate(), 5000);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/27/8062fc9c690d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/27/8062fc9c690d00131719b896d543f08c
new file mode 100644
index 0000000..3245db9
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/27/8062fc9c690d00131719b896d543f08c
@@ -0,0 +1,115 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/27/b0ff1ddf650d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/27/b0ff1ddf650d00131719b896d543f08c
new file mode 100644
index 0000000..10ab5c9
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/27/b0ff1ddf650d00131719b896d543f08c
@@ -0,0 +1,66 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/005bf7374c0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/005bf7374c0d00131719b896d543f08c
new file mode 100644
index 0000000..a976666
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/005bf7374c0d00131719b896d543f08c
@@ -0,0 +1,103 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ System.out.println(m.what);
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ System.out.println(user + " : " + pass + "\n");
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/a00c947d310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/a00c947d310d00131249f322b63acde8
new file mode 100644
index 0000000..3ca0dfe
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/a00c947d310d00131249f322b63acde8
@@ -0,0 +1,133 @@
+package com.macaroon.piztor;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.annotation.SuppressLint;
+import android.os.Handler;
+import android.os.Message;
+
+public class Transam implements Runnable {
+
+ public Timer timer;
+ public Timer mtimer;
+ public boolean running = false;
+ public boolean flag = true;
+ public int cnt = 4;
+ Res res;
+ Req req;
+ public int p; //port
+ public String i; //ip
+ Thread thread;
+ Handler core;
+ Handler recall; //recall
+ Queue<Req> reqtask ; //request task
+
+ Transam(String ip, int port,Handler Recall) {
+ p = port;
+ i = ip;
+ recall = Recall;
+ reqtask = new LinkedList<Req>();
+ }
+
+ public void send(Req r){
+ reqtask.offer(r);
+
+ }
+
+ public void run() { //start the main timer
+ //TimerTask tmain = new Timertk();
+ //mtimer = new Timer();
+ //mtimer.schedule(tmain, 100, 100); //check the queue for every 100 msec
+
+ while(true){
+ if(running == false){
+
+ if(!reqtask.isEmpty()){ //poll the head request
+ req = reqtask.poll();
+ if(req.time + req.alive < System.currentTimeMillis()){ //time out!
+ Message ret = new Message();
+ ret.obj = "Time out!";
+ ret.what = 100;
+ recall.sendMessage(ret);
+ }
+ else{ //run the request
+ final thd t = new thd();
+ flag = false;
+ thread = new Thread(t);
+ cnt = 4;
+ running = true;
+ thread.start();
+ timer = new Timer();
+ TimerTask task = new Timertk();
+ timer.schedule(task, 2000, 2000);
+ }
+ }
+ }
+ }
+ }
+
+ class tmain extends TimerTask {
+ public void run() {
+
+ }
+ };
+
+ class thd implements Runnable {
+ public void run() {
+ try {
+ SocketClient client = new SocketClient(i,p);
+ client.sendMsg(req,recall);
+ Message msg = new Message();
+ msg.what = 1;
+ handler.sendMessage(msg);
+ client.closeSocket();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ System.out.println("UnknownHostException");
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("IOException");
+ }
+
+ }
+ }
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case 1:
+ flag = true;
+ break;
+ case 2:
+ final thd t = new thd();
+ thread = new Thread(t);
+ thread.start();
+ break;
+ }
+ super.handleMessage(msg);
+ }
+ };
+
+ class Timertk extends TimerTask {
+ public void run() {
+ if (flag == false && cnt > 0) {
+ cnt--;
+ } else if (cnt == 0) {
+ Message msg = new Message();
+ msg.obj = "connecting failed";
+ msg.what = 101;
+ recall.sendMessage(msg);
+ timer.cancel();
+ } else if (flag == true) {
+ timer.cancel();
+ running = false;
+ }
+ }
+ };
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/e0fe6e7a310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/e0fe6e7a310d00131249f322b63acde8
new file mode 100644
index 0000000..043638e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/28/e0fe6e7a310d00131249f322b63acde8
@@ -0,0 +1,76 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ fromGPS = new Handler();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/2b/90dd627f4f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2b/90dd627f4f0d00131719b896d543f08c
new file mode 100644
index 0000000..75c5057
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2b/90dd627f4f0d00131719b896d543f08c
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/title_activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/title_activity_main" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Setting"
+ android:label="@string/title_activity_setting" >
+ </activity>
+ </application>
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/2b/e0b1b2b86a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2b/e0b1b2b86a0d00131719b896d543f08c
new file mode 100644
index 0000000..6add4a7
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2b/e0b1b2b86a0d00131719b896d543f08c
@@ -0,0 +1,137 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "SearchButtonPress";
+ case FetchButtonPress:
+ return "FetchButtonPress";
+ case FocuseButtonPress:
+ return "FocuseButtonPress";
+ case SuccessFetch:
+ return "SuccessFetch";
+ case FailedFetch:
+ return "FailedFetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!!");
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/10589e1d530d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/10589e1d530d00131719b896d543f08c
new file mode 100644
index 0000000..f15cf6b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/10589e1d530d00131719b896d543f08c
@@ -0,0 +1,33 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ Handler handler = new Handler() {
+
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/b0547e04360d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/b0547e04360d00131249f322b63acde8
new file mode 100644
index 0000000..296d940
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/b0547e04360d00131249f322b63acde8
@@ -0,0 +1,70 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ }
+ }
+ };
+
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/d03e1c612c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/d03e1c612c0d00131249f322b63acde8
new file mode 100644
index 0000000..4a9b5cd
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2d/d03e1c612c0d00131249f322b63acde8
@@ -0,0 +1,30 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ //if (U)
+ AppMgr.trigger(AppMgr.hasToken);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/2e/80cdc91d560d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2e/80cdc91d560d00131719b896d543f08c
new file mode 100644
index 0000000..b7b4329
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/2e/80cdc91d560d00131719b896d543f08c
@@ -0,0 +1,45 @@
+package com.macaroon.piztor;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(), l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send();
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/3/b0bdfe23320d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3/b0bdfe23320d00131249f322b63acde8
new file mode 100644
index 0000000..1d030dd
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3/b0bdfe23320d00131249f322b63acde8
@@ -0,0 +1,81 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ new Thread(transam).run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/30/909951c6530d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/30/909951c6530d00131719b896d543f08c
new file mode 100644
index 0000000..a60b62b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/30/909951c6530d00131719b896d543f08c
@@ -0,0 +1,42 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/31/50f2612d2d0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/31/50f2612d2d0d00131249f322b63acde8
new file mode 100644
index 0000000..d08b6e2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/31/50f2612d2d0d00131249f322b63acde8
@@ -0,0 +1,35 @@
+package com.macaroon.piztor;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ Intent i = new Intent();
+ i.putExtra("haha", new Handler());
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else {
+ //TODO jump to main
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/32/00f713722c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/32/00f713722c0d00131249f322b63acde8
new file mode 100644
index 0000000..055a218
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/32/00f713722c0d00131249f322b63acde8
@@ -0,0 +1,32 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/33/00c793445a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/33/00c793445a0d00131719b896d543f08c
new file mode 100644
index 0000000..a931dae
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/33/00c793445a0d00131719b896d543f08c
@@ -0,0 +1,104 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ System.out.println(m.what);
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ System.out.println(user + " : " + pass + "\n");
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ AppMgr.transam.setHandler(hand);
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/34/b0a7c7dc250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/34/b0a7c7dc250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..7b0bee0
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/34/b0a7c7dc250d00131a9bb9bc5a5e6171
@@ -0,0 +1,64 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/34/c0f6cc4a530d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/34/c0f6cc4a530d00131719b896d543f08c
new file mode 100644
index 0000000..d68704e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/34/c0f6cc4a530d00131719b896d543f08c
@@ -0,0 +1,37 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/35/4093eb606b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/35/4093eb606b0d00131719b896d543f08c
new file mode 100644
index 0000000..c417882
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/35/4093eb606b0d00131719b896d543f08c
@@ -0,0 +1,149 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/36/90c1e030690d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/36/90c1e030690d00131719b896d543f08c
new file mode 100644
index 0000000..8797872
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/36/90c1e030690d00131719b896d543f08c
@@ -0,0 +1,110 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[1]);
+ actMgr.add
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/36/d038f44e800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/36/d038f44e800d00131719b896d543f08c
new file mode 100644
index 0000000..2e5e2b3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/36/d038f44e800d00131719b896d543f08c
@@ -0,0 +1,89 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Tracker tracker = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ tracker = new Tracker(nowAct.getApplicationContext(), fromGPS);
+ tTransam = new Thread(transam);
+ tTransam.start();
+ tGPS = new Thread(tracker);
+ tGPS.start();
+ System.out.println("!!!!!!");
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/38/003d32e92d0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/38/003d32e92d0d00131249f322b63acde8
new file mode 100644
index 0000000..32d14fa
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/38/003d32e92d0d00131249f322b63acde8
@@ -0,0 +1,74 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/50c1a310570d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/50c1a310570d00131719b896d543f08c
new file mode 100644
index 0000000..479c8fb
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/50c1a310570d00131719b896d543f08c
@@ -0,0 +1,49 @@
+package com.macaroon.piztor;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70725e2b330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70725e2b330d00131249f322b63acde8
new file mode 100644
index 0000000..e0cd3be
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70725e2b330d00131249f322b63acde8
@@ -0,0 +1,84 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ tTransam = new Thread(transam);
+ tTransam.run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/c06b1bbd810d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/c06b1bbd810d00131719b896d543f08c
new file mode 100644
index 0000000..c3fe034
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3a/c06b1bbd810d00131719b896d543f08c
@@ -0,0 +1,23 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+ static int myGroup = -1;
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+
+ static HashMap<Integer, Group> mp;
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/3b/908be6833c0d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3b/908be6833c0d00131524a793807f338e
new file mode 100644
index 0000000..e0a3278
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3b/908be6833c0d00131524a793807f338e
@@ -0,0 +1,90 @@
+<?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
+ 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
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ 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: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/white"
+ />
+
+ <EditText
+ android:layout_width="0dp"
+ android:layout_weight="0.75"
+ android:id="@+id/user_pass"
+ android:password="true"
+ 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" />
+ </LinearLayout>
+
+</LinearLayout>
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/3c/e05994772c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3c/e05994772c0d00131249f322b63acde8
new file mode 100644
index 0000000..1f9d9b0
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3c/e05994772c0d00131249f322b63acde8
@@ -0,0 +1,32 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/00def6177b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/00def6177b0d00131719b896d543f08c
new file mode 100644
index 0000000..4fb4aa7
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/00def6177b0d00131719b896d543f08c
@@ -0,0 +1,196 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == TimerFlush) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1, System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ autodate.schedule(new AutoUpdate(), 0, 5000);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/1089ba593d0d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/1089ba593d0d00131524a793807f338e
new file mode 100644
index 0000000..06c1791
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/1089ba593d0d00131524a793807f338e
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/title_activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/title_activity_main" >
+ </activity>
+ </application>
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/70b085c6280d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/70b085c6280d00131249f322b63acde8
new file mode 100644
index 0000000..54242d5
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3e/70b085c6280d00131249f322b63acde8
@@ -0,0 +1,69 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int hasToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, hasToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/3f/20d16da8790d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3f/20d16da8790d00131719b896d543f08c
new file mode 100644
index 0000000..cc0021f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/3f/20d16da8790d00131719b896d543f08c
@@ -0,0 +1,191 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4/208b4473550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4/208b4473550d00131719b896d543f08c
new file mode 100644
index 0000000..da24dd6
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4/208b4473550d00131719b896d543f08c
@@ -0,0 +1,69 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4/d06a2613260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4/d06a2613260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..8ef1739
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4/d06a2613260d00131a9bb9bc5a5e6171
@@ -0,0 +1,71 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ public enum Event {
+ hasToken
+ }
+
+
+ static HashMap<Class<?>, HashMap<Event, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Event event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Event, Class<?>> h = new HashMap<Event, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, Event i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Event, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Event, Class<?>> h = new HashMap<Event, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Event, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Event, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/40/d0cd94022e0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/40/d0cd94022e0d00131249f322b63acde8
new file mode 100644
index 0000000..e2f6ef1
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/40/d0cd94022e0d00131249f322b63acde8
@@ -0,0 +1,76 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromeGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ fromGPS = new Handler();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/41/c042e3c3810d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/41/c042e3c3810d00131719b896d543f08c
new file mode 100644
index 0000000..c3fe034
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/41/c042e3c3810d00131719b896d543f08c
@@ -0,0 +1,23 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+ static int myGroup = -1;
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+
+ static HashMap<Integer, Group> mp;
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/42/202de8244f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/42/202de8244f0d00131719b896d543f08c
new file mode 100644
index 0000000..8ce1e90
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/42/202de8244f0d00131719b896d543f08c
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/activity_main" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Setting"
+ android:label="@string/title_activity_setting" >
+ </activity>
+ </application>
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/43/d08732c36a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/43/d08732c36a0d00131719b896d543f08c
new file mode 100644
index 0000000..00f4f6a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/43/d08732c36a0d00131719b896d543f08c
@@ -0,0 +1,137 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "SearchButtonPress";
+ case FetchButtonPress:
+ return "FetchButtonPress";
+ case FocuseButtonPress:
+ return "FocuseButtonPress";
+ case SuccessFetch:
+ return "SuccessFetch";
+ case FailedFetch:
+ return "FailedFetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/43/e05e9ddd800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/43/e05e9ddd800d00131719b896d543f08c
new file mode 100644
index 0000000..6173bd0
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/43/e05e9ddd800d00131719b896d543f08c
@@ -0,0 +1,22 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+
+ static HashMap<Integer, Group> mp;
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/44/00604d29230d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/44/00604d29230d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..c33f70a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/44/00604d29230d00131a9bb9bc5a5e6171
@@ -0,0 +1,6 @@
+package com.macaroon.piztor;
+
+public class PiztorExcepiton extends Exception{
+ private static final long serialVersionUID = -7147530695009854988L;
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/44/50b1dc18530d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/44/50b1dc18530d00131719b896d543f08c
new file mode 100644
index 0000000..2fdaba1
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/44/50b1dc18530d00131719b896d543f08c
@@ -0,0 +1,23 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/44/b0ce412f550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/44/b0ce412f550d00131719b896d543f08c
new file mode 100644
index 0000000..ad82cc8
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/44/b0ce412f550d00131719b896d543f08c
@@ -0,0 +1,241 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public location getLocation() {
+ try {
+
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/48/f02ec265260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/48/f02ec265260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..c75989c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/48/f02ec265260d00131a9bb9bc5a5e6171
@@ -0,0 +1,71 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ public enum Event {
+ hasToken
+ }
+
+
+ static HashMap<Class<?>, HashMap<Event, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(Event event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Event event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Event, Class<?>> h = new HashMap<Event, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, Event i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Event, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Event, Class<?>> h = new HashMap<Event, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Event, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Event, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, Event.hasToken, Login.class);
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/10547e20330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/10547e20330d00131249f322b63acde8
new file mode 100644
index 0000000..6b756f2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/10547e20330d00131249f322b63acde8
@@ -0,0 +1,83 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ tTransam = new Thread(transam);
+ tTransam.run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/d0e63f99550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/d0e63f99550d00131719b896d543f08c
new file mode 100644
index 0000000..34a8b04
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/49/d0e63f99550d00131719b896d543f08c
@@ -0,0 +1,241 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public Location getLocation() {
+ try {
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+ return location;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return location;
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4a/2006f95e2b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4a/2006f95e2b0d00131249f322b63acde8
new file mode 100644
index 0000000..000f373
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4a/2006f95e2b0d00131249f322b63acde8
@@ -0,0 +1,14 @@
+package com.macaroon.piztor;
+
+//--------------------------------------//
+// Ask Location //
+//--------------------------------------//
+
+public class ReqLocation extends Req{
+ int gid; //group id;
+
+ ReqLocation(int token,int groupid,long time,long alive){
+ super(3,token,time,alive); //for type 3
+ gid = groupid;
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4b/60e6bdcd310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4b/60e6bdcd310d00131249f322b63acde8
new file mode 100644
index 0000000..401f985
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4b/60e6bdcd310d00131249f322b63acde8
@@ -0,0 +1,34 @@
+package com.macaroon.piztor;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else {
+ //TODO jump to main
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/10fd771f320d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/10fd771f320d00131249f322b63acde8
new file mode 100644
index 0000000..9db1a78
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/10fd771f320d00131249f322b63acde8
@@ -0,0 +1,81 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+
+ //Event
+
+ final static int noToken = 101;
+
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ new Thread(transam).run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/2088d09b260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/2088d09b260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..1ce492c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/2088d09b260d00131a9bb9bc5a5e6171
@@ -0,0 +1,22 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/30e8770c260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/30e8770c260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..3a65842
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/30e8770c260d00131a9bb9bc5a5e6171
@@ -0,0 +1,71 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ public enum Event {
+ hasToken
+ }
+
+
+ static HashMap<Class<?>, HashMap<Event, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Event event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Event, Class<?>> h = new HashMap<Event, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Event, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Event, Class<?>> h = new HashMap<Event, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Event, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Event, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/d04b30d8520d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/d04b30d8520d00131719b896d543f08c
new file mode 100644
index 0000000..6623a65
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4c/d04b30d8520d00131719b896d543f08c
@@ -0,0 +1,62 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.snedMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/40eb8393390d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/40eb8393390d00131524a793807f338e
new file mode 100644
index 0000000..71415fe
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/40eb8393390d00131524a793807f338e
@@ -0,0 +1,85 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ //fromGPS = new Handler();
+ tTransam = new Thread(transam);
+ tTransam.run();
+ System.out.println("!!!!!!");
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/5025c807320d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/5025c807320d00131249f322b63acde8
new file mode 100644
index 0000000..a06c885
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/5025c807320d00131249f322b63acde8
@@ -0,0 +1,82 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+
+ static ActivityStatus status;
+
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static Transam transam = null;
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ new Thread(transam).run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/60e7a753340d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/60e7a753340d00131249f322b63acde8
new file mode 100644
index 0000000..bfd9398
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/60e7a753340d00131249f322b63acde8
@@ -0,0 +1,58 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/709e4dd5770d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/709e4dd5770d00131719b896d543f08c
new file mode 100644
index 0000000..4e44cb4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/709e4dd5770d00131719b896d543f08c
@@ -0,0 +1,193 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ autodate = new Timer();
+
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/d078d3c5670d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/d078d3c5670d00131719b896d543f08c
new file mode 100644
index 0000000..051eaf6
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4e/d078d3c5670d00131719b896d543f08c
@@ -0,0 +1,87 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/4f/20629bba350d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4f/20629bba350d00131249f322b63acde8
new file mode 100644
index 0000000..1bb7e9a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/4f/20629bba350d00131249f322b63acde8
@@ -0,0 +1,66 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ }
+ }
+ };
+
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5/c09802f4810d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5/c09802f4810d00131719b896d543f08c
new file mode 100644
index 0000000..c1827b4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5/c09802f4810d00131719b896d543f08c
@@ -0,0 +1,28 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+ static int myGroup = -1;
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+
+ static HashMap<Integer, Group> mp;
+
+ static void init() {
+ mp = new HashMap<Integer, Group>();
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/51/1058bc287a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/51/1058bc287a0d00131719b896d543f08c
new file mode 100644
index 0000000..7df8334
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/51/1058bc287a0d00131719b896d543f08c
@@ -0,0 +1,195 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == TimerFlush) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1, System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/51/d01e0d2c7c0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/51/d01e0d2c7c0d00131719b896d543f08c
new file mode 100644
index 0000000..5315060
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/51/d01e0d2c7c0d00131719b896d543f08c
@@ -0,0 +1,202 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ else {
+ ReqUpdate r = new ReqUpdate(UserInfo.token,
+ l.getLatitude(), l.getLongitude(),
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == TimerFlush) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ autodate.schedule(new AutoUpdate(), 0, 5000);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/51/e043216f2c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/51/e043216f2c0d00131249f322b63acde8
new file mode 100644
index 0000000..2771596
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/51/e043216f2c0d00131249f322b63acde8
@@ -0,0 +1,31 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/52/80fa1082370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/52/80fa1082370d00131249f322b63acde8
new file mode 100644
index 0000000..5b68421
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/52/80fa1082370d00131249f322b63acde8
@@ -0,0 +1,80 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/52/908340203a0d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/52/908340203a0d00131524a793807f338e
new file mode 100644
index 0000000..08d6230
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/52/908340203a0d00131524a793807f338e
@@ -0,0 +1,101 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/52/b0f7e5f4300d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/52/b0f7e5f4300d00131249f322b63acde8
new file mode 100644
index 0000000..3ca0dfe
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/52/b0f7e5f4300d00131249f322b63acde8
@@ -0,0 +1,133 @@
+package com.macaroon.piztor;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.annotation.SuppressLint;
+import android.os.Handler;
+import android.os.Message;
+
+public class Transam implements Runnable {
+
+ public Timer timer;
+ public Timer mtimer;
+ public boolean running = false;
+ public boolean flag = true;
+ public int cnt = 4;
+ Res res;
+ Req req;
+ public int p; //port
+ public String i; //ip
+ Thread thread;
+ Handler core;
+ Handler recall; //recall
+ Queue<Req> reqtask ; //request task
+
+ Transam(String ip, int port,Handler Recall) {
+ p = port;
+ i = ip;
+ recall = Recall;
+ reqtask = new LinkedList<Req>();
+ }
+
+ public void send(Req r){
+ reqtask.offer(r);
+
+ }
+
+ public void run() { //start the main timer
+ //TimerTask tmain = new Timertk();
+ //mtimer = new Timer();
+ //mtimer.schedule(tmain, 100, 100); //check the queue for every 100 msec
+
+ while(true){
+ if(running == false){
+
+ if(!reqtask.isEmpty()){ //poll the head request
+ req = reqtask.poll();
+ if(req.time + req.alive < System.currentTimeMillis()){ //time out!
+ Message ret = new Message();
+ ret.obj = "Time out!";
+ ret.what = 100;
+ recall.sendMessage(ret);
+ }
+ else{ //run the request
+ final thd t = new thd();
+ flag = false;
+ thread = new Thread(t);
+ cnt = 4;
+ running = true;
+ thread.start();
+ timer = new Timer();
+ TimerTask task = new Timertk();
+ timer.schedule(task, 2000, 2000);
+ }
+ }
+ }
+ }
+ }
+
+ class tmain extends TimerTask {
+ public void run() {
+
+ }
+ };
+
+ class thd implements Runnable {
+ public void run() {
+ try {
+ SocketClient client = new SocketClient(i,p);
+ client.sendMsg(req,recall);
+ Message msg = new Message();
+ msg.what = 1;
+ handler.sendMessage(msg);
+ client.closeSocket();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ System.out.println("UnknownHostException");
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("IOException");
+ }
+
+ }
+ }
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case 1:
+ flag = true;
+ break;
+ case 2:
+ final thd t = new thd();
+ thread = new Thread(t);
+ thread.start();
+ break;
+ }
+ super.handleMessage(msg);
+ }
+ };
+
+ class Timertk extends TimerTask {
+ public void run() {
+ if (flag == false && cnt > 0) {
+ cnt--;
+ } else if (cnt == 0) {
+ Message msg = new Message();
+ msg.obj = "connecting failed";
+ msg.what = 101;
+ recall.sendMessage(msg);
+ timer.cancel();
+ } else if (flag == true) {
+ timer.cancel();
+ running = false;
+ }
+ }
+ };
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/53/20300883550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/53/20300883550d00131719b896d543f08c
new file mode 100644
index 0000000..c808aa2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/53/20300883550d00131719b896d543f08c
@@ -0,0 +1,67 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/53/a06c6384500d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/53/a06c6384500d00131719b896d543f08c
new file mode 100644
index 0000000..dd6b5ed
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/53/a06c6384500d00131719b896d543f08c
@@ -0,0 +1,92 @@
+<?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
+ 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
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ 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/white"
+ 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" />
+ </LinearLayout>
+
+</LinearLayout>
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/53/b0d150cf4d0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/53/b0d150cf4d0d00131719b896d543f08c
new file mode 100644
index 0000000..8ce051f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/53/b0d150cf4d0d00131719b896d543f08c
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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:orientation="horizontal" >
+
+ <RelativeLayout
+ android:id="@+id/settings_headbar_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true" >
+
+ <include layout="@layout/settings_headbar" />
+ </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="wrap_content"
+ android:orientation="horizontal"
+ -->
+ <!-- TextView
+ android:id="@+id/GPS_min_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentLeft="true"
+ android:layout_marginLeft="10dip"
+ android:text="1s"
+ android:textSize="10dip"
+ android:textColor="@android:color/white"/-->
+
+ <!--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" />
+
+ <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/.metadata/.plugins/org.eclipse.core.resources/.history/54/105bdc86800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/54/105bdc86800d00131719b896d543f08c
new file mode 100644
index 0000000..02ab321
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/54/105bdc86800d00131719b896d543f08c
@@ -0,0 +1,19 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+
+ static class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ static class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/55/c0697f702b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/55/c0697f702b0d00131249f322b63acde8
new file mode 100644
index 0000000..5b597a4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/55/c0697f702b0d00131249f322b63acde8
@@ -0,0 +1,15 @@
+package com.macaroon.piztor;
+
+
+//--------------------------------------//
+// Respond to login //
+//--------------------------------------//
+
+public class ResLogin extends Res{
+ int t; //user token
+
+ ResLogin(int token,int status){
+ super(0,status); //for type 0
+ t = token;
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/56/70ea45fe4b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/56/70ea45fe4b0d00131719b896d543f08c
new file mode 100644
index 0000000..cc59885
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/56/70ea45fe4b0d00131719b896d543f08c
@@ -0,0 +1,102 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ System.out.println(user + " : " + pass + "\n");
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/56/e0d3f982370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/56/e0d3f982370d00131249f322b63acde8
new file mode 100644
index 0000000..270e26b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/56/e0d3f982370d00131249f322b63acde8
@@ -0,0 +1,96 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/58/c0259769680d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/58/c0259769680d00131719b896d543f08c
new file mode 100644
index 0000000..217c86a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/58/c0259769680d00131719b896d543f08c
@@ -0,0 +1,92 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/59/604165f5520d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/59/604165f5520d00131719b896d543f08c
new file mode 100644
index 0000000..de79560
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/59/604165f5520d00131719b896d543f08c
@@ -0,0 +1,62 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/59/b0dfede04f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/59/b0dfede04f0d00131719b896d543f08c
new file mode 100644
index 0000000..3ba7c18
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/59/b0dfede04f0d00131719b896d543f08c
@@ -0,0 +1,21 @@
+<resources>
+
+ <string name="app_name">piztor</string>
+ <string name="action_settings">Settings</string>
+ <string name="hello_world">Hello world!</string>
+ <string name="settings">Settings</string>
+ <string name="search">Search</string>
+ <string name="fetch">Fetch</string>
+ <string name="checkin">Checkin</string>
+ <string name="focus">Focus</string>
+ <string name="show_sex">Show sex: </string>
+ <string name="male">Male</string>
+ <string name="female">Female</string>
+ <string name="show_team">Show team: </string>
+ <string name="all">All</string>
+ <string name="mine">Mine</string>
+ <string name="title_activity_login">Login</string>
+ <string name="title_activity_main">Main</string>
+
+
+</resources>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5a/1067b967520d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5a/1067b967520d00131719b896d543f08c
new file mode 100644
index 0000000..bd67eb4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5a/1067b967520d00131719b896d543f08c
@@ -0,0 +1,62 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 1; // 1 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Controller newController, Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5a/20289dc1250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5a/20289dc1250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..9259786
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5a/20289dc1250d00131a9bb9bc5a5e6171
@@ -0,0 +1,62 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5b/a01d01234f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5b/a01d01234f0d00131719b896d543f08c
new file mode 100644
index 0000000..5ef6d3d
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5b/a01d01234f0d00131719b896d543f08c
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/title_activity_main" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Setting"
+ android:label="@string/title_activity_setting" >
+ </activity>
+ </application>
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5b/b09b88be520d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5b/b09b88be520d00131719b896d543f08c
new file mode 100644
index 0000000..5c0e0de
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5b/b09b88be520d00131719b896d543f08c
@@ -0,0 +1,62 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 1; // 1 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5c/40ac8a2a760d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5c/40ac8a2a760d00131719b896d543f08c
new file mode 100644
index 0000000..b542348
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5c/40ac8a2a760d00131719b896d543f08c
@@ -0,0 +1,174 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation r = (ResLocation) m.obj;
+ Vector<Rlocation> l = r.l;
+ for (int i = 0; i < n; i++) {
+ System.out.println(l.get(i).lat + " " + l.get(i).lot);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5c/a0a26974330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5c/a0a26974330d00131249f322b63acde8
new file mode 100644
index 0000000..0b0b39c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5c/a0a26974330d00131249f322b63acde8
@@ -0,0 +1,53 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/10ddd0bd550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/10ddd0bd550d00131719b896d543f08c
new file mode 100644
index 0000000..5356063
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/10ddd0bd550d00131719b896d543f08c
@@ -0,0 +1,68 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.location.Location;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ Location location = myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/b06ac273760d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/b06ac273760d00131719b896d543f08c
new file mode 100644
index 0000000..70fe77c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5d/b06ac273760d00131719b896d543f08c
@@ -0,0 +1,174 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation r = (ResLocation) m.obj;
+ for (int i = 0; i < r.n; i++) {
+ System.out.println(r.l.get(i).lat + " " + r.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5e/5026feaa340d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5e/5026feaa340d00131249f322b63acde8
new file mode 100644
index 0000000..4aaa9a5
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5e/5026feaa340d00131249f322b63acde8
@@ -0,0 +1,61 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ actMgr.trigger(AppMgr.loginSuccess);
+ }
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/5f/40817ce9810d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5f/40817ce9810d00131719b896d543f08c
new file mode 100644
index 0000000..18e7b2b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/5f/40817ce9810d00131719b896d543f08c
@@ -0,0 +1,28 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+ static int myGroup = -1;
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+
+ static HashMap<Integer, Group> mp;
+
+ static void init() {
+ mp = new HashMap<Integer, Group>;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/6/509d88ee670d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6/509d88ee670d00131719b896d543f08c
new file mode 100644
index 0000000..7630c2a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6/509d88ee670d00131719b896d543f08c
@@ -0,0 +1,91 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/60/c0fbac51760d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/60/c0fbac51760d00131719b896d543f08c
new file mode 100644
index 0000000..460b7e4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/60/c0fbac51760d00131719b896d543f08c
@@ -0,0 +1,173 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation r = (ResLocation) m.obj;
+ for (int i = 0; i < r.n; i++) {
+ System.out.println(r.l.get(i).lat + " " + r.l.get(i).lot);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/61/503835816a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/61/503835816a0d00131719b896d543f08c
new file mode 100644
index 0000000..1ebf61c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/61/503835816a0d00131719b896d543f08c
@@ -0,0 +1,116 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/62/f050f6cd300d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/62/f050f6cd300d00131249f322b63acde8
new file mode 100644
index 0000000..c31924d
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/62/f050f6cd300d00131249f322b63acde8
@@ -0,0 +1,132 @@
+package com.macaroon.piztor;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.annotation.SuppressLint;
+import android.os.Handler;
+import android.os.Message;
+
+public class Transam implements Runnable {
+ public Timer timer;
+ public Timer mtimer;
+ public boolean running = false;
+ public boolean flag = true;
+ public int cnt = 4;
+ Res res;
+ Req req;
+ public int p; //port
+ public String i; //ip
+ Thread thread;
+ Handler core;
+ Handler recall; //recall
+ Queue<Req> reqtask ; //request task
+
+ Transam(String ip, int port,Handler Recall) {
+ p = port;
+ i = ip;
+ recall = Recall;
+ reqtask = new LinkedList<Req>();
+ }
+
+ public void send(Req r){
+ reqtask.offer(r);
+
+ }
+
+ public void run() { //start the main timer
+ //TimerTask tmain = new Timertk();
+ //mtimer = new Timer();
+ //mtimer.schedule(tmain, 100, 100); //check the queue for every 100 msec
+
+ while(true){
+ if(running == false){
+
+ if(!reqtask.isEmpty()){ //poll the head request
+ req = reqtask.poll();
+ if(req.time + req.alive < System.currentTimeMillis()){ //time out!
+ Message ret = new Message();
+ ret.obj = "Time out!";
+ ret.what = 100;
+ recall.sendMessage(ret);
+ }
+ else{ //run the request
+ final thd t = new thd();
+ flag = false;
+ thread = new Thread(t);
+ cnt = 4;
+ running = true;
+ thread.start();
+ timer = new Timer();
+ TimerTask task = new Timertk();
+ timer.schedule(task, 2000, 2000);
+ }
+ }
+ }
+ }
+ }
+
+ class tmain extends TimerTask {
+ public void run() {
+
+ }
+ };
+
+ class thd implements Runnable {
+ public void run() {
+ try {
+ SocketClient client = new SocketClient(i,p);
+ client.sendMsg(req,recall);
+ Message msg = new Message();
+ msg.what = 1;
+ handler.sendMessage(msg);
+ client.closeSocket();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ System.out.println("UnknownHostException");
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("IOException");
+ }
+
+ }
+ }
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case 1:
+ flag = true;
+ break;
+ case 2:
+ final thd t = new thd();
+ thread = new Thread(t);
+ thread.start();
+ break;
+ }
+ super.handleMessage(msg);
+ }
+ };
+
+ class Timertk extends TimerTask {
+ public void run() {
+ if (flag == false && cnt > 0) {
+ cnt--;
+ } else if (cnt == 0) {
+ Message msg = new Message();
+ msg.obj = "connecting failed";
+ msg.what = 101;
+ recall.sendMessage(msg);
+ timer.cancel();
+ } else if (flag == true) {
+ timer.cancel();
+ running = false;
+ }
+ }
+ };
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/65/10afe9c2560d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/65/10afe9c2560d00131719b896d543f08c
new file mode 100644
index 0000000..d2c7c5f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/65/10afe9c2560d00131719b896d543f08c
@@ -0,0 +1,68 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.location.Location;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ Location location = myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ message = new Message();
+ message.what = 0;
+ message.obj = location;
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message = new Message();
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/65/7015966a370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/65/7015966a370d00131249f322b63acde8
new file mode 100644
index 0000000..5254e91
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/65/7015966a370d00131249f322b63acde8
@@ -0,0 +1,83 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/65/c008735d330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/65/c008735d330d00131249f322b63acde8
new file mode 100644
index 0000000..4660356
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/65/c008735d330d00131249f322b63acde8
@@ -0,0 +1,134 @@
+package com.macaroon.piztor;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.annotation.SuppressLint;
+import android.os.Handler;
+import android.os.Message;
+
+public class Transam implements Runnable {
+
+ public Timer timer;
+ public Timer mtimer;
+ public boolean running = false;
+ public boolean flag = true;
+ public int cnt = 4;
+ Res res;
+ Req req;
+ public int p; // port
+ public String i; // ip
+ Thread thread;
+ Handler core;
+ Handler recall; // recall
+ Queue<Req> reqtask; // request task
+
+ Transam(String ip, int port, Handler Recall) {
+ p = port;
+ i = ip;
+ recall = Recall;
+ reqtask = new LinkedList<Req>();
+ }
+
+ public void send(Req r) {
+ reqtask.offer(r);
+
+ }
+
+ public void run() { // start the main timer
+ // TimerTask tmain = new Timertk();
+ // mtimer = new Timer();
+ // mtimer.schedule(tmain, 100, 100); //check the queue for every 100
+ // msec
+
+ while (true) {
+ if (running == false) {
+
+ if (!reqtask.isEmpty()) { // poll the head request
+ req = reqtask.poll();
+ if (req.time + req.alive < System.currentTimeMillis()) { // time
+ // out!
+ Message ret = new Message();
+ ret.obj = "Time out!";
+ ret.what = 100;
+ recall.sendMessage(ret);
+ } else { // run the request
+ final thd t = new thd();
+ flag = false;
+ thread = new Thread(t);
+ cnt = 4;
+ running = true;
+ thread.start();
+ timer = new Timer();
+ TimerTask task = new Timertk();
+ timer.schedule(task, 2000, 2000);
+ }
+ }
+ }
+ }
+ }
+
+ class tmain extends TimerTask {
+ public void run() {
+
+ }
+ };
+
+ class thd implements Runnable {
+ public void run() {
+ try {
+ SocketClient client = new SocketClient(i, p);
+ client.sendMsg(req, recall);
+ Message msg = new Message();
+ msg.what = 1;
+ handler.sendMessage(msg);
+ client.closeSocket();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ System.out.println("UnknownHostException");
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("IOException");
+ }
+
+ }
+ }
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case 1:
+ flag = true;
+ break;
+ case 2:
+ final thd t = new thd();
+ thread = new Thread(t);
+ thread.start();
+ break;
+ }
+ super.handleMessage(msg);
+ }
+ };
+
+ class Timertk extends TimerTask {
+ public void run() {
+ if (flag == false && cnt > 0) {
+ cnt--;
+ } else if (cnt == 0) {
+ Message msg = new Message();
+ msg.obj = "connecting failed";
+ msg.what = 101;
+ recall.sendMessage(msg);
+ timer.cancel();
+ } else if (flag == true) {
+ timer.cancel();
+ running = false;
+ }
+ }
+ };
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/66/108b1d6a2c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/66/108b1d6a2c0d00131249f322b63acde8
new file mode 100644
index 0000000..0547f4f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/66/108b1d6a2c0d00131249f322b63acde8
@@ -0,0 +1,72 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int hasToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, hasToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/67/7089926a2b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/67/7089926a2b0d00131249f322b63acde8
new file mode 100644
index 0000000..727eaa3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/67/7089926a2b0d00131249f322b63acde8
@@ -0,0 +1,13 @@
+package com.macaroon.piztor;
+
+
+//--------------------------------------//
+// Respond to update location //
+//--------------------------------------//
+
+public class ResUpdate extends Res{
+
+ ResUpdate(int status){
+ super(2,status); //for type 2
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/67/80e1a600230d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/67/80e1a600230d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..c846594
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/67/80e1a600230d00131a9bb9bc5a5e6171
@@ -0,0 +1,5 @@
+package com.macaroon.piztor;
+
+public class PiztorExcepiton {
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/6b/40af41ee250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6b/40af41ee250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..bab59bd
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6b/40af41ee250d00131a9bb9bc5a5e6171
@@ -0,0 +1,69 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int hasToken = 1;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/6b/50c980702b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6b/50c980702b0d00131249f322b63acde8
new file mode 100644
index 0000000..5b597a4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6b/50c980702b0d00131249f322b63acde8
@@ -0,0 +1,15 @@
+package com.macaroon.piztor;
+
+
+//--------------------------------------//
+// Respond to login //
+//--------------------------------------//
+
+public class ResLogin extends Res{
+ int t; //user token
+
+ ResLogin(int token,int status){
+ super(0,status); //for type 0
+ t = token;
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/6c/e0cb25df390d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6c/e0cb25df390d00131524a793807f338e
new file mode 100644
index 0000000..a4cce6a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6c/e0cb25df390d00131524a793807f338e
@@ -0,0 +1,99 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/6d/30ed916a2b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6d/30ed916a2b0d00131249f322b63acde8
new file mode 100644
index 0000000..727eaa3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6d/30ed916a2b0d00131249f322b63acde8
@@ -0,0 +1,13 @@
+package com.macaroon.piztor;
+
+
+//--------------------------------------//
+// Respond to update location //
+//--------------------------------------//
+
+public class ResUpdate extends Res{
+
+ ResUpdate(int status){
+ super(2,status); //for type 2
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/6e/a03ae288270d00131050e648e11def2a b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6e/a03ae288270d00131050e648e11def2a
new file mode 100644
index 0000000..3fdce81
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6e/a03ae288270d00131050e648e11def2a
@@ -0,0 +1,28 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ AppMgr.trigger(AppMgr.hasToken);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/6f/0020dd3c560d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6f/0020dd3c560d00131719b896d543f08c
new file mode 100644
index 0000000..3d9493d
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/6f/0020dd3c560d00131719b896d543f08c
@@ -0,0 +1,47 @@
+package com.macaroon.piztor;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.setStatus(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/102ad2cb800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/102ad2cb800d00131719b896d543f08c
new file mode 100644
index 0000000..62f8ddf
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/102ad2cb800d00131719b896d543f08c
@@ -0,0 +1,20 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+
+ static class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ static class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/10a4d736550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/10a4d736550d00131719b896d543f08c
new file mode 100644
index 0000000..7f1f47e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/10a4d736550d00131719b896d543f08c
@@ -0,0 +1,241 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public Location getLocation() {
+ try {
+
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/806200684f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/806200684f0d00131719b896d543f08c
new file mode 100644
index 0000000..51b8a69
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/806200684f0d00131719b896d543f08c
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/activity_main" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Setting"
+ android:label="@string/activity_settings" >
+ </activity>
+ </application>
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/b00ff61a380d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/b00ff61a380d00131249f322b63acde8
new file mode 100644
index 0000000..15022f6
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/b00ff61a380d00131249f322b63acde8
@@ -0,0 +1,97 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/f0c8a1b1330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/f0c8a1b1330d00131249f322b63acde8
new file mode 100644
index 0000000..6c8a359
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/f0c8a1b1330d00131249f322b63acde8
@@ -0,0 +1,58 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ boolean sendMessage(Message m) {
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/f0e31801750d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/f0e31801750d00131719b896d543f08c
new file mode 100644
index 0000000..e67e5cf
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7/f0e31801750d00131719b896d543f08c
@@ -0,0 +1,160 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what > 100) {
+
+ }
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/501f63f7750d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/501f63f7750d00131719b896d543f08c
new file mode 100644
index 0000000..3d2621d
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/501f63f7750d00131719b896d543f08c
@@ -0,0 +1,168 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case value:
+
+ break;
+
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/803f3d632b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/803f3d632b0d00131249f322b63acde8
new file mode 100644
index 0000000..294cae3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/803f3d632b0d00131249f322b63acde8
@@ -0,0 +1,16 @@
+package com.macaroon.piztor;
+
+//--------------------------------------//
+// authentication //
+//--------------------------------------//
+
+public class ReqLogin extends Req{
+ String user; //username
+ String pass; //password
+
+ ReqLogin(String u,String p,long time,long alive){
+ super(0,0,time,alive); //for type 0
+ user = u;
+ pass = p;
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/c00737b35b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/c00737b35b0d00131719b896d543f08c
new file mode 100644
index 0000000..4556ca2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/c00737b35b0d00131719b896d543f08c
@@ -0,0 +1,53 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/e041e862500d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/e041e862500d00131719b896d543f08c
new file mode 100644
index 0000000..7b27646
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/70/e041e862500d00131719b896d543f08c
@@ -0,0 +1,92 @@
+<?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
+ 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
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ 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/white"
+ 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/white"
+ />
+
+ <EditText
+ android:layout_width="0dp"
+ android:layout_weight="0.75"
+ android:id="@+id/user_pass"
+ android:password="true"
+ android:textColor="@android:color/white"
+ 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" />
+ </LinearLayout>
+
+</LinearLayout>
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/71/3084ff9b220d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/71/3084ff9b220d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..548ca95
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/71/3084ff9b220d00131a9bb9bc5a5e6171
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/71/b0d73212550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/71/b0d73212550d00131719b896d543f08c
new file mode 100644
index 0000000..8f887e6
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/71/b0d73212550d00131719b896d543f08c
@@ -0,0 +1,67 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/72/40aa3d7d680d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/72/40aa3d7d680d00131719b896d543f08c
new file mode 100644
index 0000000..7d0869e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/72/40aa3d7d680d00131719b896d543f08c
@@ -0,0 +1,109 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[1]);
+
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/72/7046908d340d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/72/7046908d340d00131249f322b63acde8
new file mode 100644
index 0000000..bce14da
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/72/7046908d340d00131249f322b63acde8
@@ -0,0 +1,61 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+
+ }
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/72/b0a7a169550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/72/b0a7a169550d00131719b896d543f08c
new file mode 100644
index 0000000..d20c14a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/72/b0a7a169550d00131719b896d543f08c
@@ -0,0 +1,240 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public Location getLocation() {
+ try {
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+ return location;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/73/006fa23d5a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/73/006fa23d5a0d00131719b896d543f08c
new file mode 100644
index 0000000..a931dae
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/73/006fa23d5a0d00131719b896d543f08c
@@ -0,0 +1,104 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ System.out.println(m.what);
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ System.out.println(user + " : " + pass + "\n");
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ AppMgr.transam.setHandler(hand);
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/73/c01d2030760d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/73/c01d2030760d00131719b896d543f08c
new file mode 100644
index 0000000..166091d
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/73/c01d2030760d00131719b896d543f08c
@@ -0,0 +1,173 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation r = (ResLocation) m.obj;
+ for (int i = 0; i < n; i++) {
+ System.out.println(r.l.get(i).lat + " " + r.l.get(i).lot);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/73/c08e77fb780d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/73/c08e77fb780d00131719b896d543f08c
new file mode 100644
index 0000000..e90c2ff
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/73/c08e77fb780d00131719b896d543f08c
@@ -0,0 +1,192 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/74/40c025d4770d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/74/40c025d4770d00131719b896d543f08c
new file mode 100644
index 0000000..75db4de
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/74/40c025d4770d00131719b896d543f08c
@@ -0,0 +1,182 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ autodate = new Timer();
+
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/74/80e6f54e800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/74/80e6f54e800d00131719b896d543f08c
new file mode 100644
index 0000000..ebce59c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/74/80e6f54e800d00131719b896d543f08c
@@ -0,0 +1,106 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ @SuppressLint("HandlerLeak")
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ System.out.println(m.what);
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ System.out.println(user + " : " + pass + "\n");
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ //TODO log out failed!
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ AppMgr.transam.setHandler(hand);
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/74/901b4f2c550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/74/901b4f2c550d00131719b896d543f08c
new file mode 100644
index 0000000..178f6b6
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/74/901b4f2c550d00131719b896d543f08c
@@ -0,0 +1,241 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public void getLocation() {
+ try {
+
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/75/601f31e7390d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/75/601f31e7390d00131524a793807f338e
new file mode 100644
index 0000000..b982501
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/75/601f31e7390d00131524a793807f338e
@@ -0,0 +1,99 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/75/b047617e310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/75/b047617e310d00131249f322b63acde8
new file mode 100644
index 0000000..c31924d
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/75/b047617e310d00131249f322b63acde8
@@ -0,0 +1,132 @@
+package com.macaroon.piztor;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.annotation.SuppressLint;
+import android.os.Handler;
+import android.os.Message;
+
+public class Transam implements Runnable {
+ public Timer timer;
+ public Timer mtimer;
+ public boolean running = false;
+ public boolean flag = true;
+ public int cnt = 4;
+ Res res;
+ Req req;
+ public int p; //port
+ public String i; //ip
+ Thread thread;
+ Handler core;
+ Handler recall; //recall
+ Queue<Req> reqtask ; //request task
+
+ Transam(String ip, int port,Handler Recall) {
+ p = port;
+ i = ip;
+ recall = Recall;
+ reqtask = new LinkedList<Req>();
+ }
+
+ public void send(Req r){
+ reqtask.offer(r);
+
+ }
+
+ public void run() { //start the main timer
+ //TimerTask tmain = new Timertk();
+ //mtimer = new Timer();
+ //mtimer.schedule(tmain, 100, 100); //check the queue for every 100 msec
+
+ while(true){
+ if(running == false){
+
+ if(!reqtask.isEmpty()){ //poll the head request
+ req = reqtask.poll();
+ if(req.time + req.alive < System.currentTimeMillis()){ //time out!
+ Message ret = new Message();
+ ret.obj = "Time out!";
+ ret.what = 100;
+ recall.sendMessage(ret);
+ }
+ else{ //run the request
+ final thd t = new thd();
+ flag = false;
+ thread = new Thread(t);
+ cnt = 4;
+ running = true;
+ thread.start();
+ timer = new Timer();
+ TimerTask task = new Timertk();
+ timer.schedule(task, 2000, 2000);
+ }
+ }
+ }
+ }
+ }
+
+ class tmain extends TimerTask {
+ public void run() {
+
+ }
+ };
+
+ class thd implements Runnable {
+ public void run() {
+ try {
+ SocketClient client = new SocketClient(i,p);
+ client.sendMsg(req,recall);
+ Message msg = new Message();
+ msg.what = 1;
+ handler.sendMessage(msg);
+ client.closeSocket();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ System.out.println("UnknownHostException");
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("IOException");
+ }
+
+ }
+ }
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case 1:
+ flag = true;
+ break;
+ case 2:
+ final thd t = new thd();
+ thread = new Thread(t);
+ thread.start();
+ break;
+ }
+ super.handleMessage(msg);
+ }
+ };
+
+ class Timertk extends TimerTask {
+ public void run() {
+ if (flag == false && cnt > 0) {
+ cnt--;
+ } else if (cnt == 0) {
+ Message msg = new Message();
+ msg.obj = "connecting failed";
+ msg.what = 101;
+ recall.sendMessage(msg);
+ timer.cancel();
+ } else if (flag == true) {
+ timer.cancel();
+ running = false;
+ }
+ }
+ };
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/76/207ce70b330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/76/207ce70b330d00131249f322b63acde8
new file mode 100644
index 0000000..4a180d9
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/76/207ce70b330d00131249f322b63acde8
@@ -0,0 +1,82 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ tTransam = new Thread(transam);
+ tTransam.run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/76/608e011f4f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/76/608e011f4f0d00131719b896d543f08c
new file mode 100644
index 0000000..75c5057
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/76/608e011f4f0d00131719b896d543f08c
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/title_activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/title_activity_main" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Setting"
+ android:label="@string/title_activity_setting" >
+ </activity>
+ </application>
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/77/e09023cf310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/77/e09023cf310d00131249f322b63acde8
new file mode 100644
index 0000000..2b4cf6c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/77/e09023cf310d00131249f322b63acde8
@@ -0,0 +1,35 @@
+package com.macaroon.piztor;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ AppMgr.fromTransam
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else {
+ //TODO jump to main
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/77/f09da14b290d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/77/f09da14b290d00131249f322b63acde8
new file mode 100644
index 0000000..2b15092
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/77/f09da14b290d00131249f322b63acde8
@@ -0,0 +1,30 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ id = "initAct";
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ AppMgr.trigger(AppMgr.hasToken);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/78/d014d7fc220d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/78/d014d7fc220d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/78/d014d7fc220d00131a9bb9bc5a5e6171
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/2065267c2c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/2065267c2c0d00131249f322b63acde8
new file mode 100644
index 0000000..c78bc91
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/2065267c2c0d00131249f322b63acde8
@@ -0,0 +1,33 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else {
+
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/90c475984b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/90c475984b0d00131719b896d543f08c
new file mode 100644
index 0000000..5be3de8
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/79/90c475984b0d00131719b896d543f08c
@@ -0,0 +1,63 @@
+package com.macaroon.piztor;
+
+import java.util.*;
+
+import android.annotation.SuppressLint;
+
+@SuppressLint("UseSparseArrays")
+public class ActMgr {
+ // event
+ PiztorAct act;
+ ActStatus nowStatus;
+ HashMap<ActStatus, HashMap<Integer, ActStatus>> mp;
+
+ ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) {
+ this.act = act;
+ this.nowStatus = nowStatus;
+ mp = new HashMap<ActStatus, HashMap<Integer, ActStatus>>();
+ for (int i = 0; i < r.length; i++) {
+ mp.put(r[i], new HashMap<Integer, ActStatus>());
+ }
+ }
+
+ void trigger(int event) {
+ for (Integer i : mp.get(nowStatus).keySet())
+ System.out.println(i);
+ if (mp.get(nowStatus).containsKey(event)) {
+ nowStatus.leave(event);
+ nowStatus = mp.get(nowStatus).get(event);
+ nowStatus.enter(event);
+ } else if (AppMgr.mp.get(act.getClass()).containsKey(event)) {
+ AppMgr.trigger(event);
+ }
+ }
+
+ void add(ActStatus a, int event, ActStatus b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, ActStatus> h = mp.get(a);
+ h.put(event, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, ActStatus> h = new HashMap<Integer, ActStatus>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+}
+
+abstract class ActStatus {
+ abstract void enter(int e);
+
+ abstract void leave(int e);
+}
+
+class EmptyStatus extends ActStatus {
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7a/906f6f46800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7a/906f6f46800d00131719b896d543f08c
new file mode 100644
index 0000000..cc44346
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7a/906f6f46800d00131719b896d543f08c
@@ -0,0 +1,9 @@
+package com.macaroon.piztor;
+
+public class UserInfo {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7b/5015928e500d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7b/5015928e500d00131719b896d543f08c
new file mode 100644
index 0000000..75c5057
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7b/5015928e500d00131719b896d543f08c
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/title_activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/title_activity_main" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Setting"
+ android:label="@string/title_activity_setting" >
+ </activity>
+ </application>
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7b/b0d770546b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7b/b0d770546b0d00131719b896d543f08c
new file mode 100644
index 0000000..e888998
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7b/b0d770546b0d00131719b896d543f08c
@@ -0,0 +1,151 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7c/f0024b04260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7c/f0024b04260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..09e1dbc
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7c/f0024b04260d00131a9bb9bc5a5e6171
@@ -0,0 +1,71 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ public enum Event {
+ hasToken
+ }
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7c/f0272c32560d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7c/f0272c32560d00131719b896d543f08c
new file mode 100644
index 0000000..7a124ca
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7c/f0272c32560d00131719b896d543f08c
@@ -0,0 +1,46 @@
+package com.macaroon.piztor;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7d/10fd3cab810d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7d/10fd3cab810d00131719b896d543f08c
new file mode 100644
index 0000000..dad95a8
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7d/10fd3cab810d00131719b896d543f08c
@@ -0,0 +1,23 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+
+ static HashMap<Integer, Group> mp;
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7d/e021b37a330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7d/e021b37a330d00131249f322b63acde8
new file mode 100644
index 0000000..4aa65b2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7d/e021b37a330d00131249f322b63acde8
@@ -0,0 +1,54 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7e/00390e21280d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7e/00390e21280d00131249f322b63acde8
new file mode 100644
index 0000000..422fa96
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7e/00390e21280d00131249f322b63acde8
@@ -0,0 +1,29 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ id = "initAct";
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ AppMgr.trigger(AppMgr.hasToken);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7e/a0c4a019530d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7e/a0c4a019530d00131719b896d543f08c
new file mode 100644
index 0000000..52bb70a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7e/a0c4a019530d00131719b896d543f08c
@@ -0,0 +1,33 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ Handler handler = new Handler() {
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/7f/5045a039260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7f/5045a039260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..b40257e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/7f/5045a039260d00131a9bb9bc5a5e6171
@@ -0,0 +1,71 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ public enum Event {
+ hasToken
+ }
+
+
+ static HashMap<Class<?>, HashMap<Event, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(Event event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Event event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Event, Class<?>> h = new HashMap<Event, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, Event i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Event, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Event, Class<?>> h = new HashMap<Event, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Event, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Event, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, hasToken, Login.class);
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8/208ac81c560d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8/208ac81c560d00131719b896d543f08c
new file mode 100644
index 0000000..8af3bb7
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8/208ac81c560d00131719b896d543f08c
@@ -0,0 +1,45 @@
+package com.macaroon.piztor;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(), l.getLongitude(), time, alive)
+ AppMgr.transam.send();
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8/40515524760d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8/40515524760d00131719b896d543f08c
new file mode 100644
index 0000000..9464802
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8/40515524760d00131719b896d543f08c
@@ -0,0 +1,173 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ Vector<Rlocation> l =(Vector<Rlocation>) m.obj;
+ for (int i = 0; i < n; i++) {
+ System.out.println(l.get(i).lat + " " + l.get(i).lot);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8/c064fb4e800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8/c064fb4e800d00131719b896d543f08c
new file mode 100644
index 0000000..929c0bb
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8/c064fb4e800d00131719b896d543f08c
@@ -0,0 +1,8 @@
+package com.macaroon.piztor;
+
+public class UserInfo {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/80/706d105f250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/80/706d105f250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..629f1c1
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/80/706d105f250d00131a9bb9bc5a5e6171
@@ -0,0 +1,90 @@
+<?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
+ 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
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ 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: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/white"
+ />
+
+ <EditText
+ android:layout_width="0dp"
+ android:layout_weight="0.75"
+ android:id="@+id/user_pass"
+ android:password="true"
+ 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" />
+ </LinearLayout>
+
+</LinearLayout>
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/80/9080b2de4d0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/80/9080b2de4d0d00131719b896d543f08c
new file mode 100644
index 0000000..69760c0
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/80/9080b2de4d0d00131719b896d543f08c
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="48dip"
+ android:orientation="horizontal"
+ android:background="@drawable/footbar_background" >
+
+ <LinearLayout
+ android:id="@+id/footbar_btn_search_layout"
+ android:layout_width="64dip"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_marginTop="3dip"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1">
+ <ImageButton
+ android:id="@+id/footbar_btn_search"
+ android:layout_width="30dip"
+ android:layout_height="30dip"
+ android:layout_gravity="center"
+ android:background="@drawable/footbar_btn_search_style"/>
+ <TextView
+ android:id="@+id/footbar_btn_search"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:textSize="10dip"
+ android:textColor="@android:color/white"
+ android:layout_gravity="center"
+ android:text="@string/search"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/footbar_btn_fetch_layout"
+ android:layout_width="64dip"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_marginTop="3dip"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1">
+ <ImageButton
+ android:id="@+id/footbar_btn_fetch"
+ android:layout_width="30dip"
+ android:layout_height="30dip"
+ android:layout_gravity="center"
+ android:background="@drawable/footbar_btn_fetch_style"/>
+ <TextView
+ android:id="@+id/footbar_btn_fetch_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:textSize="10dip"
+ android:textColor="@android:color/white"
+ android:layout_gravity="center"
+ android:text="@string/fetch"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/footbar_btn_focus_layout"
+ android:layout_width="64dip"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_marginTop="3dip"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1">
+ <ImageButton
+ android:id="@+id/footbar_btn_focus"
+ android:layout_width="30dip"
+ android:layout_height="30dip"
+ android:layout_gravity="center"
+ android:background="@drawable/footbar_btn_focus_style"/>
+ <TextView
+ android:id="@+id/footbar_btn_focus_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:textSize="10dip"
+ android:textColor="@android:color/white"
+ android:layout_gravity="center"
+ android:text="@string/focus"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/footbar_btn_settings_layout"
+ android:layout_width="64dip"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_marginTop="3dip"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1">
+ <ImageButton
+ android:id="@+id/footbar_btn_settings"
+ android:layout_width="30dip"
+ android:layout_height="30dip"
+ android:layout_gravity="center"
+ android:background="@drawable/footbar_btn_settings_style"/>
+ <TextView
+ android:id="@+id/footbar_btn_settings_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:textSize="10dip"
+ android:textColor="@android:color/white"
+ android:text="@string/settings"/>
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/81/10091b6d2b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/81/10091b6d2b0d00131249f322b63acde8
new file mode 100644
index 0000000..eb90840
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/81/10091b6d2b0d00131249f322b63acde8
@@ -0,0 +1,18 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+//--------------------------------------//
+// Location Info //
+//--------------------------------------//
+
+public class ResLocation extends Res{
+ Vector<Rlocation> l; //vector for location info
+ int n; //number of location info
+
+ ResLocation(int num,Vector<Rlocation> locationvec){
+ super(3,255); //for type 3
+ l = locationvec;
+ n = num;
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/81/60af4207370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/81/60af4207370d00131249f322b63acde8
new file mode 100644
index 0000000..7033236
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/81/60af4207370d00131249f322b63acde8
@@ -0,0 +1,63 @@
+package com.macaroon.piztor;
+
+import java.util.*;
+
+import android.annotation.SuppressLint;
+
+@SuppressLint("UseSparseArrays")
+public class ActMgr {
+ // event
+ PiztorAct act;
+ ActStatus nowStatus;
+ HashMap<ActStatus, HashMap<Integer, ActStatus>> mp;
+
+ ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) {
+ this.act = act;
+ this.nowStatus = nowStatus;
+ mp = new HashMap<ActStatus, HashMap<Integer, ActStatus>>();
+ for (int i = 0; i < r.length; i++) {
+ mp.put(r[i], new HashMap<Integer, ActStatus>());
+ }
+ }
+
+ void trigger(int event) {
+ //for (Integer i : mp.get(nowStatus).keySet())
+ //System.out.println(i);
+ if (mp.get(nowStatus).containsKey(event)) {
+ nowStatus.leave(event);
+ nowStatus = mp.get(nowStatus).get(event);
+ nowStatus.enter(event);
+ } else if (AppMgr.mp.get(act.getClass()).containsKey(event)) {
+ AppMgr.trigger(event);
+ }
+ }
+
+ void add(ActStatus a, int event, ActStatus b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, ActStatus> h = mp.get(a);
+ h.put(event, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, ActStatus> h = new HashMap<Integer, ActStatus>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+}
+
+abstract class ActStatus {
+ abstract void enter(int e);
+
+ abstract void leave(int e);
+}
+
+class EmptyStatus extends ActStatus {
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/81/d0e51ef7320d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/81/d0e51ef7320d00131249f322b63acde8
new file mode 100644
index 0000000..c2f876b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/81/d0e51ef7320d00131249f322b63acde8
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/title_activity_login" >
+ </activity>
+ </application>
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/82/70f000a8770d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/82/70f000a8770d00131719b896d543f08c
new file mode 100644
index 0000000..8991894
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/82/70f000a8770d00131719b896d543f08c
@@ -0,0 +1,178 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/82/909cd18d310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/82/909cd18d310d00131249f322b63acde8
new file mode 100644
index 0000000..9f6ec22
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/82/909cd18d310d00131249f322b63acde8
@@ -0,0 +1,133 @@
+package com.macaroon.piztor;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.annotation.SuppressLint;
+import android.os.Handler;
+import android.os.Message;
+
+public class Transam implements Runnable {
+ public Timer timer;
+ public Timer mtimer;
+ public boolean running = false;
+ public boolean flag = true;
+ public int cnt = 4;
+ Res res;
+ Req req;
+ public int p; // port
+ public String i; // ip
+ Thread thread;
+ Handler core;
+ Handler recall; // recall
+ Queue<Req> reqtask; // request task
+
+ Transam(String ip, int port, Handler Recall) {
+ p = port;
+ i = ip;
+ recall = Recall;
+ reqtask = new LinkedList<Req>();
+ }
+
+ public void send(Req r) {
+ reqtask.offer(r);
+
+ }
+
+ public void run() { // start the main timer
+ // TimerTask tmain = new Timertk();
+ // mtimer = new Timer();
+ // mtimer.schedule(tmain, 100, 100); //check the queue for every 100
+ // msec
+
+ while (true) {
+ if (running == false) {
+
+ if (!reqtask.isEmpty()) { // poll the head request
+ req = reqtask.poll();
+ if (req.time + req.alive < System.currentTimeMillis()) { // time
+ // out!
+ Message ret = new Message();
+ ret.obj = "Time out!";
+ ret.what = 100;
+ recall.sendMessage(ret);
+ } else { // run the request
+ final thd t = new thd();
+ flag = false;
+ thread = new Thread(t);
+ cnt = 4;
+ running = true;
+ thread.start();
+ timer = new Timer();
+ TimerTask task = new Timertk();
+ timer.schedule(task, 2000, 2000);
+ }
+ }
+ }
+ }
+ }
+
+ class tmain extends TimerTask {
+ public void run() {
+
+ }
+ };
+
+ class thd implements Runnable {
+ public void run() {
+ try {
+ SocketClient client = new SocketClient(i, p);
+ client.sendMsg(req, recall);
+ Message msg = new Message();
+ msg.what = 1;
+ handler.sendMessage(msg);
+ client.closeSocket();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ System.out.println("UnknownHostException");
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("IOException");
+ }
+
+ }
+ }
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case 1:
+ flag = true;
+ break;
+ case 2:
+ final thd t = new thd();
+ thread = new Thread(t);
+ thread.start();
+ break;
+ }
+ super.handleMessage(msg);
+ }
+ };
+
+ class Timertk extends TimerTask {
+ public void run() {
+ if (flag == false && cnt > 0) {
+ cnt--;
+ } else if (cnt == 0) {
+ Message msg = new Message();
+ msg.obj = "connecting failed";
+ msg.what = 101;
+ recall.sendMessage(msg);
+ timer.cancel();
+ } else if (flag == true) {
+ timer.cancel();
+ running = false;
+ }
+ }
+ };
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/30d53cf3280d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/30d53cf3280d00131249f322b63acde8
new file mode 100644
index 0000000..54242d5
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/30d53cf3280d00131249f322b63acde8
@@ -0,0 +1,69 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int hasToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, hasToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/700a3adf290d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/700a3adf290d00131249f322b63acde8
new file mode 100644
index 0000000..63770f2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/700a3adf290d00131249f322b63acde8
@@ -0,0 +1,31 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ AppMgr.trigger(AppMgr.hasToken);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/901e3ac8250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/901e3ac8250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..7b0bee0
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/901e3ac8250d00131a9bb9bc5a5e6171
@@ -0,0 +1,64 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/c01bf7ee550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/c01bf7ee550d00131719b896d543f08c
new file mode 100644
index 0000000..3019420
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/c01bf7ee550d00131719b896d543f08c
@@ -0,0 +1,67 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.location.Location;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ Location location = myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ message = new Message();
+ message.what = 0;
+ message.obj = location;
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/c080c339520d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/c080c339520d00131719b896d543f08c
new file mode 100644
index 0000000..38a6106
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/84/c080c339520d00131719b896d543f08c
@@ -0,0 +1,241 @@
+package com.example.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 1; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public void getLocation() {
+ try {
+
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/86/90090791270d00131050e648e11def2a b/client/.metadata/.plugins/org.eclipse.core.resources/.history/86/90090791270d00131050e648e11def2a
new file mode 100644
index 0000000..c92af4b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/86/90090791270d00131050e648e11def2a
@@ -0,0 +1,22 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class Login extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/86/b0ac05a2810d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/86/b0ac05a2810d00131719b896d543f08c
new file mode 100644
index 0000000..2b10d1b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/86/b0ac05a2810d00131719b896d543f08c
@@ -0,0 +1,23 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+
+// static HashMap<Integer, Group> mp;
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/201980b5760d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/201980b5760d00131719b896d543f08c
new file mode 100644
index 0000000..90bee98
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/201980b5760d00131719b896d543f08c
@@ -0,0 +1,176 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation r = (ResLocation) m.obj;
+ for (int i = 0; i < r.n; i++) {
+ System.out.println(r.l.get(i).lat + " " + r.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate r = (ResUpdate) m.obj;
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/5019e3b3260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/5019e3b3260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..4df6b44
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/5019e3b3260d00131a9bb9bc5a5e6171
@@ -0,0 +1,28 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/50ba72af3b0d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/50ba72af3b0d00131524a793807f338e
new file mode 100644
index 0000000..f59c543
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/50ba72af3b0d00131524a793807f338e
@@ -0,0 +1,7 @@
+package com.macaroon.piztor;
+
+public class UserInfo {
+ static String ip = "123.123.123.123";
+ static int port = 9990;
+ static int token = -1;
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/d0e225b3310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/d0e225b3310d00131249f322b63acde8
new file mode 100644
index 0000000..a93105a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/87/d0e225b3310d00131249f322b63acde8
@@ -0,0 +1,80 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static Transam transam = null;
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ fromGPS = new Handler();
+ new Thread(transam).run();
+
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/88/50d41de3290d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/88/50d41de3290d00131249f322b63acde8
new file mode 100644
index 0000000..6fbccda
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/88/50d41de3290d00131249f322b63acde8
@@ -0,0 +1,30 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ AppMgr.trigger(AppMgr.hasToken);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/88/a0228599540d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/88/a0228599540d00131719b896d543f08c
new file mode 100644
index 0000000..180c21c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/88/a0228599540d00131719b896d543f08c
@@ -0,0 +1,87 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Tracker tracker = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ tracker = new Tracker(nowAct.getApplicationContext(), fromGPS);
+ tTransam = new Thread(transam);
+ tTransam.start();
+ System.out.println("!!!!!!");
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/88/a0b797df250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/88/a0b797df250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..bb16d98
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/88/a0b797df250d00131a9bb9bc5a5e6171
@@ -0,0 +1,69 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int hasToken;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/89/0029672d5a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/89/0029672d5a0d00131719b896d543f08c
new file mode 100644
index 0000000..d5a6059
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/89/0029672d5a0d00131719b896d543f08c
@@ -0,0 +1,34 @@
+package com.macaroon.piztor;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token == -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else {
+ //TODO jump to main
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8a/c0860fa32d0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8a/c0860fa32d0d00131249f322b63acde8
new file mode 100644
index 0000000..4564070
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8a/c0860fa32d0d00131249f322b63acde8
@@ -0,0 +1,72 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int noToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8b/908f0c6a360d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8b/908f0c6a360d00131249f322b63acde8
new file mode 100644
index 0000000..0e5adb3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8b/908f0c6a360d00131249f322b63acde8
@@ -0,0 +1,72 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8b/d056c37d2d0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8b/d056c37d2d0d00131249f322b63acde8
new file mode 100644
index 0000000..d870b73
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8b/d056c37d2d0d00131249f322b63acde8
@@ -0,0 +1,36 @@
+package com.macaroon.piztor;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ Intent i = new Intent();
+ i.putExtra("haha", new Handler());
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else {
+ //TODO jump to main
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8c/10eb0b46390d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8c/10eb0b46390d00131524a793807f338e
new file mode 100644
index 0000000..01b87ff
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8c/10eb0b46390d00131524a793807f338e
@@ -0,0 +1,84 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ tTransam = new Thread(transam);
+ tTransam.run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8c/e09a6d15560d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8c/e09a6d15560d00131719b896d543f08c
new file mode 100644
index 0000000..8839e04
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8c/e09a6d15560d00131719b896d543f08c
@@ -0,0 +1,45 @@
+package com.macaroon.piztor;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, , longitude, time, alive)
+ AppMgr.transam.send();
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/10e89b06370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/10e89b06370d00131249f322b63acde8
new file mode 100644
index 0000000..81fa6f2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/10e89b06370d00131249f322b63acde8
@@ -0,0 +1,63 @@
+package com.macaroon.piztor;
+
+import java.util.*;
+
+import android.annotation.SuppressLint;
+
+@SuppressLint("UseSparseArrays")
+public class ActMgr {
+ // event
+ PiztorAct act;
+ ActStatus nowStatus;
+ HashMap<ActStatus, HashMap<Integer, ActStatus>> mp;
+
+ ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) {
+ this.act = act;
+ this.nowStatus = nowStatus;
+ mp = new HashMap<ActStatus, HashMap<Integer, ActStatus>>();
+ for (int i = 0; i < r.length; i++) {
+ mp.put(r[i], new HashMap<Integer, ActStatus>());
+ }
+ }
+
+ void trigger(int event) {
+ for (Integer i : mp.get(nowStatus).keySet())
+ System.out.println(i);
+ if (mp.get(nowStatus).containsKey(event)) {
+ nowStatus.leave(event);
+ nowStatus = mp.get(nowStatus).get(event);
+ nowStatus.enter(event);
+ } else if (AppMgr.mp.get(act.getClass()).containsKey(event)) {
+ AppMgr.trigger(event);
+ }
+ }
+
+ void add(ActStatus a, int event, ActStatus b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, ActStatus> h = mp.get(a);
+ h.put(event, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, ActStatus> h = new HashMap<Integer, ActStatus>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+}
+
+abstract class ActStatus {
+ abstract void enter(int e);
+
+ abstract void leave(int e);
+}
+
+class EmptyStatus extends ActStatus {
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/80e1dd33540d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/80e1dd33540d00131719b896d543f08c
new file mode 100644
index 0000000..b89f1ab
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/80e1dd33540d00131719b896d543f08c
@@ -0,0 +1,85 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ //fromGPS = new Handler();
+ tTransam = new Thread(transam);
+ tTransam.start();
+ System.out.println("!!!!!!");
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/a08e799e530d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/a08e799e530d00131719b896d543f08c
new file mode 100644
index 0000000..d68704e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/a08e799e530d00131719b896d543f08c
@@ -0,0 +1,37 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/a0b8e0b1310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/a0b8e0b1310d00131249f322b63acde8
new file mode 100644
index 0000000..4884d31
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/a0b8e0b1310d00131249f322b63acde8
@@ -0,0 +1,78 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static Transam transam = null;
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ fromGPS = new Handler();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/b05c6824790d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/b05c6824790d00131719b896d543f08c
new file mode 100644
index 0000000..7b562b8
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8d/b05c6824790d00131719b896d543f08c
@@ -0,0 +1,192 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ final static int Create = 7;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8e/b08854886b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8e/b08854886b0d00131719b896d543f08c
new file mode 100644
index 0000000..b23f1b9
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8e/b08854886b0d00131719b896d543f08c
@@ -0,0 +1,149 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8f/e0acc70a360d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8f/e0acc70a360d00131249f322b63acde8
new file mode 100644
index 0000000..3a172b5
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8f/e0acc70a360d00131249f322b63acde8
@@ -0,0 +1,72 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else (m.what == 101) {
+
+ }
+ }
+ };
+
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/8f/f0503e632b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8f/f0503e632b0d00131249f322b63acde8
new file mode 100644
index 0000000..294cae3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/8f/f0503e632b0d00131249f322b63acde8
@@ -0,0 +1,16 @@
+package com.macaroon.piztor;
+
+//--------------------------------------//
+// authentication //
+//--------------------------------------//
+
+public class ReqLogin extends Req{
+ String user; //username
+ String pass; //password
+
+ ReqLogin(String u,String p,long time,long alive){
+ super(0,0,time,alive); //for type 0
+ user = u;
+ pass = p;
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/9/80eaba674e0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9/80eaba674e0d00131719b896d543f08c
new file mode 100644
index 0000000..b759a1c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9/80eaba674e0d00131719b896d543f08c
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">Piztor</string>
+ <string name="action_settings">Settings</string>
+ <string name="hello_world">Hello world!</string>
+ <string name="title_activity_login">Login</string>
+ <string name="title_activity_main">Main</string>
+
+</resources>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/9/d0125955810d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9/d0125955810d00131719b896d543f08c
new file mode 100644
index 0000000..dad95a8
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9/d0125955810d00131719b896d543f08c
@@ -0,0 +1,23 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+
+ static HashMap<Integer, Group> mp;
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/90/00e09e727b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/90/00e09e727b0d00131719b896d543f08c
new file mode 100644
index 0000000..fcbed8a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/90/00e09e727b0d00131719b896d543f08c
@@ -0,0 +1,198 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == TimerFlush) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1, System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ autodate.schedule(new AutoUpdate(), 0, 5000);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/90/2028ee04230d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/90/2028ee04230d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..ad93257
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/90/2028ee04230d00131a9bb9bc5a5e6171
@@ -0,0 +1,10 @@
+package com.macaroon.piztor;
+
+public class PiztorExcepiton extends Exception{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7147530695009854988L;
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/90/d01af94e800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/90/d01af94e800d00131719b896d543f08c
new file mode 100644
index 0000000..9f83659
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/90/d01af94e800d00131719b896d543f08c
@@ -0,0 +1,205 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ else {
+ ReqUpdate r = new ReqUpdate(UserInfo.token,
+ l.getLatitude(), l.getLongitude(),
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == TimerFlush) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[0], SuccessFetch, r[0]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[1], SuccessFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ AppMgr.transam.setHandler(fromTransam);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ autodate.schedule(new AutoUpdate(), 0, 5000);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/92/90d0196d2b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/92/90d0196d2b0d00131249f322b63acde8
new file mode 100644
index 0000000..eb90840
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/92/90d0196d2b0d00131249f322b63acde8
@@ -0,0 +1,18 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+//--------------------------------------//
+// Location Info //
+//--------------------------------------//
+
+public class ResLocation extends Res{
+ Vector<Rlocation> l; //vector for location info
+ int n; //number of location info
+
+ ResLocation(int num,Vector<Rlocation> locationvec){
+ super(3,255); //for type 3
+ l = locationvec;
+ n = num;
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/95/6090f2e14d0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/95/6090f2e14d0d00131719b896d543f08c
new file mode 100644
index 0000000..9065bdb
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/95/6090f2e14d0d00131719b896d543f08c
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="48dip"
+ android:background="@drawable/topbar_background"
+ android:id="@+id/settings_headbar_layout" >
+
+ <ImageButton
+ android:id="@+id/settings_btn_back"
+ android:layout_width="40dip"
+ android:layout_height="40dip"
+ android:layout_marginLeft="5dip"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true"
+ android:background="@drawable/navigation_back"/>
+
+ <TextView
+ android:id="@+id/settings_headbar_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="30dip"
+ android:textColor="@android:color/white"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:layout_marginRight="40dip"
+ android:text="@string/settings"/>
+
+
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/95/d0e2b9652c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/95/d0e2b9652c0d00131249f322b63acde8
new file mode 100644
index 0000000..2752afa
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/95/d0e2b9652c0d00131249f322b63acde8
@@ -0,0 +1,30 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.hasToken);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/96/00f46dd44f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/96/00f46dd44f0d00131719b896d543f08c
new file mode 100644
index 0000000..46efee3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/96/00f46dd44f0d00131719b896d543f08c
@@ -0,0 +1,19 @@
+<resources>
+
+ <string name="app_name">piztor</string>
+ <string name="action_settings">Settings</string>
+ <string name="hello_world">Hello world!</string>
+ <string name="settings">Settings</string>
+ <string name="search">Search</string>
+ <string name="fetch">Fetch</string>
+ <string name="checkin">Checkin</string>
+ <string name="focus">Focus</string>
+ <string name="show_sex">Show sex: </string>
+ <string name="male">Male</string>
+ <string name="female">Female</string>
+ <string name="show_team">Show team: </string>
+ <string name="all">All</string>
+ <string name="mine">Mine</string>
+ <string name="title_activity_login">Login</string>
+
+</resources>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/96/7099eaee250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/96/7099eaee250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..a935075
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/96/7099eaee250d00131a9bb9bc5a5e6171
@@ -0,0 +1,71 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ public enum Event {
+ hasToken;
+ }
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/96/d045188a780d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/96/d045188a780d00131719b896d543f08c
new file mode 100644
index 0000000..630c035
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/96/d045188a780d00131719b896d543f08c
@@ -0,0 +1,191 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ autodate = new Timer();
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/97/b0d85224540d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/97/b0d85224540d00131719b896d543f08c
new file mode 100644
index 0000000..0732a3f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/97/b0d85224540d00131719b896d543f08c
@@ -0,0 +1,42 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ AppMgr.transam.send(new ReqLocation(UserInfo.token, 1, System.currentTimeMillis(), 1000));
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/97/b0e93a1f560d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/97/b0e93a1f560d00131719b896d543f08c
new file mode 100644
index 0000000..cd9372f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/97/b0e93a1f560d00131719b896d543f08c
@@ -0,0 +1,46 @@
+package com.macaroon.piztor;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send();
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/98/90d9c0a3260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/98/90d9c0a3260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..5df4638
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/98/90d9c0a3260d00131a9bb9bc5a5e6171
@@ -0,0 +1,28 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/98/c0bccf492c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/98/c0bccf492c0d00131249f322b63acde8
new file mode 100644
index 0000000..d0d8a48
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/98/c0bccf492c0d00131249f322b63acde8
@@ -0,0 +1,5 @@
+package com.macaroon.piztor;
+
+public class UserInfo {
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/98/d01ce77a780d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/98/d01ce77a780d00131719b896d543f08c
new file mode 100644
index 0000000..9f6dfb4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/98/d01ce77a780d00131719b896d543f08c
@@ -0,0 +1,192 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ autodate = new Timer();
+
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/99/502b88e7810d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/99/502b88e7810d00131719b896d543f08c
new file mode 100644
index 0000000..d3a498f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/99/502b88e7810d00131719b896d543f08c
@@ -0,0 +1,28 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+ static int myGroup = -1;
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+
+ static HashMap<Integer, Group> mp;
+
+ static void init() {
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/99/603b4d34230d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/99/603b4d34230d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..ff37673
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/99/603b4d34230d00131a9bb9bc5a5e6171
@@ -0,0 +1,10 @@
+package com.macaroon.piztor;
+
+class PiztorExcepiton extends Exception{
+ private static final long serialVersionUID = -7147530695009854988L;
+
+}
+
+class ClassCannotFind extends PiztorExcepiton {
+ private
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/99/70ce9093370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/99/70ce9093370d00131249f322b63acde8
new file mode 100644
index 0000000..652a271
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/99/70ce9093370d00131249f322b63acde8
@@ -0,0 +1,96 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText();
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/9b/90a9ae62770d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9b/90a9ae62770d00131719b896d543f08c
new file mode 100644
index 0000000..a5c36f7
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9b/90a9ae62770d00131719b896d543f08c
@@ -0,0 +1,181 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/9c/606048dc370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9c/606048dc370d00131249f322b63acde8
new file mode 100644
index 0000000..2c804a6
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9c/606048dc370d00131249f322b63acde8
@@ -0,0 +1,96 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/9d/1036ff9b220d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9d/1036ff9b220d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..d45dd56
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9d/1036ff9b220d00131a9bb9bc5a5e6171
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.compliance=1.6
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/9d/3091338f6b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9d/3091338f6b0d00131719b896d543f08c
new file mode 100644
index 0000000..c44cd80
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9d/3091338f6b0d00131719b896d543f08c
@@ -0,0 +1,156 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/9e/80db2574360d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9e/80db2574360d00131249f322b63acde8
new file mode 100644
index 0000000..0e5adb3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9e/80db2574360d00131249f322b63acde8
@@ -0,0 +1,72 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/90356481800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/90356481800d00131719b896d543f08c
new file mode 100644
index 0000000..d0ca8a4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/90356481800d00131719b896d543f08c
@@ -0,0 +1,15 @@
+package com.macaroon.piztor;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+
+ static class UserInfo {
+ double lat, lot;
+ }
+
+ static class Group {
+ int id;
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/a064e6d0330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/a064e6d0330d00131249f322b63acde8
new file mode 100644
index 0000000..25614b9
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/a064e6d0330d00131249f322b63acde8
@@ -0,0 +1,58 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/f04144582b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/f04144582b0d00131249f322b63acde8
new file mode 100644
index 0000000..e4b1497
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/9f/f04144582b0d00131249f322b63acde8
@@ -0,0 +1,16 @@
+package com.macaroon.piztor;
+
+//--------------------------------------//
+// Update Location //
+//--------------------------------------//
+
+public class ReqUpdate extends Req{
+ double lat; //latitude
+ double lot; //longitude
+
+ ReqUpdate(int token,double latitude,double longitude,long time,long alive){
+ super(2,token,time,alive); //for type 2
+ lat = latitude;
+ lot = longitude;
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a/40b9ebd22d0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a/40b9ebd22d0d00131249f322b63acde8
new file mode 100644
index 0000000..0a711af
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a/40b9ebd22d0d00131249f322b63acde8
@@ -0,0 +1,73 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ static Handler handle;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/70559b0a250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/70559b0a250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..372bf97
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/70559b0a250d00131a9bb9bc5a5e6171
@@ -0,0 +1,16 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ 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=".Login" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/hello_world" />
+
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/90d4db88800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/90d4db88800d00131719b896d543f08c
new file mode 100644
index 0000000..0713782
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/90d4db88800d00131719b896d543f08c
@@ -0,0 +1,19 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+ static class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ static class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/e0b88562370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/e0b88562370d00131249f322b63acde8
new file mode 100644
index 0000000..9b160ad
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a0/e0b88562370d00131249f322b63acde8
@@ -0,0 +1,71 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ //class StartStatus extends Piz
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a2/308cf16f2c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a2/308cf16f2c0d00131249f322b63acde8
new file mode 100644
index 0000000..3e73b92
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a2/308cf16f2c0d00131249f322b63acde8
@@ -0,0 +1,32 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a2/50ad9b0a560d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a2/50ad9b0a560d00131719b896d543f08c
new file mode 100644
index 0000000..d4acdc9
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a2/50ad9b0a560d00131719b896d543f08c
@@ -0,0 +1,43 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+// ReqUpdate r = new ReqUpdate(UserInfo.token, AppMgr., longitude, time, alive)
+ AppMgr.transam.send();
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a3/f02825fc2d0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a3/f02825fc2d0d00131249f322b63acde8
new file mode 100644
index 0000000..b6fb62c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a3/f02825fc2d0d00131249f322b63acde8
@@ -0,0 +1,74 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromeGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a6/a016c8c14f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a6/a016c8c14f0d00131719b896d543f08c
new file mode 100644
index 0000000..c2d070c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a6/a016c8c14f0d00131719b896d543f08c
@@ -0,0 +1,20 @@
+activity_loginactivity_loginactivity_loginactivity_loginactivity_loginactivity_loginactivity_loginactivity_loginactivity_login<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">piztor</string>
+ <string name="action_settings">Settings</string>
+ <string name="hello_world">Hello world!</string>
+ <string name="settings">Settings</string>
+ <string name="search">Search</string>
+ <string name="fetch">Fetch</string>
+ <string name="checkin">Checkin</string>
+ <string name="focus">Focus</string>
+ <string name="show_sex">Show sex: </string>
+ <string name="male">Male</string>
+ <string name="female">Female</string>
+ <string name="show_team">Show team: </string>
+ <string name="all">All</string>
+ <string name="mine">Mine</string>
+ <string name="title_activity_login">Login</string>
+
+</resources>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a7/a0893aae550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a7/a0893aae550d00131719b896d543f08c
new file mode 100644
index 0000000..b653442
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a7/a0893aae550d00131719b896d543f08c
@@ -0,0 +1,68 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.location.Location;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a8/20fcf44e800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a8/20fcf44e800d00131719b896d543f08c
new file mode 100644
index 0000000..59bb8b5
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a8/20fcf44e800d00131719b896d543f08c
@@ -0,0 +1,32 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token == -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else {
+ //TODO jump to main
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a8/80a9829d690d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a8/80a9829d690d00131719b896d543f08c
new file mode 100644
index 0000000..bebf3ae
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a8/80a9829d690d00131719b896d543f08c
@@ -0,0 +1,116 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);''
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/100cbe75540d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/100cbe75540d00131719b896d543f08c
new file mode 100644
index 0000000..8bb993a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/100cbe75540d00131719b896d543f08c
@@ -0,0 +1,86 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Tracker tracker = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ //fromGPS = new Handler();
+ tTransam = new Thread(transam);
+ tTransam.start();
+ System.out.println("!!!!!!");
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/409f33a52d0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/409f33a52d0d00131249f322b63acde8
new file mode 100644
index 0000000..07b5812
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/409f33a52d0d00131249f322b63acde8
@@ -0,0 +1,72 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ static Handler handle;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/e083aa57340d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/e083aa57340d00131249f322b63acde8
new file mode 100644
index 0000000..070b1ab
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/a9/e083aa57340d00131249f322b63acde8
@@ -0,0 +1,60 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ }
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/aa/1010278f550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/aa/1010278f550d00131719b896d543f08c
new file mode 100644
index 0000000..d3fa0f2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/aa/1010278f550d00131719b896d543f08c
@@ -0,0 +1,241 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public Location getLocation() {
+ try {
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+ return location
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return location;
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/aa/a0a35aa1550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/aa/a0a35aa1550d00131719b896d543f08c
new file mode 100644
index 0000000..d5590eb
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/aa/a0a35aa1550d00131719b896d543f08c
@@ -0,0 +1,242 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public Location getLocation() {
+ try {
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+ return location;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ return location;
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ab/608c6879260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ab/608c6879260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..bab59bd
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ab/608c6879260d00131a9bb9bc5a5e6171
@@ -0,0 +1,69 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int hasToken = 1;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ac/00248cbd360d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ac/00248cbd360d00131249f322b63acde8
new file mode 100644
index 0000000..c7eaee7
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ac/00248cbd360d00131249f322b63acde8
@@ -0,0 +1,71 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ae/30296b52560d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ae/30296b52560d00131719b896d543f08c
new file mode 100644
index 0000000..8bb336e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ae/30296b52560d00131719b896d543f08c
@@ -0,0 +1,47 @@
+package com.macaroon.piztor;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ae/c0defd575a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ae/c0defd575a0d00131719b896d543f08c
new file mode 100644
index 0000000..3c46136
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ae/c0defd575a0d00131719b896d543f08c
@@ -0,0 +1,68 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.location.Location;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ Location location = myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+
+// Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+// System.out.println("GPSTIME" + myTracker.location.getTime());
+// System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ message = new Message();
+ message.what = 0;
+ message.obj = location;
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message = new Message();
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/af/30d4b2674e0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/af/30d4b2674e0d00131719b896d543f08c
new file mode 100644
index 0000000..1f986ed
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/af/30d4b2674e0d00131719b896d543f08c
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/title_activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/title_activity_main" >
+ </activity>
+ </application>
+ <uses-permission android:name="android.permission.INTERNET"/>
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/7084ef6a550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/7084ef6a550d00131719b896d543f08c
new file mode 100644
index 0000000..064b504
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/7084ef6a550d00131719b896d543f08c
@@ -0,0 +1,241 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public Location getLocation() {
+ try {
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return location;
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/c09fb905760d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/c09fb905760d00131719b896d543f08c
new file mode 100644
index 0000000..c50b159
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/c09fb905760d00131719b896d543f08c
@@ -0,0 +1,171 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ Vector<Rlocation> l =(Vector<Rlocation>) m.obj;
+ for (int i = 0; i < n; i++) {
+ System.out.println()
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/d04f2b58380d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/d04f2b58380d00131249f322b63acde8
new file mode 100644
index 0000000..a649f02
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b0/d04f2b58380d00131249f322b63acde8
@@ -0,0 +1,99 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/00a1a652550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/00a1a652550d00131719b896d543f08c
new file mode 100644
index 0000000..18bdeae
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/00a1a652550d00131719b896d543f08c
@@ -0,0 +1,240 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public Location getLocation() {
+ try {
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/00b0df34260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/00b0df34260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..5803683
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/00b0df34260d00131a9bb9bc5a5e6171
@@ -0,0 +1,71 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ public enum Event {
+ hasToken
+ }
+
+
+ static HashMap<Class<?>, HashMap<Event, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(Event event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Event event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Event, Class<?>> h = new HashMap<Event, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, Event i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Event, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Event, Class<?>> h = new HashMap<Event, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Event, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Event, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/806ea1b54f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/806ea1b54f0d00131719b896d543f08c
new file mode 100644
index 0000000..7587807
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/806ea1b54f0d00131719b896d543f08c
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <string name="app_name">piztor</string>
+ <string name="action_settings">Settings</string>
+ <string name="hello_world">Hello world!</string>
+ <string name="settings">Settings</string>
+ <string name="search">Search</string>
+ <string name="fetch">Fetch</string>
+ <string name="checkin">Checkin</string>
+ <string name="focus">Focus</string>
+ <string name="show_sex">Show sex: </string>
+ <string name="male">Male</string>
+ <string name="female">Female</string>
+ <string name="show_team">Show team: </string>
+ <string name="all">All</string>
+ <string name="mine">Mine</string>
+
+</resources>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/a0011e00530d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/a0011e00530d00131719b896d543f08c
new file mode 100644
index 0000000..8adf71f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b2/a0011e00530d00131719b896d543f08c
@@ -0,0 +1,22 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b3/005ecbdb800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b3/005ecbdb800d00131719b896d543f08c
new file mode 100644
index 0000000..b4bddc4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b3/005ecbdb800d00131719b896d543f08c
@@ -0,0 +1,20 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/d054deff370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/d054deff370d00131249f322b63acde8
new file mode 100644
index 0000000..a79cbad
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/d054deff370d00131249f322b63acde8
@@ -0,0 +1,96 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/e0f38c9f260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/e0f38c9f260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..33636d9
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/e0f38c9f260d00131a9bb9bc5a5e6171
@@ -0,0 +1,27 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/f0db4c2f390d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/f0db4c2f390d00131524a793807f338e
new file mode 100644
index 0000000..01b87ff
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b5/f0db4c2f390d00131524a793807f338e
@@ -0,0 +1,84 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ tTransam = new Thread(transam);
+ tTransam.run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b6/907c20d0330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b6/907c20d0330d00131249f322b63acde8
new file mode 100644
index 0000000..2821a56
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b6/907c20d0330d00131249f322b63acde8
@@ -0,0 +1,58 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public boolean handleMessage(Message m) {
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b7/00d0ee3f5a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b7/00d0ee3f5a0d00131719b896d543f08c
new file mode 100644
index 0000000..9e3ea68
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b7/00d0ee3f5a0d00131719b896d543f08c
@@ -0,0 +1,104 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ static Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ System.out.println(m.what);
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ System.out.println(user + " : " + pass + "\n");
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ AppMgr.transam.setHandler(hand);
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b7/7017f2e32d0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b7/7017f2e32d0d00131249f322b63acde8
new file mode 100644
index 0000000..74de717
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b7/7017f2e32d0d00131249f322b63acde8
@@ -0,0 +1,74 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler callBack;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/b9/002a6f89770d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b9/002a6f89770d00131719b896d543f08c
new file mode 100644
index 0000000..e634232
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/b9/002a6f89770d00131719b896d543f08c
@@ -0,0 +1,178 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ actMgr.trigger(FailedFetch);
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/bd/90228f69800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/bd/90228f69800d00131719b896d543f08c
new file mode 100644
index 0000000..631fe8e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/bd/90228f69800d00131719b896d543f08c
@@ -0,0 +1,8 @@
+package com.macaroon.piztor;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/a0e7485e390d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/a0e7485e390d00131524a793807f338e
new file mode 100644
index 0000000..49e6552
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/a0e7485e390d00131524a793807f338e
@@ -0,0 +1,84 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ //fromGPS = new Handler();
+ tTransam = new Thread(transam);
+ tTransam.run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/b07e9999380d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/b07e9999380d00131249f322b63acde8
new file mode 100644
index 0000000..401f985
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/b07e9999380d00131249f322b63acde8
@@ -0,0 +1,34 @@
+package com.macaroon.piztor;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else {
+ //TODO jump to main
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/c0281dde290d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/c0281dde290d00131249f322b63acde8
new file mode 100644
index 0000000..6177eaf
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/bf/c0281dde290d00131249f322b63acde8
@@ -0,0 +1,31 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ id = "initAct";
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ AppMgr.trigger(AppMgr.hasToken);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c/20533453360d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c/20533453360d00131249f322b63acde8
new file mode 100644
index 0000000..1308a5e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c/20533453360d00131249f322b63acde8
@@ -0,0 +1,72 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } ;else (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c/c0b909df780d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c/c0b909df780d00131719b896d543f08c
new file mode 100644
index 0000000..4df6bae
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c/c0b909df780d00131719b896d543f08c
@@ -0,0 +1,62 @@
+package com.macaroon.piztor;
+
+import java.util.*;
+
+import android.annotation.SuppressLint;
+
+@SuppressLint("UseSparseArrays")
+public class ActMgr {
+ // event
+ PiztorAct act;
+ ActStatus nowStatus;
+ HashMap<ActStatus, HashMap<Integer, ActStatus>> mp;
+
+ ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) {
+ this.act = act;
+ this.nowStatus = nowStatus;
+ mp = new HashMap<ActStatus, HashMap<Integer, ActStatus>>();
+ for (int i = 0; i < r.length; i++) {
+ mp.put(r[i], new HashMap<Integer, ActStatus>());
+ }
+ }
+
+ void trigger(int event) {
+ System.out.println(act.id + " : " + event);
+ if (mp.get(nowStatus).containsKey(event)) {
+ nowStatus.leave(event);
+ nowStatus = mp.get(nowStatus).get(event);
+ nowStatus.enter(event);
+ } else if (AppMgr.mp.get(act.getClass()).containsKey(event)) {
+ AppMgr.trigger(event);
+ }
+ }
+
+ void add(ActStatus a, int event, ActStatus b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, ActStatus> h = mp.get(a);
+ h.put(event, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, ActStatus> h = new HashMap<Integer, ActStatus>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+}
+
+abstract class ActStatus {
+ abstract void enter(int e);
+
+ abstract void leave(int e);
+}
+
+class EmptyStatus extends ActStatus {
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c1/70c31bc4770d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c1/70c31bc4770d00131719b896d543f08c
new file mode 100644
index 0000000..94737ae
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c1/70c31bc4770d00131719b896d543f08c
@@ -0,0 +1,180 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c1/90049d68370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c1/90049d68370d00131249f322b63acde8
new file mode 100644
index 0000000..27c94bf
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c1/90049d68370d00131249f322b63acde8
@@ -0,0 +1,84 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c2/305132042e0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c2/305132042e0d00131249f322b63acde8
new file mode 100644
index 0000000..1b7a948
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c2/305132042e0d00131249f322b63acde8
@@ -0,0 +1,77 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+
+ fromGPS = new Handler();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c2/905743582b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c2/905743582b0d00131249f322b63acde8
new file mode 100644
index 0000000..e4b1497
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c2/905743582b0d00131249f322b63acde8
@@ -0,0 +1,16 @@
+package com.macaroon.piztor;
+
+//--------------------------------------//
+// Update Location //
+//--------------------------------------//
+
+public class ReqUpdate extends Req{
+ double lat; //latitude
+ double lot; //longitude
+
+ ReqUpdate(int token,double latitude,double longitude,long time,long alive){
+ super(2,token,time,alive); //for type 2
+ lat = latitude;
+ lot = longitude;
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c3/c02b54e56a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c3/c02b54e56a0d00131719b896d543f08c
new file mode 100644
index 0000000..5083cb4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c3/c02b54e56a0d00131719b896d543f08c
@@ -0,0 +1,137 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "SearchButtonPress";
+ case FetchButtonPress:
+ return "FetchButtonPress";
+ case FocuseButtonPress:
+ return "FocuseButtonPress";
+ case SuccessFetch:
+ return "SuccessFetch";
+ case FailedFetch:
+ return "FailedFetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c3/e083ea64370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c3/e083ea64370d00131249f322b63acde8
new file mode 100644
index 0000000..a69306e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c3/e083ea64370d00131249f322b63acde8
@@ -0,0 +1,85 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c4/80454f67500d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c4/80454f67500d00131719b896d543f08c
new file mode 100644
index 0000000..37e55a7
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c4/80454f67500d00131719b896d543f08c
@@ -0,0 +1,92 @@
+<?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
+ 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
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ 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/white"
+ />
+
+ <EditText
+ android:layout_width="0dp"
+ android:layout_weight="0.75"
+ android:id="@+id/user_pass"
+ android:password="true"
+ android:textColor="@android:color/white"
+ 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" />
+ </LinearLayout>
+
+</LinearLayout>
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c4/a02a68e4550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c4/a02a68e4550d00131719b896d543f08c
new file mode 100644
index 0000000..49b0b38
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c4/a02a68e4550d00131719b896d543f08c
@@ -0,0 +1,66 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.location.Location;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ Location location = myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ message = new Message();
+ message.obj = location;
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c5/b0f3fcc27c0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c5/b0f3fcc27c0d00131719b896d543f08c
new file mode 100644
index 0000000..94c1e0d
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c5/b0f3fcc27c0d00131719b896d543f08c
@@ -0,0 +1,204 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ else {
+ ReqUpdate r = new ReqUpdate(UserInfo.token,
+ l.getLatitude(), l.getLongitude(),
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == TimerFlush) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[1], SuccessFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ AppMgr.transam.setHandler(fromTransam);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ autodate.schedule(new AutoUpdate(), 0, 5000);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c8/b082216a2c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c8/b082216a2c0d00131249f322b63acde8
new file mode 100644
index 0000000..2769127
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c8/b082216a2c0d00131249f322b63acde8
@@ -0,0 +1,31 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.hasToken);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/c9/406dedec4e0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c9/406dedec4e0d00131719b896d543f08c
new file mode 100644
index 0000000..ebd1331
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/c9/406dedec4e0d00131719b896d543f08c
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/title_activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/title_activity_main" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Setting"
+ android:label="@string/title_activity_setting" >
+ </activity>
+ </application>
+
+ <uses-permission android:name="android.permission.INTERNET" />
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/20f3b0b5340d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/20f3b0b5340d00131249f322b63acde8
new file mode 100644
index 0000000..bc3f8c2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/20f3b0b5340d00131249f322b63acde8
@@ -0,0 +1,62 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ }
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/90266484690d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/90266484690d00131719b896d543f08c
new file mode 100644
index 0000000..4689c27
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/90266484690d00131719b896d543f08c
@@ -0,0 +1,114 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/a02a83fc310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/a02a83fc310d00131249f322b63acde8
new file mode 100644
index 0000000..6250eae
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/a02a83fc310d00131249f322b63acde8
@@ -0,0 +1,80 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static Transam transam = null;
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ new Thread(transam).run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/d0283431550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/d0283431550d00131719b896d543f08c
new file mode 100644
index 0000000..ff69271
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ca/d0283431550d00131719b896d543f08c
@@ -0,0 +1,241 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public Locatio getLocation() {
+ try {
+
+ Log.d("getLocation",n "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/cb/30fcab3d6b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cb/30fcab3d6b0d00131719b896d543f08c
new file mode 100644
index 0000000..8740d07
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cb/30fcab3d6b0d00131719b896d543f08c
@@ -0,0 +1,137 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/30d547d6300d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/30d547d6300d00131249f322b63acde8
new file mode 100644
index 0000000..c31924d
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/30d547d6300d00131249f322b63acde8
@@ -0,0 +1,132 @@
+package com.macaroon.piztor;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.annotation.SuppressLint;
+import android.os.Handler;
+import android.os.Message;
+
+public class Transam implements Runnable {
+ public Timer timer;
+ public Timer mtimer;
+ public boolean running = false;
+ public boolean flag = true;
+ public int cnt = 4;
+ Res res;
+ Req req;
+ public int p; //port
+ public String i; //ip
+ Thread thread;
+ Handler core;
+ Handler recall; //recall
+ Queue<Req> reqtask ; //request task
+
+ Transam(String ip, int port,Handler Recall) {
+ p = port;
+ i = ip;
+ recall = Recall;
+ reqtask = new LinkedList<Req>();
+ }
+
+ public void send(Req r){
+ reqtask.offer(r);
+
+ }
+
+ public void run() { //start the main timer
+ //TimerTask tmain = new Timertk();
+ //mtimer = new Timer();
+ //mtimer.schedule(tmain, 100, 100); //check the queue for every 100 msec
+
+ while(true){
+ if(running == false){
+
+ if(!reqtask.isEmpty()){ //poll the head request
+ req = reqtask.poll();
+ if(req.time + req.alive < System.currentTimeMillis()){ //time out!
+ Message ret = new Message();
+ ret.obj = "Time out!";
+ ret.what = 100;
+ recall.sendMessage(ret);
+ }
+ else{ //run the request
+ final thd t = new thd();
+ flag = false;
+ thread = new Thread(t);
+ cnt = 4;
+ running = true;
+ thread.start();
+ timer = new Timer();
+ TimerTask task = new Timertk();
+ timer.schedule(task, 2000, 2000);
+ }
+ }
+ }
+ }
+ }
+
+ class tmain extends TimerTask {
+ public void run() {
+
+ }
+ };
+
+ class thd implements Runnable {
+ public void run() {
+ try {
+ SocketClient client = new SocketClient(i,p);
+ client.sendMsg(req,recall);
+ Message msg = new Message();
+ msg.what = 1;
+ handler.sendMessage(msg);
+ client.closeSocket();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ System.out.println("UnknownHostException");
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("IOException");
+ }
+
+ }
+ }
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case 1:
+ flag = true;
+ break;
+ case 2:
+ final thd t = new thd();
+ thread = new Thread(t);
+ thread.start();
+ break;
+ }
+ super.handleMessage(msg);
+ }
+ };
+
+ class Timertk extends TimerTask {
+ public void run() {
+ if (flag == false && cnt > 0) {
+ cnt--;
+ } else if (cnt == 0) {
+ Message msg = new Message();
+ msg.obj = "connecting failed";
+ msg.what = 101;
+ recall.sendMessage(msg);
+ timer.cancel();
+ } else if (flag == true) {
+ timer.cancel();
+ running = false;
+ }
+ }
+ };
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/40540cea780d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/40540cea780d00131719b896d543f08c
new file mode 100644
index 0000000..0df0ca4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/40540cea780d00131719b896d543f08c
@@ -0,0 +1,65 @@
+package com.macaroon.piztor;
+
+import java.util.*;
+
+import android.annotation.SuppressLint;
+
+@SuppressLint("UseSparseArrays")
+public class ActMgr {
+ // event
+ PiztorAct act;
+ ActStatus nowStatus;
+ HashMap<ActStatus, HashMap<Integer, ActStatus>> mp;
+
+ ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) {
+ this.act = act;
+ this.nowStatus = nowStatus;
+ mp = new HashMap<ActStatus, HashMap<Integer, ActStatus>>();
+ for (int i = 0; i < r.length; i++) {
+ mp.put(r[i], new HashMap<Integer, ActStatus>());
+ }
+ }
+
+ void trigger(int event) {
+ System.out.println(act.id + " : " + event);
+ if (mp.get(nowStatus).containsKey(event)) {
+ nowStatus.leave(event);
+ nowStatus = mp.get(nowStatus).get(event);
+ nowStatus.enter(event);
+ } else if (AppMgr.mp.get(act.getClass()).containsKey(event)) {
+ AppMgr.trigger(event);
+ } else {
+ System.out.println("can not trigger the event at " + act.id + " : "
+ + event);
+ }
+ }
+
+ void add(ActStatus a, int event, ActStatus b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, ActStatus> h = mp.get(a);
+ h.put(event, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, ActStatus> h = new HashMap<Integer, ActStatus>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+}
+
+abstract class ActStatus {
+ abstract void enter(int e);
+
+ abstract void leave(int e);
+}
+
+class EmptyStatus extends ActStatus {
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/a06019c6550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/a06019c6550d00131719b896d543f08c
new file mode 100644
index 0000000..3676f6b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/a06019c6550d00131719b896d543f08c
@@ -0,0 +1,66 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.location.Location;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ Location location = myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/b0cf5a29320d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/b0cf5a29320d00131249f322b63acde8
new file mode 100644
index 0000000..f30d9b3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/b0cf5a29320d00131249f322b63acde8
@@ -0,0 +1,81 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ fromGPS = new Handler();
+ tTransam = new Thread(transam).run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/e0b44c18280d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/e0b44c18280d00131249f322b63acde8
new file mode 100644
index 0000000..b298e0c
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cc/e0b44c18280d00131249f322b63acde8
@@ -0,0 +1,29 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ AppMgr.trigger(AppMgr.hasToken);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ce/400f0022790d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ce/400f0022790d00131719b896d543f08c
new file mode 100644
index 0000000..0df0ca4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ce/400f0022790d00131719b896d543f08c
@@ -0,0 +1,65 @@
+package com.macaroon.piztor;
+
+import java.util.*;
+
+import android.annotation.SuppressLint;
+
+@SuppressLint("UseSparseArrays")
+public class ActMgr {
+ // event
+ PiztorAct act;
+ ActStatus nowStatus;
+ HashMap<ActStatus, HashMap<Integer, ActStatus>> mp;
+
+ ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) {
+ this.act = act;
+ this.nowStatus = nowStatus;
+ mp = new HashMap<ActStatus, HashMap<Integer, ActStatus>>();
+ for (int i = 0; i < r.length; i++) {
+ mp.put(r[i], new HashMap<Integer, ActStatus>());
+ }
+ }
+
+ void trigger(int event) {
+ System.out.println(act.id + " : " + event);
+ if (mp.get(nowStatus).containsKey(event)) {
+ nowStatus.leave(event);
+ nowStatus = mp.get(nowStatus).get(event);
+ nowStatus.enter(event);
+ } else if (AppMgr.mp.get(act.getClass()).containsKey(event)) {
+ AppMgr.trigger(event);
+ } else {
+ System.out.println("can not trigger the event at " + act.id + " : "
+ + event);
+ }
+ }
+
+ void add(ActStatus a, int event, ActStatus b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, ActStatus> h = mp.get(a);
+ h.put(event, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, ActStatus> h = new HashMap<Integer, ActStatus>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+}
+
+abstract class ActStatus {
+ abstract void enter(int e);
+
+ abstract void leave(int e);
+}
+
+class EmptyStatus extends ActStatus {
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/509df39b220d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/509df39b220d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..0725982
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/509df39b220d00131a9bb9bc5a5e6171
@@ -0,0 +1,5 @@
+<resources>
+
+ <string name="app_name">Piztor</string>
+
+</resources>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/80bdfc51360d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/80bdfc51360d00131249f322b63acde8
new file mode 100644
index 0000000..12a937e
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/80bdfc51360d00131249f322b63acde8
@@ -0,0 +1,72 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/80e32f683a0d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/80e32f683a0d00131524a793807f338e
new file mode 100644
index 0000000..ef561b6
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/80e32f683a0d00131524a793807f338e
@@ -0,0 +1,85 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ //fromGPS = new Handler();
+ tTransam = new Thread(transam);
+// tTransam.run();
+ System.out.println("!!!!!!");
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/b0399970330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/b0399970330d00131249f322b63acde8
new file mode 100644
index 0000000..d6b9c4f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/cf/b0399970330d00131249f322b63acde8
@@ -0,0 +1,48 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/d1/e0493fd6550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d1/e0493fd6550d00131719b896d543f08c
new file mode 100644
index 0000000..96a9ed1
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d1/e0493fd6550d00131719b896d543f08c
@@ -0,0 +1,64 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.location.Location;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ Location location = myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/d2/80c7346a770d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d2/80c7346a770d00131719b896d543f08c
new file mode 100644
index 0000000..10cf824
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d2/80c7346a770d00131719b896d543f08c
@@ -0,0 +1,181 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ actMgr.trigger(FailedFetch);
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/d3/d07246a16a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d3/d07246a16a0d00131719b896d543f08c
new file mode 100644
index 0000000..ef0ed17
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d3/d07246a16a0d00131719b896d543f08c
@@ -0,0 +1,128 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "SearchButtonPress";
+
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!!");
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/d4/b08e74497f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d4/b08e74497f0d00131719b896d543f08c
new file mode 100644
index 0000000..04be578
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d4/b08e74497f0d00131719b896d543f08c
@@ -0,0 +1,7 @@
+package com.macaroon.piztor;
+
+public class UserInfo {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/d6/70651b8c4f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d6/70651b8c4f0d00131719b896d543f08c
new file mode 100644
index 0000000..e5faf14
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d6/70651b8c4f0d00131719b896d543f08c
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/title_activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/title_activity_main" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Setting"
+ android:label="@string/title_activity_setting" >
+ </activity>
+ </application>
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/d7/50a452ea310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d7/50a452ea310d00131249f322b63acde8
new file mode 100644
index 0000000..d2eb5bd
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d7/50a452ea310d00131249f322b63acde8
@@ -0,0 +1,80 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static Transam transam = null;
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ fromGPS = new Handler();
+
+ new Thread(transam).run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/d7/50d6caf2240d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d7/50d6caf2240d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..379817d
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d7/50d6caf2240d00131a9bb9bc5a5e6171
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/d8/90a207514b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d8/90a207514b0d00131719b896d543f08c
new file mode 100644
index 0000000..5742d39
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d8/90a207514b0d00131719b896d543f08c
@@ -0,0 +1,101 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ System.out.println(user + " : " + pass + "\n");
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/d8/f0ae11884d0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d8/f0ae11884d0d00131719b896d543f08c
new file mode 100644
index 0000000..23a210b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d8/f0ae11884d0d00131719b896d543f08c
@@ -0,0 +1,16 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ 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=".Main" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/hello_world" />
+
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/d9/b0831880280d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d9/b0831880280d00131249f322b63acde8
new file mode 100644
index 0000000..997217f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d9/b0831880280d00131249f322b63acde8
@@ -0,0 +1,69 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int hasToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ System.out.println(event);
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, hasToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/d9/c0cdd6df780d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d9/c0cdd6df780d00131719b896d543f08c
new file mode 100644
index 0000000..6b1c62a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/d9/c0cdd6df780d00131719b896d543f08c
@@ -0,0 +1,64 @@
+package com.macaroon.piztor;
+
+import java.util.*;
+
+import android.annotation.SuppressLint;
+
+@SuppressLint("UseSparseArrays")
+public class ActMgr {
+ // event
+ PiztorAct act;
+ ActStatus nowStatus;
+ HashMap<ActStatus, HashMap<Integer, ActStatus>> mp;
+
+ ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) {
+ this.act = act;
+ this.nowStatus = nowStatus;
+ mp = new HashMap<ActStatus, HashMap<Integer, ActStatus>>();
+ for (int i = 0; i < r.length; i++) {
+ mp.put(r[i], new HashMap<Integer, ActStatus>());
+ }
+ }
+
+ void trigger(int event) {
+ System.out.println(act.id + " : " + event);
+ if (mp.get(nowStatus).containsKey(event)) {
+ nowStatus.leave(event);
+ nowStatus = mp.get(nowStatus).get(event);
+ nowStatus.enter(event);
+ } else if (AppMgr.mp.get(act.getClass()).containsKey(event)) {
+ AppMgr.trigger(event);
+ } else {
+ System.out.println("can not trigger the event at " + act.id + " : " + event);
+ }
+ }
+
+ void add(ActStatus a, int event, ActStatus b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, ActStatus> h = mp.get(a);
+ h.put(event, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, ActStatus> h = new HashMap<Integer, ActStatus>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+}
+
+abstract class ActStatus {
+ abstract void enter(int e);
+
+ abstract void leave(int e);
+}
+
+class EmptyStatus extends ActStatus {
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/da/b0c3a5433d0d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/da/b0c3a5433d0d00131524a793807f338e
new file mode 100644
index 0000000..edb3968
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/da/b0c3a5433d0d00131524a793807f338e
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/title_activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/title_activity_main" >
+ </activity>
+ </application>
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/db/50df9b974b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/db/50df9b974b0d00131719b896d543f08c
new file mode 100644
index 0000000..e007692
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/db/50df9b974b0d00131719b896d543f08c
@@ -0,0 +1,63 @@
+package com.macaroon.piztor;
+
+import java.util.*;
+
+import android.annotation.SuppressLint;
+
+@SuppressLint("UseSparseArrays")
+public class ActMgr {
+ // event
+ PiztorAct act;
+ ActStatus nowStatus;
+ HashMap<ActStatus, HashMap<Integer, ActStatus>> mp;
+
+ ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) {
+ this.act = act;
+ this.nowStatus = nowStatus;
+ mp = new HashMap<ActStatus, HashMap<Integer, ActStatus>>();
+ for (int i = 0; i < r.length; i++) {
+ mp.put(r[i], new HashMap<Integer, ActStatus>());
+ }
+ }
+
+ void trigger(int event) {
+ // for (Integer i : mp.get(nowStatus).keySet())
+ // System.out.println(i);
+ if (mp.get(nowStatus).containsKey(event)) {
+ nowStatus.leave(event);
+ nowStatus = mp.get(nowStatus).get(event);
+ nowStatus.enter(event);
+ } else if (AppMgr.mp.get(act.getClass()).containsKey(event)) {
+ AppMgr.trigger(event);
+ }
+ }
+
+ void add(ActStatus a, int event, ActStatus b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, ActStatus> h = mp.get(a);
+ h.put(event, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, ActStatus> h = new HashMap<Integer, ActStatus>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+}
+
+abstract class ActStatus {
+ abstract void enter(int e);
+
+ abstract void leave(int e);
+}
+
+class EmptyStatus extends ActStatus {
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/dd/600b7a0f780d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/dd/600b7a0f780d00131719b896d543f08c
new file mode 100644
index 0000000..aec589a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/dd/600b7a0f780d00131719b896d543f08c
@@ -0,0 +1,192 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ autodate = new Timer();
+
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/dd/c0b636965b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/dd/c0b636965b0d00131719b896d543f08c
new file mode 100644
index 0000000..0e48f46
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/dd/c0b636965b0d00131719b896d543f08c
@@ -0,0 +1,106 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ @SuppressLint("HandlerLeak")
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ System.out.println(m.what);
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ System.out.println(user + " : " + pass + "\n");
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ AppMgr.transam.setHandler(hand);
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/de/20eb032c3c0d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/de/20eb032c3c0d00131524a793807f338e
new file mode 100644
index 0000000..005b0e7
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/de/20eb032c3c0d00131524a793807f338e
@@ -0,0 +1,100 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/de/a03d00d2760d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/de/a03d00d2760d00131719b896d543f08c
new file mode 100644
index 0000000..be5fc0f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/de/a03d00d2760d00131719b896d543f08c
@@ -0,0 +1,177 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " " + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0) System.out.println();
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/de/f01bbbba310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/de/f01bbbba310d00131249f322b63acde8
new file mode 100644
index 0000000..76e7505
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/de/f01bbbba310d00131249f322b63acde8
@@ -0,0 +1,79 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ //Event
+
+ final static int noToken = 101;
+
+
+ static Transam transam = null;
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ fromTransam = new Handler();
+ fromGPS = new Handler();
+ new Thread(transam).run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/df/406bf637390d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/df/406bf637390d00131524a793807f338e
new file mode 100644
index 0000000..4563127
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/df/406bf637390d00131524a793807f338e
@@ -0,0 +1,84 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.os.Handler;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+ //TODO fix
+ static Handler fromTransam, fromGPS;
+ static Transam transam = null;
+ static Thread tTransam, tGPS;
+ //Event
+
+ final static int noToken = 101;
+ final static int loginSuccess = 102;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+// fromTransam = new Handler();
+ transam = new Transam(UserInfo.ip, UserInfo.port, fromTransam);
+ //fromGPS = new Handler();
+// tTransam = new Thread(transam);
+// tTransam.run();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addStatus(Main.class);
+ addTransition(InitAct.class, noToken, Login.class);
+ addTransition(Login.class, loginSuccess, Main.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/e/d06a5fb7520d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e/d06a5fb7520d00131719b896d543f08c
new file mode 100644
index 0000000..62c7a40
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e/d06a5fb7520d00131719b896d543f08c
@@ -0,0 +1,241 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 1; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public void getLocation() {
+ try {
+
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/e0/40e5bce9370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e0/40e5bce9370d00131249f322b63acde8
new file mode 100644
index 0000000..b520b66
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e0/40e5bce9370d00131249f322b63acde8
@@ -0,0 +1,98 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ AppMgr.transam.send(new ReqLogin(user, pass, ));
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/306f6f46360d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/306f6f46360d00131249f322b63acde8
new file mode 100644
index 0000000..3a172b5
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/306f6f46360d00131249f322b63acde8
@@ -0,0 +1,72 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else (m.what == 101) {
+
+ }
+ }
+ };
+
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/9017fa5e2b0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/9017fa5e2b0d00131249f322b63acde8
new file mode 100644
index 0000000..000f373
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/9017fa5e2b0d00131249f322b63acde8
@@ -0,0 +1,14 @@
+package com.macaroon.piztor;
+
+//--------------------------------------//
+// Ask Location //
+//--------------------------------------//
+
+public class ReqLocation extends Req{
+ int gid; //group id;
+
+ ReqLocation(int token,int groupid,long time,long alive){
+ super(3,token,time,alive); //for type 3
+ gid = groupid;
+ }
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/b01fa77a4e0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/b01fa77a4e0d00131719b896d543f08c
new file mode 100644
index 0000000..94cfac8
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e1/b01fa77a4e0d00131719b896d543f08c
@@ -0,0 +1,16 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ 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=".Setting" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/hello_world" />
+
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/005a5d292d0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/005a5d292d0d00131249f322b63acde8
new file mode 100644
index 0000000..bd0b952
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/005a5d292d0d00131249f322b63acde8
@@ -0,0 +1,33 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+ else {
+ //TODO jump to main
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/4039c9d3330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/4039c9d3330d00131249f322b63acde8
new file mode 100644
index 0000000..831f4d7
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/4039c9d3330d00131249f322b63acde8
@@ -0,0 +1,58 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/d0880974550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/d0880974550d00131719b896d543f08c
new file mode 100644
index 0000000..55eb215
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e4/d0880974550d00131719b896d543f08c
@@ -0,0 +1,68 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ void setHandler(Handler hand) {
+ mHandler = hand;
+ }
+
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/e6/20fcf772310d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e6/20fcf772310d00131249f322b63acde8
new file mode 100644
index 0000000..71c3ad0
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e6/20fcf772310d00131249f322b63acde8
@@ -0,0 +1,133 @@
+package com.macaroon.piztor;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.annotation.SuppressLint;
+import android.os.Handler;
+import android.os.Message;
+
+public class Transam implements Runnable {
+ static Transam transam = null;
+ public Timer timer;
+ public Timer mtimer;
+ public boolean running = false;
+ public boolean flag = true;
+ public int cnt = 4;
+ Res res;
+ Req req;
+ public int p; //port
+ public String i; //ip
+ Thread thread;
+ Handler core;
+ Handler recall; //recall
+ Queue<Req> reqtask ; //request task
+
+ Transam(String ip, int port,Handler Recall) {
+ p = port;
+ i = ip;
+ recall = Recall;
+ reqtask = new LinkedList<Req>();
+ }
+
+ public void send(Req r){
+ reqtask.offer(r);
+
+ }
+
+ public void run() { //start the main timer
+ //TimerTask tmain = new Timertk();
+ //mtimer = new Timer();
+ //mtimer.schedule(tmain, 100, 100); //check the queue for every 100 msec
+
+ while(true){
+ if(running == false){
+
+ if(!reqtask.isEmpty()){ //poll the head request
+ req = reqtask.poll();
+ if(req.time + req.alive < System.currentTimeMillis()){ //time out!
+ Message ret = new Message();
+ ret.obj = "Time out!";
+ ret.what = 100;
+ recall.sendMessage(ret);
+ }
+ else{ //run the request
+ final thd t = new thd();
+ flag = false;
+ thread = new Thread(t);
+ cnt = 4;
+ running = true;
+ thread.start();
+ timer = new Timer();
+ TimerTask task = new Timertk();
+ timer.schedule(task, 2000, 2000);
+ }
+ }
+ }
+ }
+ }
+
+ class tmain extends TimerTask {
+ public void run() {
+
+ }
+ };
+
+ class thd implements Runnable {
+ public void run() {
+ try {
+ SocketClient client = new SocketClient(i,p);
+ client.sendMsg(req,recall);
+ Message msg = new Message();
+ msg.what = 1;
+ handler.sendMessage(msg);
+ client.closeSocket();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ System.out.println("UnknownHostException");
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("IOException");
+ }
+
+ }
+ }
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case 1:
+ flag = true;
+ break;
+ case 2:
+ final thd t = new thd();
+ thread = new Thread(t);
+ thread.start();
+ break;
+ }
+ super.handleMessage(msg);
+ }
+ };
+
+ class Timertk extends TimerTask {
+ public void run() {
+ if (flag == false && cnt > 0) {
+ cnt--;
+ } else if (cnt == 0) {
+ Message msg = new Message();
+ msg.obj = "connecting failed";
+ msg.what = 101;
+ recall.sendMessage(msg);
+ timer.cancel();
+ } else if (flag == true) {
+ timer.cancel();
+ running = false;
+ }
+ }
+ };
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/e7/00e5c3933a0d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e7/00e5c3933a0d00131524a793807f338e
new file mode 100644
index 0000000..e9712ce
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e7/00e5c3933a0d00131524a793807f338e
@@ -0,0 +1,22 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class Main extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/e9/201bd58e370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e9/201bd58e370d00131249f322b63acde8
new file mode 100644
index 0000000..7ab3c03
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/e9/201bd58e370d00131249f322b63acde8
@@ -0,0 +1,95 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/0041c861520d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/0041c861520d00131719b896d543f08c
new file mode 100644
index 0000000..af1543b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/0041c861520d00131719b896d543f08c
@@ -0,0 +1,64 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 1; // 1 second
+ public Timer timer;
+ private final Context mContext;
+ Controller controller;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Controller newController, Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ controller = newController;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/50149cac330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/50149cac330d00131249f322b63acde8
new file mode 100644
index 0000000..4aa65b2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/50149cac330d00131249f322b63acde8
@@ -0,0 +1,54 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/50fcb17a260d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/50fcb17a260d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..b652549
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/eb/50fcb17a260d00131a9bb9bc5a5e6171
@@ -0,0 +1,69 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int hasToken = 1;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, hasToken, Login.class);
+
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ed/d0b50c637c0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ed/d0b50c637c0d00131719b896d543f08c
new file mode 100644
index 0000000..1abca7b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ed/d0b50c637c0d00131719b896d543f08c
@@ -0,0 +1,203 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ else {
+ ReqUpdate r = new ReqUpdate(UserInfo.token,
+ l.getLatitude(), l.getLongitude(),
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == TimerFlush) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ AppMgr.transam.setHandler(fromTransam);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ autodate.schedule(new AutoUpdate(), 0, 5000);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/800bef37290d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/800bef37290d00131249f322b63acde8
new file mode 100644
index 0000000..4f58257
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/800bef37290d00131249f322b63acde8
@@ -0,0 +1,73 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int hasToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ System.out.println(nowAct.id + " : " + event);
+ if (mp.get(nowAct.getClass()) == null)
+ System.out.println("first");
+ else if (mp.get(nowAct.getClass()) == null)
+ System.out.println("second");
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, hasToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/8094037e770d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/8094037e770d00131719b896d543f08c
new file mode 100644
index 0000000..f0e8c6b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/8094037e770d00131719b896d543f08c
@@ -0,0 +1,181 @@
+package com.macaroon.piztor;
+
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ actMgr.trigger(FailedFetch);
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == SuccessFetch) {
+
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/e062b6d0520d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/e062b6d0520d00131719b896d543f08c
new file mode 100644
index 0000000..de79560
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/ee/e062b6d0520d00131719b896d543f08c
@@ -0,0 +1,62 @@
+package com.macaroon.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 3; // 3 second
+ public Timer timer;
+ private final Context mContext;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f/702f615d280d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f/702f615d280d00131249f322b63acde8
new file mode 100644
index 0000000..fd21453
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f/702f615d280d00131249f322b63acde8
@@ -0,0 +1,68 @@
+package com.macaroon.piztor;
+
+import java.util.HashMap;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+
+@SuppressLint("UseSparseArrays")
+public class AppMgr {
+ // Status
+ public enum ActivityStatus{
+ create, start, resume, restart, stop, pause, destroy
+ }
+ static ActivityStatus status;
+ static PiztorAct nowAct;
+
+ //Event
+
+ final static int hasToken = 101;
+
+
+ static HashMap<Class<?>, HashMap<Integer, Class<?>>> mp;
+
+ static void setStatus(ActivityStatus st) {
+ status = st;
+ }
+
+ static void trigger(int event) {
+
+ Intent i = new Intent();
+ i.setClass(nowAct, mp.get(nowAct.getClass()).get(event));
+ nowAct.startActivity(i);
+ }
+
+ static void add(Class<?> a, Integer event, Class<?> b) {
+ if (mp.containsKey(a))
+ mp.get(a).put(event, b);
+ else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addTransition(Class<?> a, int i, Class<?> b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, Class<?>> h = mp.get(a);
+ h.put(i, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, Class<?>> h = new HashMap<Integer, Class<?>>();
+ h.put(i, b);
+ mp.put(a, h);
+ }
+ }
+
+ static void addStatus(Class<?> a) {
+ mp.put(a, new HashMap<Integer, Class<?>>());
+ }
+
+ static void init() {
+ mp = new HashMap<Class<?>, HashMap<Integer, Class<?>>>();
+ addStatus(InitAct.class);
+ addStatus(Login.class);
+ addTransition(InitAct.class, hasToken, Login.class);
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f/c043e2232c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f/c043e2232c0d00131249f322b63acde8
new file mode 100644
index 0000000..f607c1f
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f/c043e2232c0d00131249f322b63acde8
@@ -0,0 +1,29 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ AppMgr.trigger(AppMgr.hasToken);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f0/a000529a350d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f0/a000529a350d00131249f322b63acde8
new file mode 100644
index 0000000..b3c9c89
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f0/a000529a350d00131249f322b63acde8
@@ -0,0 +1,63 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ }
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/00249bf3370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/00249bf3370d00131249f322b63acde8
new file mode 100644
index 0000000..db5a3d8
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/00249bf3370d00131249f322b63acde8
@@ -0,0 +1,98 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/e068ac2a250d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/e068ac2a250d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..629f1c1
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/e068ac2a250d00131a9bb9bc5a5e6171
@@ -0,0 +1,90 @@
+<?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
+ 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
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ 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: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/white"
+ />
+
+ <EditText
+ android:layout_width="0dp"
+ android:layout_weight="0.75"
+ android:id="@+id/user_pass"
+ android:password="true"
+ 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" />
+ </LinearLayout>
+
+</LinearLayout>
+</RelativeLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/e0f0dd782c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/e0f0dd782c0d00131249f322b63acde8
new file mode 100644
index 0000000..1623576
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f1/e0f0dd782c0d00131249f322b63acde8
@@ -0,0 +1,31 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+
+public class InitAct extends PiztorAct {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "initAct";
+ super.onCreate(savedInstanceState);
+ AppMgr.init();
+ setContentView(R.layout.activity_init);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ if (UserInfo.token != -1)
+ AppMgr.trigger(AppMgr.noToken);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.init, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f2/101fed70800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f2/101fed70800d00131719b896d543f08c
new file mode 100644
index 0000000..f0a2e0d
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f2/101fed70800d00131719b896d543f08c
@@ -0,0 +1,15 @@
+package com.macaroon.piztor;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+
+ static class UserInfo {
+ double lat, lot;
+ }
+
+ static class Group {
+
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f4/a087fd4e800d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f4/a087fd4e800d00131719b896d543f08c
new file mode 100644
index 0000000..929c0bb
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f4/a087fd4e800d00131719b896d543f08c
@@ -0,0 +1,8 @@
+package com.macaroon.piztor;
+
+public class UserInfo {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f4/a0da18d74d0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f4/a0da18d74d0d00131719b896d543f08c
new file mode 100644
index 0000000..e573032
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f4/a0da18d74d0d00131719b896d543f08c
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="48dip"
+ android:orientation="horizontal"
+ android:background="@drawable/footbar_background" >
+
+ <LinearLayout
+ android:id="@+id/footbar_btn_search_layout"
+ android:layout_width="64dip"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_marginTop="3dip"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1">
+ <ImageButton
+ android:id="@+id/footbar_btn_search"
+ android:layout_width="30dip"
+ android:layout_height="30dip"
+ android:layout_gravity="center"
+ android:background="@drawable/footbar_btn_search_style"/>
+ <TextView
+ android:id="@+id/footbar_btn_search_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:textSize="10dip"
+ android:textColor="@android:color/white"
+ android:layout_gravity="center"
+ android:text="@string/search"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/footbar_btn_fetch_layout"
+ android:layout_width="64dip"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_marginTop="3dip"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1">
+ <ImageButton
+ android:id="@+id/footbar_btn_fetch"
+ android:layout_width="30dip"
+ android:layout_height="30dip"
+ android:layout_gravity="center"
+ android:background="@drawable/footbar_btn_fetch_style"/>
+ <TextView
+ android:id="@+id/footbar_btn_fetch_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:textSize="10dip"
+ android:textColor="@android:color/white"
+ android:layout_gravity="center"
+ android:text="@string/fetch"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/footbar_btn_checkin_layout"
+ android:layout_width="64dip"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:layout_marginTop="3dip"
+ android:layout_gravity="center_vertical"
+ android:orientation="vertical">
+ <ImageButton
+ android:id="@+id/footbar_btn_checkin"
+ android:layout_width="30dip"
+ android:layout_height="30dip"
+ android:layout_gravity="center"
+ android:background="@drawable/footbar_btn_checkin_style"
+ />
+ <TextView
+ android:id="@+id/footbar_btn_checkin_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:textSize="10dip"
+ android:textColor="@android:color/white"
+ android:layout_gravity="center"
+ android:text="@string/checkin"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/footbar_btn_focus_layout"
+ android:layout_width="64dip"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_marginTop="3dip"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1">
+ <ImageButton
+ android:id="@+id/footbar_btn_focus"
+ android:layout_width="30dip"
+ android:layout_height="30dip"
+ android:layout_gravity="center"
+ android:background="@drawable/footbar_btn_focus_style"/>
+ <TextView
+ android:id="@+id/footbar_btn_focus_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:textSize="10dip"
+ android:textColor="@android:color/white"
+ android:layout_gravity="center"
+ android:text="@string/focus"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/footbar_btn_settings_layout"
+ android:layout_width="64dip"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:layout_marginTop="3dip"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1">
+ <ImageButton
+ android:id="@+id/footbar_btn_settings"
+ android:layout_width="30dip"
+ android:layout_height="30dip"
+ android:layout_gravity="center"
+ android:background="@drawable/footbar_btn_settings_style"/>
+ <TextView
+ android:id="@+id/footbar_btn_settings"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:textSize="10dip"
+ android:textColor="@android:color/white"
+ android:text="@string/settings"/>
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/50b3bf00680d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/50b3bf00680d00131719b896d543f08c
new file mode 100644
index 0000000..7bb08ae
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/50b3bf00680d00131719b896d543f08c
@@ -0,0 +1,91 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/c0432fca650d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/c0432fca650d00131719b896d543f08c
new file mode 100644
index 0000000..407ba24
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/c0432fca650d00131719b896d543f08c
@@ -0,0 +1,56 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/f009dded390d00131524a793807f338e b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/f009dded390d00131524a793807f338e
new file mode 100644
index 0000000..df74c99
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/f009dded390d00131524a793807f338e
@@ -0,0 +1,100 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+ String pass = edtPass.getText().toString();
+ long nowtime = System.currentTimeMillis();
+ AppMgr.transam.send(new ReqLogin(user, pass, nowtime, 1000));
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ ActStatus[] r = new ActStatus[2];
+ r[0] = new StartStatus();
+ r[1] = new LoginStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], loginButtonClick, r[1]);
+ actMgr.add(r[1], loginFailed, r[0]);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(loginButtonClick);
+ }
+ });
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/f0f9d74b5a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/f0f9d74b5a0d00131719b896d543f08c
new file mode 100644
index 0000000..0b24abd
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f6/f0f9d74b5a0d00131719b896d543f08c
@@ -0,0 +1,51 @@
+package com.macaroon.piztor;
+
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ ActMgr actMgr;
+
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f7/404fa93a860d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f7/404fa93a860d00131719b896d543f08c
new file mode 100644
index 0000000..d989280
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f7/404fa93a860d00131719b896d543f08c
@@ -0,0 +1,30 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import java.util.HashMap;
+import java.util.Vector;
+
+public class Infomation {
+ static String ip = "69.85.86.42";
+ static int port = 9990;
+ static int token = -1;
+ static int myId = -1;
+ static int myGroup = -1;
+ class UserInfo {
+ int id;
+ double lat, lot;
+ }
+
+ class Group {
+ int id;
+ Vector<UserInfo> v;
+ }
+
+ static HashMap<Integer, Group> mp;
+
+ @SuppressLint("UseSparseArrays")
+ static void init() {
+ mp = new HashMap<Integer, Group>();
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f8/10ed0356660d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f8/10ed0356660d00131719b896d543f08c
new file mode 100644
index 0000000..e530ef2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f8/10ed0356660d00131719b896d543f08c
@@ -0,0 +1,86 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+
+ ActMgr actMgr;
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f8/60faee49750d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f8/60faee49750d00131719b896d543f08c
new file mode 100644
index 0000000..c9f6043
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f8/60faee49750d00131719b896d543f08c
@@ -0,0 +1,159 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what > 100) {
+
+ }
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f9/40812ada6a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f9/40812ada6a0d00131719b896d543f08c
new file mode 100644
index 0000000..3778249
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f9/40812ada6a0d00131719b896d543f08c
@@ -0,0 +1,137 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "SearchButtonPress";
+ case FetchButtonPress:
+ return "FetchButtonPress";
+ case FocuseButtonPress:
+ return "FocuseButtonPress";
+ case SuccessFetch:
+ return "SuccessFetch";
+ case FailedFetch:
+ return "FailedFetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/f9/e06a5470670d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f9/e06a5470670d00131719b896d543f08c
new file mode 100644
index 0000000..c220c02
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/f9/e06a5470670d00131719b896d543f08c
@@ -0,0 +1,86 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+
+ ActMgr actMgr;
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ if (l == null)
+ System.out.println("fuck!!!");
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(handler);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fa/f0caef03230d00131a9bb9bc5a5e6171 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fa/f0caef03230d00131a9bb9bc5a5e6171
new file mode 100644
index 0000000..c760a59
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fa/f0caef03230d00131a9bb9bc5a5e6171
@@ -0,0 +1,5 @@
+package com.macaroon.piztor;
+
+public class PiztorExcepiton extends Exception{
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/10233142530d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/10233142530d00131719b896d543f08c
new file mode 100644
index 0000000..ec8f8bd
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/10233142530d00131719b896d543f08c
@@ -0,0 +1,33 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Menu;
+
+public class Main extends PiztorAct {
+
+ Handler handler = new Handler() {
+
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/10a53b2a7a0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/10a53b2a7a0d00131719b896d543f08c
new file mode 100644
index 0000000..a38e5a3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/10a53b2a7a0d00131719b896d543f08c
@@ -0,0 +1,197 @@
+package com.macaroon.piztor;
+
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ Timer autodate;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ switch (m.what) {
+ case 3:
+ ResLocation location = (ResLocation) m.obj;
+ for (int i = 0; i < location.n; i++) {
+ System.out.println(location.l.get(i).lat + " "
+ + location.l.get(i).lot);
+ }
+ actMgr.trigger(SuccessFetch);
+ break;
+ case 2:
+ ResUpdate update = (ResUpdate) m.obj;
+ if (update.t == 0)
+ System.out.println("update success");
+ else
+ System.out.println("update failed");
+ break;
+ default:
+ break;
+ }
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ if (e == TimerFlush) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1, System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+ if (e == FetchButtonPress) {
+ ReqLocation r = new ReqLocation(UserInfo.token, 1,
+ System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class AutoUpdate extends TimerTask {
+
+ @Override
+ public void run() {
+ actMgr.trigger(Main.TimerFlush);
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ actMgr.add(r[2], TimerFlush, r[2]);
+ autodate = new Timer();
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+
+ autodate.schedule(new AutoUpdate(), 5000);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/901006312c0d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/901006312c0d00131249f322b63acde8
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/901006312c0d00131249f322b63acde8
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/d0859c9d370d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/d0859c9d370d00131249f322b63acde8
new file mode 100644
index 0000000..d0ef95b
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/d0859c9d370d00131249f322b63acde8
@@ -0,0 +1,96 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+
+
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ int loginButtonClick = 1, retryButtonClick = 2, loginFailed = 3;
+
+ Handler hand = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what == 0) {
+ ResLogin res = (ResLogin) m.obj;
+ UserInfo.token = res.t;
+ actMgr.trigger(AppMgr.loginSuccess);
+ } else if (m.what == 101) {
+ actMgr.trigger(loginFailed);
+ }
+ }
+ };
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+ }
+
+ class LoginStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ String user = edtUser.getText().toString();
+
+ }
+
+ @Override
+ void leave(int e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ //AppMgr.transam.send(new ReqLogin(u, p, time, alive))
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/d0f7938e550d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/d0f7938e550d00131719b896d543f08c
new file mode 100644
index 0000000..82962d2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/d0f7938e550d00131719b896d543f08c
@@ -0,0 +1,240 @@
+package com.macaroon.piztor;
+
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.location.GpsStatus;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.SystemClock;
+import android.provider.Settings;
+import android.util.Log;
+
+public class GPSTracker extends Service implements LocationListener, GpsStatus.Listener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 3; // 10 seconds
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ // for GPS satellite status listener
+ Location mLastLocation;
+ long mLastLocationMillis;
+ boolean isGPSFix;
+
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ isGPSFix = false;
+ getLocation();
+ }
+
+ public Location getLocation() {
+ try {
+ Log.d("getLocation", "Start getting location......");
+
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+
+ Log.d("Network", "Network Updated");
+
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("Network", "Received Network Data");
+ System.out.println("***From Network: "+latitude + " " + longitude);
+ }
+ }
+ }// end of network section
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (true) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS", "GPS Updated");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ Log.d("GPS", "Received GPS Data");
+ System.out.println("***From GPS: "+latitude + " " + longitude);
+
+ }
+ }
+ }
+ }// end of GPS section
+ }// end of fetching data
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return location;
+ }
+
+ /**
+ * Stop using GPS listener Calling this function will stop using GPS in your
+ * app
+ * */
+ public void stopUsingGPS() {
+ if (locationManager != null) {
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude() {
+ if (location != null) {
+ latitude = location.getLatitude();
+ }
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude() {
+ if (location != null) {
+ longitude = location.getLongitude();
+ }
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ *
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ public boolean isGPSFix() {
+ return (this.isGPSFix && location != null);
+ }
+
+ /**
+ * Function to show settings alert dialog On pressing Settings button will
+ * lauch Settings Options
+ * */
+ public void showSettingsAlert() {
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog
+ .setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(
+ Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel",
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ if (location == null) return;
+ mLastLocationMillis = SystemClock.elapsedRealtime();
+ mLastLocation = location;
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+ @Override
+ public void onGpsStatusChanged(int event) {
+ switch (event) {
+ case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
+ if(mLastLocation != null)
+ isGPSFix = (SystemClock.elapsedRealtime() - mLastLocationMillis) < 3000;
+ break;
+
+ case GpsStatus.GPS_EVENT_FIRST_FIX:
+ isGPSFix = true;
+ break;
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/e0d4eed4300d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/e0d4eed4300d00131249f322b63acde8
new file mode 100644
index 0000000..3ca0dfe
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fb/e0d4eed4300d00131249f322b63acde8
@@ -0,0 +1,133 @@
+package com.macaroon.piztor;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.annotation.SuppressLint;
+import android.os.Handler;
+import android.os.Message;
+
+public class Transam implements Runnable {
+
+ public Timer timer;
+ public Timer mtimer;
+ public boolean running = false;
+ public boolean flag = true;
+ public int cnt = 4;
+ Res res;
+ Req req;
+ public int p; //port
+ public String i; //ip
+ Thread thread;
+ Handler core;
+ Handler recall; //recall
+ Queue<Req> reqtask ; //request task
+
+ Transam(String ip, int port,Handler Recall) {
+ p = port;
+ i = ip;
+ recall = Recall;
+ reqtask = new LinkedList<Req>();
+ }
+
+ public void send(Req r){
+ reqtask.offer(r);
+
+ }
+
+ public void run() { //start the main timer
+ //TimerTask tmain = new Timertk();
+ //mtimer = new Timer();
+ //mtimer.schedule(tmain, 100, 100); //check the queue for every 100 msec
+
+ while(true){
+ if(running == false){
+
+ if(!reqtask.isEmpty()){ //poll the head request
+ req = reqtask.poll();
+ if(req.time + req.alive < System.currentTimeMillis()){ //time out!
+ Message ret = new Message();
+ ret.obj = "Time out!";
+ ret.what = 100;
+ recall.sendMessage(ret);
+ }
+ else{ //run the request
+ final thd t = new thd();
+ flag = false;
+ thread = new Thread(t);
+ cnt = 4;
+ running = true;
+ thread.start();
+ timer = new Timer();
+ TimerTask task = new Timertk();
+ timer.schedule(task, 2000, 2000);
+ }
+ }
+ }
+ }
+ }
+
+ class tmain extends TimerTask {
+ public void run() {
+
+ }
+ };
+
+ class thd implements Runnable {
+ public void run() {
+ try {
+ SocketClient client = new SocketClient(i,p);
+ client.sendMsg(req,recall);
+ Message msg = new Message();
+ msg.what = 1;
+ handler.sendMessage(msg);
+ client.closeSocket();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ System.out.println("UnknownHostException");
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.out.println("IOException");
+ }
+
+ }
+ }
+
+ @SuppressLint("HandlerLeak")
+ Handler handler = new Handler() {
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case 1:
+ flag = true;
+ break;
+ case 2:
+ final thd t = new thd();
+ thread = new Thread(t);
+ thread.start();
+ break;
+ }
+ super.handleMessage(msg);
+ }
+ };
+
+ class Timertk extends TimerTask {
+ public void run() {
+ if (flag == false && cnt > 0) {
+ cnt--;
+ } else if (cnt == 0) {
+ Message msg = new Message();
+ msg.obj = "connecting failed";
+ msg.what = 101;
+ recall.sendMessage(msg);
+ timer.cancel();
+ } else if (flag == true) {
+ timer.cancel();
+ running = false;
+ }
+ }
+ };
+} \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fc/f05e84f54e0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fc/f05e84f54e0d00131719b896d543f08c
new file mode 100644
index 0000000..e5faf14
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fc/f05e84f54e0d00131719b896d543f08c
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/title_activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/title_activity_main" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Setting"
+ android:label="@string/title_activity_setting" >
+ </activity>
+ </application>
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/50c48d3c520d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/50c48d3c520d00131719b896d543f08c
new file mode 100644
index 0000000..e4aa2b1
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/50c48d3c520d00131719b896d543f08c
@@ -0,0 +1,64 @@
+package com.example.piztor;
+
+import android.content.Context;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.os.SystemClock;
+
+
+public class Tracker implements Runnable {
+
+ private static final long TIME_DELTA = 1000 * 1; // 1 second
+ public Timer timer;
+ private final Context mContext;
+ Controller controller;
+ GPSTracker myTracker;
+ Handler mHandler;
+ Message message;
+
+ public Tracker(Controller newController, Context context, Handler yHandler) {
+ timer = new Timer();
+ mContext = context;
+ controller = newController;
+ myTracker = new GPSTracker(mContext);
+ mHandler = yHandler;
+ }
+
+ public void run() {
+ GPSTask myTask = new GPSTask();
+ timer.schedule(myTask, 0, TIME_DELTA);
+ }
+
+ class GPSTask extends TimerTask {
+ @Override
+ public void run() {
+ message = new Message();
+ message.what = 0;
+ myTracker.getLocation();
+ Log.d("Location", "Fetching location.....");
+ if (myTracker.canGetLocation()) {
+ double latitude = myTracker.getLatitude();
+ double longitude = myTracker.getLongitude();
+
+ Log.d("TTTTTTTTTTTTTTTTTTTTTTTime","TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTime");
+ System.out.println("GPSTIME" + myTracker.location.getTime());
+ System.out.println("SYSTIME" + SystemClock.elapsedRealtime());
+
+ if(myTracker.isGPSFix()) {
+ message.what = 1;
+ } else {
+ message.what = 2;
+ }
+ mHandler.sendMessage(message);
+ } else {
+ message.what = 0;
+ mHandler.sendMessage(message);
+ }
+ }
+ }
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/7081acc66c0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/7081acc66c0d00131719b896d543f08c
new file mode 100644
index 0000000..4d75ae6
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/7081acc66c0d00131719b896d543f08c
@@ -0,0 +1,154 @@
+package com.macaroon.piztor;
+
+import android.annotation.SuppressLint;
+import android.location.Location;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.ImageButton;
+
+public class Main extends PiztorAct {
+
+ final static int SearchButtonPress = 1;
+ final static int FetchButtonPress = 2;
+ final static int FocuseButtonPress = 3;
+ final static int SuccessFetch = 4;
+ final static int FailedFetch = 5;
+ final static int TimerFlush = 6;
+ ActMgr actMgr;
+ ImageButton btnSearch, btnFetch, btnFocus, btnSettings;
+ @SuppressLint("HandlerLeak")
+ Handler fromGPS = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ if (m.what != 0) {
+ Location l = (Location) m.obj;
+ ReqUpdate r = new ReqUpdate(UserInfo.token, l.getLatitude(),
+ l.getLongitude(), System.currentTimeMillis(), 1000);
+ AppMgr.transam.send(r);
+ }
+ }
+ };
+
+ Handler fromTransam = new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+
+ }
+ };
+
+ String cause(int t) {
+ switch (t) {
+ case SearchButtonPress:
+ return "Search Button Press";
+ case FetchButtonPress:
+ return "Fetch Button Press";
+ case FocuseButtonPress:
+ return "Focuse Button Press";
+ case SuccessFetch:
+ return "Success Fetch";
+ case FailedFetch:
+ return "Failed Fetch";
+ case TimerFlush:
+ return "TimerFlush";
+ default:
+ return "Fuck!!!";
+ }
+ }
+
+ class StartStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter start status!!!!");
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave start status!!!! because" + cause(e));
+ }
+
+ }
+
+ class FetchStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter Fetch status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave fetch status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ class FocusStatus extends ActStatus {
+
+ @Override
+ void enter(int e) {
+ System.out.println("enter focus status!!!!");
+
+ }
+
+ @Override
+ void leave(int e) {
+ System.out.println("leave focus status!!!! because" + cause(e));
+
+ }
+
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "Main";
+ super.onCreate(savedInstanceState);
+ AppMgr.tracker.setHandler(fromGPS);
+ ActStatus[] r = new ActStatus[3];
+ r[0] = new StartStatus();
+ r[1] = new FetchStatus();
+ r[2] = new FocusStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ actMgr.add(r[0], FocuseButtonPress, r[2]);
+ actMgr.add(r[0], FetchButtonPress, r[1]);
+ actMgr.add(r[1], FetchButtonPress, r[0]);
+ actMgr.add(r[1], FailedFetch, r[0]);
+ actMgr.add(r[2], FocuseButtonPress, r[0]);
+ actMgr.add(r[0], TimerFlush, r[0]);
+ setContentView(R.layout.activity_main);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ btnFetch = (ImageButton) findViewById(R.id.footbar_btn_fetch);
+ btnFocus = (ImageButton) findViewById(R.id.footbar_btn_focus);
+ btnSearch = (ImageButton) findViewById(R.id.footbar_btn_search);
+ btnSettings = (ImageButton) findViewById(R.id.footbar_btn_settings);
+ btnFetch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ actMgr.trigger(FetchButtonPress);
+ }
+ });
+ btnFocus.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ actMgr.trigger(FocuseButtonPress);
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/90b04d264f0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/90b04d264f0d00131719b896d543f08c
new file mode 100644
index 0000000..eea1611
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fd/90b04d264f0d00131719b896d543f08c
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.macaroon.piztor"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar" >
+ <activity
+ android:name="com.macaroon.piztor.InitAct"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Login"
+ android:label="@string/activity_login" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Main"
+ android:label="@string/activity_main" >
+ </activity>
+ <activity
+ android:name="com.macaroon.piztor.Setting"
+ android:label="@string/activity_setting" >
+ </activity>
+ </application>
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+
+</manifest>
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fe/4015f3cd330d00131249f322b63acde8 b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fe/4015f3cd330d00131249f322b63acde8
new file mode 100644
index 0000000..9886d46
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fe/4015f3cd330d00131249f322b63acde8
@@ -0,0 +1,58 @@
+package com.macaroon.piztor;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.Menu;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class Login extends PiztorAct {
+ ActMgr actMgr;
+ Button btnLogin;
+ EditText edtUser, edtPass;
+
+ Handler hand = new Handler() {
+ @Override
+ public boolean sendMessage(Message m) {
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ id = "login";
+ super.onCreate(savedInstanceState);
+ btnLogin = (Button) findViewById(R.id.login_btn_login);
+ edtUser = (EditText) findViewById(R.id.user_id);
+ edtPass = (EditText) findViewById(R.id.user_pass);
+ EmptyStatus[] r = new EmptyStatus[1];
+ r[0] = new EmptyStatus();
+ actMgr = new ActMgr(this, r[0], r);
+ setContentView(R.layout.activity_login);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ btnLogin.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.login, menu);
+ return true;
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.history/fe/c09a68a94b0d00131719b896d543f08c b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fe/c09a68a94b0d00131719b896d543f08c
new file mode 100644
index 0000000..81fa6f2
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.history/fe/c09a68a94b0d00131719b896d543f08c
@@ -0,0 +1,63 @@
+package com.macaroon.piztor;
+
+import java.util.*;
+
+import android.annotation.SuppressLint;
+
+@SuppressLint("UseSparseArrays")
+public class ActMgr {
+ // event
+ PiztorAct act;
+ ActStatus nowStatus;
+ HashMap<ActStatus, HashMap<Integer, ActStatus>> mp;
+
+ ActMgr(PiztorAct act, ActStatus nowStatus, ActStatus[] r) {
+ this.act = act;
+ this.nowStatus = nowStatus;
+ mp = new HashMap<ActStatus, HashMap<Integer, ActStatus>>();
+ for (int i = 0; i < r.length; i++) {
+ mp.put(r[i], new HashMap<Integer, ActStatus>());
+ }
+ }
+
+ void trigger(int event) {
+ for (Integer i : mp.get(nowStatus).keySet())
+ System.out.println(i);
+ if (mp.get(nowStatus).containsKey(event)) {
+ nowStatus.leave(event);
+ nowStatus = mp.get(nowStatus).get(event);
+ nowStatus.enter(event);
+ } else if (AppMgr.mp.get(act.getClass()).containsKey(event)) {
+ AppMgr.trigger(event);
+ }
+ }
+
+ void add(ActStatus a, int event, ActStatus b) {
+ if (mp.containsKey(a)) {
+ HashMap<Integer, ActStatus> h = mp.get(a);
+ h.put(event, b);
+ mp.put(a, h);
+ } else {
+ HashMap<Integer, ActStatus> h = new HashMap<Integer, ActStatus>();
+ h.put(event, b);
+ mp.put(a, h);
+ }
+ }
+}
+
+abstract class ActStatus {
+ abstract void enter(int e);
+
+ abstract void leave(int e);
+}
+
+class EmptyStatus extends ActStatus {
+ @Override
+ void enter(int e) {
+ }
+
+ @Override
+ void leave(int e) {
+ }
+
+}
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/5f/properties.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/5f/properties.index
new file mode 100644
index 0000000..e7671ef
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/5f/properties.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/62/properties.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/62/properties.index
new file mode 100644
index 0000000..1e11659
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/62/properties.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/66/properties.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/66/properties.index
new file mode 100644
index 0000000..57d84c4
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/66/properties.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/cd/properties.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/cd/properties.index
new file mode 100644
index 0000000..3efb4ac
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/cd/properties.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/d6/history.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/d6/history.index
new file mode 100644
index 0000000..c8e5f63
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/d6/history.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/d6/properties.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/d6/properties.index
new file mode 100644
index 0000000..7344135
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/d6/properties.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/de/history.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/de/history.index
new file mode 100644
index 0000000..1949e88
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/de/history.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/de/properties.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/de/properties.index
new file mode 100644
index 0000000..e1d4fc9
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/de/properties.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/eb/properties.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/eb/properties.index
new file mode 100644
index 0000000..99b3382
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/eb/properties.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/ee/properties.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/ee/properties.index
new file mode 100644
index 0000000..e123a38
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/a0/ee/properties.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/af/history.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/af/history.index
new file mode 100644
index 0000000..23cfed3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/af/history.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/e4/81/32/ea/history.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/e4/81/32/ea/history.index
new file mode 100644
index 0000000..d864ea3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/e4/81/32/ea/history.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/e4/history.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/e4/history.index
new file mode 100644
index 0000000..9d98849
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/e4/history.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/history.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/history.index
new file mode 100644
index 0000000..9a6bfd9
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/history.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/properties.index b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/properties.index
new file mode 100644
index 0000000..1005094
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.indexes/properties.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.markers b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.markers
new file mode 100644
index 0000000..9d6ddfa
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.markers
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.markers.snap b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.markers.snap
new file mode 100644
index 0000000..2a8bb67
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.markers.snap
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.syncinfo.snap b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.syncinfo.snap
new file mode 100644
index 0000000..5213c44
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.projects/Piztor/.syncinfo.snap
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version
new file mode 100644
index 0000000..25cb955
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index
new file mode 100644
index 0000000..a25bfee
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version
new file mode 100644
index 0000000..6b2aaa7
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap b/client/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap
new file mode 100644
index 0000000..79a81b5
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.root/7.tree b/client/.metadata/.plugins/org.eclipse.core.resources/.root/7.tree
new file mode 100644
index 0000000..d5bd564
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.root/7.tree
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/client/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources
new file mode 100644
index 0000000..b497eb3
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources
Binary files differ
diff --git a/client/.metadata/.plugins/org.eclipse.core.resources/.snap b/client/.metadata/.plugins/org.eclipse.core.resources/.snap
new file mode 100644
index 0000000..369021a
--- /dev/null
+++ b/client/.metadata/.plugins/org.eclipse.core.resources/.snap
Binary files differ