commit 46ce31ba6ad96c425b5361a02a07c0a062b4f031 Author: Andrew K. Choi Date: Thu Sep 25 16:08:36 2025 +0900 init commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..dfe5c3a --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Woman Safe \ No newline at end of file diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml new file mode 100644 index 0000000..4a53bee --- /dev/null +++ b/.idea/AndroidProjectSystem.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/appInsightsSettings.xml b/.idea/appInsightsSettings.xml new file mode 100644 index 0000000..371f2e2 --- /dev/null +++ b/.idea/appInsightsSettings.xml @@ -0,0 +1,26 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..7643783 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,123 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b86273d --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/copilot.data.migration.agent.xml b/.idea/copilot.data.migration.agent.xml new file mode 100644 index 0000000..4ea72a9 --- /dev/null +++ b/.idea/copilot.data.migration.agent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/copilot.data.migration.ask.xml b/.idea/copilot.data.migration.ask.xml new file mode 100644 index 0000000..7ef04e2 --- /dev/null +++ b/.idea/copilot.data.migration.ask.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/copilot.data.migration.ask2agent.xml b/.idea/copilot.data.migration.ask2agent.xml new file mode 100644 index 0000000..1f2ea11 --- /dev/null +++ b/.idea/copilot.data.migration.ask2agent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/copilot.data.migration.edit.xml b/.idea/copilot.data.migration.edit.xml new file mode 100644 index 0000000..8648f94 --- /dev/null +++ b/.idea/copilot.data.migration.edit.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..b268ef3 --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/deviceManager.xml b/.idea/deviceManager.xml new file mode 100644 index 0000000..91f9558 --- /dev/null +++ b/.idea/deviceManager.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..639c779 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b2c751a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..16660f1 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/API desc b/app/API desc new file mode 100644 index 0000000..6fc1818 --- /dev/null +++ b/app/API desc @@ -0,0 +1 @@ +{"openapi":"3.1.0","info":{"title":"Women's Safety App API Gateway","description":"API Gateway для Women's Safety App с поддержкой микросервисной архитектуры","version":"1.0.0"},"paths":{"/api/v1/profile":{"get":{"tags":["Users"],"summary":"User Service Proxy","description":"Proxy requests to User Service","operationId":"user_profile_get","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_profile_get"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["Users"],"summary":"User Service Proxy","description":"Proxy requests to User Service","operationId":"user_profile_update","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_profile_update"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/me/change-password":{"post":{"tags":["Users"],"summary":"User Service Proxy","description":"Proxy requests to User Service","operationId":"user_change_password","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_change_password"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/dashboard":{"get":{"tags":["Users"],"summary":"User Service Proxy","description":"Proxy requests to User Service","operationId":"user_dashboard_get","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_dashboard_get"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/me/emergency-contacts/{contact_id}":{"get":{"tags":["Emergency Contacts"],"summary":"Get emergency contact by ID","description":"Proxy requests to User Service","operationId":"user_emergency_contact_get","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_emergency_contact_get"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmergencyContactResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["Emergency Contacts"],"summary":"Delete emergency contact","description":"Proxy requests to User Service","operationId":"user_emergency_contact_delete","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_emergency_contact_delete"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["Emergency Contacts"],"summary":"Update emergency contact","description":"Proxy requests to User Service","operationId":"user_emergency_contact_patch","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_emergency_contact_patch"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmergencyContactResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/me/emergency-contacts":{"get":{"tags":["Emergency Contacts"],"summary":"Get all emergency contacts","description":"Proxy requests to User Service","operationId":"user_emergency_contacts_get","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_emergency_contacts_get"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/EmergencyContactResponse"},"type":"array","title":"Response User Emergency Contacts Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["Emergency Contacts"],"summary":"Create a new emergency contact","description":"Proxy requests to User Service","operationId":"user_emergency_contacts_post","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_emergency_contacts_post"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmergencyContactResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/me":{"get":{"tags":["Users"],"summary":"Get current user profile","description":"Proxy requests to User Service","operationId":"user_me_get","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_me_get"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["Users"],"summary":"Update user profile","description":"Proxy requests to User Service","operationId":"user_me_put","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_me_put"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["Users"],"summary":"Update user profile","description":"Proxy requests to User Service","operationId":"user_me_patch","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_me_patch"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/users/register":{"post":{"tags":["Users"],"summary":"Register a new user","description":"Proxy requests to User Service","operationId":"user_register","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_register"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/auth/login":{"post":{"tags":["Authentication"],"summary":"Login user","description":"Proxy requests to User Service","operationId":"user_auth_login","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_auth_login"}],"title":"Body"},"example":{"username":"user123","password":"Password123!"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Token"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/auth/register":{"post":{"tags":["Authentication"],"summary":"Register a new user","description":"Proxy requests to User Service","operationId":"user_auth_register","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Body_user_auth_register"}],"title":"Body"},"example":{"username":"user123","email":"user@example.com","password":"Password123!","full_name":"John Doe","phone_number":"+7123456789"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/emergency/reports/{report_id}":{"get":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_report_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"delete":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_report_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"patch":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_report_patch","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/emergency/reports/nearby":{"get":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_reports_nearby_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/emergency/reports":{"get":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_reports_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"post":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_reports_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/emergency/alerts/{alert_id}/cancel":{"patch":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_alert_cancel","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/emergency/alerts/{alert_id}":{"get":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_alert_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"delete":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_alert_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"patch":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_alert_patch","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/emergency/alerts/nearby":{"get":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_alerts_nearby_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/emergency/alerts/my":{"get":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_alerts_my_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/emergency/alerts":{"get":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_alerts_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"post":{"summary":"Emergency Service Proxy","description":"Proxy requests to Emergency Service","operationId":"emergency_alerts_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/locations/safe-places/{place_id}":{"get":{"summary":"Location Service Proxy","description":"Proxy requests to Location Service","operationId":"location_safe_place_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"delete":{"summary":"Location Service Proxy","description":"Proxy requests to Location Service","operationId":"location_safe_place_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"patch":{"summary":"Location Service Proxy","description":"Proxy requests to Location Service","operationId":"location_safe_place_patch","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/locations/safe-places":{"get":{"summary":"Location Service Proxy","description":"Proxy requests to Location Service","operationId":"location_safe_places_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"post":{"summary":"Location Service Proxy","description":"Proxy requests to Location Service","operationId":"location_safe_places_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/locations/users/nearby":{"get":{"summary":"Location Service Proxy","description":"Proxy requests to Location Service","operationId":"location_users_nearby_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/locations/history":{"get":{"summary":"Location Service Proxy","description":"Proxy requests to Location Service","operationId":"location_history_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/locations/last":{"get":{"summary":"Location Service Proxy","description":"Proxy requests to Location Service","operationId":"location_last_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/locations/update":{"post":{"summary":"Location Service Proxy","description":"Proxy requests to Location Service","operationId":"location_update_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/calendar/settings":{"get":{"summary":"Calendar Service Proxy","description":"Proxy requests to Calendar Service","operationId":"calendar_settings_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"put":{"summary":"Calendar Service Proxy","description":"Proxy requests to Calendar Service","operationId":"calendar_settings_put","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/calendar/reminders":{"get":{"summary":"Calendar Service Proxy","description":"Proxy requests to Calendar Service","operationId":"calendar_reminders_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"post":{"summary":"Calendar Service Proxy","description":"Proxy requests to Calendar Service","operationId":"calendar_reminders_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/calendar/insights":{"get":{"summary":"Calendar Service Proxy","description":"Proxy requests to Calendar Service","operationId":"calendar_insights_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/calendar/cycle-overview":{"get":{"summary":"Calendar Service Proxy","description":"Proxy requests to Calendar Service","operationId":"calendar_cycle_overview_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/calendar/entries/{entry_id}":{"get":{"summary":"Calendar Service Proxy","description":"Proxy requests to Calendar Service","operationId":"calendar_entry_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"put":{"summary":"Calendar Service Proxy","description":"Proxy requests to Calendar Service","operationId":"calendar_entry_put","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"delete":{"summary":"Calendar Service Proxy","description":"Proxy requests to Calendar Service","operationId":"calendar_entry_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/calendar/entries":{"get":{"summary":"Calendar Service Proxy","description":"Proxy requests to Calendar Service","operationId":"calendar_entries_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"post":{"summary":"Calendar Service Proxy","description":"Proxy requests to Calendar Service","operationId":"calendar_entries_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/notifications/history":{"get":{"summary":"Notification Service Proxy","description":"Proxy requests to Notification Service","operationId":"notifications_history_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/notifications/test":{"post":{"summary":"Notification Service Proxy","description":"Proxy requests to Notification Service","operationId":"notifications_test_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/notifications/preferences":{"get":{"summary":"Notification Service Proxy","description":"Proxy requests to Notification Service","operationId":"notifications_preferences_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"post":{"summary":"Notification Service Proxy","description":"Proxy requests to Notification Service","operationId":"notifications_preferences_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/notifications/devices/{device_id}":{"get":{"summary":"Notification Service Proxy","description":"Proxy requests to Notification Service","operationId":"notifications_device_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"delete":{"summary":"Notification Service Proxy","description":"Proxy requests to Notification Service","operationId":"notifications_device_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/notifications/devices":{"get":{"summary":"Notification Service Proxy","description":"Proxy requests to Notification Service","operationId":"notifications_devices_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"post":{"summary":"Notification Service Proxy","description":"Proxy requests to Notification Service","operationId":"notifications_devices_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/health":{"get":{"summary":"Gateway Health Check","description":"Gateway health check","operationId":"gateway_health_check_api_v1_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/api/v1/services-status":{"get":{"summary":"Check Services Status","description":"Check status of all microservices","operationId":"check_services_status_api_v1_services_status_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/":{"get":{"summary":"Root","description":"Root endpoint with API information","operationId":"root__get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}}},"components":{"schemas":{"Body_user_auth_login":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_auth_login"},"Body_user_auth_register":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_auth_register"},"Body_user_change_password":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_change_password"},"Body_user_dashboard_get":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_dashboard_get"},"Body_user_emergency_contact_delete":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_emergency_contact_delete"},"Body_user_emergency_contact_get":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_emergency_contact_get"},"Body_user_emergency_contact_patch":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_emergency_contact_patch"},"Body_user_emergency_contacts_get":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_emergency_contacts_get"},"Body_user_emergency_contacts_post":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_emergency_contacts_post"},"Body_user_me_get":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_me_get"},"Body_user_me_patch":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_me_patch"},"Body_user_me_put":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_me_put"},"Body_user_profile_get":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_profile_get"},"Body_user_profile_update":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_profile_update"},"Body_user_register":{"properties":{"user_create":{"anyOf":[{"$ref":"#/components/schemas/UserCreate"},{"type":"null"}]},"user_login":{"anyOf":[{"$ref":"#/components/schemas/UserLogin"},{"type":"null"}]},"user_update":{"anyOf":[{"$ref":"#/components/schemas/UserUpdate"},{"type":"null"}]},"emergency_contact_create":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactCreate"},{"type":"null"}]},"emergency_contact_update":{"anyOf":[{"$ref":"#/components/schemas/EmergencyContactUpdate"},{"type":"null"}]}},"type":"object","title":"Body_user_register"},"EmergencyContactCreate":{"properties":{"name":{"type":"string","maxLength":100,"minLength":1,"title":"Name"},"phone_number":{"type":"string","maxLength":20,"minLength":5,"title":"Phone Number"},"relationship":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Relationship"},"notes":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Notes"}},"type":"object","required":["name","phone_number"],"title":"EmergencyContactCreate"},"EmergencyContactResponse":{"properties":{"name":{"type":"string","maxLength":100,"minLength":1,"title":"Name"},"phone_number":{"type":"string","maxLength":20,"minLength":5,"title":"Phone Number"},"relationship":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Relationship"},"notes":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Notes"},"id":{"type":"integer","title":"Id"},"uuid":{"type":"string","title":"Uuid"},"user_id":{"type":"integer","title":"User Id"}},"type":"object","required":["name","phone_number","id","uuid","user_id"],"title":"EmergencyContactResponse"},"EmergencyContactUpdate":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":100,"minLength":1},{"type":"null"}],"title":"Name"},"phone_number":{"anyOf":[{"type":"string","maxLength":20,"minLength":5},{"type":"null"}],"title":"Phone Number"},"relationship":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Relationship"},"notes":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Notes"}},"type":"object","title":"EmergencyContactUpdate"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"Token":{"properties":{"access_token":{"type":"string","title":"Access Token"},"token_type":{"type":"string","title":"Token Type"}},"type":"object","required":["access_token","token_type"],"title":"Token"},"UserCreate":{"properties":{"email":{"type":"string","format":"email","title":"Email"},"username":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Username"},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone"},"phone_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone Number"},"first_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"First Name","default":""},"last_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Name","default":""},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"},"date_of_birth":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Date Of Birth"},"bio":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Bio"},"password":{"type":"string","maxLength":100,"minLength":8,"title":"Password"}},"type":"object","required":["email","password"],"title":"UserCreate"},"UserLogin":{"properties":{"email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Email"},"username":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Username"},"password":{"type":"string","title":"Password"}},"type":"object","required":["password"],"title":"UserLogin"},"UserResponse":{"properties":{"email":{"type":"string","format":"email","title":"Email"},"username":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Username"},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone"},"phone_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone Number"},"first_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"First Name","default":""},"last_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Name","default":""},"full_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Full Name"},"date_of_birth":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Date Of Birth"},"bio":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Bio"},"id":{"type":"integer","title":"Id"},"uuid":{"type":"string","title":"Uuid"},"avatar_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Avatar Url"},"emergency_contact_1_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Emergency Contact 1 Name"},"emergency_contact_1_phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Emergency Contact 1 Phone"},"emergency_contact_2_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Emergency Contact 2 Name"},"emergency_contact_2_phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Emergency Contact 2 Phone"},"location_sharing_enabled":{"type":"boolean","title":"Location Sharing Enabled"},"emergency_notifications_enabled":{"type":"boolean","title":"Emergency Notifications Enabled"},"push_notifications_enabled":{"type":"boolean","title":"Push Notifications Enabled"},"email_verified":{"type":"boolean","title":"Email Verified"},"phone_verified":{"type":"boolean","title":"Phone Verified"},"is_active":{"type":"boolean","title":"Is Active"}},"type":"object","required":["email","id","uuid","location_sharing_enabled","emergency_notifications_enabled","push_notifications_enabled","email_verified","phone_verified","is_active"],"title":"UserResponse"},"UserUpdate":{"properties":{"first_name":{"anyOf":[{"type":"string","maxLength":50,"minLength":1},{"type":"null"}],"title":"First Name"},"last_name":{"anyOf":[{"type":"string","maxLength":50,"minLength":1},{"type":"null"}],"title":"Last Name"},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone"},"date_of_birth":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Date Of Birth"},"bio":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Bio"},"avatar_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Avatar Url"},"emergency_contact_1_name":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Emergency Contact 1 Name"},"emergency_contact_1_phone":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Emergency Contact 1 Phone"},"emergency_contact_2_name":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Emergency Contact 2 Name"},"emergency_contact_2_phone":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Emergency Contact 2 Phone"},"location_sharing_enabled":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Location Sharing Enabled"},"emergency_notifications_enabled":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Emergency Notifications Enabled"},"push_notifications_enabled":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Push Notifications Enabled"}},"type":"object","title":"UserUpdate"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..5d15fc6 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,80 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.compose) +} + +android { + namespace = "com.example.womansafe" + compileSdk = 36 + + defaultConfig { + applicationId = "com.example.womansafe" + minSdk = 24 + targetSdk = 36 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "11" + } + buildFeatures { + compose = true + } +} + +dependencies { + + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.ui.graphics) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(libs.androidx.compose.material3) + + // Networking + implementation("com.squareup.retrofit2:retrofit:2.9.0") + implementation("com.squareup.retrofit2:converter-gson:2.9.0") + implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") + + // JSON + implementation("com.google.code.gson:gson:2.10.1") + + // Navigation + implementation("androidx.navigation:navigation-compose:2.7.6") + + // ViewModel + implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0") + + // Coroutines + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3") + + // DataStore for preferences + implementation("androidx.datastore:datastore-preferences:1.0.0") + + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.compose.ui.test.junit4) + debugImplementation(libs.androidx.compose.ui.tooling) + debugImplementation(libs.androidx.compose.ui.test.manifest) +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/womansafe/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/example/womansafe/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..983d3e3 --- /dev/null +++ b/app/src/androidTest/java/com/example/womansafe/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.example.womansafe + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.example.womansafe", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..707ee08 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/example/womansafe/MainActivity.kt b/app/src/main/java/com/example/womansafe/MainActivity.kt new file mode 100644 index 0000000..b8f174d --- /dev/null +++ b/app/src/main/java/com/example/womansafe/MainActivity.kt @@ -0,0 +1,38 @@ +package com.example.womansafe + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Scaffold +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import com.example.womansafe.ui.screens.ApiTestScreen +import com.example.womansafe.ui.theme.WomanSafeTheme + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + WomanSafeTheme { + Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> + ApiTestScreen( + modifier = Modifier.padding(innerPadding) + ) + } + } + } + } +} + +@Preview(showBackground = true) +@Composable +fun GreetingPreview() { + WomanSafeTheme { + ApiTestScreen() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/womansafe/data/api/WomanSafeApi.kt b/app/src/main/java/com/example/womansafe/data/api/WomanSafeApi.kt new file mode 100644 index 0000000..fd0de55 --- /dev/null +++ b/app/src/main/java/com/example/womansafe/data/api/WomanSafeApi.kt @@ -0,0 +1,204 @@ +package com.example.womansafe.data.api + +import com.example.womansafe.data.model.* +import retrofit2.Response +import retrofit2.http.* + +interface WomanSafeApi { + + // Authentication endpoints + @POST("api/v1/auth/login") + suspend fun login(@Body request: ApiRequestBody): Response + + @POST("api/v1/auth/register") + suspend fun register(@Body request: ApiRequestBody): Response + + // User endpoints + @GET("api/v1/users/me") + suspend fun getCurrentUser(@Body request: ApiRequestBody = ApiRequestBody()): Response + + @PUT("api/v1/users/me") + suspend fun updateCurrentUser(@Body request: ApiRequestBody): Response + + @PATCH("api/v1/users/me") + suspend fun patchCurrentUser(@Body request: ApiRequestBody): Response + + @POST("api/v1/users/me/change-password") + suspend fun changePassword(@Body request: ApiRequestBody): Response + + @GET("api/v1/users/dashboard") + suspend fun getDashboard(@Body request: ApiRequestBody = ApiRequestBody()): Response + + // Profile endpoints + @GET("api/v1/profile") + suspend fun getProfile(@Body request: ApiRequestBody = ApiRequestBody()): Response + + @PUT("api/v1/profile") + suspend fun updateProfile(@Body request: ApiRequestBody): Response + + // Emergency Contacts endpoints + @GET("api/v1/users/me/emergency-contacts") + suspend fun getEmergencyContacts(@Body request: ApiRequestBody = ApiRequestBody()): Response> + + @POST("api/v1/users/me/emergency-contacts") + suspend fun createEmergencyContact(@Body request: ApiRequestBody): Response + + @GET("api/v1/users/me/emergency-contacts/{contact_id}") + suspend fun getEmergencyContact( + @Path("contact_id") contactId: String, + @Body request: ApiRequestBody = ApiRequestBody() + ): Response + + @PATCH("api/v1/users/me/emergency-contacts/{contact_id}") + suspend fun updateEmergencyContact( + @Path("contact_id") contactId: String, + @Body request: ApiRequestBody + ): Response + + @DELETE("api/v1/users/me/emergency-contacts/{contact_id}") + suspend fun deleteEmergencyContact( + @Path("contact_id") contactId: String, + @Body request: ApiRequestBody = ApiRequestBody() + ): Response + + // Emergency endpoints + @GET("api/v1/emergency/reports") + suspend fun getEmergencyReports(): Response + + @POST("api/v1/emergency/reports") + suspend fun createEmergencyReport(): Response + + @GET("api/v1/emergency/reports/nearby") + suspend fun getNearbyEmergencyReports(): Response + + @GET("api/v1/emergency/reports/{report_id}") + suspend fun getEmergencyReport(@Path("report_id") reportId: String): Response + + @PATCH("api/v1/emergency/reports/{report_id}") + suspend fun updateEmergencyReport(@Path("report_id") reportId: String): Response + + @DELETE("api/v1/emergency/reports/{report_id}") + suspend fun deleteEmergencyReport(@Path("report_id") reportId: String): Response + + // Emergency Alerts endpoints + @GET("api/v1/emergency/alerts") + suspend fun getEmergencyAlerts(): Response + + @POST("api/v1/emergency/alerts") + suspend fun createEmergencyAlert(): Response + + @GET("api/v1/emergency/alerts/my") + suspend fun getMyEmergencyAlerts(): Response + + @GET("api/v1/emergency/alerts/nearby") + suspend fun getNearbyEmergencyAlerts(): Response + + @GET("api/v1/emergency/alerts/{alert_id}") + suspend fun getEmergencyAlert(@Path("alert_id") alertId: String): Response + + @PATCH("api/v1/emergency/alerts/{alert_id}") + suspend fun updateEmergencyAlert(@Path("alert_id") alertId: String): Response + + @DELETE("api/v1/emergency/alerts/{alert_id}") + suspend fun deleteEmergencyAlert(@Path("alert_id") alertId: String): Response + + @PATCH("api/v1/emergency/alerts/{alert_id}/cancel") + suspend fun cancelEmergencyAlert(@Path("alert_id") alertId: String): Response + + // Location endpoints + @POST("api/v1/locations/update") + suspend fun updateLocation(): Response + + @GET("api/v1/locations/last") + suspend fun getLastLocation(): Response + + @GET("api/v1/locations/history") + suspend fun getLocationHistory(): Response + + @GET("api/v1/locations/users/nearby") + suspend fun getNearbyUsers(): Response + + @GET("api/v1/locations/safe-places") + suspend fun getSafePlaces(): Response + + @POST("api/v1/locations/safe-places") + suspend fun createSafePlace(): Response + + @GET("api/v1/locations/safe-places/{place_id}") + suspend fun getSafePlace(@Path("place_id") placeId: String): Response + + @PATCH("api/v1/locations/safe-places/{place_id}") + suspend fun updateSafePlace(@Path("place_id") placeId: String): Response + + @DELETE("api/v1/locations/safe-places/{place_id}") + suspend fun deleteSafePlace(@Path("place_id") placeId: String): Response + + // Calendar endpoints + @GET("api/v1/calendar/entries") + suspend fun getCalendarEntries(): Response + + @POST("api/v1/calendar/entries") + suspend fun createCalendarEntry(): Response + + @GET("api/v1/calendar/entries/{entry_id}") + suspend fun getCalendarEntry(@Path("entry_id") entryId: String): Response + + @PUT("api/v1/calendar/entries/{entry_id}") + suspend fun updateCalendarEntry(@Path("entry_id") entryId: String): Response + + @DELETE("api/v1/calendar/entries/{entry_id}") + suspend fun deleteCalendarEntry(@Path("entry_id") entryId: String): Response + + @GET("api/v1/calendar/cycle-overview") + suspend fun getCycleOverview(): Response + + @GET("api/v1/calendar/insights") + suspend fun getCalendarInsights(): Response + + @GET("api/v1/calendar/reminders") + suspend fun getCalendarReminders(): Response + + @POST("api/v1/calendar/reminders") + suspend fun createCalendarReminder(): Response + + @GET("api/v1/calendar/settings") + suspend fun getCalendarSettings(): Response + + @PUT("api/v1/calendar/settings") + suspend fun updateCalendarSettings(): Response + + // Notification endpoints + @GET("api/v1/notifications/devices") + suspend fun getNotificationDevices(): Response + + @POST("api/v1/notifications/devices") + suspend fun createNotificationDevice(): Response + + @GET("api/v1/notifications/devices/{device_id}") + suspend fun getNotificationDevice(@Path("device_id") deviceId: String): Response + + @DELETE("api/v1/notifications/devices/{device_id}") + suspend fun deleteNotificationDevice(@Path("device_id") deviceId: String): Response + + @GET("api/v1/notifications/preferences") + suspend fun getNotificationPreferences(): Response + + @POST("api/v1/notifications/preferences") + suspend fun updateNotificationPreferences(): Response + + @POST("api/v1/notifications/test") + suspend fun testNotification(): Response + + @GET("api/v1/notifications/history") + suspend fun getNotificationHistory(): Response + + // Health check endpoints + @GET("api/v1/health") + suspend fun getHealth(): Response + + @GET("api/v1/services-status") + suspend fun getServicesStatus(): Response + + @GET("") + suspend fun getRoot(): Response +} diff --git a/app/src/main/java/com/example/womansafe/data/model/ApiModels.kt b/app/src/main/java/com/example/womansafe/data/model/ApiModels.kt new file mode 100644 index 0000000..5ab662c --- /dev/null +++ b/app/src/main/java/com/example/womansafe/data/model/ApiModels.kt @@ -0,0 +1,157 @@ +package com.example.womansafe.data.model + +import com.google.gson.annotations.SerializedName + +// Authentication models +data class UserLogin( + val email: String? = null, + val username: String? = null, + val password: String +) + +data class UserCreate( + val email: String, + val username: String? = null, + val phone: String? = null, + @SerializedName("phone_number") + val phoneNumber: String? = null, + @SerializedName("first_name") + val firstName: String? = "", + @SerializedName("last_name") + val lastName: String? = "", + @SerializedName("full_name") + val fullName: String? = null, + @SerializedName("date_of_birth") + val dateOfBirth: String? = null, + val bio: String? = null, + val password: String +) + +data class UserUpdate( + @SerializedName("first_name") + val firstName: String? = null, + @SerializedName("last_name") + val lastName: String? = null, + val phone: String? = null, + @SerializedName("date_of_birth") + val dateOfBirth: String? = null, + val bio: String? = null, + @SerializedName("avatar_url") + val avatarUrl: String? = null, + @SerializedName("emergency_contact_1_name") + val emergencyContact1Name: String? = null, + @SerializedName("emergency_contact_1_phone") + val emergencyContact1Phone: String? = null, + @SerializedName("emergency_contact_2_name") + val emergencyContact2Name: String? = null, + @SerializedName("emergency_contact_2_phone") + val emergencyContact2Phone: String? = null, + @SerializedName("location_sharing_enabled") + val locationSharingEnabled: Boolean? = null, + @SerializedName("emergency_notifications_enabled") + val emergencyNotificationsEnabled: Boolean? = null, + @SerializedName("push_notifications_enabled") + val pushNotificationsEnabled: Boolean? = null +) + +data class UserResponse( + val email: String, + val username: String? = null, + val phone: String? = null, + @SerializedName("phone_number") + val phoneNumber: String? = null, + @SerializedName("first_name") + val firstName: String? = "", + @SerializedName("last_name") + val lastName: String? = "", + @SerializedName("full_name") + val fullName: String? = null, + @SerializedName("date_of_birth") + val dateOfBirth: String? = null, + val bio: String? = null, + val id: Int, + val uuid: String, + @SerializedName("avatar_url") + val avatarUrl: String? = null, + @SerializedName("emergency_contact_1_name") + val emergencyContact1Name: String? = null, + @SerializedName("emergency_contact_1_phone") + val emergencyContact1Phone: String? = null, + @SerializedName("emergency_contact_2_name") + val emergencyContact2Name: String? = null, + @SerializedName("emergency_contact_2_phone") + val emergencyContact2Phone: String? = null, + @SerializedName("location_sharing_enabled") + val locationSharingEnabled: Boolean, + @SerializedName("emergency_notifications_enabled") + val emergencyNotificationsEnabled: Boolean, + @SerializedName("push_notifications_enabled") + val pushNotificationsEnabled: Boolean, + @SerializedName("email_verified") + val emailVerified: Boolean, + @SerializedName("phone_verified") + val phoneVerified: Boolean, + @SerializedName("is_active") + val isActive: Boolean +) + +data class Token( + @SerializedName("access_token") + val accessToken: String, + @SerializedName("token_type") + val tokenType: String +) + +// Emergency Contact models +data class EmergencyContactCreate( + val name: String, + @SerializedName("phone_number") + val phoneNumber: String, + val relationship: String? = null, + val notes: String? = null +) + +data class EmergencyContactUpdate( + val name: String? = null, + @SerializedName("phone_number") + val phoneNumber: String? = null, + val relationship: String? = null, + val notes: String? = null +) + +data class EmergencyContactResponse( + val name: String, + @SerializedName("phone_number") + val phoneNumber: String, + val relationship: String? = null, + val notes: String? = null, + val id: Int, + val uuid: String, + @SerializedName("user_id") + val userId: Int +) + +// API Request body wrapper +data class ApiRequestBody( + @SerializedName("user_create") + val userCreate: UserCreate? = null, + @SerializedName("user_login") + val userLogin: UserLogin? = null, + @SerializedName("user_update") + val userUpdate: UserUpdate? = null, + @SerializedName("emergency_contact_create") + val emergencyContactCreate: EmergencyContactCreate? = null, + @SerializedName("emergency_contact_update") + val emergencyContactUpdate: EmergencyContactUpdate? = null +) + +// Error models +data class ValidationError( + val loc: List, + val msg: String, + val type: String +) + +data class HTTPValidationError( + val detail: List +) diff --git a/app/src/main/java/com/example/womansafe/data/network/NetworkClient.kt b/app/src/main/java/com/example/womansafe/data/network/NetworkClient.kt new file mode 100644 index 0000000..06a0c05 --- /dev/null +++ b/app/src/main/java/com/example/womansafe/data/network/NetworkClient.kt @@ -0,0 +1,51 @@ +package com.example.womansafe.data.network + +import com.google.gson.GsonBuilder +import okhttp3.Interceptor +import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import java.util.concurrent.TimeUnit + +object NetworkClient { + private const val BASE_URL = "http://10.0.2.2:8000/" // For Android Emulator + // For real device, use: "http://YOUR_IP:8000/" + + private var authToken: String? = null + + fun setAuthToken(token: String?) { + authToken = token + } + + private val authInterceptor = Interceptor { chain -> + val request = chain.request().newBuilder() + authToken?.let { token -> + request.addHeader("Authorization", "Bearer $token") + } + request.addHeader("Content-Type", "application/json") + chain.proceed(request.build()) + } + + private val loggingInterceptor = HttpLoggingInterceptor().apply { + level = HttpLoggingInterceptor.Level.BODY + } + + private val okHttpClient = OkHttpClient.Builder() + .addInterceptor(authInterceptor) + .addInterceptor(loggingInterceptor) + .connectTimeout(30, TimeUnit.SECONDS) + .readTimeout(30, TimeUnit.SECONDS) + .writeTimeout(30, TimeUnit.SECONDS) + .build() + + private val gson = GsonBuilder() + .setLenient() + .create() + + val retrofit: Retrofit = Retrofit.Builder() + .baseUrl(BASE_URL) + .client(okHttpClient) + .addConverterFactory(GsonConverterFactory.create(gson)) + .build() +} diff --git a/app/src/main/java/com/example/womansafe/data/repository/ApiRepository.kt b/app/src/main/java/com/example/womansafe/data/repository/ApiRepository.kt new file mode 100644 index 0000000..e3d3947 --- /dev/null +++ b/app/src/main/java/com/example/womansafe/data/repository/ApiRepository.kt @@ -0,0 +1,277 @@ +package com.example.womansafe.data.repository + +import com.example.womansafe.data.api.WomanSafeApi +import com.example.womansafe.data.model.* +import com.example.womansafe.data.network.NetworkClient +import retrofit2.Response + +class ApiRepository { + private val api = NetworkClient.retrofit.create(WomanSafeApi::class.java) + + // Authentication methods + suspend fun login(email: String?, username: String?, password: String): Response { + val loginData = UserLogin(email = email, username = username, password = password) + val requestBody = ApiRequestBody(userLogin = loginData) + return api.login(requestBody) + } + + suspend fun register( + email: String, + username: String?, + password: String, + fullName: String?, + phoneNumber: String? + ): Response { + val userData = UserCreate( + email = email, + username = username, + password = password, + fullName = fullName, + phoneNumber = phoneNumber + ) + val requestBody = ApiRequestBody(userCreate = userData) + return api.register(requestBody) + } + + // User methods + suspend fun getCurrentUser(): Response { + return api.getCurrentUser() + } + + suspend fun updateUser(userUpdate: UserUpdate): Response { + val requestBody = ApiRequestBody(userUpdate = userUpdate) + return api.updateCurrentUser(requestBody) + } + + suspend fun patchUser(userUpdate: UserUpdate): Response { + val requestBody = ApiRequestBody(userUpdate = userUpdate) + return api.patchCurrentUser(requestBody) + } + + suspend fun changePassword(): Response { + return api.changePassword(ApiRequestBody()) + } + + suspend fun getDashboard(): Response { + return api.getDashboard() + } + + // Profile methods + suspend fun getProfile(): Response { + return api.getProfile() + } + + suspend fun updateProfile(userUpdate: UserUpdate): Response { + val requestBody = ApiRequestBody(userUpdate = userUpdate) + return api.updateProfile(requestBody) + } + + // Emergency Contacts methods + suspend fun getEmergencyContacts(): Response> { + return api.getEmergencyContacts() + } + + suspend fun createEmergencyContact(contact: EmergencyContactCreate): Response { + val requestBody = ApiRequestBody(emergencyContactCreate = contact) + return api.createEmergencyContact(requestBody) + } + + suspend fun getEmergencyContact(contactId: String): Response { + return api.getEmergencyContact(contactId) + } + + suspend fun updateEmergencyContact(contactId: String, contact: EmergencyContactUpdate): Response { + val requestBody = ApiRequestBody(emergencyContactUpdate = contact) + return api.updateEmergencyContact(contactId, requestBody) + } + + suspend fun deleteEmergencyContact(contactId: String): Response { + return api.deleteEmergencyContact(contactId) + } + + // Emergency methods + suspend fun getEmergencyReports(): Response { + return api.getEmergencyReports() + } + + suspend fun createEmergencyReport(): Response { + return api.createEmergencyReport() + } + + suspend fun getNearbyEmergencyReports(): Response { + return api.getNearbyEmergencyReports() + } + + suspend fun getEmergencyReport(reportId: String): Response { + return api.getEmergencyReport(reportId) + } + + suspend fun updateEmergencyReport(reportId: String): Response { + return api.updateEmergencyReport(reportId) + } + + suspend fun deleteEmergencyReport(reportId: String): Response { + return api.deleteEmergencyReport(reportId) + } + + // Emergency Alerts methods + suspend fun getEmergencyAlerts(): Response { + return api.getEmergencyAlerts() + } + + suspend fun createEmergencyAlert(): Response { + return api.createEmergencyAlert() + } + + suspend fun getMyEmergencyAlerts(): Response { + return api.getMyEmergencyAlerts() + } + + suspend fun getNearbyEmergencyAlerts(): Response { + return api.getNearbyEmergencyAlerts() + } + + suspend fun getEmergencyAlert(alertId: String): Response { + return api.getEmergencyAlert(alertId) + } + + suspend fun updateEmergencyAlert(alertId: String): Response { + return api.updateEmergencyAlert(alertId) + } + + suspend fun deleteEmergencyAlert(alertId: String): Response { + return api.deleteEmergencyAlert(alertId) + } + + suspend fun cancelEmergencyAlert(alertId: String): Response { + return api.cancelEmergencyAlert(alertId) + } + + // Location methods + suspend fun updateLocation(): Response { + return api.updateLocation() + } + + suspend fun getLastLocation(): Response { + return api.getLastLocation() + } + + suspend fun getLocationHistory(): Response { + return api.getLocationHistory() + } + + suspend fun getNearbyUsers(): Response { + return api.getNearbyUsers() + } + + suspend fun getSafePlaces(): Response { + return api.getSafePlaces() + } + + suspend fun createSafePlace(): Response { + return api.createSafePlace() + } + + suspend fun getSafePlace(placeId: String): Response { + return api.getSafePlace(placeId) + } + + suspend fun updateSafePlace(placeId: String): Response { + return api.updateSafePlace(placeId) + } + + suspend fun deleteSafePlace(placeId: String): Response { + return api.deleteSafePlace(placeId) + } + + // Calendar methods + suspend fun getCalendarEntries(): Response { + return api.getCalendarEntries() + } + + suspend fun createCalendarEntry(): Response { + return api.createCalendarEntry() + } + + suspend fun getCalendarEntry(entryId: String): Response { + return api.getCalendarEntry(entryId) + } + + suspend fun updateCalendarEntry(entryId: String): Response { + return api.updateCalendarEntry(entryId) + } + + suspend fun deleteCalendarEntry(entryId: String): Response { + return api.deleteCalendarEntry(entryId) + } + + suspend fun getCycleOverview(): Response { + return api.getCycleOverview() + } + + suspend fun getCalendarInsights(): Response { + return api.getCalendarInsights() + } + + suspend fun getCalendarReminders(): Response { + return api.getCalendarReminders() + } + + suspend fun createCalendarReminder(): Response { + return api.createCalendarReminder() + } + + suspend fun getCalendarSettings(): Response { + return api.getCalendarSettings() + } + + suspend fun updateCalendarSettings(): Response { + return api.updateCalendarSettings() + } + + // Notification methods + suspend fun getNotificationDevices(): Response { + return api.getNotificationDevices() + } + + suspend fun createNotificationDevice(): Response { + return api.createNotificationDevice() + } + + suspend fun getNotificationDevice(deviceId: String): Response { + return api.getNotificationDevice(deviceId) + } + + suspend fun deleteNotificationDevice(deviceId: String): Response { + return api.deleteNotificationDevice(deviceId) + } + + suspend fun getNotificationPreferences(): Response { + return api.getNotificationPreferences() + } + + suspend fun updateNotificationPreferences(): Response { + return api.updateNotificationPreferences() + } + + suspend fun testNotification(): Response { + return api.testNotification() + } + + suspend fun getNotificationHistory(): Response { + return api.getNotificationHistory() + } + + // Health check methods + suspend fun getHealth(): Response { + return api.getHealth() + } + + suspend fun getServicesStatus(): Response { + return api.getServicesStatus() + } + + suspend fun getRoot(): Response { + return api.getRoot() + } +} diff --git a/app/src/main/java/com/example/womansafe/ui/components/TabComponents.kt b/app/src/main/java/com/example/womansafe/ui/components/TabComponents.kt new file mode 100644 index 0000000..820df2e --- /dev/null +++ b/app/src/main/java/com/example/womansafe/ui/components/TabComponents.kt @@ -0,0 +1,567 @@ +package com.example.womansafe.ui.components + +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.* +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.input.KeyboardType +import androidx.compose.ui.text.input.PasswordVisualTransformation +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.example.womansafe.data.model.EmergencyContactResponse +import com.example.womansafe.data.model.UserResponse +import com.example.womansafe.ui.viewmodel.ApiTestViewModel + +@Composable +fun AuthTab( + email: String, + onEmailChange: (String) -> Unit, + username: String, + onUsernameChange: (String) -> Unit, + password: String, + onPasswordChange: (String) -> Unit, + fullName: String, + onFullNameChange: (String) -> Unit, + phoneNumber: String, + onPhoneNumberChange: (String) -> Unit, + viewModel: ApiTestViewModel, + isLoading: Boolean +) { + Column( + modifier = Modifier + .fillMaxWidth() + .verticalScroll(rememberScrollState()) + ) { + Card( + modifier = Modifier.fillMaxWidth() + ) { + Column( + modifier = Modifier.padding(16.dp) + ) { + Text( + text = "🔐 Аутентификация", + style = MaterialTheme.typography.titleMedium, + fontWeight = FontWeight.Bold + ) + + Spacer(modifier = Modifier.height(16.dp)) + + OutlinedTextField( + value = email, + onValueChange = onEmailChange, + label = { Text("Email") }, + modifier = Modifier.fillMaxWidth(), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email) + ) + + Spacer(modifier = Modifier.height(8.dp)) + + OutlinedTextField( + value = username, + onValueChange = onUsernameChange, + label = { Text("Username (опционально)") }, + modifier = Modifier.fillMaxWidth() + ) + + Spacer(modifier = Modifier.height(8.dp)) + + OutlinedTextField( + value = password, + onValueChange = onPasswordChange, + label = { Text("Пароль") }, + modifier = Modifier.fillMaxWidth(), + visualTransformation = PasswordVisualTransformation(), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password) + ) + + Spacer(modifier = Modifier.height(16.dp)) + + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(8.dp) + ) { + Button( + onClick = { + viewModel.login( + email = if (email.isNotBlank()) email else null, + username = if (username.isNotBlank()) username else null, + password = password + ) + }, + modifier = Modifier.weight(1f), + enabled = !isLoading && password.isNotBlank() + ) { + if (isLoading) { + CircularProgressIndicator(modifier = Modifier.size(16.dp)) + } else { + Text("Войти") + } + } + + OutlinedButton( + onClick = { viewModel.clearAuth() }, + modifier = Modifier.weight(1f) + ) { + Text("Выйти") + } + } + + Spacer(modifier = Modifier.height(16.dp)) + + Text( + text = "Регистрация", + style = MaterialTheme.typography.titleSmall, + fontWeight = FontWeight.Bold + ) + + Spacer(modifier = Modifier.height(8.dp)) + + OutlinedTextField( + value = fullName, + onValueChange = onFullNameChange, + label = { Text("Полное имя") }, + modifier = Modifier.fillMaxWidth() + ) + + Spacer(modifier = Modifier.height(8.dp)) + + OutlinedTextField( + value = phoneNumber, + onValueChange = onPhoneNumberChange, + label = { Text("Номер телефона") }, + modifier = Modifier.fillMaxWidth(), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Phone) + ) + + Spacer(modifier = Modifier.height(16.dp)) + + Button( + onClick = { + viewModel.register( + email = email, + username = if (username.isNotBlank()) username else null, + password = password, + fullName = if (fullName.isNotBlank()) fullName else null, + phoneNumber = if (phoneNumber.isNotBlank()) phoneNumber else null + ) + }, + modifier = Modifier.fillMaxWidth(), + enabled = !isLoading && email.isNotBlank() && password.isNotBlank() + ) { + Text("Зарегистрироваться") + } + } + } + } +} + +@Composable +fun UserTab( + viewModel: ApiTestViewModel, + currentUser: UserResponse?, + isLoading: Boolean +) { + Column( + modifier = Modifier + .fillMaxWidth() + .verticalScroll(rememberScrollState()) + ) { + Card( + modifier = Modifier.fillMaxWidth() + ) { + Column( + modifier = Modifier.padding(16.dp) + ) { + Text( + text = "👤 Профиль пользователя", + style = MaterialTheme.typography.titleMedium, + fontWeight = FontWeight.Bold + ) + + Spacer(modifier = Modifier.height(16.dp)) + + Button( + onClick = { viewModel.getCurrentUser() }, + modifier = Modifier.fillMaxWidth(), + enabled = !isLoading + ) { + Text("Получить профиль") + } + + Spacer(modifier = Modifier.height(8.dp)) + + Button( + onClick = { viewModel.getDashboard() }, + modifier = Modifier.fillMaxWidth(), + enabled = !isLoading + ) { + Text("Получить дашборд") + } + + if (currentUser != null) { + Spacer(modifier = Modifier.height(16.dp)) + + Card( + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant) + ) { + Column( + modifier = Modifier.padding(16.dp) + ) { + Text( + text = "Информация о пользователе:", + fontWeight = FontWeight.Bold + ) + Text("ID: ${currentUser.id}") + Text("UUID: ${currentUser.uuid}") + Text("Email: ${currentUser.email}") + currentUser.fullName?.let { Text("Имя: $it") } + currentUser.phoneNumber?.let { Text("Телефон: $it") } + Text("Email подтвержден: ${if (currentUser.emailVerified) "Да" else "Нет"}") + Text("Активен: ${if (currentUser.isActive) "Да" else "Нет"}") + } + } + } + } + } + } +} + +@Composable +fun ContactsTab( + contactName: String, + onContactNameChange: (String) -> Unit, + contactPhone: String, + onContactPhoneChange: (String) -> Unit, + contactRelationship: String, + onContactRelationshipChange: (String) -> Unit, + contactNotes: String, + onContactNotesChange: (String) -> Unit, + viewModel: ApiTestViewModel, + contacts: List, + isLoading: Boolean +) { + Column( + modifier = Modifier + .fillMaxWidth() + .verticalScroll(rememberScrollState()) + ) { + Card( + modifier = Modifier.fillMaxWidth() + ) { + Column( + modifier = Modifier.padding(16.dp) + ) { + Text( + text = "🚨 Экстренные контакты", + style = MaterialTheme.typography.titleMedium, + fontWeight = FontWeight.Bold + ) + + Spacer(modifier = Modifier.height(16.dp)) + + Button( + onClick = { viewModel.getEmergencyContacts() }, + modifier = Modifier.fillMaxWidth(), + enabled = !isLoading + ) { + Text("Получить список контактов") + } + + Spacer(modifier = Modifier.height(16.dp)) + + Text( + text = "Добавить новый контакт:", + fontWeight = FontWeight.Bold + ) + + Spacer(modifier = Modifier.height(8.dp)) + + OutlinedTextField( + value = contactName, + onValueChange = onContactNameChange, + label = { Text("Имя контакта") }, + modifier = Modifier.fillMaxWidth() + ) + + Spacer(modifier = Modifier.height(8.dp)) + + OutlinedTextField( + value = contactPhone, + onValueChange = onContactPhoneChange, + label = { Text("Номер телефона") }, + modifier = Modifier.fillMaxWidth(), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Phone) + ) + + Spacer(modifier = Modifier.height(8.dp)) + + OutlinedTextField( + value = contactRelationship, + onValueChange = onContactRelationshipChange, + label = { Text("Отношение (опционально)") }, + modifier = Modifier.fillMaxWidth() + ) + + Spacer(modifier = Modifier.height(8.dp)) + + OutlinedTextField( + value = contactNotes, + onValueChange = onContactNotesChange, + label = { Text("Заметки (опционально)") }, + modifier = Modifier.fillMaxWidth(), + maxLines = 3 + ) + + Spacer(modifier = Modifier.height(16.dp)) + + Button( + onClick = { + viewModel.createEmergencyContact( + name = contactName, + phoneNumber = contactPhone, + relationship = if (contactRelationship.isNotBlank()) contactRelationship else null, + notes = if (contactNotes.isNotBlank()) contactNotes else null + ) + }, + modifier = Modifier.fillMaxWidth(), + enabled = !isLoading && contactName.isNotBlank() && contactPhone.isNotBlank() + ) { + Text("Создать контакт") + } + + if (contacts.isNotEmpty()) { + Spacer(modifier = Modifier.height(16.dp)) + + Text( + text = "Существующие контакты:", + fontWeight = FontWeight.Bold + ) + + contacts.forEach { contact -> + Card( + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 4.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant) + ) { + Column( + modifier = Modifier.padding(12.dp) + ) { + Text("${contact.name} - ${contact.phoneNumber}") + contact.relationship?.let { Text("Отношение: $it", fontSize = 12.sp) } + contact.notes?.let { Text("Заметки: $it", fontSize = 12.sp) } + Text("ID: ${contact.id}", fontSize = 10.sp, color = Color.Gray) + } + } + } + } + } + } + } +} + +@Composable +fun ApiTestsTab( + viewModel: ApiTestViewModel, + isLoading: Boolean +) { + Column( + modifier = Modifier + .fillMaxWidth() + .verticalScroll(rememberScrollState()) + ) { + Card( + modifier = Modifier.fillMaxWidth() + ) { + Column( + modifier = Modifier.padding(16.dp) + ) { + Text( + text = "🧪 API Тесты", + style = MaterialTheme.typography.titleMedium, + fontWeight = FontWeight.Bold + ) + + Spacer(modifier = Modifier.height(16.dp)) + + val endpoints = listOf( + "Health Check" to "/api/v1/health", + "Services Status" to "/api/v1/services-status", + "Root" to "/", + "Emergency Reports" to "/api/v1/emergency/reports", + "Emergency Alerts" to "/api/v1/emergency/alerts", + "Last Location" to "/api/v1/locations/last", + "Location History" to "/api/v1/locations/history", + "Calendar Entries" to "/api/v1/calendar/entries", + "Notification Preferences" to "/api/v1/notifications/preferences" + ) + + endpoints.forEach { (name, endpoint) -> + Button( + onClick = { viewModel.testGenericEndpoint(endpoint, "GET") }, + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 2.dp), + enabled = !isLoading + ) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically + ) { + Text(name) + Text( + text = endpoint, + fontSize = 10.sp, + color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.7f) + ) + } + } + } + } + } + } +} + +@Composable +fun SettingsTab( + baseUrl: String, + onBaseUrlChange: (String) -> Unit, + viewModel: ApiTestViewModel +) { + Column( + modifier = Modifier + .fillMaxWidth() + .verticalScroll(rememberScrollState()) + ) { + Card( + modifier = Modifier.fillMaxWidth() + ) { + Column( + modifier = Modifier.padding(16.dp) + ) { + Text( + text = "⚙️ Настройки", + style = MaterialTheme.typography.titleMedium, + fontWeight = FontWeight.Bold + ) + + Spacer(modifier = Modifier.height(16.dp)) + + OutlinedTextField( + value = baseUrl, + onValueChange = onBaseUrlChange, + label = { Text("Base URL API") }, + modifier = Modifier.fillMaxWidth(), + supportingText = { + Text("Для эмулятора: http://10.0.2.2:8000/\nДля реального устройства: http://YOUR_IP:8000/") + } + ) + + Spacer(modifier = Modifier.height(16.dp)) + + Text( + text = "Примеры URL:", + fontWeight = FontWeight.Bold + ) + + val exampleUrls = listOf( + "Эмулятор" to "http://10.0.2.2:8000/", + "Localhost" to "http://127.0.0.1:8000/", + "Удаленный сервер" to "https://api.womansafe.com/" + ) + + exampleUrls.forEach { (name, url) -> + OutlinedButton( + onClick = { onBaseUrlChange(url) }, + modifier = Modifier + .fillMaxWidth() + .padding(vertical = 2.dp) + ) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween + ) { + Text(name) + Text(url, fontSize = 12.sp) + } + } + } + } + } + } +} + +@Composable +fun ResultsSection( + endpoint: String, + response: String, + error: String, + onClear: () -> Unit +) { + Card( + modifier = Modifier.fillMaxWidth(), + colors = CardDefaults.cardColors( + containerColor = if (error.isNotEmpty()) + MaterialTheme.colorScheme.errorContainer + else + MaterialTheme.colorScheme.surfaceVariant + ) + ) { + Column( + modifier = Modifier.padding(16.dp) + ) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically + ) { + Text( + text = "📡 Результат: $endpoint", + fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f) + ) + TextButton(onClick = onClear) { + Text("Очистить") + } + } + + Spacer(modifier = Modifier.height(8.dp)) + + if (error.isNotEmpty()) { + Text( + text = "❌ Ошибка:", + fontWeight = FontWeight.Bold, + color = MaterialTheme.colorScheme.error + ) + Text( + text = error, + fontFamily = FontFamily.Monospace, + fontSize = 12.sp, + color = MaterialTheme.colorScheme.error + ) + } + + if (response.isNotEmpty()) { + Text( + text = "✅ Ответ:", + fontWeight = FontWeight.Bold, + color = if (error.isEmpty()) Color(0xFF4CAF50) else MaterialTheme.colorScheme.onSurface + ) + Text( + text = response, + fontFamily = FontFamily.Monospace, + fontSize = 12.sp, + modifier = Modifier.padding(top = 4.dp) + ) + } + } + } +} diff --git a/app/src/main/java/com/example/womansafe/ui/screens/ApiTestScreen.kt b/app/src/main/java/com/example/womansafe/ui/screens/ApiTestScreen.kt new file mode 100644 index 0000000..5fd1c07 --- /dev/null +++ b/app/src/main/java/com/example/womansafe/ui/screens/ApiTestScreen.kt @@ -0,0 +1,159 @@ +package com.example.womansafe.ui.screens + +import androidx.compose.foundation.layout.* +import androidx.compose.material3.* +import androidx.compose.runtime.* +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.lifecycle.viewmodel.compose.viewModel +import com.example.womansafe.ui.viewmodel.ApiTestViewModel +import com.example.womansafe.ui.components.* + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun ApiTestScreen( + modifier: Modifier = Modifier, + viewModel: ApiTestViewModel = viewModel() +) { + val state by viewModel.state.collectAsState() + + var email by remember { mutableStateOf("user@example.com") } + var username by remember { mutableStateOf("user123") } + var password by remember { mutableStateOf("Password123!") } + var fullName by remember { mutableStateOf("John Doe") } + var phoneNumber by remember { mutableStateOf("+7123456789") } + var baseUrl by remember { mutableStateOf(state.baseUrl) } + + var contactName by remember { mutableStateOf("Emergency Contact") } + var contactPhone by remember { mutableStateOf("+7987654321") } + var contactRelationship by remember { mutableStateOf("Friend") } + var contactNotes by remember { mutableStateOf("Test contact") } + + var selectedTab by remember { mutableStateOf(0) } + val tabs = listOf("Аутентификация", "Пользователь", "Контакты", "API Тесты", "Настройки") + + LaunchedEffect(baseUrl) { + viewModel.updateBaseUrl(baseUrl) + } + + Column( + modifier = Modifier + .fillMaxSize() + .padding(16.dp) + ) { + // Header + Card( + modifier = Modifier.fillMaxWidth(), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.primaryContainer) + ) { + Column( + modifier = Modifier.padding(16.dp) + ) { + Text( + text = "Women's Safety API Tester", + style = MaterialTheme.typography.headlineSmall, + fontWeight = FontWeight.Bold + ) + + if (state.isAuthenticated) { + Text( + text = "✅ Авторизован", + color = Color(0xFF4CAF50), + fontSize = 14.sp + ) + } else { + Text( + text = "❌ Не авторизован", + color = Color(0xFFF44336), + fontSize = 14.sp + ) + } + + Text( + text = "API: $baseUrl", + fontSize = 12.sp, + color = MaterialTheme.colorScheme.onSurfaceVariant + ) + } + } + + Spacer(modifier = Modifier.height(8.dp)) + + // Tabs + ScrollableTabRow(selectedTabIndex = selectedTab) { + tabs.forEachIndexed { index, title -> + Tab( + selected = selectedTab == index, + onClick = { selectedTab = index }, + text = { Text(title) } + ) + } + } + + Spacer(modifier = Modifier.height(8.dp)) + + // Content based on selected tab + when (selectedTab) { + 0 -> AuthTab( + email = email, + onEmailChange = { email = it }, + username = username, + onUsernameChange = { username = it }, + password = password, + onPasswordChange = { password = it }, + fullName = fullName, + onFullNameChange = { fullName = it }, + phoneNumber = phoneNumber, + onPhoneNumberChange = { phoneNumber = it }, + viewModel = viewModel, + isLoading = state.isLoading + ) + + 1 -> UserTab( + viewModel = viewModel, + currentUser = state.currentUser, + isLoading = state.isLoading + ) + + 2 -> ContactsTab( + contactName = contactName, + onContactNameChange = { contactName = it }, + contactPhone = contactPhone, + onContactPhoneChange = { contactPhone = it }, + contactRelationship = contactRelationship, + onContactRelationshipChange = { contactRelationship = it }, + contactNotes = contactNotes, + onContactNotesChange = { contactNotes = it }, + viewModel = viewModel, + contacts = state.emergencyContacts, + isLoading = state.isLoading + ) + + 3 -> ApiTestsTab( + viewModel = viewModel, + isLoading = state.isLoading + ) + + 4 -> SettingsTab( + baseUrl = baseUrl, + onBaseUrlChange = { baseUrl = it }, + viewModel = viewModel + ) + } + + Spacer(modifier = Modifier.height(16.dp)) + + // Results section + if (state.selectedEndpoint.isNotEmpty()) { + ResultsSection( + endpoint = state.selectedEndpoint, + response = state.lastApiResponse, + error = state.lastApiError, + onClear = { viewModel.clearResults() } + ) + } + } +} diff --git a/app/src/main/java/com/example/womansafe/ui/theme/Color.kt b/app/src/main/java/com/example/womansafe/ui/theme/Color.kt new file mode 100644 index 0000000..2f85f01 --- /dev/null +++ b/app/src/main/java/com/example/womansafe/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package com.example.womansafe.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/app/src/main/java/com/example/womansafe/ui/theme/Theme.kt b/app/src/main/java/com/example/womansafe/ui/theme/Theme.kt new file mode 100644 index 0000000..6e5575d --- /dev/null +++ b/app/src/main/java/com/example/womansafe/ui/theme/Theme.kt @@ -0,0 +1,58 @@ +package com.example.womansafe.ui.theme + +import android.app.Activity +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun WomanSafeTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/example/womansafe/ui/theme/Type.kt b/app/src/main/java/com/example/womansafe/ui/theme/Type.kt new file mode 100644 index 0000000..5ef3150 --- /dev/null +++ b/app/src/main/java/com/example/womansafe/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package com.example.womansafe.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) \ No newline at end of file diff --git a/app/src/main/java/com/example/womansafe/ui/viewmodel/ApiTestViewModel.kt b/app/src/main/java/com/example/womansafe/ui/viewmodel/ApiTestViewModel.kt new file mode 100644 index 0000000..c4e2f7b --- /dev/null +++ b/app/src/main/java/com/example/womansafe/ui/viewmodel/ApiTestViewModel.kt @@ -0,0 +1,328 @@ +package com.example.womansafe.ui.viewmodel + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.example.womansafe.data.model.* +import com.example.womansafe.data.network.NetworkClient +import com.example.womansafe.data.repository.ApiRepository +import com.google.gson.Gson +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch + +data class ApiTestState( + val isLoading: Boolean = false, + val currentUser: UserResponse? = null, + val authToken: String? = null, + val isAuthenticated: Boolean = false, + val emergencyContacts: List = emptyList(), + val lastApiResponse: String = "", + val lastApiError: String = "", + val selectedEndpoint: String = "", + val baseUrl: String = "http://10.0.2.2:8000/" +) + +class ApiTestViewModel : ViewModel() { + private val repository = ApiRepository() + private val gson = Gson() + + private val _state = MutableStateFlow(ApiTestState()) + val state: StateFlow = _state.asStateFlow() + + fun updateBaseUrl(url: String) { + _state.value = _state.value.copy(baseUrl = url) + } + + fun login(email: String?, username: String?, password: String) { + viewModelScope.launch { + _state.value = _state.value.copy( + isLoading = true, + selectedEndpoint = "POST /api/v1/auth/login", + lastApiError = "", + lastApiResponse = "" + ) + + try { + val response = repository.login(email, username, password) + if (response.isSuccessful) { + val token = response.body() + token?.let { + NetworkClient.setAuthToken(it.accessToken) + _state.value = _state.value.copy( + authToken = it.accessToken, + isAuthenticated = true, + lastApiResponse = "Login successful! Token: ${it.accessToken.take(20)}...", + isLoading = false + ) + } + } else { + val errorBody = response.errorBody()?.string() ?: "Unknown error" + _state.value = _state.value.copy( + lastApiError = "Error ${response.code()}: $errorBody", + lastApiResponse = "", + isLoading = false + ) + } + } catch (e: Exception) { + _state.value = _state.value.copy( + lastApiError = "Network error: ${e.message}", + lastApiResponse = "", + isLoading = false + ) + } + } + } + + fun register(email: String, username: String?, password: String, fullName: String?, phoneNumber: String?) { + viewModelScope.launch { + _state.value = _state.value.copy( + isLoading = true, + selectedEndpoint = "POST /api/v1/auth/register", + lastApiError = "", + lastApiResponse = "" + ) + + try { + val response = repository.register(email, username, password, fullName, phoneNumber) + if (response.isSuccessful) { + val user = response.body() + _state.value = _state.value.copy( + currentUser = user, + lastApiResponse = gson.toJson(user), + isLoading = false + ) + } else { + val errorBody = response.errorBody()?.string() ?: "Unknown error" + _state.value = _state.value.copy( + lastApiError = "Error ${response.code()}: $errorBody", + lastApiResponse = "", + isLoading = false + ) + } + } catch (e: Exception) { + _state.value = _state.value.copy( + lastApiError = "Network error: ${e.message}", + lastApiResponse = "", + isLoading = false + ) + } + } + } + + fun getCurrentUser() { + viewModelScope.launch { + _state.value = _state.value.copy( + isLoading = true, + selectedEndpoint = "GET /api/v1/users/me", + lastApiError = "", + lastApiResponse = "" + ) + + try { + val response = repository.getCurrentUser() + if (response.isSuccessful) { + val user = response.body() + _state.value = _state.value.copy( + currentUser = user, + lastApiResponse = gson.toJson(user), + isLoading = false + ) + } else { + val errorBody = response.errorBody()?.string() ?: "Unknown error" + _state.value = _state.value.copy( + lastApiError = "Error ${response.code()}: $errorBody", + lastApiResponse = "", + isLoading = false + ) + } + } catch (e: Exception) { + _state.value = _state.value.copy( + lastApiError = "Network error: ${e.message}", + lastApiResponse = "", + isLoading = false + ) + } + } + } + + fun getDashboard() { + viewModelScope.launch { + _state.value = _state.value.copy( + isLoading = true, + selectedEndpoint = "GET /api/v1/users/dashboard", + lastApiError = "", + lastApiResponse = "" + ) + + try { + val response = repository.getDashboard() + if (response.isSuccessful) { + val dashboard = response.body() + _state.value = _state.value.copy( + lastApiResponse = gson.toJson(dashboard), + isLoading = false + ) + } else { + val errorBody = response.errorBody()?.string() ?: "Unknown error" + _state.value = _state.value.copy( + lastApiError = "Error ${response.code()}: $errorBody", + lastApiResponse = "", + isLoading = false + ) + } + } catch (e: Exception) { + _state.value = _state.value.copy( + lastApiError = "Network error: ${e.message}", + lastApiResponse = "", + isLoading = false + ) + } + } + } + + fun getEmergencyContacts() { + viewModelScope.launch { + _state.value = _state.value.copy( + isLoading = true, + selectedEndpoint = "GET /api/v1/users/me/emergency-contacts", + lastApiError = "", + lastApiResponse = "" + ) + + try { + val response = repository.getEmergencyContacts() + if (response.isSuccessful) { + val contacts = response.body() ?: emptyList() + _state.value = _state.value.copy( + emergencyContacts = contacts, + lastApiResponse = gson.toJson(contacts), + isLoading = false + ) + } else { + val errorBody = response.errorBody()?.string() ?: "Unknown error" + _state.value = _state.value.copy( + lastApiError = "Error ${response.code()}: $errorBody", + lastApiResponse = "", + isLoading = false + ) + } + } catch (e: Exception) { + _state.value = _state.value.copy( + lastApiError = "Network error: ${e.message}", + lastApiResponse = "", + isLoading = false + ) + } + } + } + + fun createEmergencyContact(name: String, phoneNumber: String, relationship: String?, notes: String?) { + viewModelScope.launch { + _state.value = _state.value.copy( + isLoading = true, + selectedEndpoint = "POST /api/v1/users/me/emergency-contacts", + lastApiError = "", + lastApiResponse = "" + ) + + try { + val contact = EmergencyContactCreate(name, phoneNumber, relationship, notes) + val response = repository.createEmergencyContact(contact) + if (response.isSuccessful) { + val createdContact = response.body() + _state.value = _state.value.copy( + lastApiResponse = gson.toJson(createdContact), + isLoading = false + ) + // Refresh the contacts list + getEmergencyContacts() + } else { + val errorBody = response.errorBody()?.string() ?: "Unknown error" + _state.value = _state.value.copy( + lastApiError = "Error ${response.code()}: $errorBody", + lastApiResponse = "", + isLoading = false + ) + } + } catch (e: Exception) { + _state.value = _state.value.copy( + lastApiError = "Network error: ${e.message}", + lastApiResponse = "", + isLoading = false + ) + } + } + } + + fun testGenericEndpoint(endpoint: String, method: String) { + viewModelScope.launch { + _state.value = _state.value.copy( + isLoading = true, + selectedEndpoint = "$method $endpoint", + lastApiError = "", + lastApiResponse = "" + ) + + try { + val response = when (endpoint.lowercase()) { + "/api/v1/health" -> repository.getHealth() + "/api/v1/services-status" -> repository.getServicesStatus() + "/" -> repository.getRoot() + "/api/v1/users/dashboard" -> repository.getDashboard() + "/api/v1/emergency/reports" -> repository.getEmergencyReports() + "/api/v1/emergency/alerts" -> repository.getEmergencyAlerts() + "/api/v1/locations/last" -> repository.getLastLocation() + "/api/v1/locations/history" -> repository.getLocationHistory() + "/api/v1/calendar/entries" -> repository.getCalendarEntries() + "/api/v1/notifications/preferences" -> repository.getNotificationPreferences() + else -> { + _state.value = _state.value.copy( + lastApiError = "Endpoint not implemented in this test app", + isLoading = false + ) + return@launch + } + } + + if (response.isSuccessful) { + val body = response.body() + _state.value = _state.value.copy( + lastApiResponse = gson.toJson(body), + isLoading = false + ) + } else { + val errorBody = response.errorBody()?.string() ?: "Unknown error" + _state.value = _state.value.copy( + lastApiError = "Error ${response.code()}: $errorBody", + lastApiResponse = "", + isLoading = false + ) + } + } catch (e: Exception) { + _state.value = _state.value.copy( + lastApiError = "Network error: ${e.message}", + lastApiResponse = "", + isLoading = false + ) + } + } + } + + fun clearAuth() { + NetworkClient.setAuthToken(null) + _state.value = _state.value.copy( + authToken = null, + isAuthenticated = false, + currentUser = null + ) + } + + fun clearResults() { + _state.value = _state.value.copy( + lastApiResponse = "", + lastApiError = "", + selectedEndpoint = "" + ) + } +} diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..b40b51b --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Woman Safe + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml new file mode 100644 index 0000000..e42cece --- /dev/null +++ b/app/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +