diff --git a/.idea/libraries/android_android_25.xml b/.idea/libraries/android_android_25.xml
new file mode 100644
index 0000000..98ea25c
--- /dev/null
+++ b/.idea/libraries/android_android_25.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/animated_vector_drawable_25_2_0.xml b/.idea/libraries/animated_vector_drawable_25_2_0.xml
index 6bc507e..5853cea 100644
--- a/.idea/libraries/animated_vector_drawable_25_2_0.xml
+++ b/.idea/libraries/animated_vector_drawable_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/appcompat_v7_25_2_0.xml b/.idea/libraries/appcompat_v7_25_2_0.xml
index c3bf7d3..f95222b 100644
--- a/.idea/libraries/appcompat_v7_25_2_0.xml
+++ b/.idea/libraries/appcompat_v7_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/constraint_layout_1_0_2.xml b/.idea/libraries/constraint_layout_1_0_2.xml
index d1b5ec4..7728ce2 100644
--- a/.idea/libraries/constraint_layout_1_0_2.xml
+++ b/.idea/libraries/constraint_layout_1_0_2.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/constraint_layout_solver_1_0_2.xml b/.idea/libraries/constraint_layout_solver_1_0_2.xml
index f71d1a6..56b0a1d 100644
--- a/.idea/libraries/constraint_layout_solver_1_0_2.xml
+++ b/.idea/libraries/constraint_layout_solver_1_0_2.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/.idea/libraries/design_25_2_0.xml b/.idea/libraries/design_25_2_0.xml
index c28c011..ffb67d5 100644
--- a/.idea/libraries/design_25_2_0.xml
+++ b/.idea/libraries/design_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_analytics_10_2_1.xml b/.idea/libraries/firebase_analytics_10_2_1.xml
index e2e5b79..808e345 100644
--- a/.idea/libraries/firebase_analytics_10_2_1.xml
+++ b/.idea/libraries/firebase_analytics_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_analytics_impl_10_2_1.xml b/.idea/libraries/firebase_analytics_impl_10_2_1.xml
index 6ee0802..c7c555c 100644
--- a/.idea/libraries/firebase_analytics_impl_10_2_1.xml
+++ b/.idea/libraries/firebase_analytics_impl_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_appindexing_10_2_1.xml b/.idea/libraries/firebase_appindexing_10_2_1.xml
index 3ad2d83..67f978f 100644
--- a/.idea/libraries/firebase_appindexing_10_2_1.xml
+++ b/.idea/libraries/firebase_appindexing_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_auth_10_2_1.xml b/.idea/libraries/firebase_auth_10_2_1.xml
index 2032806..09a4811 100644
--- a/.idea/libraries/firebase_auth_10_2_1.xml
+++ b/.idea/libraries/firebase_auth_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_common_10_2_1.xml b/.idea/libraries/firebase_common_10_2_1.xml
index 4aadd32..363b350 100644
--- a/.idea/libraries/firebase_common_10_2_1.xml
+++ b/.idea/libraries/firebase_common_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_config_10_2_1.xml b/.idea/libraries/firebase_config_10_2_1.xml
index a76837c..e5283a2 100644
--- a/.idea/libraries/firebase_config_10_2_1.xml
+++ b/.idea/libraries/firebase_config_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_crash_10_2_1.xml b/.idea/libraries/firebase_crash_10_2_1.xml
index d8d5305..67f081f 100644
--- a/.idea/libraries/firebase_crash_10_2_1.xml
+++ b/.idea/libraries/firebase_crash_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_database_10_2_1.xml b/.idea/libraries/firebase_database_10_2_1.xml
index 2a999c4..667de92 100644
--- a/.idea/libraries/firebase_database_10_2_1.xml
+++ b/.idea/libraries/firebase_database_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_database_connection_10_2_1.xml b/.idea/libraries/firebase_database_connection_10_2_1.xml
index 9885f15..672fd5c 100644
--- a/.idea/libraries/firebase_database_connection_10_2_1.xml
+++ b/.idea/libraries/firebase_database_connection_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_iid_10_2_1.xml b/.idea/libraries/firebase_iid_10_2_1.xml
index 66a0d4c..7c7c87e 100644
--- a/.idea/libraries/firebase_iid_10_2_1.xml
+++ b/.idea/libraries/firebase_iid_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_messaging_10_2_1.xml b/.idea/libraries/firebase_messaging_10_2_1.xml
index 2f3ce31..39a28be 100644
--- a/.idea/libraries/firebase_messaging_10_2_1.xml
+++ b/.idea/libraries/firebase_messaging_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_storage_10_2_1.xml b/.idea/libraries/firebase_storage_10_2_1.xml
index a38480b..913dcd9 100644
--- a/.idea/libraries/firebase_storage_10_2_1.xml
+++ b/.idea/libraries/firebase_storage_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/firebase_storage_common_10_2_1.xml b/.idea/libraries/firebase_storage_common_10_2_1.xml
index 51e9305..b0a51e8 100644
--- a/.idea/libraries/firebase_storage_common_10_2_1.xml
+++ b/.idea/libraries/firebase_storage_common_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/mediarouter_v7_24_0_0.xml b/.idea/libraries/mediarouter_v7_24_0_0.xml
index fc56bf3..101a1bf 100644
--- a/.idea/libraries/mediarouter_v7_24_0_0.xml
+++ b/.idea/libraries/mediarouter_v7_24_0_0.xml
@@ -1,9 +1,9 @@
-
-
-
+
+
+
diff --git a/.idea/libraries/palette_v7_24_0_0.xml b/.idea/libraries/palette_v7_24_0_0.xml
index af2601f..6122d8d 100644
--- a/.idea/libraries/palette_v7_24_0_0.xml
+++ b/.idea/libraries/palette_v7_24_0_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_10_2_1.xml b/.idea/libraries/play_services_10_2_1.xml
index 414b103..a120cfb 100644
--- a/.idea/libraries/play_services_10_2_1.xml
+++ b/.idea/libraries/play_services_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_ads_10_2_1.xml b/.idea/libraries/play_services_ads_10_2_1.xml
index 6a617f7..c0bfa92 100644
--- a/.idea/libraries/play_services_ads_10_2_1.xml
+++ b/.idea/libraries/play_services_ads_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_ads_lite_10_2_1.xml b/.idea/libraries/play_services_ads_lite_10_2_1.xml
index fab8387..cc394f1 100644
--- a/.idea/libraries/play_services_ads_lite_10_2_1.xml
+++ b/.idea/libraries/play_services_ads_lite_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_analytics_10_2_1.xml b/.idea/libraries/play_services_analytics_10_2_1.xml
index 025cf75..fcf22a6 100644
--- a/.idea/libraries/play_services_analytics_10_2_1.xml
+++ b/.idea/libraries/play_services_analytics_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_analytics_impl_10_2_1.xml b/.idea/libraries/play_services_analytics_impl_10_2_1.xml
index a6e983a..945b270 100644
--- a/.idea/libraries/play_services_analytics_impl_10_2_1.xml
+++ b/.idea/libraries/play_services_analytics_impl_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_appinvite_10_2_1.xml b/.idea/libraries/play_services_appinvite_10_2_1.xml
index 9d2dc23..8e36a2f 100644
--- a/.idea/libraries/play_services_appinvite_10_2_1.xml
+++ b/.idea/libraries/play_services_appinvite_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_auth_10_2_1.xml b/.idea/libraries/play_services_auth_10_2_1.xml
index 3d05e55..7e09141 100644
--- a/.idea/libraries/play_services_auth_10_2_1.xml
+++ b/.idea/libraries/play_services_auth_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_auth_base_10_2_1.xml b/.idea/libraries/play_services_auth_base_10_2_1.xml
index b6ebdec..8827d8b 100644
--- a/.idea/libraries/play_services_auth_base_10_2_1.xml
+++ b/.idea/libraries/play_services_auth_base_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_awareness_10_2_1.xml b/.idea/libraries/play_services_awareness_10_2_1.xml
index 01105ba..2d5c4db 100644
--- a/.idea/libraries/play_services_awareness_10_2_1.xml
+++ b/.idea/libraries/play_services_awareness_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_base_10_2_1.xml b/.idea/libraries/play_services_base_10_2_1.xml
index 92b4f58..3042019 100644
--- a/.idea/libraries/play_services_base_10_2_1.xml
+++ b/.idea/libraries/play_services_base_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_basement_10_2_1.xml b/.idea/libraries/play_services_basement_10_2_1.xml
index 95cebd0..5c6e9ec 100644
--- a/.idea/libraries/play_services_basement_10_2_1.xml
+++ b/.idea/libraries/play_services_basement_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_cast_10_2_1.xml b/.idea/libraries/play_services_cast_10_2_1.xml
index 39c2884..8a9c3ad 100644
--- a/.idea/libraries/play_services_cast_10_2_1.xml
+++ b/.idea/libraries/play_services_cast_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_cast_framework_10_2_1.xml b/.idea/libraries/play_services_cast_framework_10_2_1.xml
index 8322311..c66ae7e 100644
--- a/.idea/libraries/play_services_cast_framework_10_2_1.xml
+++ b/.idea/libraries/play_services_cast_framework_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_clearcut_10_2_1.xml b/.idea/libraries/play_services_clearcut_10_2_1.xml
index efbcb85..9ea87b6 100644
--- a/.idea/libraries/play_services_clearcut_10_2_1.xml
+++ b/.idea/libraries/play_services_clearcut_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_drive_10_2_1.xml b/.idea/libraries/play_services_drive_10_2_1.xml
index bdf6671..2de700f 100644
--- a/.idea/libraries/play_services_drive_10_2_1.xml
+++ b/.idea/libraries/play_services_drive_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_fitness_10_2_1.xml b/.idea/libraries/play_services_fitness_10_2_1.xml
index 66d6b95..824f44b 100644
--- a/.idea/libraries/play_services_fitness_10_2_1.xml
+++ b/.idea/libraries/play_services_fitness_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_games_10_2_1.xml b/.idea/libraries/play_services_games_10_2_1.xml
index 3da5ec7..f735d29 100644
--- a/.idea/libraries/play_services_games_10_2_1.xml
+++ b/.idea/libraries/play_services_games_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_gass_10_2_1.xml b/.idea/libraries/play_services_gass_10_2_1.xml
index 4900b8b..c707293 100644
--- a/.idea/libraries/play_services_gass_10_2_1.xml
+++ b/.idea/libraries/play_services_gass_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_gcm_10_2_1.xml b/.idea/libraries/play_services_gcm_10_2_1.xml
index b7da4a6..2a9cdc5 100644
--- a/.idea/libraries/play_services_gcm_10_2_1.xml
+++ b/.idea/libraries/play_services_gcm_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_identity_10_2_1.xml b/.idea/libraries/play_services_identity_10_2_1.xml
index 2b50011..8e097b8 100644
--- a/.idea/libraries/play_services_identity_10_2_1.xml
+++ b/.idea/libraries/play_services_identity_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_iid_10_2_1.xml b/.idea/libraries/play_services_iid_10_2_1.xml
index d071b18..09a1e64 100644
--- a/.idea/libraries/play_services_iid_10_2_1.xml
+++ b/.idea/libraries/play_services_iid_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_instantapps_10_2_1.xml b/.idea/libraries/play_services_instantapps_10_2_1.xml
index b07ca8f..63f32db 100644
--- a/.idea/libraries/play_services_instantapps_10_2_1.xml
+++ b/.idea/libraries/play_services_instantapps_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_location_10_2_1.xml b/.idea/libraries/play_services_location_10_2_1.xml
index 341932a..b34e4f9 100644
--- a/.idea/libraries/play_services_location_10_2_1.xml
+++ b/.idea/libraries/play_services_location_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_maps_10_2_1.xml b/.idea/libraries/play_services_maps_10_2_1.xml
index 4e47fac..eb78348 100644
--- a/.idea/libraries/play_services_maps_10_2_1.xml
+++ b/.idea/libraries/play_services_maps_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_nearby_10_2_1.xml b/.idea/libraries/play_services_nearby_10_2_1.xml
index 41cfb77..ded4263 100644
--- a/.idea/libraries/play_services_nearby_10_2_1.xml
+++ b/.idea/libraries/play_services_nearby_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_panorama_10_2_1.xml b/.idea/libraries/play_services_panorama_10_2_1.xml
index ebb72ca..61c013f 100644
--- a/.idea/libraries/play_services_panorama_10_2_1.xml
+++ b/.idea/libraries/play_services_panorama_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_places_10_2_1.xml b/.idea/libraries/play_services_places_10_2_1.xml
index fde1fe2..8edfc10 100644
--- a/.idea/libraries/play_services_places_10_2_1.xml
+++ b/.idea/libraries/play_services_places_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_plus_10_2_1.xml b/.idea/libraries/play_services_plus_10_2_1.xml
index 6632723..5bd78cd 100644
--- a/.idea/libraries/play_services_plus_10_2_1.xml
+++ b/.idea/libraries/play_services_plus_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_safetynet_10_2_1.xml b/.idea/libraries/play_services_safetynet_10_2_1.xml
index a89d968..54564df 100644
--- a/.idea/libraries/play_services_safetynet_10_2_1.xml
+++ b/.idea/libraries/play_services_safetynet_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_tagmanager_10_2_1.xml b/.idea/libraries/play_services_tagmanager_10_2_1.xml
index 3c84978..3eb6585 100644
--- a/.idea/libraries/play_services_tagmanager_10_2_1.xml
+++ b/.idea/libraries/play_services_tagmanager_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_tagmanager_api_10_2_1.xml b/.idea/libraries/play_services_tagmanager_api_10_2_1.xml
index abca14b..1e5e79d 100644
--- a/.idea/libraries/play_services_tagmanager_api_10_2_1.xml
+++ b/.idea/libraries/play_services_tagmanager_api_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_tagmanager_v4_impl_10_2_1.xml b/.idea/libraries/play_services_tagmanager_v4_impl_10_2_1.xml
index b9ca396..1252988 100644
--- a/.idea/libraries/play_services_tagmanager_v4_impl_10_2_1.xml
+++ b/.idea/libraries/play_services_tagmanager_v4_impl_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_tasks_10_2_1.xml b/.idea/libraries/play_services_tasks_10_2_1.xml
index 26ea46e..4792681 100644
--- a/.idea/libraries/play_services_tasks_10_2_1.xml
+++ b/.idea/libraries/play_services_tasks_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_vision_10_2_1.xml b/.idea/libraries/play_services_vision_10_2_1.xml
index 79d9f62..bc4f4e1 100644
--- a/.idea/libraries/play_services_vision_10_2_1.xml
+++ b/.idea/libraries/play_services_vision_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_wallet_10_2_1.xml b/.idea/libraries/play_services_wallet_10_2_1.xml
index b9cd397..cc560ae 100644
--- a/.idea/libraries/play_services_wallet_10_2_1.xml
+++ b/.idea/libraries/play_services_wallet_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/play_services_wearable_10_2_1.xml b/.idea/libraries/play_services_wearable_10_2_1.xml
index 66fd7ad..bbf69ea 100644
--- a/.idea/libraries/play_services_wearable_10_2_1.xml
+++ b/.idea/libraries/play_services_wearable_10_2_1.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/recyclerview_v7_25_2_0.xml b/.idea/libraries/recyclerview_v7_25_2_0.xml
index 19c8e35..14f3d97 100644
--- a/.idea/libraries/recyclerview_v7_25_2_0.xml
+++ b/.idea/libraries/recyclerview_v7_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/support_annotations_25_2_0.xml b/.idea/libraries/support_annotations_25_2_0.xml
index 42b4756..f65f4d8 100644
--- a/.idea/libraries/support_annotations_25_2_0.xml
+++ b/.idea/libraries/support_annotations_25_2_0.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/.idea/libraries/support_compat_25_2_0.xml b/.idea/libraries/support_compat_25_2_0.xml
index 25563ae..1a09417 100644
--- a/.idea/libraries/support_compat_25_2_0.xml
+++ b/.idea/libraries/support_compat_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/support_core_ui_25_2_0.xml b/.idea/libraries/support_core_ui_25_2_0.xml
index 751daf9..b0bcc01 100644
--- a/.idea/libraries/support_core_ui_25_2_0.xml
+++ b/.idea/libraries/support_core_ui_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/support_core_utils_25_2_0.xml b/.idea/libraries/support_core_utils_25_2_0.xml
index 6ec9ea5..01f0ed4 100644
--- a/.idea/libraries/support_core_utils_25_2_0.xml
+++ b/.idea/libraries/support_core_utils_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/support_fragment_25_2_0.xml b/.idea/libraries/support_fragment_25_2_0.xml
index acfae86..28d58a2 100644
--- a/.idea/libraries/support_fragment_25_2_0.xml
+++ b/.idea/libraries/support_fragment_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/support_media_compat_25_2_0.xml b/.idea/libraries/support_media_compat_25_2_0.xml
index 73b6569..344ed4d 100644
--- a/.idea/libraries/support_media_compat_25_2_0.xml
+++ b/.idea/libraries/support_media_compat_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/support_v4_25_2_0.xml b/.idea/libraries/support_v4_25_2_0.xml
index a4b53bf..5898cf3 100644
--- a/.idea/libraries/support_v4_25_2_0.xml
+++ b/.idea/libraries/support_v4_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/support_vector_drawable_25_2_0.xml b/.idea/libraries/support_vector_drawable_25_2_0.xml
index 5ebb56e..ea4f3a8 100644
--- a/.idea/libraries/support_vector_drawable_25_2_0.xml
+++ b/.idea/libraries/support_vector_drawable_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/libraries/transition_25_2_0.xml b/.idea/libraries/transition_25_2_0.xml
index 9a92616..92ce25f 100644
--- a/.idea/libraries/transition_25_2_0.xml
+++ b/.idea/libraries/transition_25_2_0.xml
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 98cd332..23800c5 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 94a25f7..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index d58da86..7681e9a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -10,83 +10,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -145,116 +69,131 @@
-
-
-
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
+
-
-
+
+
-
-
+
+
-
+
+
+
+
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
+
+
+
+
+
-
-
+
+
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
@@ -267,6 +206,8 @@
+
+
@@ -284,7 +225,7 @@
@@ -3362,144 +3303,144 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
+
+
+
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
+
-
-
+
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
-
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
@@ -3523,13 +3464,11 @@
-
-
@@ -3537,26 +3476,33 @@
-
-
-
-
-
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
@@ -3583,6 +3529,12 @@
+
+
+
+
+
+
@@ -3598,55 +3550,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
@@ -3660,7 +3580,7 @@
-
+
@@ -3678,29 +3598,27 @@
-
+
+
+
+
+
-
-
-
-
-
-
-
+
-
+
@@ -4130,71 +4048,101 @@
1491003456960
-
+
+ 1491046763227
+
+
+
+ 1491046763228
+
+
+ 1491052779705
+
+
+
+ 1491052779705
+
+
+ 1491058978967
+
+
+
+ 1491058978968
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
@@ -4215,14 +4163,73 @@
-
+
+
+
+
-
+
+
+
+ file://$PROJECT_DIR$/app/src/main/java/teamtreehouse/com/iamhere/UltraTeamApplication.java
+ 103
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -4244,331 +4251,400 @@
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
-
+
-
-
+
+
-
+
+
+
+
-
-
+
+
+
-
+
-
-
+
+
-
+
-
+
+
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
-
+
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
-
-
-
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
-
+
-
-
+
+
+
-
-
-
-
-
-
+
-
-
+
+
+
-
-
-
-
-
-
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
-
-
+
+
-
-
+
+
-
-
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
+
-
-
-
-
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/app.iml b/app/app.iml
index 370e0ce..8548410 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -78,23 +78,14 @@
-
-
-
-
-
-
-
-
-
@@ -169,6 +160,7 @@
+
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3ecf2a7..e229add 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,28 +1,34 @@
-
-
+
+
+
+
+
+
+
-
-
+
+
-
+
-
+
-
+ android:theme="@style/AppTheme"
+ tools:ignore="GoogleAppIndexingWarning">
@@ -75,6 +82,7 @@
+
\ No newline at end of file
diff --git a/app/src/main/java/teamtreehouse/com/iamhere/GroupeAdapter.java b/app/src/main/java/teamtreehouse/com/iamhere/GroupeAdapter.java
index 05a0c5d..d97f75c 100644
--- a/app/src/main/java/teamtreehouse/com/iamhere/GroupeAdapter.java
+++ b/app/src/main/java/teamtreehouse/com/iamhere/GroupeAdapter.java
@@ -49,6 +49,7 @@ public void onClick(View view) {
String thisMember;
thisMember = GroupeAdapter.super.getItem(position);
GroupeAdapter.super.remove(thisMember);
+ UltraTeamApplication.getInstance().remove_someone(thisMember);
}
});
@@ -57,6 +58,7 @@ public void onClick(View view) {
return convertView;
}
+
private class ItemViewHolder {
public TextView name;
public Button deleteButton;
diff --git a/app/src/main/java/teamtreehouse/com/iamhere/Groupe_Activity.java b/app/src/main/java/teamtreehouse/com/iamhere/Groupe_Activity.java
index c3887ac..5fadda5 100644
--- a/app/src/main/java/teamtreehouse/com/iamhere/Groupe_Activity.java
+++ b/app/src/main/java/teamtreehouse/com/iamhere/Groupe_Activity.java
@@ -111,7 +111,8 @@ public void onFocusChange(View v, boolean hasFocus) {
id_a_ajouter=textView.getText().toString();
Log.i("ST",id_a_ajouter);
if (!membres.contains(id_a_ajouter)) {
- UltraTeamApplication.getInstance().getAdapter().add(id_a_ajouter);// ajoute la personne dans ultrateam
+ UltraTeamApplication.getInstance().getAdapter().add(id_a_ajouter);
+ UltraTeamApplication.getInstance().add_someone(id_a_ajouter);// ajoute la personne dans ultrateam
} else {
Context context = getApplicationContext();
CharSequence text = "L'identifiant doit être unique!";
diff --git a/app/src/main/java/teamtreehouse/com/iamhere/MainActivity.java b/app/src/main/java/teamtreehouse/com/iamhere/MainActivity.java
index 96ef1ff..0cc0ab5 100644
--- a/app/src/main/java/teamtreehouse/com/iamhere/MainActivity.java
+++ b/app/src/main/java/teamtreehouse/com/iamhere/MainActivity.java
@@ -16,6 +16,10 @@
import android.widget.TextView;
import android.widget.Toast;
+import com.google.android.gms.maps.model.LatLng;
+
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Hashtable;
@@ -25,6 +29,10 @@ public class MainActivity extends AppCompatActivity {
private boolean BLUETOOTH_SERVICE_REGISTER;
private MediaPlayer mediaPlayer;
+ public Button valider;
+ UltraTeamApplication ultraTeamApplication= UltraTeamApplication.getInstance();
+ Hashtable personnes = ultraTeamApplication.getPersonnes();
+
@Override
protected void onResume(){
@@ -46,6 +54,7 @@ protected void onCreate(Bundle savedInstanceState) {
Mqtt_client mqtt_client = new Mqtt_client(getApplicationContext());
ultraTeamApplication.setMqtt_client(mqtt_client);
+ //Bluetooth
mDataField = (TextView) findViewById(R.id.data_value_service);
setSupportActionBar(toolbar);
if(BLUETOOTH_SERVICE_ACTIVE) {
@@ -53,6 +62,24 @@ protected void onCreate(Bundle savedInstanceState) {
BLUETOOTH_SERVICE_REGISTER = true;
}
+ //entre de coordonnées manuellement
+ valider = (Button) findViewById(R.id.valider);
+ valider.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ //Personne p = UltraTeamApplication.getInstance().getPersonnes().get("you");
+ Personne p =personnes.get("you");
+ TextView latitude = (TextView) findViewById(R.id.latitude2);
+ TextView longitude = (TextView) findViewById(R.id.longitude);
+ double lat = Double.valueOf(latitude.getText().toString());
+ double lon = Double.valueOf(longitude.getText().toString());
+ LatLng latLng = new LatLng(lat, lon);
+ p.setPosition(latLng);
+ UltraTeamApplication.getInstance().getMqtt_client().publishMessage();
+ }
+ });
+
+
mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.enavant);
@@ -65,12 +92,6 @@ public void onClick(View view) {
unregisterReceiver(mGattUpdateReceiver);
BLUETOOTH_SERVICE_REGISTER = false;
}
- //SeekBar sb = (SeekBar) findViewById(R.id.seekBarNombreMembre);
- Hashtable personnes = UltraTeamApplication.getInstance().getPersonnes();
- for (int i = 0; i < UltraTeamApplication.getInstance().getAdapter().getCount(); i++)
- personnes.put(UltraTeamApplication.getInstance().getAdapter().getItem(i), new Personne(UltraTeamApplication.getInstance().getAdapter().getItem(i), i, null));
-
-
mediaPlayer.start();
Intent intent = new Intent(MainActivity.this, MapsActivity.class);
@@ -131,30 +152,9 @@ public void onClick(View v) {
}
});
-
-
- //SeekBar sb = (SeekBar) findViewById(R.id.seekBarNombreMembre);
- /*sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
- @Override
- public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
- TextView tv = (TextView) findViewById(R.id.textViewNbMembre);
- tv.setText(String.valueOf(seekBar.getProgress()));
-
-
- }
-
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
-
- }
-
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
-
- }
- });*/
}
+ //gestion des données bluetooth
private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -164,14 +164,12 @@ public void onReceive(Context context, Intent intent) {
}
}
};
-
private void displayData(String data) {
if (data != null) {
mDataField.setText(data);
}
}
-
private static IntentFilter makeGattUpdateIntentFilter() {
final IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE);
diff --git a/app/src/main/java/teamtreehouse/com/iamhere/MapsActivity.java b/app/src/main/java/teamtreehouse/com/iamhere/MapsActivity.java
index f5c8612..484178c 100644
--- a/app/src/main/java/teamtreehouse/com/iamhere/MapsActivity.java
+++ b/app/src/main/java/teamtreehouse/com/iamhere/MapsActivity.java
@@ -24,8 +24,11 @@
import android.widget.TextView;
import android.widget.Toast;
+import com.example.mqtt_service.MqttService;
+import com.example.mqtt_service.MqttServiceConstants;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
+import com.google.android.gms.common.data.DataBufferObserver;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
@@ -48,6 +51,9 @@
import java.text.NumberFormat;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
import java.util.Random;
import java.util.Set;
@@ -57,7 +63,7 @@
public class MapsActivity extends FragmentActivity implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
- LocationListener, GoogleMap.OnMarkerClickListener, OnMapReadyCallback {
+ LocationListener, GoogleMap.OnMarkerClickListener, OnMapReadyCallback{
public static final String TAG = MapsActivity.class.getSimpleName();
private Hashtable personnes = UltraTeamApplication.getInstance().getPersonnes();
@@ -77,12 +83,43 @@ public class MapsActivity extends FragmentActivity implements
private Polyline polylineProcheAMarker;
public Hashtable listeDesMarkers = new Hashtable<>();
private MediaPlayer mediaplayer;
+ private Mqtt_client mqtt_client =UltraTeamApplication.getInstance().getMqtt_client();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
- //setUpMapIfNeeded();
+ mqtt_client.callback = new MyCallBack() {
+ @Override
+ public void callbackCall() {
+ //TODO mettre a jour la carte
+ Log.i("CARTE ", "on entre dans la call BACK" + personnes.toString() + "\n" + personnes.entrySet());
+ for (Map.Entry e : personnes.entrySet()) {
+ Log.i("CARTE", "je change le marker de " + e.getValue().getNom() + " et je le mets en " + e.getValue().getPosition());
+ //if (e.getValue().getMarker()!=null) {
+ e.getValue().getMarker().remove();
+ e.getValue().setMarker(null);
+ e.getValue().setMarker(mMap.addMarker(new MarkerOptions().position(e.getValue().getPosition()).title(e.getValue().getNom())));
+
+
+ }
+ }
+
+ @Override
+ public void callbackCall(Personne personne) {
+ Log.i("CARTE", "2je change le marker de " + personne.getNom() + " et je le mets en " + personne.getPosition());
+ // personne.getMarker().setPosition(personne.getPosition());
+ personne.getMarker().remove();
+ personne.setMarker(null);
+ mMap.clear();
+ personne.setMarker(mMap.addMarker(new MarkerOptions().position(personne.getPosition()).title(personne.getNom())));
+
+
+ }
+
+
+ };
+
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
@@ -178,49 +215,34 @@ private void setUpMapIfNeeded() {
* This should only be called once and when we are sure that {@link #mMap} is not null.
*/
private void setUpMap() {
-
-
-
- int nombrePersonne = UltraTeamApplication.getInstance().getNbPersonnes();
-
- Random random = new Random();
-
+ Hashtable personnes = UltraTeamApplication.getInstance().getPersonnes();
LatLngBounds.Builder builder = new LatLngBounds.Builder();
-
- for (int i = 0; i < nombrePersonne; i++) {
- Double randomLat = random.nextDouble() * 2 - 1;
- Double randomLon = random.nextDouble() * 2 - 1;
-
- LatLng randomPosition = new LatLng(45.166672 + randomLat, 5.71667 + randomLon);
- Marker m = mMap.addMarker(new MarkerOptions().position(randomPosition).title(personnes.get(UltraTeamApplication.getInstance().getAdapter().getItem(i)).getNom()));
- listeDesMarkers.put(personnes.get(UltraTeamApplication.getInstance().getAdapter().getItem(i)).getNom(), m);
- personnes.get(UltraTeamApplication.getInstance().getAdapter().getItem(i)).setMarker(m);
-
- personnes.get(UltraTeamApplication.getInstance().getAdapter().getItem(i)).setPosition(randomPosition);
-
- builder.include(m.getPosition());
+ //nombre de marker que l'on positionne
+ int nbMarkerSet=0;
+ for (Map.Entry e : personnes.entrySet()) {
+ if (e.getValue().isPositionSet()) {
+ nbMarkerSet++;
+ if (e.getValue().getMarker()==null) {
+ Marker m = mMap.addMarker(new MarkerOptions().position(e.getValue().getPosition()).title(e.getValue().getNom()));
+ e.getValue().setMarker(m);
+ builder.include(e.getValue().getPosition());
+ }
+ else {
+ e.getValue().setMarker(mMap.addMarker(new MarkerOptions().position(e.getValue().getPosition()).title(e.getValue().getNom())));
+ builder.include(e.getValue().getPosition());
+ }
+ }
}
- //Centrer la camera pour voir tous les markers
- LatLngBounds bounds = builder.build();
- int padding = 0 ;
- CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds,padding);
- mMap.moveCamera(cu);
-
-
-
-
-
-
-
- /* //Comme je peux pas test avec mon tél je mais des positions random pour tester
- Marker m1 = mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Membre 1"));
- Marker m2 = mMap.addMarker(new MarkerOptions().position(new LatLng(45, 0)).title("Membre 2"));
- Marker m3 = mMap.addMarker(new MarkerOptions().position(new LatLng(0, 45)).title("Membre 3"));*/
-
-
-
+ // si il ya des marker on centre la camera
+ if (nbMarkerSet>1) {
+ //Centrer la camera pour voir tous les markers
+ LatLngBounds bounds = builder.build();
+ int padding = 0;
+ CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
+ mMap.moveCamera(cu);
+ }
}
@@ -234,17 +256,30 @@ private void handleNewLocation(Location location) {
Hashtable personnes = UltraTeamApplication.getInstance().getPersonnes();
- //TODO Le marker du chef sera pas mis à jour
-
+ personnes.get("you").setPosition(latLng);
personnes.get(UltraTeamApplication.getInstance().getAdapter().getItem(0)).setPosition(latLng);
+ if (personnes.get("you").getMarker()!=null){
+ personnes.get("you").getMarker().setPosition(latLng);
+ }
+ else{
+ Marker m = mMap.addMarker(new MarkerOptions().position(latLng).title("you"));
+ personnes.get("you").setMarker(m);
+ }
-
+ if (personnes.get("you").message_needed()) {
+ teamtreehouse.com.iamhere.Message message = new teamtreehouse.com.iamhere.Message(personnes.get("you"));
+ //envoie de message LORA
+ usbService.write(message.loraPayload());
+ //Envoie de message via le reseau
+ Log.i("LORA", "envoi du message :" + message.toString());
+ UltraTeamApplication.getInstance().getMqtt_client().publishMessage();
+ }
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
if(UltraTeamApplication.getInstance().getBase()==null){
- Marker m = mMap.addMarker(new MarkerOptions()
+ Marker m =mMap.addMarker(new MarkerOptions()
.position(new LatLng(location.getLatitude()+1, location.getLongitude()))
.title("Point de rdv")
.draggable(true)
@@ -260,7 +295,6 @@ private void handleNewLocation(Location location) {
@Override
public void onConnected(Bundle bundle) {
//if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
- // TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
@@ -278,7 +312,6 @@ public void onConnected(Bundle bundle) {
handleNewLocation(location);
}
} catch (SecurityException s) {
- //TODO
}
}
@@ -324,7 +357,6 @@ public void onLocationChanged(Location location) {
// USB
-
/*
* Notifications from UsbService will be received here.
*/
@@ -354,24 +386,7 @@ public void onReceive(Context context, Intent intent) {
private void updateMarker(String data) {
- /*
- String id = null;
- Double lat = null;
- Double lon = null;
-
- Hashtable personnes = UltraTeamApplication.getInstance().getPersonnes();
-
- if (p.containsKey(id)) {
- listeDesMarkers.get(id).setPosition(new LatLng(lat, lon));
- } else {
- Marker m = mMap.addMarker(new MarkerOptions()
- .position(new LatLng(10, 10))
- .title("Position de " + id));
- listeDesMarkers.put(Integer.getInteger(id), m);
-
- }*/
-
-
+ //TODO peut etre reutiliser
}
// USB Fonctions
@@ -438,6 +453,7 @@ String getHumanDistance(double distance){
private Personne getPersonneLaPlusProche(LatLng position){
Hashtable personnes = UltraTeamApplication.getInstance().getPersonnes();
+
Personne personneLaplusProche = personnes.get(UltraTeamApplication.getInstance().getAdapter().getItem(0));
double distanceChef= distance(personneLaplusProche.getPosition(), position);
@@ -462,19 +478,20 @@ private Personne getPersonneLaPlusProche(LatLng position){
}
-
-
@Override
public boolean onMarkerClick(Marker marker) {
Hashtable personnes = UltraTeamApplication.getInstance().getPersonnes();
+ Log.i("CARTE", "title : " + marker.getTitle());
if (!marker.getTitle().contains("Point de rdv")) {
+
if (personnes.get(UltraTeamApplication.getInstance().getAdapter().getItem(0)).getNom().equals(marker.getTitle()))
markerCliked = true;
else
markerCliked = false;
//Hashtable personnes = UltraTeamApplication.getInstance().getPersonnes();
+
LatLng posChef = personnes.get(UltraTeamApplication.getInstance().getAdapter().getItem(0)).getPosition();
LatLng posMembre = marker.getPosition();
@@ -534,6 +551,7 @@ public void onMapReady(GoogleMap googleMap) {
setUpMapIfNeeded();
}
+
/*
* This handler will be passed to UsbService. Data received from serial port is displayed through this handler
*/
@@ -550,8 +568,13 @@ public void handleMessage(Message msg) {
case UsbService.MESSAGE_FROM_SERIAL_PORT:
String data = (String) msg.obj;
//mActivity.get().add.append(data);
+ teamtreehouse.com.iamhere.Message message = new teamtreehouse.com.iamhere.Message(data);
+ //Personne personne= UltraTeamApplication.getInstance().getPersonnes().get( message.getId());
+ UltraTeamApplication.getInstance().traiterMessage(message);
+ //TODO verifier que ca marche
mActivity.get().updateMarker(data);
+ Log.i("LORA", "Message Received :" + message.toString());
break;
}
}
@@ -566,6 +589,7 @@ public void handleMessage(Message msg) {
public void onServiceConnected(ComponentName arg0, IBinder arg1) {
usbService = ((UsbService.UsbBinder) arg1).getService();
usbService.setHandler(mHandler);
+
}
@Override
@@ -574,51 +598,81 @@ public void onServiceDisconnected(ComponentName arg0) {
}
};
+
+ //gestion d'arrivée de message MQTT:
+
+ private final BroadcastReceiver mqttReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ final String action = intent.getAction();
+ //TODO faire quelque chose
+ Log.i("MQTT", "je decouvre que j'ai recu un message ");
+ }
+ };
+
+
+ private static IntentFilter mqttReceiverIntentFilter() {
+ final IntentFilter intentFilter = new IntentFilter();
+ intentFilter.addAction(MqttServiceConstants.MESSAGE_ARRIVED_ACTION);
+ //intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE);
+ return intentFilter;
+ }
+
+
+ //gestion modification bluetooth
private final BroadcastReceiver mGattUpdateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- if (!listeDesMarkers.isEmpty()) {
- final String action = intent.getAction();
- if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
- Random random = new Random();
- Double randomLat = random.nextDouble() * 2 - 1;
- Double randomLon = random.nextDouble() * 2 - 1;
- Double tmpLat = listeDesMarkers.get(UltraTeamApplication.getInstance().getAdapter().getItem(0)).getPosition().latitude + randomLat;
- Double tmpLon = listeDesMarkers.get(UltraTeamApplication.getInstance().getAdapter().getItem(0)).getPosition().longitude + randomLon;
- LatLng position = new LatLng(tmpLat, tmpLon);
- listeDesMarkers.get(UltraTeamApplication.getInstance().getAdapter().getItem(0)).remove();
- listeDesMarkers.remove(UltraTeamApplication.getInstance().getAdapter().getItem(0));
- Marker m = mMap.addMarker(new MarkerOptions().position(position).title(personnes.get(UltraTeamApplication.getInstance().getAdapter().getItem(0)).getNom()));
- listeDesMarkers.put(personnes.get(UltraTeamApplication.getInstance().getAdapter().getItem(0)).getNom(), m);
- LatLng posChef = personnes.get(UltraTeamApplication.getInstance().getAdapter().getItem(0)).getPosition();
-
- LatLng posMembre = m.getPosition();
- if (markerCliked) {
- if (polylineChefAMarker != null) {
- polylineChefAMarker.remove();
- }
-
- PolylineOptions polylineOptions = new PolylineOptions().add(posChef).add(posMembre).color(0xFFFF0000).startCap(new RoundCap()).endCap(new RoundCap());
-
- polylineChefAMarker = mMap.addPolyline(polylineOptions);
-
- if (polylineProcheAMarker != null) {
- polylineProcheAMarker.remove();
- }
-
- polylineOptions = new PolylineOptions().add(getPersonneLaPlusProche(position).getPosition()).add(posMembre).color(0xFF0000FF).startCap(new RoundCap()).endCap(new RoundCap());
-
- polylineProcheAMarker = mMap.addPolyline(polylineOptions);
+
+ final String action = intent.getAction();
+ if (BluetoothLeService.ACTION_DATA_AVAILABLE.equals(action)) {
+ Random random = new Random();
+ Double randomLat = random.nextDouble() * 2 - 1;
+ Double randomLon = random.nextDouble() * 2 - 1;
+ Double tmpLat = personnes.get("you").getPosition().latitude + randomLat;
+ Double tmpLon = personnes.get("you").getPosition().longitude + randomLon;
+ //LatLng position = new LatLng(tmpLat, tmpLon);
+ //personnes.get("you").getMarker().remove();
+ //personnes.get("you").setMarker(null);
+ LatLng position = personnes.get("you").getPosition();
+
+ Marker m = mMap.addMarker(new MarkerOptions().position(position).title(personnes.get("you").getNom()));
+ //personnes.get("you").setMarker(m);
+ LatLng posChef = personnes.get("you").getPosition();
+
+ LatLng posMembre = m.getPosition();
+ if (markerCliked) {
+ if (polylineChefAMarker != null) {
+ polylineChefAMarker.remove();
}
+
+ PolylineOptions polylineOptions = new PolylineOptions().add(posChef).add(posMembre).color(0xFFFF0000).startCap(new RoundCap()).endCap(new RoundCap());
+
+ polylineChefAMarker = mMap.addPolyline(polylineOptions);
+
+ if (polylineProcheAMarker != null) {
+ polylineProcheAMarker.remove();
+ }
+
+ polylineOptions = new PolylineOptions().add(getPersonneLaPlusProche(position).getPosition()).add(posMembre).color(0xFF0000FF).startCap(new RoundCap()).endCap(new RoundCap());
+
+ polylineProcheAMarker = mMap.addPolyline(polylineOptions);
}
}
}
};
- private static IntentFilter makeGattUpdateIntentFilter() {
+ private static IntentFilter makeGattUpdateIntentFilter() {
final IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE);
return intentFilter;
}
+
+
+
}
+
+
+
+
diff --git a/app/src/main/java/teamtreehouse/com/iamhere/Membres.java b/app/src/main/java/teamtreehouse/com/iamhere/Membres.java
index 1186f79..8f5979e 100644
--- a/app/src/main/java/teamtreehouse/com/iamhere/Membres.java
+++ b/app/src/main/java/teamtreehouse/com/iamhere/Membres.java
@@ -7,7 +7,7 @@
*/
public class Membres extends ArrayList {
// private ArrayList membres;
-
+//TODO si on as le temp remplacer par un simple tableau dans Groupe_Activity
private static Membres ourInstance = new Membres();
public static Membres getInstance() {
@@ -18,15 +18,11 @@ private Membres() {
@Override
public boolean add(String a_ajouter){
- //TODO surement a faire ailleurs
- UltraTeamApplication.getInstance().add_someone(a_ajouter);
- // mqtt_client.subscribeToTopic(a_ajouter);
return super.add(a_ajouter);
}
@Override
public boolean remove(Object memberName) {
- UltraTeamApplication.getInstance().remove_someone((String)memberName);
return super.remove(memberName);
}
}
diff --git a/app/src/main/java/teamtreehouse/com/iamhere/Message.java b/app/src/main/java/teamtreehouse/com/iamhere/Message.java
index 350cfb1..52d0607 100644
--- a/app/src/main/java/teamtreehouse/com/iamhere/Message.java
+++ b/app/src/main/java/teamtreehouse/com/iamhere/Message.java
@@ -1,43 +1,394 @@
package teamtreehouse.com.iamhere;
-import android.graphics.Point;
+
+import com.google.android.gms.maps.model.LatLng;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Date;
+
+//import com.google.android.gms.maps.model.LatLng;
/**
- * Created by roman on 28/03/2017.
+ * Created by romane on 23/03/17.
+
+ Use : -create message with Message m = new Message(Person p)
+
+ OR
+
+ -create message with Message m = new Message()
+ -set fields with the m.setXX() methods
+
+ -use m.makeLoraPayload() to create the byte[] describing the message
+ -get the byte[] message with m.loraPayload()
+ -notify the receiver that this is a SOS (8'th bit) and that the message contains heartrate (7'th bit) with m.setOptions((byte) 0x3);
+ -sos and heartRate can be set through setSOS() and setbluetooth_heartRate() (unecessary if setHeartRate() already used.)
+
+
+ on receive : create message with Message m = Message()
+ - set fields with m.decodeLoraPayload(byte[] received_data)
+
+ OR create message with Message m = Message
+
+ - get fields with m.getXX() methods
+ - message can be verifyed with m.checked()
+ - message is SOS if m.isSos() returns true
+ - message contains heartRate if m.isHeartRate() returns true
+
*/
public class Message {
- private String id;
- private Point coord;
- public Message(){};
- public Message(String id, Point coord){
- this.id=id;
+ private ByteOrder byteOrder;
+
+ private String nom;
+ private short heartRate;
+ private byte[] loraPayload;
+
+ private byte options; // id size, heartRate, sos
+ private short seq; //sequence number of the message
+
+ LatLng coord;
+
+ private short hour;
+ private short min;
+ private short sec;
+
+ private boolean checked;
+
+
+ public Message() {
+ if (ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN)) {
+ byteOrder = ByteOrder.BIG_ENDIAN;
+ } else {
+ byteOrder = ByteOrder.LITTLE_ENDIAN;
+ }
+
+ options = 0;
+ }
+
+ public Message(byte[] message) {
+ decodeLoraPayload(message);
+ }
+
+ public Message(String nom , LatLng coord) {
+ this.nom=nom;
this.coord=coord;
+ options = 0;
}
- public Message(String s){
- String[] tab=s.split(":");
- id=tab[0];
- coord= new Point(Integer.valueOf(tab[1]),Integer.valueOf(tab[2]));
+
+
+ private byte checksum1(byte[] payload) {
+ byte res = 0;
+ for (int i = 0; i < 43; i++) {
+ res += payload[i];
+ }
+
+
+ return res;
}
- public void setId (String id){
- this.id=id;
+
+ private byte checksum2(byte[] payload) {
+ byte res = 0;
+ for (int i = 0; i < 43; i++) {
+ res += i * payload[i];
+ }
+
+ return res;
}
- public void setPoint(Point point){
- this.coord=point;
+ private byte checksum3(byte[] payload) {
+ byte res = 0;
+ for (int i = 0; i < 43; i++) {
+ res += (43 - i) * payload[i];
+ }
+
+ return res;
}
- public String getId (){
- return id;
+
+ private boolean verifyChecksums(byte[] payloadReceived) {
+ byte check1 = checksum1(payloadReceived);
+ byte check2 = checksum2(payloadReceived);
+ byte check3 = checksum3(payloadReceived);
+
+ boolean res = check1 == payloadReceived[43];
+ res = res && (check2 == payloadReceived[44]);
+ res = res && (check3 == payloadReceived[45]);
+
+ return res;
}
- public Point getPoint(){
+
+
+ public boolean checked() {
+ return checked;
+ }
+
+ public void setSOS() {
+ options = (byte) (options | 0x1);
+ }
+
+ public void setBlueTooth_HeartRate() {
+ options = (byte) (options | 0x2);
+ }
+
+ @SuppressWarnings("deprecation")
+ public void setDate(Date date) {
+ this.hour = (byte) date.getHours();
+ this.min = (byte) date.getMinutes();
+ this.sec = (byte) date.getSeconds();
+ }
+
+ public Date getDate() {
+ Date date = new Date();
+ date.setHours(hour);
+ date.setMinutes(min);
+ date.setSeconds(sec);
+ return date;
+ }
+
+ public short getSeq() {
+ return seq;
+ }
+
+ public boolean isHeartRate() {
+ if ((options & 0x2) == 2)
+ return true;
+ else return false;
+ }
+
+
+ public boolean isSOS() {
+ if ((options & 0x1) == 1)
+ return true;
+ else return false;
+ }
+
+ public short getHeartRate() {
+ // TODO Auto-generated method stub
+ return heartRate;
+ }
+
+
+ public void setHeartRate(short heartRate) {
+ // TODO Auto-generated method stub
+ this.heartRate = heartRate;
+ }
+
+
+ public LatLng getPos() {
+ // TODO Auto-generated method stub
return coord;
}
+ private void setNameLength(int l) {
+ options = (byte) (options | (l << 2));
+ }
+
+ public byte getOptions() {
+ // TODO Auto-generated method stub
+ return options;
+ }
+
+
+ public byte[] loraPayload() {
+
+ if (loraPayload==null){makeLoraPayload();}
+ return loraPayload;
+ }
+
+
+ public void setOptions(Byte byte1) {
+ options = byte1;
+ }
+
+
+ public void setSeq(short s) {
+ // TODO Auto-generated method stub
+ seq = s;
+ }
+
+
+ public Message(Personne p) {
+ this.nom = p.getNom();
+ this.coord = p.getPosition();
+ setDate(new Date());
+ this.options = 0;
+
+ setNameLength(this.nom.length());
+ }
+
+
+ public Message(String s){
+// String[] tab=s.split(":");
+ nom = s;
+ options = 0;
+ // coord= new Point(Integer.valueOf(tab[1]),Integer.valueOf(tab[2]));
+ }
+
+
+ private int getNameLength() {
+ return (loraPayload[0]>>2);
+ }
+
+ public void setNom (String nom){
+ this.nom=nom;
+ }
+
+ public void setPos(LatLng pos) {
+ this.coord = pos;
+ }
+
+ public String getNom (){
+ return nom;
+ }
+
+ @Override
public String toString (){
- return id+":"+coord.x+":"+coord.y;
+ return "Nom :" + nom + "\nPos" + coord.toString() + "\nheart rate" + heartRate + "\nsos" + isSOS() + "\nbluetooth->heartRate" + isHeartRate() + "\nseq : " + getSeq() + "\ntime :" + getDate()+"\nchecked: "+checked();
+ }
+
+ public void makeLoraPayload() {
+ loraPayload = new byte[51];
+ loraPayload[0] = options;
+
+ byte[] idBytes = nom.getBytes();
+
+ for (int i = 0; i < idBytes.length; i++) {
+ loraPayload[1 + i] = idBytes[i];
+ }
+
+ byte[] posBytes = getBytesFromLatLng();
+ for (int i = 0; i < 16; i++) {
+ loraPayload[i + 21] = posBytes[i];
+ }
+
+ byte heartRateByte;
+ byte[] hhmmss = new byte[3];
+ if (byteOrder == ByteOrder.BIG_ENDIAN) {
+ heartRateByte = (byte) (heartRate >> 8);
+ hhmmss[0] = (byte) (hour >> 8);
+ hhmmss[1] = (byte) (min >> 8);
+ hhmmss[2] = (byte) (sec >> 8);
+ } else {
+ heartRateByte = (byte) (heartRate);
+
+ hhmmss[0] = (byte) (hour);
+ hhmmss[1] = (byte) (min);
+ hhmmss[2] = (byte) (sec);
+ }
+
+ loraPayload[37] = heartRateByte;
+
+ byte[] seqByte = new byte[2];
+
+ seqByte[0] = (byte) (seq);
+ seqByte[1] = (byte) ((seq >> 8) & 0xff);
+
+ loraPayload[38] = seqByte[0];
+ loraPayload[39] = seqByte[1];
+
+
+ //We define the time
+ for (int i = 0; i < 3; i++) {
+ loraPayload[i + 40] = hhmmss[i];
+ }
+
+
+ byte[] checksums = {checksum1(loraPayload), checksum2(loraPayload), checksum3(loraPayload)};
+
+ for (int i = 0; i < 3; i++) {
+ loraPayload[i + 43] = checksums[i];
+ }
+
+ }
+
+ private void decodeLoraPayload(byte[] bytesReceived) {
+ loraPayload = bytesReceived;
+
+ options = bytesReceived[0];
+
+
+ int nameLength = getNameLength();
+
+ byte[] idBytes = new byte[nameLength];
+
+ for (int i = 0; i < nameLength; i++) {
+ idBytes[i] = bytesReceived[i + 1];
+ }
+ nom = new String(idBytes);
+
+
+ coord = getLatLngFromBytes(bytesReceived, 21);
+
+
+ byte heartRateByte = bytesReceived[37];
+ if (byteOrder == ByteOrder.BIG_ENDIAN) {
+ heartRate = (short) ((heartRateByte & 0xFF));
+ hour = (short) ((bytesReceived[40] & 0xFF));
+ min = (short) ((bytesReceived[41] & 0xFF));
+ sec = (short) ((bytesReceived[42] & 0xFF));
+ } else {
+ heartRate = (short) ((heartRateByte) + (0x00));
+ hour = (short) ((bytesReceived[40] + 0x00));
+ min = (short) ((bytesReceived[41] + 0x00));
+ sec = (short) ((bytesReceived[42] + 0x00));
+ }
+
+ if (heartRate < 0)
+ heartRate += 256;
+
+ byte[] seqBytes = {bytesReceived[38], bytesReceived[39]};
+
+
+ seq = (short) ((seqBytes[1] << 8) + (seqBytes[0] & 0xFF));
+
+ checked = verifyChecksums(bytesReceived);
+
}
-}
+ /**
+ * makes coordinates from byte array
+ *
+ * @param payload
+ * @param index_data index of the first byte representing the coordinates
+ */
+ public LatLng getLatLngFromBytes(byte[] payload, int index_data) {
+ byte[] xBytes = new byte[8];
+ byte[] yBytes = new byte[8];
+
+ for (int i = 0; i < 8; i++) {
+ xBytes[i] = payload[i + index_data];
+ yBytes[i] = payload[i + index_data + 8];
+ }
+
+ double x = bytesToDouble(xBytes);
+ double y = bytesToDouble(yBytes);
+ return new LatLng(x, y);
+ }
+
+
+ public byte[] toByteArray(double value) {
+ byte[] bytes = new byte[8];
+ ByteBuffer.wrap(bytes).putDouble(value);
+ return bytes;
+ }
+
+ public double bytesToDouble(byte[] bytes) {
+ return ByteBuffer.wrap(bytes).getDouble();
+ }
+
+ public byte[] getBytesFromLatLng() {
+ byte[] res = new byte[16];
+ byte[] xBytes = toByteArray(coord.latitude);
+ byte[] yBytes = toByteArray(coord.longitude);
+
+ for (int i = 0; i < 8; i++) {
+ res[i] = xBytes[i];
+ res[i + 8] = yBytes[i];
+ }
+
+ return res;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/teamtreehouse/com/iamhere/Mqtt_client.java b/app/src/main/java/teamtreehouse/com/iamhere/Mqtt_client.java
index 8ab6f21..d786d10 100644
--- a/app/src/main/java/teamtreehouse/com/iamhere/Mqtt_client.java
+++ b/app/src/main/java/teamtreehouse/com/iamhere/Mqtt_client.java
@@ -7,6 +7,7 @@
import com.example.mqtt_service.MqttAndroidClient;
import com.google.android.gms.maps.model.LatLng;
+import com.example.mqtt_service.*;
//import org.eclipse.paho.android.service.MqttAndroidClient;
import org.eclipse.paho.client.mqttv3.DisconnectedBufferOptions;
@@ -19,6 +20,7 @@
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
+
import java.util.Map;
/**
@@ -28,20 +30,18 @@
public class Mqtt_client {
MqttAndroidClient mqttAndroidClient;
- final String serverUri = "tcp://iot.eclipse.org:1883"; //TODO c'est la bonne ?
- // final String serverUri = "vps364763.ovh.net";
-
- String clientId = "Client1"; //TODO faire en sorte que ce soit lier a l'ID de la personnes
- final String subscriptionTopic = "exampleAndroidTopic";
+ final String serverUri = "tcp://vps364763.ovh.net:1883";
+ String clientId = UltraTeamApplication.getInstance().monID;
+ // final String subscriptionTopic = "exampleAndroidTopic";
final String publishTopic = clientId;
- final String publishMessage = "Hello World!";
+ //final String publishMessage = "Hello World!";
UltraTeamApplication ultraTeamApplication = UltraTeamApplication.getInstance();
-
+ public MyCallBack callback;
public Mqtt_client(Context applicationContext){
//clientId = clientId + System.currentTimeMillis();
- Log.i("MQTT", "Demarage de MQTT"+ serverUri);
+ Log.i("MQTT", "Demarage de MQTT sur le serveur : " + serverUri);
mqttAndroidClient = new MqttAndroidClient(applicationContext, serverUri, clientId);
mqttAndroidClient.setCallback(new MqttCallbackExtended() {
@Override
@@ -69,11 +69,13 @@ public void connectionLost(Throwable cause) {
@Override
public void messageArrived(String topic, MqttMessage message) throws Exception {
Log.i("MQTT","Incoming message: " + new String(message.getPayload()));
- //TODO en faire quelque chose
- //Recuperer les info dans le message.
- Message m = new Message(message.toString());
- ultraTeamApplication.setPosition(m.getId(),m.getPoint());
- //addToHistory("Incoming message: " + new String(message.getPayload()));
+ Log.i("MQTT","Incoming message:");
+
+ //Message message2 = new Message(message.getPayload());
+ Message message2 = new Message(message.getPayload());
+ UltraTeamApplication.getInstance().traiterMessage(message2);
+ //callback.callbackCall();
+ callback.callbackCall(UltraTeamApplication.getInstance().getPersonnes().get("Romane"));//TODO
}
@Override
@@ -99,16 +101,13 @@ public void onSuccess(IMqttToken asyncActionToken) {
disconnectedBufferOptions.setBufferSize(100);
disconnectedBufferOptions.setPersistBuffer(false);
disconnectedBufferOptions.setDeleteOldestMessages(false);
- //TODO peut etre a reenlever
mqttAndroidClient.setBufferOpts(disconnectedBufferOptions);
- //subscribeToTopic();
subscribeToallTopic();
}
@Override
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
Log.i("MQTT","Failed to connect to: " + serverUri);
- //addToHistory("Failed to connect to: " + serverUri);
}
});
@@ -119,7 +118,7 @@ public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
}
- public void subscribeToTopic(){
+ /* public void subscribeToTopic(){
try {
mqttAndroidClient.subscribe("ultratrail/"+subscriptionTopic, 0, null, new IMqttActionListener() {
@Override
@@ -142,9 +141,9 @@ public void messageArrived(String topic, MqttMessage message) throws Exception {
// message Arrived!
Log.i("MQTT", "Message incomming2 dans subscribe sans topic special");
System.out.println("Message: " + topic + " : " + new String(message.getPayload()));
- Message m = new Message(message.toString());
- ultraTeamApplication.setPosition(m.getId(),m.getPoint());
-
+ Message message2 = new Message(message.getPayload());
+ UltraTeamApplication.getInstance().traiterMessage(message2);
+ callback.callbackCall(UltraTeamApplication.getInstance().getPersonnes().get("Romane"));//TODO
}
});
@@ -153,7 +152,7 @@ public void messageArrived(String topic, MqttMessage message) throws Exception {
ex.printStackTrace();
}
}
-
+*/
public void subscribeToTopic(final String topic){
try {
Log.i("MQTT","tentative de soubscription "+ topic);
@@ -161,27 +160,25 @@ public void subscribeToTopic(final String topic){
@Override
public void onSuccess(IMqttToken asyncActionToken) {
Log.i("MQTT","Subscribed!"+ topic);
- //addToHistory("Subscribed!");
publishMessage();
}
@Override
public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
Log.i("MQTT","Failed to subscribe"+topic);
- //addToHistory("Failed to subscribe");
}
});
- // THIS DOES NOT WORK!
+
mqttAndroidClient.subscribe(topic, 0, new IMqttMessageListener() {
@Override
public void messageArrived(String topic, MqttMessage message) throws Exception {
// message Arrived!
Log.i("MQTT", "Message incomming2 dans subscribe avec topic : "+ topic);
System.out.println("Message: " + topic + " : " + new String(message.getPayload()));
- Message m = new Message(message.toString());
- ultraTeamApplication.setPosition(m.getId(),m.getPoint());
-
+ Message message2 = new Message(message.getPayload());
+ UltraTeamApplication.getInstance().traiterMessage(message2);
+ callback.callbackCall(UltraTeamApplication.getInstance().getPersonnes().get("Romane"));//TODO
}
});
@@ -194,32 +191,60 @@ public void messageArrived(String topic, MqttMessage message) throws Exception {
public void subscribeToallTopic(){
Log.i("MQTT", "je souscrit a tous les topics");
//parcour la hastable
- for (Map.Entry e : ultraTeamApplication.getPersonnes().entrySet()){
- subscribeToTopic(e.getValue().getNom());
+ for (Map.Entry e : UltraTeamApplication.getInstance().getPersonnes().entrySet()){
+ if (e.getValue().getNom()!= UltraTeamApplication.getInstance().monID) {
+ subscribeToTopic(e.getValue().getNom());
+ }
}
}
+/* public void publishMessage(){
+ MqttMessage message = new MqttMessage();
+ if (UltraTeamApplication.getInstance().getPersonnes().containsKey("you")) {
+ Personne personne = UltraTeamApplication.getInstance().getPersonnes().get("you");
+ if (personne.isPositionSet()) {
+ LatLng l = UltraTeamApplication.getInstance().getPersonnes().get("you").getPosition();
+ Message m = new Message(UltraTeamApplication.getInstance().getPersonnes().get("you"));
+ //m.setNom(UltraTeamApplication.getInstance().monID);
+ message.setPayload(m.loraPayload());
+ //message.setPayload(publishMessage.getBytes());
+ //mqttAndroidClient.publish(publishTopic, message);
+ Log.i("MQTT", "Message Published... " + publishTopic + " : " + message);
+ } else Log.i("MQTT", "je sais pas ou je suis \n");
+ if (!mqttAndroidClient.isConnected()) {
+ Log.i("MQTT", mqttAndroidClient.getBufferedMessageCount() + " messages in buffer.");
+ //addToHistory(mqttAndroidClient.getBufferedMessageCount() + " messages in buffer.");
+ }
+ }
+ }*/
+
public void publishMessage(){
+ publishMessage("you");
+ }
+
+
+ public void publishMessage(String p){
+ MqttMessage message = new MqttMessage();
+
+ if (UltraTeamApplication.getInstance().getPersonnes().containsKey(p)) {
+ Personne personne = UltraTeamApplication.getInstance().getPersonnes().get(p);
+ if (personne.isPositionSet()) {
+ LatLng l = UltraTeamApplication.getInstance().getPersonnes().get(p).getPosition();
+ Message m = new Message(UltraTeamApplication.getInstance().getPersonnes().get(p));
+ message.setPayload(m.loraPayload());
+ try {
+ mqttAndroidClient.publish("ultratrail/"+publishTopic, message);
+ Log.i("MQTT", "Message Published... " + publishTopic + " : " + message);
+ } catch (MqttException e) {
+ e.printStackTrace();
+ }
+
+ }
+ if (!mqttAndroidClient.isConnected()) {
+ Log.i("MQTT", mqttAndroidClient.getBufferedMessageCount() + " messages in buffer.");
- try {
- MqttMessage message = new MqttMessage();
- LatLng l = ultraTeamApplication.getPersonnes().get("you").getPosition();
- Point p = new Point((int)l.latitude,(int)l.longitude);
- Message m = new Message(this.clientId,p);
-
- message.setPayload(m.toString().getBytes());
- message.setPayload(publishMessage.getBytes());
- mqttAndroidClient.publish(publishTopic, message);
- Log.i("MQTT","Message Published... "+publishTopic+" : "+message);
-
- if(!mqttAndroidClient.isConnected()){
- Log.i("MQTT",mqttAndroidClient.getBufferedMessageCount() + " messages in buffer.");
- //addToHistory(mqttAndroidClient.getBufferedMessageCount() + " messages in buffer.");
}
- } catch (MqttException e) {
- System.err.println("Error Publishing: " + e.getMessage());
- e.printStackTrace();
}
}
diff --git a/app/src/main/java/teamtreehouse/com/iamhere/MyCallBack.java b/app/src/main/java/teamtreehouse/com/iamhere/MyCallBack.java
new file mode 100644
index 0000000..af6c33a
--- /dev/null
+++ b/app/src/main/java/teamtreehouse/com/iamhere/MyCallBack.java
@@ -0,0 +1,12 @@
+package teamtreehouse.com.iamhere;
+
+/**
+ * Created by roman on 03/04/2017.
+ */
+
+public interface MyCallBack {
+
+ void callbackCall();
+ void callbackCall(Personne personne);
+
+}
diff --git a/app/src/main/java/teamtreehouse/com/iamhere/Personne.java b/app/src/main/java/teamtreehouse/com/iamhere/Personne.java
index 10c6183..278e0bb 100644
--- a/app/src/main/java/teamtreehouse/com/iamhere/Personne.java
+++ b/app/src/main/java/teamtreehouse/com/iamhere/Personne.java
@@ -1,21 +1,59 @@
package teamtreehouse.com.iamhere;
+import android.util.Log;
+
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
+import com.google.android.gms.maps.model.MarkerOptions;
+
+import java.util.Date;
/**
* Created by anthony on 25/03/17.
*/
class Personne {
-//TODO ajouter le rythme cardiaque
- private String nom;
+final float distance = 1;
- private int id;
+ public String getNom() {
+ return nom;
+ }
+ public void setNom(String nom) {
+ this.nom = nom;
+ }
+
+ private String nom;
+ private int id;
private boolean isPositionSet;
private LatLng position;
+ private Marker marker;
+ private LatLng oldPosition;
+ private Date dernier_message_recu= new Date((long)0);
+ private int HeartRate;
+ private boolean isHeartRate;
+
+
+ public Date getDernier_message_recu() {
+ return dernier_message_recu;
+ }
+
+ public void setDernier_message_recu(Date dernier_message_recu) {
+ this.dernier_message_recu = dernier_message_recu;
+ }
+ public int getHeartRate() {
+ return HeartRate;
+ }
+
+ public void setHeartRate(int heartRate) {
+ HeartRate = heartRate;
+ isHeartRate = true;
+ }
+
+ public boolean isHeartRate() {
+ return isHeartRate;
+ }
public Marker getMarker() {
return marker;
@@ -25,28 +63,37 @@ public void setMarker(Marker marker) {
this.marker = marker;
}
- private Marker marker;
-
public Personne(String nom, int id, LatLng position) {
this.nom = nom;
this.id = id;
this.position = position;
this.isPositionSet=true;
+ this.isHeartRate = false;
}
public Personne(String nom, int id) {
- this.nom = nom;
this.id = id;
- this.isPositionSet=false;
+ this.nom = nom;
+ this.isPositionSet = false;
+ this.isHeartRate = false;
}
-
- public String getNom() {
- return nom;
+ public boolean message_needed() {
+ if (oldPosition == null) {
+ oldPosition = position;
+ return true;
+ }
+ boolean b = (position.latitude - oldPosition.latitude) >= distance || (position.longitude - oldPosition.longitude) >= distance;
+ if (b) {
+ oldPosition = position;
+ return true;
+ } else return false;
}
- public void setNom(String nom) {
- this.nom = nom;
+ public Personne(int id) {
+ this.id = id;
+ this.isPositionSet=false;
+ this.isHeartRate = false;
}
public int getId() {
@@ -62,10 +109,16 @@ public LatLng getPosition() {
}
public void setPosition(LatLng position) {
-
- marker.setPosition(position);
this.position = position;
this.isPositionSet=true;
+ if (this.nom!= UltraTeamApplication.getInstance().monID) {
+ Log.i("MQTT","je publie sans mon nom");
+ //UltraTeamApplication.getInstance().getMqtt_client().publishMessage(this.getNom());
+ }
+ else {
+ //UltraTeamApplication.getInstance().getMqtt_client().publishMessage();
+ Log.i("MQTT", "je publie en mon nom");
+ }
}
public boolean isPositionSet() {
diff --git a/app/src/main/java/teamtreehouse/com/iamhere/UltraTeamApplication.java b/app/src/main/java/teamtreehouse/com/iamhere/UltraTeamApplication.java
index 75570ab..4cb3a36 100644
--- a/app/src/main/java/teamtreehouse/com/iamhere/UltraTeamApplication.java
+++ b/app/src/main/java/teamtreehouse/com/iamhere/UltraTeamApplication.java
@@ -2,6 +2,7 @@
import android.app.Application;
import android.graphics.Point;
+import android.util.Log;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
@@ -10,6 +11,8 @@
import java.security.acl.Group;
import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
import java.util.Hashtable;
/**
@@ -22,7 +25,8 @@ public class UltraTeamApplication extends Application {
private static UltraTeamApplication singleton;
public GroupeAdapter adapter;
-
+ //public String monID ="Romane";
+ public String monID ="Alexandre";
public static UltraTeamApplication getInstance(){
return singleton;
}
@@ -30,6 +34,8 @@ public static UltraTeamApplication getInstance(){
public void onCreate() {
super.onCreate();
personnes=new Hashtable<>();
+
+ personnes.put("you", new Personne(monID, 0));
singleton = this;
groupeInitialized = false;
}
@@ -41,10 +47,6 @@ public int getNbPersonnes(){
return personnes.size();
}
- public Hashtable getPersonnes (){
- return personnes;
- }
-
private Marker base;
public Mqtt_client getMqtt_client() {
return mqtt_client;
@@ -71,8 +73,9 @@ public void setMqtt_client(Mqtt_client mqtt_client) {
}
public void add_someone(String s){
- personnes.put(s,new Personne(s,0,new LatLng(0,0)));
- //mqtt_client.subscribeToTopic(s);
+ Log.i("MQTT", "j'ajoute "+s);
+ personnes.put(s,new Personne(s,0,new LatLng(10,10)));
+ mqtt_client.subscribeToTopic(s);
}
public void setPosition(String s, Point p){
LatLng l = new LatLng(p.x,p.y);
@@ -85,7 +88,6 @@ public void setPosition(String s, Point p){
public void remove_someone(String s){
personnes.remove(s);
//mqtt_client.unsubscribe(s);
- //TODO possible problemme avec le marker
}
@@ -99,4 +101,42 @@ public void setGroupeInitialized (boolean b){
groupeInitialized=b;
}
+ public void traiterMessage(Message message) {
+ Log.i("MQTT", "je commence a traiter le message");
+ //if (message.checked()) {
+ Log.i("MQTT", "le message est bon et le nom est : "+ message.getNom() );
+ String nom = message.getNom();
+ Log.i("MQTT", "La Map est : "+personnes.toString());
+ if (personnes.containsKey(nom)) {
+ Log.i("MQTT", "je connais cette personne ");
+ Personne p = personnes.get(nom);
+ if (message.getDate().after(p.getDernier_message_recu())) {
+ Log.i("MQTT", "la date est bonne ");
+ p.setPosition(message.getPos());
+ if (p.getMarker()!= null){
+ Log.i("MQTT", "je change le marker");
+ // p.getMarker().setPosition(message.getPos());
+
+ }
+ else {
+ Log.i("MQTT","traitement de message j'ai recu la position de quelqu'un qui n'as pas de marker");
+ }
+ if (message.isSOS()) {
+ //TODO
+ }
+ if (message.isHeartRate()) {
+ p.setHeartRate(message.getHeartRate());
+ }
+ p.setDernier_message_recu(message.getDate());
+ }
+
+ }
+ else {
+ Log.i("MQTT", "je ne connais pas cette personne");
+ }
+ }
+
+ public Hashtable getPersonnes() {
+ return personnes;
+ }
}
diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml
index 4660ba5..d7573eb 100644
--- a/app/src/main/res/layout/content_main.xml
+++ b/app/src/main/res/layout/content_main.xml
@@ -18,7 +18,7 @@
android:layout_below="@+id/goToBluetoothActivity"
android:layout_centerHorizontal="true"
- android:layout_marginTop="86dp"
+ android:layout_marginTop="16dp"
android:drawableLeft="@android:drawable/ic_menu_manage"
android:text="Configurer un groupe" />
@@ -32,7 +32,7 @@
android:layout_below="@+id/goToGroupActivity"
android:layout_centerHorizontal="true"
- android:layout_marginTop="21dp"
+ android:layout_marginTop="5dp"
android:drawableLeft="@drawable/ic_launcher"
android:text="Démarrer " />
@@ -43,7 +43,7 @@
android:layout_alignEnd="@+id/goToMapActivity"
android:layout_alignStart="@+id/goToMapActivity"
android:layout_below="@+id/goToMapActivity"
- android:layout_marginTop="21dp"
+ android:layout_marginTop="5dp"
android:drawableLeft="@android:drawable/ic_menu_help"
android:text="Crédits" />
@@ -67,5 +67,53 @@
android:text="@string/no_data"
android:textSize="18sp" />
+
+
+
+
+
+
+
+
+
+
diff --git a/clement_mobapp2.iml b/clement_mobapp2.iml
new file mode 100644
index 0000000..0f3de91
--- /dev/null
+++ b/clement_mobapp2.iml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/mqtt_service/mqtt_service.iml b/mqtt_service/mqtt_service.iml
index 4b5f65a..7b944fc 100644
--- a/mqtt_service/mqtt_service.iml
+++ b/mqtt_service/mqtt_service.iml
@@ -104,5 +104,6 @@
+
\ No newline at end of file
diff --git a/mqtt_service/src/main/AndroidManifest.xml b/mqtt_service/src/main/AndroidManifest.xml
index 63065cf..3212c66 100644
--- a/mqtt_service/src/main/AndroidManifest.xml
+++ b/mqtt_service/src/main/AndroidManifest.xml
@@ -1,11 +1,20 @@
-
-
+
+
+
+
+
-
+
+
+
+
+
+