├── settings.gradle
├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── refs.xml
│ │ │ │ ├── ids.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── attrs.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── group.png
│ │ │ │ ├── ic_car.png
│ │ │ │ ├── ic_call.png
│ │ │ │ ├── icondrive.png
│ │ │ │ ├── right_arrow.png
│ │ │ │ ├── ic_map_marker.png
│ │ │ │ ├── ios_checkmark.png
│ │ │ │ ├── car_marker_dark.png
│ │ │ │ ├── directions_icon.png
│ │ │ │ ├── ic_right_arrow.png
│ │ │ │ ├── ic_source_marker.png
│ │ │ │ ├── icon_drive_base.png
│ │ │ │ ├── profile_avatar.png
│ │ │ │ ├── directions_button.png
│ │ │ │ ├── icn_titlebar_close.png
│ │ │ │ ├── icon_drive_pointer.png
│ │ │ │ ├── ic_destination_marker.png
│ │ │ │ ├── ic_location_default.png
│ │ │ │ ├── ic_location_pressed.png
│ │ │ │ ├── iconmap_marker_filled.png
│ │ │ │ └── icon_drive_base_transparent.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── group.png
│ │ │ │ ├── ic_call.png
│ │ │ │ ├── ic_car.png
│ │ │ │ ├── icondrive.png
│ │ │ │ ├── right_arrow.png
│ │ │ │ ├── car_marker_dark.png
│ │ │ │ ├── directions_icon.png
│ │ │ │ ├── ic_map_marker.png
│ │ │ │ ├── ic_right_arrow.png
│ │ │ │ ├── icon_drive_base.png
│ │ │ │ ├── ios_checkmark.png
│ │ │ │ ├── profile_avatar.png
│ │ │ │ ├── directions_button.png
│ │ │ │ ├── ic_source_marker.png
│ │ │ │ ├── ic_location_default.png
│ │ │ │ ├── ic_location_pressed.png
│ │ │ │ ├── icn_titlebar_close.png
│ │ │ │ ├── icon_drive_pointer.png
│ │ │ │ ├── ic_destination_marker.png
│ │ │ │ ├── iconmap_marker_filled.png
│ │ │ │ └── icon_drive_base_transparent.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── group.png
│ │ │ │ ├── ic_car.png
│ │ │ │ ├── ic_call.png
│ │ │ │ ├── icondrive.png
│ │ │ │ ├── right_arrow.png
│ │ │ │ ├── ic_map_marker.png
│ │ │ │ ├── ic_right_arrow.png
│ │ │ │ ├── ios_checkmark.png
│ │ │ │ ├── profile_avatar.png
│ │ │ │ ├── background_login.png
│ │ │ │ ├── car_marker_dark.png
│ │ │ │ ├── directions_icon.png
│ │ │ │ ├── ic_source_marker.png
│ │ │ │ ├── icon_drive_base.png
│ │ │ │ ├── natural_resource.png
│ │ │ │ ├── directions_button.png
│ │ │ │ ├── ic_location_default.png
│ │ │ │ ├── ic_location_pressed.png
│ │ │ │ ├── icn_titlebar_close.png
│ │ │ │ ├── icon_drive_pointer.png
│ │ │ │ ├── ic_destination_marker.png
│ │ │ │ ├── iconmap_marker_filled.png
│ │ │ │ └── icon_drive_base_transparent.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ │ ├── group.png
│ │ │ │ ├── ic_call.png
│ │ │ │ ├── ic_car.png
│ │ │ │ ├── icondrive.png
│ │ │ │ ├── ic_map_marker.png
│ │ │ │ ├── ios_checkmark.png
│ │ │ │ ├── right_arrow.png
│ │ │ │ ├── car_marker_dark.png
│ │ │ │ ├── directions_icon.png
│ │ │ │ ├── ic_right_arrow.png
│ │ │ │ ├── icon_drive_base.png
│ │ │ │ ├── profile_avatar.png
│ │ │ │ ├── directions_button.png
│ │ │ │ ├── ic_source_marker.png
│ │ │ │ ├── icon_drive_pointer.png
│ │ │ │ ├── ic_location_default.png
│ │ │ │ ├── ic_location_pressed.png
│ │ │ │ ├── ic_destination_marker.png
│ │ │ │ ├── iconmap_marker_filled.png
│ │ │ │ └── icon_drive_base_transparent.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── layout
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_registration.xml
│ │ │ │ ├── fragment_permissions.xml
│ │ │ │ ├── info_window_from.xml
│ │ │ │ ├── info_window_to.xml
│ │ │ │ ├── snackbar_choose_dest.xml
│ │ │ │ ├── fragment_map.xml
│ │ │ │ ├── fragment_role_registration.xml
│ │ │ │ ├── snackbar_driver_info.xml
│ │ │ │ ├── notification_item.xml
│ │ │ │ ├── user_info.xml
│ │ │ │ ├── snackbar_state.xml
│ │ │ │ ├── fragment_name_registration.xml
│ │ │ │ ├── dialog_accept_ride.xml
│ │ │ │ ├── activity_launcher.xml
│ │ │ │ ├── snackbar_book_ride.xml
│ │ │ │ ├── snackbar_trip_end_info.xml
│ │ │ │ └── snackbar_order_info.xml
│ │ │ ├── drawable
│ │ │ │ ├── divider.xml
│ │ │ │ ├── ic_location.xml
│ │ │ │ ├── elevation.xml
│ │ │ │ ├── bg_button_red.xml
│ │ │ │ ├── bg_dialogs.xml
│ │ │ │ ├── bg_popup.xml
│ │ │ │ ├── bg_text.xml
│ │ │ │ ├── bg_popup_black.xml
│ │ │ │ ├── bg_button.xml
│ │ │ │ ├── bg_button_black.xml
│ │ │ │ ├── bg_button_white.xml
│ │ │ │ ├── bg_ridehole.xml
│ │ │ │ ├── bg_text_left.xml
│ │ │ │ ├── bg_popup_bottom.xml
│ │ │ │ ├── bg_snackbar.xml
│ │ │ │ ├── bg_snackbar_header.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── hypertrack
│ │ │ │ └── ridesharing
│ │ │ │ ├── MySharedPreferences.java
│ │ │ │ ├── parsers
│ │ │ │ ├── Parser.java
│ │ │ │ ├── UserParser.java
│ │ │ │ └── OrderParser.java
│ │ │ │ ├── utils
│ │ │ │ ├── HyperTrackUtils.java
│ │ │ │ ├── TextFormatUtils.java
│ │ │ │ └── MapUtils.java
│ │ │ │ ├── models
│ │ │ │ ├── Car.java
│ │ │ │ ├── User.java
│ │ │ │ ├── Place.java
│ │ │ │ └── Order.java
│ │ │ │ ├── PermissionsFragment.java
│ │ │ │ ├── views
│ │ │ │ ├── Dialog.java
│ │ │ │ ├── SnackbarContentLayout.java
│ │ │ │ └── Snackbar.java
│ │ │ │ ├── FirebaseFirestoreApi.java
│ │ │ │ ├── MyDeviceUpdatesHandler.java
│ │ │ │ ├── RoleRegistrationFragment.java
│ │ │ │ ├── NameRegistrationFragment.java
│ │ │ │ ├── LauncherActivity.java
│ │ │ │ ├── tracking
│ │ │ │ ├── MapViewsPresenter.java
│ │ │ │ └── TrackingPresenter.java
│ │ │ │ ├── components
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── rider
│ │ │ │ │ └── RiderMapFragment.java
│ │ │ │ └── driver
│ │ │ │ │ └── DriverMapFragment.java
│ │ │ │ ├── adapters
│ │ │ │ ├── OrdersAdapter.java
│ │ │ │ └── MapInfoWindowAdapter.java
│ │ │ │ └── RegistrationActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── hypertrack
│ │ │ └── ridesharing
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── hypertrack
│ │ └── ridesharing
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── Images
├── Demo.gif
├── Architecture.png
└── ArchitectureUpdated.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── vcs.xml
├── misc.xml
├── runConfigurations.xml
├── gradle.xml
└── codeStyles
│ └── Project.xml
├── .gitignore
├── LICENSE
├── gradle.properties
├── gradlew.bat
└── gradlew
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | google-services.json
--------------------------------------------------------------------------------
/Images/Demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/Images/Demo.gif
--------------------------------------------------------------------------------
/app/src/main/res/values/refs.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Images/Architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/Images/Architecture.png
--------------------------------------------------------------------------------
/Images/ArchitectureUpdated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/Images/ArchitectureUpdated.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/group.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/group.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/ic_car.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/group.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/group.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_call.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/ic_call.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_call.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/ic_call.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/ic_car.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/group.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/group.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/ic_car.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/group.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/group.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/icondrive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/icondrive.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/right_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icondrive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/icondrive.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_call.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/ic_call.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icondrive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/icondrive.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_call.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/ic_call.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/ic_car.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_map_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/ic_map_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ios_checkmark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/ios_checkmark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/right_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/right_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/icondrive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/icondrive.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/car_marker_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/car_marker_dark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/directions_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/directions_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/ic_right_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_source_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/ic_source_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/icon_drive_base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/icon_drive_base.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/profile_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/profile_avatar.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/car_marker_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/car_marker_dark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/directions_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/directions_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_map_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/ic_map_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/ic_right_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_drive_base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/icon_drive_base.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ios_checkmark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/ios_checkmark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/profile_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/profile_avatar.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_map_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/ic_map_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/ic_right_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ios_checkmark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/ios_checkmark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/profile_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/profile_avatar.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_map_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/ic_map_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ios_checkmark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/ios_checkmark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/right_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/directions_button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/directions_button.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/icn_titlebar_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/icn_titlebar_close.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/icon_drive_pointer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/icon_drive_pointer.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/directions_button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/directions_button.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_source_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/ic_source_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/background_login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/background_login.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/car_marker_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/car_marker_dark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/directions_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/directions_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_source_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/ic_source_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_drive_base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/icon_drive_base.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/natural_resource.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/natural_resource.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/car_marker_dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/car_marker_dark.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/directions_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/directions_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/ic_right_arrow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/icon_drive_base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/icon_drive_base.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/profile_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/profile_avatar.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_destination_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/ic_destination_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_location_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/ic_location_default.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_location_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/ic_location_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/iconmap_marker_filled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/iconmap_marker_filled.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_location_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/ic_location_default.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_location_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/ic_location_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icn_titlebar_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/icn_titlebar_close.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_drive_pointer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/icon_drive_pointer.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/directions_button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/directions_button.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_location_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/ic_location_default.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_location_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/ic_location_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icn_titlebar_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/icn_titlebar_close.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_drive_pointer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/icon_drive_pointer.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/directions_button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/directions_button.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_source_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/ic_source_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/icon_drive_pointer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/icon_drive_pointer.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_destination_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/ic_destination_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/iconmap_marker_filled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/iconmap_marker_filled.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_destination_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/ic_destination_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/iconmap_marker_filled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/iconmap_marker_filled.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_location_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/ic_location_default.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_location_pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/ic_location_pressed.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_destination_marker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/ic_destination_marker.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/iconmap_marker_filled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/iconmap_marker_filled.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/icon_drive_base_transparent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-hdpi/icon_drive_base_transparent.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/icon_drive_base_transparent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xhdpi/icon_drive_base_transparent.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/icon_drive_base_transparent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxhdpi/icon_drive_base_transparent.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/icon_drive_base_transparent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hypertrack/ridesharing-android/HEAD/app/src/main/res/drawable-xxxhdpi/icon_drive_base_transparent.png
--------------------------------------------------------------------------------
/app/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | /firebase
15 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Nov 05 11:25:47 EET 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_location.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/elevation.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button_red.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_dialogs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_popup.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_popup_black.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button_black.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button_white.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_ridehole.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_text_left.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 | 16dp
4 | 100dp
5 | 220dp
6 | 250dp
7 | 250dp
8 | 4dp
9 | 4dp
10 |
11 |
--------------------------------------------------------------------------------
/app/src/test/java/com/hypertrack/ridesharing/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_registration.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_popup_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_snackbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/MySharedPreferences.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing;
2 |
3 | import android.content.Context;
4 |
5 | public class MySharedPreferences {
6 | public static final String USER_KEY = "user";
7 | public static final String ORDER_KEY = "order";
8 | public static final String TRIP_KEY = "trip";
9 |
10 | public static android.content.SharedPreferences get(Context context) {
11 | return context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_snackbar_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_permissions.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #50e3c2
4 | #1dc28c
5 | #D81B60
6 | #000000
7 | #ffffff
8 | #b7b7b7
9 |
10 | #66000000
11 | #ffffff
12 | #000000
13 | #f8f9fa
14 |
15 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/hypertrack/ridesharing/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.InstrumentationRegistry;
6 | import androidx.test.runner.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getTargetContext();
24 |
25 | assertEquals("com.hypertrack.uberx", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/parsers/Parser.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.parsers;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.annotation.Nullable;
5 |
6 | import com.fasterxml.jackson.databind.ObjectMapper;
7 | import com.google.firebase.firestore.DocumentSnapshot;
8 | import com.google.firebase.firestore.QuerySnapshot;
9 |
10 | import java.text.SimpleDateFormat;
11 | import java.util.List;
12 | import java.util.Locale;
13 |
14 | public abstract class Parser {
15 |
16 | public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
17 |
18 | final SimpleDateFormat dateFormat;
19 |
20 | ObjectMapper mapper = new ObjectMapper();
21 |
22 | public Parser() {
23 | dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
24 | }
25 |
26 | @NonNull
27 | abstract List parse(QuerySnapshot querySnapshot);
28 |
29 | @Nullable
30 | abstract T parse(DocumentSnapshot doc);
31 | }
32 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
23 | # Keep model classes to preserve the field names consistency across versions
24 | -keep class com.hypertrack.ridesharing.models.** { *; }
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/info_window_from.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/info_window_to.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
28 |
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 HyperTrack
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/utils/HyperTrackUtils.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.utils;
2 |
3 | import android.content.Context;
4 | import android.content.pm.ApplicationInfo;
5 | import android.content.pm.PackageManager;
6 | import android.text.TextUtils;
7 |
8 |
9 | public class HyperTrackUtils {
10 | private static String HYPERTRACK_PUB_KEY;
11 |
12 | public static String getPubKey(Context context) {
13 | if (TextUtils.isEmpty(HYPERTRACK_PUB_KEY)) {
14 | try {
15 | ApplicationInfo app = context.getPackageManager()
16 | .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
17 | HYPERTRACK_PUB_KEY = app.metaData.getString("com.hypertrack.sdk.PUB_KEY");
18 | } catch (PackageManager.NameNotFoundException e) {
19 | e.printStackTrace();
20 | }
21 | }
22 | if (TextUtils.isEmpty(HYPERTRACK_PUB_KEY)) {
23 | throw new IllegalArgumentException("There is not HyperTrack PUB_KEY in manifest");
24 | }
25 | return HYPERTRACK_PUB_KEY;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/parsers/UserParser.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.parsers;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.annotation.Nullable;
5 |
6 | import com.google.firebase.firestore.DocumentSnapshot;
7 | import com.google.firebase.firestore.QueryDocumentSnapshot;
8 | import com.google.firebase.firestore.QuerySnapshot;
9 | import com.hypertrack.ridesharing.models.User;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class UserParser extends Parser {
15 |
16 | @NonNull
17 | @Override
18 | public List parse(QuerySnapshot querySnapshot) {
19 | List users = new ArrayList<>();
20 | if (querySnapshot != null) {
21 | for (QueryDocumentSnapshot doc : querySnapshot) {
22 | users.add(parse(doc));
23 | }
24 | }
25 | return users;
26 | }
27 |
28 | @Nullable
29 | @Override
30 | public User parse(DocumentSnapshot doc) {
31 | if (doc.getData() != null) {
32 | User user = mapper.convertValue(doc.getData(), User.class);
33 | user.id = doc.getId();
34 | return user;
35 | }
36 | return null;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/parsers/OrderParser.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.parsers;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.annotation.Nullable;
5 |
6 | import com.google.firebase.firestore.DocumentSnapshot;
7 | import com.google.firebase.firestore.QueryDocumentSnapshot;
8 | import com.google.firebase.firestore.QuerySnapshot;
9 | import com.hypertrack.ridesharing.models.Order;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class OrderParser extends Parser {
15 |
16 | @NonNull
17 | @Override
18 | public List parse(QuerySnapshot querySnapshot) {
19 | List orders = new ArrayList<>();
20 | if (querySnapshot != null) {
21 | for (QueryDocumentSnapshot doc : querySnapshot) {
22 | orders.add(parse(doc));
23 | }
24 | }
25 | return orders;
26 | }
27 |
28 | @Nullable
29 | @Override
30 | public Order parse(DocumentSnapshot doc) {
31 | if (doc.getData() != null) {
32 | Order order = mapper.convertValue(doc.getData(), Order.class);
33 | order.id = doc.getId();
34 | return order;
35 | }
36 | return null;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/models/Car.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.models;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
7 | import com.fasterxml.jackson.annotation.JsonProperty;
8 |
9 | @JsonIgnoreProperties(ignoreUnknown = true)
10 | public class Car implements Parcelable {
11 |
12 | public String model;
13 | @JsonProperty("license_plate")
14 | public String licensePlate;
15 |
16 | @Override
17 | public int describeContents() {
18 | return 0;
19 | }
20 |
21 | @Override
22 | public void writeToParcel(Parcel dest, int flags) {
23 | dest.writeString(this.model);
24 | dest.writeString(this.licensePlate);
25 | }
26 |
27 | public Car() {
28 | }
29 |
30 | protected Car(Parcel in) {
31 | this.model = in.readString();
32 | this.licensePlate = in.readString();
33 | }
34 |
35 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
36 | @Override
37 | public Car createFromParcel(Parcel source) {
38 | return new Car(source);
39 | }
40 |
41 | @Override
42 | public Car[] newArray(int size) {
43 | return new Car[size];
44 | }
45 | };
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/PermissionsFragment.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing;
2 |
3 | import android.Manifest;
4 | import android.annotation.SuppressLint;
5 | import android.os.Bundle;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import androidx.annotation.NonNull;
11 | import androidx.annotation.Nullable;
12 | import androidx.core.app.ActivityCompat;
13 | import androidx.fragment.app.Fragment;
14 |
15 | import com.hypertrack.ridesharing.components.MainActivity;
16 |
17 | public class PermissionsFragment extends Fragment {
18 |
19 | @SuppressLint("InflateParams")
20 | @Nullable
21 | @Override
22 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
23 | return inflater.inflate(R.layout.fragment_permissions, null);
24 | }
25 |
26 | @SuppressWarnings("ConstantConditions")
27 | @Override
28 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
29 | super.onViewCreated(view, savedInstanceState);
30 |
31 | ActivityCompat.requestPermissions(getActivity(), new String[]{
32 | Manifest.permission.ACCESS_FINE_LOCATION,
33 | }, MainActivity.REQUEST_ACCESS_FINE_LOCATION);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/snackbar_choose_dest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
18 |
19 |
25 |
26 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/utils/TextFormatUtils.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.utils;
2 |
3 | import android.content.Context;
4 | import android.text.Html;
5 | import android.text.Spanned;
6 | import android.text.format.DateUtils;
7 |
8 | import com.hypertrack.ridesharing.R;
9 | import com.hypertrack.ridesharing.models.Order;
10 |
11 | import java.util.concurrent.TimeUnit;
12 |
13 | public class TextFormatUtils {
14 |
15 | public static String getRelativeDateTimeString(Context context, long time) {
16 | return DateUtils.getRelativeDateTimeString(context, time,
17 | TimeUnit.MINUTES.toMillis(1), TimeUnit.DAYS.toMillis(7),
18 | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE |
19 | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_WEEKDAY |
20 | DateUtils.FORMAT_ABBREV_ALL).toString();
21 | }
22 |
23 | public static Spanned getDestinationName(Context context, Order order) {
24 | boolean isPickup = Order.PICKING_UP.equals(order.status)
25 | || Order.REACHED_PICKUP.equals(order.status);
26 | String address = isPickup ? order.pickup.address : order.dropoff.address;
27 | String text = isPickup ? context.getString(R.string.address_pickup) : context.getString(R.string.address_dropoff);
28 | return Html.fromHtml(String.format(text, address));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/views/Dialog.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.views;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 |
6 | import androidx.annotation.NonNull;
7 |
8 | import com.hypertrack.ridesharing.R;
9 |
10 | public class Dialog extends android.app.Dialog {
11 |
12 | public Dialog(@NonNull Context context, int layoutResID) {
13 | super(context, R.style.DialogTheme);
14 | setContentView(layoutResID);
15 | }
16 |
17 | @NonNull
18 | public Dialog setAction(final View.OnClickListener listener) {
19 | View view = findViewById(R.id.ht_action);
20 | if (view != null) {
21 | if (listener != null) {
22 | view.setVisibility(View.VISIBLE);
23 | view.setOnClickListener(new View.OnClickListener() {
24 | public void onClick(View view) {
25 | listener.onClick(view);
26 | }
27 | });
28 | } else {
29 | view.setVisibility(View.GONE);
30 | view.setOnClickListener(null);
31 | }
32 | }
33 |
34 | return this;
35 | }
36 |
37 | @NonNull
38 | public Dialog setAction(int viewId, final View.OnClickListener listener) {
39 | View view = findViewById(viewId);
40 | if (view != null) {
41 | view.setOnClickListener(listener);
42 | }
43 |
44 | return this;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_map.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
16 |
17 |
22 |
23 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_role_registration.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
21 |
22 |
31 |
32 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/FirebaseFirestoreApi.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing;
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper;
4 | import com.google.android.gms.tasks.Task;
5 | import com.google.firebase.firestore.DocumentReference;
6 | import com.google.firebase.firestore.FirebaseFirestore;
7 | import com.hypertrack.ridesharing.models.Order;
8 | import com.hypertrack.ridesharing.models.User;
9 |
10 | import java.util.Date;
11 | import java.util.Map;
12 |
13 | public class FirebaseFirestoreApi {
14 |
15 | public static final FirebaseFirestore db = FirebaseFirestore.getInstance();
16 |
17 | public static Task createUser(User user) {
18 | ObjectMapper mapper = new ObjectMapper();
19 | Map data = mapper.convertValue(user, Map.class);
20 | data.remove("id");
21 | return db.collection("users").add(data);
22 | }
23 |
24 | @SuppressWarnings({"unchecked", "UnusedReturnValue"})
25 | public static Task updateUser(User user) {
26 | ObjectMapper mapper = new ObjectMapper();
27 | Map data = mapper.convertValue(user, Map.class);
28 | data.remove("id");
29 | return db.collection("users").document(user.id).update(data);
30 | }
31 |
32 | public static Task createOrder(Order order) {
33 | order.status = "NEW";
34 | order.createdAt = new Date();
35 | order.updatedAt = new Date();
36 | ObjectMapper mapper = new ObjectMapper();
37 | Map data = mapper.convertValue(order, Map.class);
38 | data.remove("id");
39 | return db.collection("orders").add(data);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/snackbar_driver_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
25 |
26 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/notification_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
31 |
32 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/MyDeviceUpdatesHandler.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | import com.hypertrack.sdk.views.DeviceUpdatesHandler;
6 | import com.hypertrack.sdk.views.dao.Location;
7 | import com.hypertrack.sdk.views.dao.StatusUpdate;
8 | import com.hypertrack.sdk.views.dao.Trip;
9 | import com.hypertrack.sdk.views.maps.HyperTrackMap;
10 |
11 | public abstract class MyDeviceUpdatesHandler implements DeviceUpdatesHandler {
12 |
13 | public void onLocationUpdateReceived(@NonNull android.location.Location location) {
14 | }
15 |
16 | @Override
17 | public void onLocationUpdateReceived(@NonNull Location location) {
18 | android.location.Location convertedLocation = new android.location.Location(HyperTrackMap.VIEWS_LOCATION_PROVIDER);
19 | convertedLocation.setLatitude(location.getLatitude());
20 | convertedLocation.setLongitude(location.getLongitude());
21 | convertedLocation.setAltitude(location.getAltitude() != null ? location.getAltitude() : 0.0f);
22 | convertedLocation.setAccuracy(location.getAccuracy() != null ? location.getAccuracy().floatValue() : 0.0f);
23 | convertedLocation.setBearing(location.getBearing() != null ? location.getBearing().floatValue() : 0.0f);
24 | convertedLocation.setSpeed(location.getSpeed() != null ? location.getSpeed().floatValue() : 0.0f);
25 | convertedLocation.setTime(System.currentTimeMillis());
26 | convertedLocation.setElapsedRealtimeNanos(System.nanoTime());
27 |
28 | onLocationUpdateReceived(convertedLocation);
29 | }
30 |
31 | @Override
32 | public void onBatteryStateUpdateReceived(int i) {
33 | }
34 |
35 | @Override
36 | public void onStatusUpdateReceived(@NonNull StatusUpdate statusUpdate) {
37 | }
38 |
39 | @Override
40 | public void onTripUpdateReceived(@NonNull Trip trip) {
41 | }
42 |
43 | @Override
44 | public void onError(Exception e, String s) {
45 | }
46 |
47 | @Override
48 | public void onCompleted(String s) {
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/RoleRegistrationFragment.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.annotation.Nullable;
10 | import androidx.fragment.app.Fragment;
11 |
12 | import com.hypertrack.ridesharing.models.User;
13 |
14 | public class RoleRegistrationFragment extends Fragment implements View.OnClickListener {
15 |
16 | private User user;
17 |
18 | public static Fragment newInstance(@NonNull User user) {
19 | Fragment fragment = new RoleRegistrationFragment();
20 | Bundle bundle = new Bundle();
21 | bundle.putParcelable(MySharedPreferences.USER_KEY, user);
22 | fragment.setArguments(bundle);
23 | return fragment;
24 | }
25 |
26 | @Override
27 | public void onCreate(@Nullable Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | if (getArguments() != null) {
30 | user = getArguments().getParcelable(MySharedPreferences.USER_KEY);
31 | }
32 | if (user == null) {
33 | user = new User();
34 | }
35 | }
36 |
37 | @Nullable
38 | @Override
39 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
40 | return inflater.inflate(R.layout.fragment_role_registration, null);
41 | }
42 |
43 | @Override
44 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
45 | super.onViewCreated(view, savedInstanceState);
46 |
47 | view.findViewById(R.id.driver_role).setOnClickListener(this);
48 | view.findViewById(R.id.rider_role).setOnClickListener(this);
49 | }
50 |
51 | @SuppressWarnings("ConstantConditions")
52 | @Override
53 | public void onClick(View view) {
54 | user.role = view.getId() == R.id.driver_role ? User.USER_ROLE_DRIVER : User.USER_ROLE_RIDER;
55 | ((RegistrationActivity)getActivity()).next(user);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/user_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
29 |
30 |
40 |
41 |
51 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
29 |
30 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
43 |
44 |
47 |
48 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/snackbar_state.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
25 |
26 |
41 |
42 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/models/User.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.models;
2 |
3 | import android.location.Location;
4 | import android.os.Parcel;
5 | import android.os.Parcelable;
6 |
7 | import com.fasterxml.jackson.annotation.JsonIgnore;
8 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
9 | import com.fasterxml.jackson.annotation.JsonProperty;
10 | import com.google.android.gms.maps.model.Marker;
11 | import com.hypertrack.ridesharing.MyDeviceUpdatesHandler;
12 |
13 | @JsonIgnoreProperties(ignoreUnknown = true)
14 | public class User implements Parcelable {
15 | public static final String USER_ROLE_DRIVER = "driver";
16 | public static final String USER_ROLE_RIDER = "rider";
17 |
18 | // id: String
19 | // role: String (Enum driver | rider)
20 | // name: String
21 | // phone_number: String
22 | // device_id: String
23 | // car: Car
24 | public String id;
25 | public String role;
26 | public String name;
27 | @JsonProperty("phone_number")
28 | public String phoneNumber;
29 | @JsonProperty("device_id")
30 | public String deviceId;
31 | public Car car;
32 |
33 | @JsonIgnore
34 | public Location location;
35 | @JsonIgnore
36 | public Marker marker;
37 |
38 | @JsonIgnore
39 | public MyDeviceUpdatesHandler deviceUpdatesHandler;
40 |
41 |
42 | public User() {
43 | }
44 |
45 | public User(String id) {
46 | this.id = id;
47 | }
48 |
49 | @Override
50 | public int describeContents() {
51 | return 0;
52 | }
53 |
54 | @Override
55 | public void writeToParcel(Parcel dest, int flags) {
56 | dest.writeString(this.id);
57 | dest.writeString(this.role);
58 | dest.writeString(this.name);
59 | dest.writeString(this.phoneNumber);
60 | dest.writeString(this.deviceId);
61 | }
62 |
63 | protected User(Parcel in) {
64 | this.id = in.readString();
65 | this.role = in.readString();
66 | this.name = in.readString();
67 | this.phoneNumber = in.readString();
68 | this.deviceId = in.readString();
69 | }
70 |
71 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
72 | @Override
73 | public User createFromParcel(Parcel source) {
74 | return new User(source);
75 | }
76 |
77 | @Override
78 | public User[] newArray(int size) {
79 | return new User[size];
80 | }
81 | };
82 | }
83 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_name_registration.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
28 |
36 |
37 |
46 |
47 |
56 |
57 |
58 |
59 |
68 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LOGIN
3 | Uber for X
4 | HyperTrack
5 | Driver
6 | Are you?
7 | Rider
8 | Enter your name
9 | Enter your phone
10 | car model
11 | driver licence
12 | Pickup
13 | Dropoff
14 | Save
15 | Enter pickup location
16 | Enter your destination
17 | Book ride
18 | Choose origin and destination
19 | Open
20 | App settings
21 | You can allow HyperTrack Live to access this device\'s location in settings
22 | My location
23 | Cancel
24 | Accept ride
25 | Call
26 | Connecting you to the nearest driver
27 | Order was cancelled
28 | Start trip
29 | End trip
30 | PICKUP %s]]>
31 | DROPOFF %s]]>
32 | distance
33 | Ride time
34 | Stopped
35 | Driving
36 | %.2f Miles
37 | %d mins
38 | Where do you wanna go ?
39 | Estimate…
40 | Cancel ride?
41 | Finding riders near you
42 | Get directions
43 | Find new rides
44 | Book another ride
45 | Fare | $%d
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/models/Place.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.models;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import com.fasterxml.jackson.annotation.JsonIgnore;
7 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
8 | import com.google.android.gms.maps.model.LatLng;
9 | import com.google.android.gms.maps.model.Marker;
10 | import com.google.android.libraries.places.api.model.AddressComponent;
11 |
12 | import java.util.List;
13 |
14 | @JsonIgnoreProperties(ignoreUnknown = true)
15 | public class Place implements Parcelable {
16 | public double latitude;
17 | public double longitude;
18 | public String address;
19 |
20 | @JsonIgnore
21 | public String preview;
22 | @JsonIgnore
23 | public Marker marker;
24 |
25 | @JsonIgnore
26 | public LatLng getLatLng() {
27 | return new LatLng(latitude, longitude);
28 | }
29 |
30 | @Override
31 | public int describeContents() {
32 | return 0;
33 | }
34 |
35 | @Override
36 | public void writeToParcel(Parcel dest, int flags) {
37 | dest.writeDouble(this.latitude);
38 | dest.writeDouble(this.longitude);
39 | dest.writeString(this.address);
40 | }
41 |
42 | public Place() {
43 | }
44 |
45 | public Place(LatLng latLng) {
46 | this.latitude = latLng.latitude;
47 | this.longitude = latLng.longitude;
48 | }
49 |
50 | public Place(com.google.android.libraries.places.api.model.Place place) {
51 | if (place.getLatLng() != null) {
52 | this.latitude = place.getLatLng().latitude;
53 | this.longitude = place.getLatLng().longitude;
54 | }
55 | if (place.getAddressComponents() == null || place.getAddressComponents().asList().size() < 4) {
56 | this.address = place.getAddress();
57 | } else {
58 | List components = place.getAddressComponents().asList();
59 | this.address = components.get(0).getName() + " " + components.get(1).getShortName() + ", " + components.get(3).getShortName();
60 | }
61 | }
62 |
63 | protected Place(Parcel in) {
64 | this.latitude = in.readDouble();
65 | this.longitude = in.readDouble();
66 | this.address = in.readString();
67 | }
68 |
69 | public static final Creator CREATOR = new Creator() {
70 | @Override
71 | public Place createFromParcel(Parcel source) {
72 | return new Place(source);
73 | }
74 |
75 | @Override
76 | public Place[] newArray(int size) {
77 | return new Place[size];
78 | }
79 | };
80 | }
81 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/views/SnackbarContentLayout.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.views;
2 |
3 | import android.content.Context;
4 | import android.os.Build;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.FrameLayout;
9 |
10 | import androidx.annotation.NonNull;
11 | import androidx.annotation.Nullable;
12 | import androidx.annotation.RequiresApi;
13 |
14 | import com.hypertrack.ridesharing.R;
15 |
16 | @SuppressWarnings("unused")
17 | public class SnackbarContentLayout extends FrameLayout implements com.google.android.material.snackbar.ContentViewCallback {
18 | private View contentView;
19 | private Button actionView;
20 |
21 | public SnackbarContentLayout(@NonNull Context context) {
22 | super(context);
23 | }
24 |
25 | public SnackbarContentLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
26 | super(context, attrs);
27 | }
28 |
29 | public SnackbarContentLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
30 | super(context, attrs, defStyleAttr);
31 | }
32 |
33 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
34 | public SnackbarContentLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
35 | super(context, attrs, defStyleAttr, defStyleRes);
36 | }
37 |
38 | public View getContentView() {
39 | return contentView;
40 | }
41 |
42 | public Button getActionView() {
43 | return actionView;
44 | }
45 |
46 | @Override
47 | protected void onFinishInflate() {
48 | super.onFinishInflate();
49 | contentView = findViewById(R.id.ht_snackbar_content);
50 | actionView = findViewById(R.id.ht_action);
51 | }
52 |
53 | @Override
54 | public void animateContentIn(int delay, int duration) {
55 | if (contentView != null) {
56 | contentView.setAlpha(0.0F);
57 | contentView.animate().alpha(1.0F).setDuration((long) duration).setStartDelay((long) delay).start();
58 | }
59 | if (actionView != null && actionView.getVisibility() == VISIBLE) {
60 | actionView.setAlpha(0.0F);
61 | actionView.animate().alpha(1.0F).setDuration((long) duration).setStartDelay((long) delay).start();
62 | }
63 |
64 | }
65 |
66 | @Override
67 | public void animateContentOut(int delay, int duration) {
68 | if (contentView != null) {
69 | contentView.setAlpha(1.0F);
70 | contentView.animate().alpha(0.0F).setDuration((long) duration).setStartDelay((long) delay).start();
71 | }
72 | if (actionView != null && actionView.getVisibility() == VISIBLE) {
73 | actionView.setAlpha(1.0F);
74 | actionView.animate().alpha(0.0F).setDuration((long) duration).setStartDelay((long) delay).start();
75 | }
76 |
77 | }
78 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/utils/MapUtils.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.utils;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.location.Address;
6 | import android.location.Geocoder;
7 |
8 | import com.google.android.gms.maps.model.BitmapDescriptorFactory;
9 | import com.google.android.gms.maps.model.Dash;
10 | import com.google.android.gms.maps.model.LatLng;
11 | import com.google.android.gms.maps.model.MarkerOptions;
12 | import com.google.android.gms.maps.model.PatternItem;
13 | import com.google.android.gms.maps.model.PolylineOptions;
14 | import com.hypertrack.maps.google.widget.GoogleMapConfig;
15 | import com.hypertrack.ridesharing.R;
16 |
17 | import java.io.IOException;
18 | import java.util.Collections;
19 | import java.util.List;
20 | import java.util.Locale;
21 | import java.util.concurrent.Callable;
22 |
23 | import io.reactivex.Single;
24 | import io.reactivex.android.schedulers.AndroidSchedulers;
25 | import io.reactivex.schedulers.Schedulers;
26 |
27 | public class MapUtils {
28 | public static GoogleMapConfig.Builder getBuilder(Context context) {
29 | int width = context.getResources().getDisplayMetrics().widthPixels;
30 | int height = context.getResources().getDisplayMetrics().heightPixels;
31 | int mapRouteWidth = context.getResources().getDimensionPixelSize(R.dimen.map_route_width);
32 | GoogleMapConfig.TripOptions tripOptions = GoogleMapConfig.newTripOptions()
33 | .tripDestinationMarker(new MarkerOptions()
34 | .anchor(0.5f, 0.5f)
35 | .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_destination_marker)))
36 | .tripPassedRoutePolyline(null)
37 | .tripComingRoutePolyline(new PolylineOptions()
38 | .width(mapRouteWidth)
39 | .color(Color.BLACK)
40 | .pattern(Collections.singletonList(new Dash(mapRouteWidth))));
41 | return GoogleMapConfig.newBuilder(context)
42 | .tripOptions(tripOptions)
43 | .boundingBoxDimensions(width, height / 3);
44 | }
45 |
46 | public static Single getAddress(Context context, final LatLng latLng) {
47 | final Geocoder geocoder = new Geocoder(context, Locale.getDefault());
48 | return Single.fromCallable(new Callable() {
49 | @Override
50 | public String call() {
51 | try {
52 | List addresses = geocoder.getFromLocation(latLng.latitude, latLng.longitude, 1);
53 | if (!addresses.isEmpty()) {
54 | Address address = addresses.get(0);
55 | return address.getSubThoroughfare() + " " + address.getThoroughfare() + ", " + address.getLocality();
56 | }
57 |
58 | } catch (IOException e) {
59 | e.printStackTrace();
60 | }
61 | return "";
62 | }
63 | })
64 | .subscribeOn(Schedulers.io())
65 | .observeOn(AndroidSchedulers.mainThread());
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'io.fabric'
3 |
4 | android {
5 | compileSdkVersion 29
6 | buildToolsVersion "29.0.2"
7 | defaultConfig {
8 | applicationId "com.hypertrack.ridesharing"
9 | minSdkVersion 19
10 | targetSdkVersion 29
11 | versionCode 4
12 | versionName "1.0.3"
13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14 | multiDexEnabled true
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled true
19 | shrinkResources true
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | debug{
23 | minifyEnabled false
24 | }
25 | }
26 |
27 | flavorDimensions "version"
28 | productFlavors {
29 | general {
30 | dimension "version"
31 | applicationIdSuffix ".android.github"
32 | versionNameSuffix ""
33 | resValue "string", "app_name", "Ridesharing"
34 | }
35 | driver {
36 | dimension "version"
37 | applicationIdSuffix ".driver.android.github"
38 | versionNameSuffix "-driver"
39 | resValue "string", "app_name", "Ridesharing Driver"
40 | }
41 | rider {
42 | dimension "version"
43 | applicationIdSuffix ".rider.android.github"
44 | versionNameSuffix "-rider"
45 | resValue "string", "app_name", "Ridesharing Rider"
46 | }
47 | }
48 | }
49 |
50 | repositories {
51 | mavenLocal()
52 | maven {
53 | name 'hypertrack'
54 | url 'http://m2.hypertrack.com'
55 | }
56 | maven { url 'https://maven.fabric.io/public' }
57 | }
58 |
59 | dependencies {
60 | implementation fileTree(dir: 'libs', include: ['*.jar'])
61 | implementation 'androidx.appcompat:appcompat:1.1.0'
62 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
63 | implementation 'com.google.firebase:firebase-firestore:21.3.0'
64 | implementation 'com.google.android.gms:play-services-maps:17.0.0'
65 | implementation 'com.google.maps.android:android-maps-utils:0.6.2'
66 | implementation 'com.google.android.libraries.places:places:2.1.0'
67 |
68 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
69 | implementation 'com.google.android.material:material:1.0.0'
70 | implementation 'com.daimajia.easing:library:2.0@aar'
71 | implementation 'com.daimajia.androidanimations:library:2.3@aar'
72 |
73 | implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
74 | implementation 'io.reactivex.rxjava2:rxjava:2.2.14'
75 |
76 | implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.1'
77 |
78 | implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
79 |
80 | implementation 'com.hypertrack:hypertrack:4.0.0'
81 | implementation 'com.hypertrack:hypertrack-views:0.8.5'
82 | implementation 'com.hypertrack:maps-google:0.1.1'
83 |
84 | testImplementation 'junit:junit:4.12'
85 | androidTestImplementation 'androidx.test:runner:1.2.0'
86 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
87 | }
88 |
89 | apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/NameRegistrationFragment.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing;
2 |
3 | import android.os.Bundle;
4 | import android.text.TextUtils;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.EditText;
9 |
10 | import androidx.annotation.NonNull;
11 | import androidx.annotation.Nullable;
12 | import androidx.fragment.app.Fragment;
13 |
14 | import com.hypertrack.ridesharing.models.Car;
15 | import com.hypertrack.ridesharing.models.User;
16 |
17 | public class NameRegistrationFragment extends Fragment {
18 |
19 | private EditText usernameEditText;
20 | private EditText phoneEditText;
21 | private EditText carModelEditText;
22 | private EditText driverLicenceEditText;
23 |
24 | private User user;
25 |
26 | public static Fragment newInstance(@NonNull User user) {
27 | Fragment fragment = new NameRegistrationFragment();
28 | Bundle bundle = new Bundle();
29 | bundle.putParcelable(MySharedPreferences.USER_KEY, user);
30 | fragment.setArguments(bundle);
31 | return fragment;
32 | }
33 |
34 | @Override
35 | public void onCreate(@Nullable Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | if (getArguments() != null) {
38 | user = getArguments().getParcelable(MySharedPreferences.USER_KEY);
39 | }
40 | if (user == null) {
41 | user = new User();
42 | }
43 | }
44 |
45 | @Nullable
46 | @Override
47 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
48 | return inflater.inflate(R.layout.fragment_name_registration, null);
49 | }
50 |
51 | @Override
52 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
53 | super.onViewCreated(view, savedInstanceState);
54 |
55 | View driver = view.findViewById(R.id.driver);
56 | if (User.USER_ROLE_DRIVER.equals(user.role)) {
57 | driver.setVisibility(View.VISIBLE);
58 | }
59 |
60 | usernameEditText = view.findViewById(R.id.username);
61 | phoneEditText = view.findViewById(R.id.phone);
62 | carModelEditText = view.findViewById(R.id.car_model);
63 | driverLicenceEditText = view.findViewById(R.id.driver_licence);
64 |
65 | view.findViewById(R.id.save).setOnClickListener(new View.OnClickListener() {
66 |
67 | @SuppressWarnings("ConstantConditions")
68 | @Override
69 | public void onClick(View view) {
70 | user.name = usernameEditText.getText().toString();
71 | user.phoneNumber = phoneEditText.getText().toString();
72 | if (User.USER_ROLE_DRIVER.equals(user.role)) {
73 | user.car = new Car();
74 | user.car.model = carModelEditText.getText().toString();
75 | user.car.licensePlate = driverLicenceEditText.getText().toString();
76 | }
77 | if (!TextUtils.isEmpty(user.name) && !TextUtils.isEmpty(user.phoneNumber)) {
78 | ((RegistrationActivity) getActivity()).next(user);
79 | }
80 | }
81 | });
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | xmlns:android
11 |
12 | ^$
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | xmlns:.*
22 |
23 | ^$
24 |
25 |
26 | BY_NAME
27 |
28 |
29 |
30 |
31 |
32 |
33 | .*:id
34 |
35 | http://schemas.android.com/apk/res/android
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | .*:name
45 |
46 | http://schemas.android.com/apk/res/android
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | name
56 |
57 | ^$
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | style
67 |
68 | ^$
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | .*
78 |
79 | ^$
80 |
81 |
82 | BY_NAME
83 |
84 |
85 |
86 |
87 |
88 |
89 | .*
90 |
91 | http://schemas.android.com/apk/res/android
92 |
93 |
94 | ANDROID_ATTRIBUTE_ORDER
95 |
96 |
97 |
98 |
99 |
100 |
101 | .*
102 |
103 | .*
104 |
105 |
106 | BY_NAME
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/LauncherActivity.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.os.Handler;
7 | import android.view.View;
8 | import android.view.animation.AccelerateDecelerateInterpolator;
9 |
10 | import com.daimajia.androidanimations.library.Techniques;
11 | import com.daimajia.androidanimations.library.YoYo;
12 | import com.hypertrack.ridesharing.components.MainActivity;
13 |
14 | /**
15 | * An example full-screen activity that shows and hides the system UI (i.e.
16 | * status bar and navigation/system bar) with user interaction.
17 | */
18 | public class LauncherActivity extends Activity{
19 |
20 | /**
21 | * Some older devices needs a small delay between UI widget updates
22 | * and a change of the status and navigation bar.
23 | */
24 | private static final int UI_ANIMATION_DELAY = 1000;
25 | private final Handler mHideHandler = new Handler();
26 | private View mContentView;
27 | private View mControlsView;
28 | private View text;
29 | private final Runnable mShowPart2Runnable = new Runnable() {
30 | @Override
31 | public void run() {
32 | // Show the system bar
33 | mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
34 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
35 |
36 | // Delayed display of UI elements
37 | mControlsView.setVisibility(View.VISIBLE);
38 | YoYo.with(Techniques.ZoomInRight)
39 | .duration(1200)
40 | .pivot(YoYo.CENTER_PIVOT, YoYo.CENTER_PIVOT)
41 | .interpolate(new AccelerateDecelerateInterpolator())
42 | .playOn(text);
43 | }
44 | };
45 |
46 | @Override
47 | protected void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | setContentView(R.layout.activity_launcher);
50 |
51 | if (MySharedPreferences.get(this).contains(MySharedPreferences.USER_KEY)) {
52 | start(MainActivity.class);
53 | } else {
54 | mControlsView = findViewById(R.id.fullscreen_content_controls);
55 | text = findViewById(R.id.text);
56 | mContentView = findViewById(R.id.fullscreen_content);
57 |
58 |
59 | findViewById(R.id.login).setOnClickListener(new View.OnClickListener() {
60 | @Override
61 | public void onClick(View view) {
62 | start(RegistrationActivity.class);
63 | }
64 | });
65 |
66 | // Schedule a runnable to display UI elements after a delay
67 | mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
68 | }
69 | }
70 |
71 | @Override
72 | protected void onPostCreate(Bundle savedInstanceState) {
73 | super.onPostCreate(savedInstanceState);
74 |
75 | // Trigger the initial hide() shortly after the activity has been
76 | // created, to briefly hint to the user that UI controls
77 | // are available.
78 | hide();
79 | }
80 |
81 | private void hide() {
82 | mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
83 | | View.SYSTEM_UI_FLAG_FULLSCREEN
84 | | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
85 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
86 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
87 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
88 | }
89 |
90 | private void start(Class> cls) {
91 | // Some preparation before start main functional
92 |
93 | startActivity(new Intent(this, cls));
94 | finish();
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_accept_ride.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
20 |
21 |
32 |
33 |
38 |
39 |
45 |
46 |
54 |
55 |
56 |
63 |
64 |
69 |
70 |
79 |
80 |
81 |
82 |
83 |
96 |
97 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
24 |
25 |
33 |
34 |
38 |
39 |
45 |
46 |
47 |
48 |
57 |
58 |
65 |
66 |
73 |
74 |
75 |
76 |
77 |
85 |
86 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/tracking/MapViewsPresenter.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.tracking;
2 |
3 | import android.content.Context;
4 | import android.location.LocationListener;
5 | import android.text.TextUtils;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 | import androidx.core.util.Consumer;
10 |
11 | import com.hypertrack.sdk.views.DeviceUpdatesHandler;
12 | import com.hypertrack.sdk.views.HyperTrackViews;
13 | import com.hypertrack.sdk.views.dao.MovementStatus;
14 | import com.hypertrack.sdk.views.dao.Trip;
15 | import com.hypertrack.sdk.views.maps.HyperTrackMap;
16 | import com.hypertrack.sdk.views.maps.widget.MapAdapter;
17 |
18 | @SuppressWarnings({"unused", "WeakerAccess"})
19 | public class MapViewsPresenter {
20 | private static final String TAG = "MapViewsPresenter";
21 |
22 | protected final Context mContext;
23 | private final View mView;
24 | private final State mState;
25 |
26 | private HyperTrackViews hyperTrackViews;
27 | private HyperTrackMap hyperTrackMap;
28 |
29 | public MapViewsPresenter(@NonNull Context context, @NonNull View view, @NonNull String hyperTrackPubKey) {
30 | mContext = context.getApplicationContext() == null ? context : context.getApplicationContext();
31 | mView = view;
32 | mState = new State(hyperTrackPubKey);
33 |
34 | hyperTrackViews = HyperTrackViews.getInstance(mContext, mState.getHyperTrackPubKey());
35 | }
36 |
37 | public void map(@NonNull MapAdapter mapAdapter) {
38 | hyperTrackMap = HyperTrackMap.getInstance(mContext, mapAdapter);
39 | }
40 |
41 | public void subscribe(@NonNull String deviceId) {
42 | if (!TextUtils.isEmpty(deviceId)) {
43 | hyperTrackViews.getDeviceMovementStatus(deviceId, new Consumer() {
44 | @Override
45 | public void accept(MovementStatus movementStatus) {
46 | for (Trip item : movementStatus.trips) {
47 | if (item.getStatus().equals("active")) {
48 | mState.setTripId(item.getTripId());
49 | mView.onTripChanged(item);
50 | break;
51 | }
52 | }
53 | }
54 | });
55 | hyperTrackMap.bind(hyperTrackViews, deviceId);
56 | }
57 | }
58 |
59 | public void setLocationUpdatesListener(LocationListener locationListener) {
60 | if (hyperTrackMap != null) {
61 | hyperTrackMap.setLocationUpdatesListener(locationListener);
62 | }
63 | }
64 |
65 | public void subscribeToDeviceUpdates(String deviceId, DeviceUpdatesHandler deviceUpdatesHandler) {
66 | hyperTrackViews.subscribeToDeviceUpdates(deviceId, deviceUpdatesHandler);
67 | }
68 |
69 | public void moveToMyLocation() {
70 | if (hyperTrackMap != null) {
71 | hyperTrackMap.moveToMyLocation();
72 | }
73 | }
74 |
75 | public void setMyLocationEnabled(boolean enabled) {
76 | if (hyperTrackMap != null) {
77 | hyperTrackMap.setMyLocationEnabled(enabled);
78 | }
79 | }
80 |
81 | public void destroy() {
82 | if (hyperTrackMap != null) {
83 | hyperTrackMap.destroy();
84 | hyperTrackMap = null;
85 | }
86 | }
87 |
88 | public interface View {
89 |
90 | void onTripChanged(Trip trip);
91 |
92 | void showProgressBar();
93 |
94 | void hideProgressBar();
95 | }
96 |
97 | public static class State {
98 | private final String hyperTrackPubKey;
99 | private String tripId;
100 |
101 | @NonNull
102 | public String getHyperTrackPubKey() {
103 | return hyperTrackPubKey;
104 | }
105 |
106 | @Nullable
107 | public String getTripId() {
108 | return tripId;
109 | }
110 |
111 | public void setTripId(String tripId) {
112 | this.tripId = tripId;
113 | }
114 |
115 | public State(@NonNull String hyperTrackPubKey) {
116 | this.hyperTrackPubKey = hyperTrackPubKey;
117 | }
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/models/Order.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.models;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import com.fasterxml.jackson.annotation.JsonFormat;
7 | import com.fasterxml.jackson.annotation.JsonIgnore;
8 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
9 | import com.fasterxml.jackson.annotation.JsonProperty;
10 | import com.google.android.gms.maps.model.Marker;
11 | import com.hypertrack.ridesharing.parsers.Parser;
12 |
13 | import java.util.Date;
14 |
15 | @JsonIgnoreProperties(ignoreUnknown = true)
16 | public class Order implements Parcelable {
17 |
18 | public static final String
19 | NEW = "NEW",
20 | ACCEPTED = "ACCEPTED",
21 | PICKING_UP = "PICKING_UP",
22 | REACHED_PICKUP = "REACHED_PICKUP",
23 | STARTED_RIDE = "STARTED_RIDE",
24 | DROPPING_OFF = "DROPPING_OFF",
25 | REACHED_DROPOFF = "REACHED_DROPOFF",
26 | CANCELLED = "CANCELLED",
27 | COMPLETED = "COMPLETED";
28 |
29 | // id: String
30 | // status: String (Enum NEW | PICKING_UP | REACHED_PICKUP | DROPPING_OFF | REACHED_DROPOFF | COMPLETED)
31 | // rider: User
32 | // driver: User
33 | // pickup: Place
34 | // dropoff: Place
35 | // created_at: String (ISO8601 yyyy-MM-dd'T'HH:mm:ss'Z')
36 | // trip_id: String
37 | public String id;
38 | public String status;
39 | @JsonProperty("trip_id")
40 | public String tripId;
41 | public Place pickup;
42 | public Place dropoff;
43 | public User rider;
44 | public User driver;
45 | @JsonFormat (shape = JsonFormat.Shape.STRING, pattern = Parser.DATE_FORMAT, timezone="UTC")
46 | @JsonProperty("created_at")
47 | public Date createdAt;
48 | @JsonFormat (shape = JsonFormat.Shape.STRING, pattern = Parser.DATE_FORMAT, timezone="UTC")
49 | @JsonProperty("updated_at")
50 | public Date updatedAt;
51 |
52 | @JsonIgnore
53 | public Marker marker;
54 |
55 | public Order() {
56 | }
57 |
58 | public Order(String id) {
59 | this.id = id;
60 | }
61 |
62 | public void update(Order newOrder) {
63 | status = newOrder.status;
64 | tripId = newOrder.tripId;
65 | pickup = newOrder.pickup;
66 | dropoff = newOrder.dropoff;
67 | rider = newOrder.rider;
68 | driver = newOrder.driver;
69 | createdAt = newOrder.createdAt;
70 | updatedAt = newOrder.updatedAt;
71 | }
72 |
73 | @Override
74 | public int describeContents() {
75 | return 0;
76 | }
77 |
78 | @Override
79 | public void writeToParcel(Parcel dest, int flags) {
80 | dest.writeString(this.id);
81 | dest.writeString(this.status);
82 | dest.writeString(this.tripId);
83 | dest.writeParcelable(this.pickup, flags);
84 | dest.writeParcelable(this.dropoff, flags);
85 | dest.writeParcelable(this.rider, flags);
86 | dest.writeParcelable(this.driver, flags);
87 | dest.writeLong(this.createdAt != null ? this.createdAt.getTime() : -1);
88 | dest.writeLong(this.updatedAt != null ? this.updatedAt.getTime() : -1);
89 | }
90 |
91 | protected Order(Parcel in) {
92 | this.id = in.readString();
93 | this.status = in.readString();
94 | this.tripId = in.readString();
95 | this.pickup = in.readParcelable(Place.class.getClassLoader());
96 | this.dropoff = in.readParcelable(Place.class.getClassLoader());
97 | this.rider = in.readParcelable(User.class.getClassLoader());
98 | this.driver = in.readParcelable(User.class.getClassLoader());
99 | long tmpCreatedAt = in.readLong();
100 | this.createdAt = tmpCreatedAt == -1 ? null : new Date(tmpCreatedAt);
101 | long tmpUpdatedAt = in.readLong();
102 | this.updatedAt = tmpUpdatedAt == -1 ? null : new Date(tmpUpdatedAt);
103 | }
104 |
105 | public static final Creator CREATOR = new Creator() {
106 | @Override
107 | public Order createFromParcel(Parcel source) {
108 | return new Order(source);
109 | }
110 |
111 | @Override
112 | public Order[] newArray(int size) {
113 | return new Order[size];
114 | }
115 | };
116 | }
117 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/components/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.components;
2 |
3 | import android.Manifest;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.content.pm.PackageManager;
7 | import android.net.Uri;
8 | import android.os.Bundle;
9 | import android.provider.Settings;
10 |
11 | import androidx.annotation.NonNull;
12 | import androidx.appcompat.app.AlertDialog;
13 | import androidx.core.content.ContextCompat;
14 | import androidx.fragment.app.Fragment;
15 | import androidx.fragment.app.FragmentActivity;
16 | import androidx.fragment.app.FragmentTransaction;
17 |
18 | import com.fasterxml.jackson.core.JsonProcessingException;
19 | import com.fasterxml.jackson.databind.ObjectMapper;
20 | import com.hypertrack.ridesharing.MySharedPreferences;
21 | import com.hypertrack.ridesharing.PermissionsFragment;
22 | import com.hypertrack.ridesharing.R;
23 | import com.hypertrack.ridesharing.components.driver.DriverMapFragment;
24 | import com.hypertrack.ridesharing.components.rider.RiderMapFragment;
25 | import com.hypertrack.ridesharing.models.User;
26 |
27 | public class MainActivity extends FragmentActivity {
28 |
29 | public static final int REQUEST_ACCESS_FINE_LOCATION = 10;
30 |
31 | public static final String GOOGLE_API_KEY = "AIzaSyBKZejrZNZpLlemrH28Nc46XzHsRSVRxKI";
32 |
33 | private User user;
34 |
35 | @Override
36 | protected void onCreate(Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 | setContentView(R.layout.activity_main);
39 |
40 | ObjectMapper mapper = new ObjectMapper();
41 | String json = MySharedPreferences.get(this).getString(MySharedPreferences.USER_KEY, "");
42 | try {
43 | user = mapper.readValue(json, User.class);
44 | } catch (JsonProcessingException e) {
45 | e.printStackTrace();
46 | }
47 | if (user == null) return;
48 |
49 | if (PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this,
50 | Manifest.permission.ACCESS_FINE_LOCATION)) {
51 | startMap();
52 | } else {
53 | startPermissionsRequest();
54 | }
55 | }
56 |
57 | private void startMap() {
58 | Fragment fragment = user.role.equals("driver") ?
59 | DriverMapFragment.newInstance() : RiderMapFragment.newInstance();
60 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
61 | transaction.replace(R.id.fragment_frame, fragment);
62 | transaction.commit();
63 | }
64 |
65 | private void startPermissionsRequest() {
66 | Fragment fragment = new PermissionsFragment();
67 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
68 | transaction.replace(R.id.fragment_frame, fragment);
69 | transaction.commit();
70 | }
71 |
72 | @Override
73 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
74 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
75 |
76 | if (requestCode == REQUEST_ACCESS_FINE_LOCATION) {
77 |
78 | if ((permissions.length == 1 &&
79 | permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION) &&
80 | grantResults[0] == PackageManager.PERMISSION_GRANTED)
81 | || User.USER_ROLE_RIDER.equals(user.role)) {
82 | startMap();
83 | } else {
84 | AlertDialog alertDialog = new AlertDialog.Builder(this)
85 | .setNegativeButton(android.R.string.cancel, null)
86 | .setPositiveButton(R.string.open, new DialogInterface.OnClickListener() {
87 | @Override
88 | public void onClick(DialogInterface dialogInterface, int i) {
89 | Intent intent = new Intent();
90 | intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
91 | Uri uri = Uri.parse("package:" + getPackageName());
92 | intent.setData(uri);
93 | startActivityForResult(intent, REQUEST_ACCESS_FINE_LOCATION);
94 | }
95 | })
96 | .setTitle(R.string.app_settings)
97 | .setMessage(R.string.you_can_allow)
98 | .create();
99 | alertDialog.show();
100 | }
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/adapters/OrdersAdapter.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.adapters;
2 |
3 | import android.text.format.DateUtils;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import androidx.recyclerview.widget.RecyclerView;
10 |
11 | import com.hypertrack.ridesharing.R;
12 | import com.hypertrack.ridesharing.models.Order;
13 |
14 | import java.util.ArrayList;
15 | import java.util.Collection;
16 | import java.util.Collections;
17 | import java.util.Comparator;
18 | import java.util.List;
19 | import java.util.concurrent.TimeUnit;
20 |
21 | public class OrdersAdapter extends RecyclerView.Adapter {
22 | private List orders = new ArrayList<>();
23 | private OnItemClickListener onItemClickListener;
24 |
25 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
26 | this.onItemClickListener = onItemClickListener;
27 | }
28 |
29 | public static class MyViewHolder extends RecyclerView.ViewHolder {
30 | // each data item is just a string in this case
31 | public TextView address;
32 | public TextView date;
33 | public View close;
34 |
35 | public MyViewHolder(View v) {
36 | super(v);
37 | address = v.findViewById(R.id.address);
38 | date = v.findViewById(R.id.date);
39 | close = v.findViewById(R.id.close);
40 | }
41 | }
42 |
43 | @Override
44 | public OrdersAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent,
45 | int viewType) {
46 | // create a new view
47 | View v = LayoutInflater.from(parent.getContext())
48 | .inflate(R.layout.notification_item, parent, false);
49 | MyViewHolder vh = new MyViewHolder(v);
50 | return vh;
51 | }
52 |
53 | // Replace the contents of a view (invoked by the layout manager)
54 | @Override
55 | public void onBindViewHolder(MyViewHolder holder, final int position) {
56 | // - get element from your dataset at this position
57 | // - replace the contents of the view with that element
58 | final Order order = orders.get(position);
59 |
60 | holder.address.setText(order.pickup.address);
61 | String date = DateUtils.getRelativeDateTimeString(holder.itemView.getContext(), order.createdAt.getTime(),
62 | TimeUnit.MINUTES.toMillis(1), TimeUnit.DAYS.toMillis(7),
63 | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE |
64 | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_WEEKDAY |
65 | DateUtils.FORMAT_ABBREV_ALL).toString();
66 | holder.date.setText(date);
67 | holder.close.setOnClickListener(new View.OnClickListener() {
68 | @Override
69 | public void onClick(View view) {
70 | orders.remove(position);
71 | notifyDataSetChanged();
72 | }
73 | });
74 | holder.itemView.setOnClickListener(new View.OnClickListener() {
75 | @Override
76 | public void onClick(View view) {
77 | if (onItemClickListener != null) {
78 | onItemClickListener.onItemClick(OrdersAdapter.this, view, position);
79 | }
80 | orders.remove(position);
81 | notifyDataSetChanged();
82 | }
83 | });
84 | }
85 |
86 | // Return the size of your dataset (invoked by the layout manager)
87 | @Override
88 | public int getItemCount() {
89 | return orders.size();
90 | }
91 |
92 | public Order getOrder(int position) {
93 | return orders.isEmpty() ? null : orders.get(position);
94 | }
95 |
96 | public void addAll(Collection items) {
97 | List newList = new ArrayList<>(orders);
98 | newList.addAll(items);
99 | Collections.sort(newList, new Comparator() {
100 | @Override
101 | public int compare(Order order1, Order order2) {
102 | return order2.createdAt.compareTo(order1.createdAt);
103 | }
104 | });
105 | orders.clear();
106 | if (newList.size() > 5) {
107 | orders.addAll(newList.subList(0, 5));
108 | } else {
109 | orders.addAll(newList);
110 | }
111 | }
112 |
113 | public void clear() {
114 | orders.clear();
115 | }
116 |
117 | public interface OnItemClickListener {
118 | void onItemClick(RecyclerView.Adapter> adapter, View view, int position);
119 | }
120 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/RegistrationActivity.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.text.TextUtils;
6 | import android.util.Log;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.annotation.Nullable;
10 | import androidx.appcompat.app.AppCompatActivity;
11 | import androidx.fragment.app.Fragment;
12 | import androidx.fragment.app.FragmentTransaction;
13 |
14 | import com.fasterxml.jackson.core.JsonProcessingException;
15 | import com.fasterxml.jackson.databind.ObjectMapper;
16 | import com.google.android.gms.tasks.OnFailureListener;
17 | import com.google.android.gms.tasks.OnSuccessListener;
18 | import com.google.firebase.firestore.DocumentReference;
19 | import com.google.gson.Gson;
20 | import com.hypertrack.sdk.HyperTrack;
21 | import com.hypertrack.ridesharing.components.MainActivity;
22 | import com.hypertrack.ridesharing.models.User;
23 | import com.hypertrack.ridesharing.utils.HyperTrackUtils;
24 |
25 | import java.util.HashMap;
26 | import java.util.Map;
27 |
28 | public class RegistrationActivity extends AppCompatActivity {
29 | private static final String TAG = "RegistrationActivity";
30 |
31 | private Gson gson = new Gson();
32 |
33 | @Override
34 | protected void onCreate(@Nullable Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_registration);
37 |
38 | String json = MySharedPreferences.get(this).getString(MySharedPreferences.USER_KEY, "{}");
39 | User user = gson.fromJson(json, User.class);
40 | next(user);
41 | }
42 |
43 | public void next(final User user) {
44 | if (TextUtils.isEmpty(user.role)) {
45 | if (getPackageName().contains(User.USER_ROLE_DRIVER)) {
46 | user.role = User.USER_ROLE_DRIVER;
47 | next(user);
48 | } else if (getPackageName().contains(User.USER_ROLE_RIDER)) {
49 | user.role = User.USER_ROLE_RIDER;
50 | next(user);
51 | } else {
52 | addFragment(RoleRegistrationFragment.newInstance(user));
53 | }
54 | } else if (TextUtils.isEmpty(user.name)) {
55 | addFragment(NameRegistrationFragment.newInstance(user));
56 | } else if (TextUtils.isEmpty(user.id)) {
57 | if (User.USER_ROLE_DRIVER.equals(user.role)) {
58 | HyperTrack hyperTrack = HyperTrack.getInstance(this, HyperTrackUtils.getPubKey(this));
59 | hyperTrack.setDeviceName(user.name);
60 | Map metadata = new HashMap<>();
61 | metadata.put("name", user.name);
62 | metadata.put("phone_number", user.phoneNumber);
63 | Map car = new HashMap<>();
64 | car.put("model", user.car.model);
65 | car.put("license_plate", user.car.licensePlate);
66 | metadata.put("car", car);
67 | hyperTrack.setDeviceMetadata(metadata);
68 |
69 | user.deviceId = hyperTrack.getDeviceID();
70 | }
71 | FirebaseFirestoreApi.createUser(user)
72 | .addOnSuccessListener(new OnSuccessListener() {
73 | @Override
74 | public void onSuccess(DocumentReference documentReference) {
75 | Log.d(TAG, "DocumentSnapshot added with ID: " + documentReference.getId());
76 | user.id = documentReference.getId();
77 | next(user);
78 | }
79 | })
80 | .addOnFailureListener(new OnFailureListener() {
81 | @Override
82 | public void onFailure(@NonNull Exception e) {
83 | Log.w(TAG, "Error adding document", e);
84 | }
85 | });
86 | } else {
87 | try {
88 | ObjectMapper mapper = new ObjectMapper();
89 | String json = mapper.writeValueAsString(user);
90 | MySharedPreferences.get(this).edit()
91 | .putString(MySharedPreferences.USER_KEY, json)
92 | .apply();
93 | } catch (JsonProcessingException e) {
94 | e.printStackTrace();
95 | }
96 |
97 | startActivity(new Intent(this, MainActivity.class));
98 | finish();
99 | }
100 | }
101 |
102 | private void addFragment(Fragment fragment) {
103 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
104 | transaction.replace(R.id.fragment_frame, fragment);
105 | transaction.commitAllowingStateLoss();
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/snackbar_book_ride.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
29 |
30 |
39 |
40 |
50 |
51 |
57 |
58 |
59 |
67 |
68 |
79 |
80 |
89 |
90 |
100 |
101 |
102 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/tracking/TrackingPresenter.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.tracking;
2 |
3 | import android.Manifest;
4 | import android.annotation.SuppressLint;
5 | import android.app.Activity;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.content.pm.PackageManager;
9 | import android.location.LocationManager;
10 | import android.net.Uri;
11 | import android.os.Build;
12 | import android.os.PowerManager;
13 | import android.provider.Settings;
14 |
15 | import androidx.annotation.NonNull;
16 |
17 | import com.google.android.gms.common.wrappers.InstantApps;
18 | import com.hypertrack.sdk.HyperTrack;
19 | import com.hypertrack.sdk.TrackingError;
20 | import com.hypertrack.sdk.TrackingStateObserver;
21 | import com.hypertrack.ridesharing.utils.HyperTrackUtils;
22 |
23 | @SuppressWarnings({"unused", "WeakerAccess"})
24 | public class TrackingPresenter implements TrackingStateObserver.OnTrackingStateChangeListener {
25 | private static final String TAG = "TrackingPresenter";
26 |
27 | public static final int PERMISSIONS_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS = 616;
28 |
29 | protected final Context mContext;
30 | private final View mView;
31 |
32 | protected HyperTrack hyperTrack;
33 |
34 | @SuppressWarnings("ConstantConditions")
35 | public TrackingPresenter(@NonNull Context context, @NonNull View view) {
36 | mContext = context.getApplicationContext() == null ? context : context.getApplicationContext();
37 | mView = view;
38 |
39 | hyperTrack = HyperTrack.getInstance(context, HyperTrackUtils.getPubKey(context));
40 | }
41 |
42 | @SuppressWarnings("ConstantConditions")
43 | public void requestIgnoreBatteryOptimizations() {
44 | PowerManager pm = (PowerManager) mContext.getSystemService(Activity.POWER_SERVICE);
45 | String packageName = mContext.getPackageName();
46 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
47 | && !pm.isIgnoringBatteryOptimizations(packageName)
48 | && !InstantApps.isInstantApp(mContext)) {
49 | mView.requestPermissions(new String[]{Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS},
50 | PERMISSIONS_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
51 | }
52 | }
53 |
54 | public void resume() {
55 | if (hyperTrack.isRunning()) {
56 | mView.onTrackingStart();
57 | } else {
58 | mView.onTrackingStop();
59 | }
60 | }
61 |
62 | public void adjustTrackingState() {
63 | hyperTrack.syncDeviceSettings();
64 | if (!isGpsProviderEnabled(mContext)) {
65 | actionLocationSourceSettings();
66 | }
67 | }
68 |
69 | public void actionLocationSourceSettings() {
70 | if (mContext != null && !InstantApps.isInstantApp(mContext)) {
71 | Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
72 | mContext.startActivity(intent);
73 | }
74 | }
75 |
76 | @SuppressLint({"BatteryLife", "InlinedApi"})
77 | @SuppressWarnings("ConstantConditions")
78 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
79 |
80 | if (requestCode == PERMISSIONS_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS) {
81 | if (grantResults.length > 0
82 | && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
83 | PowerManager pm = (PowerManager) mContext.getSystemService(Activity.POWER_SERVICE);
84 | String packageName = mContext.getPackageName();
85 | if (!pm.isIgnoringBatteryOptimizations(packageName)) {
86 | Intent intent = new Intent();
87 | intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
88 | Uri uri = Uri.parse("package:" + packageName);
89 | intent.setData(uri);
90 | mView.startActivityForResult(intent, PERMISSIONS_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
91 | }
92 | }
93 | }
94 | }
95 |
96 | public void destroy() {
97 | hyperTrack.removeTrackingListener(this);
98 | hyperTrack.syncDeviceSettings();
99 | }
100 |
101 | private static boolean isGpsProviderEnabled(Context context) {
102 | if (context != null) {
103 | LocationManager cm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
104 | return cm != null && cm.isProviderEnabled(LocationManager.GPS_PROVIDER);
105 | }
106 |
107 | return true;
108 | }
109 |
110 | @Override
111 | public void onError(TrackingError trackingError) {
112 | mView.onError(trackingError);
113 | }
114 |
115 | @Override
116 | public void onTrackingStart() {
117 | mView.onTrackingStart();
118 | }
119 |
120 | @Override
121 | public void onTrackingStop() {
122 | mView.onTrackingStop();
123 | }
124 |
125 | public interface View extends TrackingStateObserver.OnTrackingStateChangeListener {
126 |
127 | void requestPermissions(String[] permissions, int requestCode);
128 |
129 | void startActivityForResult(Intent intent, int requestCode);
130 | }
131 |
132 | public static class State {
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/views/Snackbar.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.views;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.view.ViewParent;
8 | import android.view.accessibility.AccessibilityManager;
9 | import android.widget.FrameLayout;
10 |
11 | import androidx.annotation.IntRange;
12 | import androidx.annotation.NonNull;
13 | import androidx.annotation.Nullable;
14 | import androidx.annotation.RestrictTo;
15 | import androidx.annotation.RestrictTo.Scope;
16 | import androidx.coordinatorlayout.widget.CoordinatorLayout;
17 |
18 | import com.google.android.material.snackbar.BaseTransientBottomBar;
19 |
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 |
23 | @SuppressWarnings({"unused", "FieldCanBeLocal"})
24 | public final class Snackbar extends BaseTransientBottomBar {
25 | private final AccessibilityManager accessibilityManager;
26 | private boolean hasAction;
27 | public static final int LENGTH_INDEFINITE = -2;
28 | public static final int LENGTH_SHORT = -1;
29 | public static final int LENGTH_LONG = 0;
30 |
31 | @Nullable
32 | private BaseCallback callback;
33 |
34 | private Snackbar(ViewGroup parent, View content, com.google.android.material.snackbar.ContentViewCallback contentViewCallback) {
35 | super(parent, content, contentViewCallback);
36 | accessibilityManager = (AccessibilityManager) parent.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
37 | getView().setBackground(null);
38 | }
39 |
40 | public void show() {
41 | super.show();
42 | }
43 |
44 | public void dismiss() {
45 | super.dismiss();
46 | }
47 |
48 | public boolean isShown() {
49 | return super.isShown();
50 | }
51 |
52 | @NonNull
53 | public static Snackbar make(@NonNull View view, int layoutResourceId, int duration) {
54 | ViewGroup parent = findSuitableParent(view);
55 | if (parent == null) {
56 | throw new IllegalArgumentException("No suitable parent found from the given view. Please provide a valid view.");
57 | } else {
58 | LayoutInflater inflater = LayoutInflater.from(parent.getContext());
59 | SnackbarContentLayout content =
60 | (SnackbarContentLayout) inflater.inflate(layoutResourceId, parent, false);
61 | Snackbar snackbar = new Snackbar(parent, content, content);
62 | snackbar.setDuration(duration);
63 | return snackbar;
64 | }
65 | }
66 |
67 | @NonNull
68 | public Snackbar setAction(final View.OnClickListener listener) {
69 | SnackbarContentLayout contentLayout = (SnackbarContentLayout) view.getChildAt(0);
70 | View view = contentLayout.getActionView();
71 | if (view != null) {
72 | if (listener != null) {
73 | hasAction = true;
74 | view.setVisibility(View.VISIBLE);
75 | view.setOnClickListener(listener);
76 | } else {
77 | view.setVisibility(View.GONE);
78 | view.setOnClickListener(null);
79 | hasAction = false;
80 | }
81 | }
82 |
83 | return this;
84 | }
85 |
86 | @NonNull
87 | public Snackbar setAction(int viewId, final View.OnClickListener listener) {
88 | SnackbarContentLayout contentLayout = (SnackbarContentLayout) view.getChildAt(0);
89 | View view = contentLayout.findViewById(viewId);
90 | if (view != null) {
91 | if (listener != null) {
92 | view.setVisibility(View.VISIBLE);
93 | view.setOnClickListener(listener);
94 | } else {
95 | view.setVisibility(View.GONE);
96 | view.setOnClickListener(null);
97 | }
98 | }
99 |
100 | return this;
101 | }
102 |
103 | private static ViewGroup findSuitableParent(View view) {
104 | ViewGroup fallback = null;
105 |
106 | do {
107 | if (view instanceof CoordinatorLayout) {
108 | return (ViewGroup) view;
109 | }
110 |
111 | if (view instanceof FrameLayout) {
112 | fallback = (ViewGroup) view;
113 | }
114 |
115 | if (view != null) {
116 | ViewParent parent = view.getParent();
117 | view = parent instanceof View ? (View) parent : null;
118 | }
119 | } while (view != null);
120 |
121 | return fallback;
122 | }
123 |
124 | public static class Callback extends BaseCallback {
125 | public static final int DISMISS_EVENT_SWIPE = 0;
126 | public static final int DISMISS_EVENT_ACTION = 1;
127 | public static final int DISMISS_EVENT_TIMEOUT = 2;
128 | public static final int DISMISS_EVENT_MANUAL = 3;
129 | public static final int DISMISS_EVENT_CONSECUTIVE = 4;
130 |
131 | public Callback() {
132 | }
133 |
134 | public void onShown(Snackbar sb) {
135 | }
136 |
137 | public void onDismissed(Snackbar transientBottomBar, int event) {
138 | }
139 | }
140 |
141 | @Retention(RetentionPolicy.SOURCE)
142 | @RestrictTo({Scope.LIBRARY_GROUP})
143 | @IntRange(
144 | from = 1L
145 | )
146 | public @interface Duration {
147 | }
148 |
149 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/snackbar_trip_end_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
23 |
24 |
36 |
37 |
38 |
47 |
48 |
59 |
60 |
69 |
70 |
80 |
81 |
90 |
91 |
101 |
102 |
111 |
112 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/snackbar_order_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
24 |
25 |
37 |
38 |
39 |
47 |
48 |
59 |
60 |
67 |
68 |
69 |
70 |
71 |
72 |
80 |
81 |
96 |
97 |
110 |
111 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/components/rider/RiderMapFragment.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.components.rider;
2 |
3 | import android.os.Bundle;
4 | import android.text.TextUtils;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import androidx.annotation.NonNull;
11 | import androidx.annotation.Nullable;
12 |
13 | import com.google.android.gms.maps.SupportMapFragment;
14 | import com.google.android.gms.maps.model.BitmapDescriptorFactory;
15 | import com.google.android.gms.maps.model.LatLng;
16 | import com.google.android.gms.maps.model.Marker;
17 | import com.google.android.gms.maps.model.MarkerOptions;
18 | import com.hypertrack.ridesharing.R;
19 | import com.hypertrack.ridesharing.components.MapFragment;
20 | import com.hypertrack.ridesharing.models.Place;
21 | import com.hypertrack.ridesharing.models.User;
22 | import com.hypertrack.ridesharing.views.Snackbar;
23 |
24 |
25 | public class RiderMapFragment extends MapFragment implements RiderMapPresenter.RiderView {
26 | private static final String TAG = "RiderMapFragment";
27 |
28 | private Snackbar chooseDestSnackbar;
29 | private Snackbar bookRideSnackbar;
30 | private TextView pickupText;
31 | private TextView dropoffText;
32 | private TextView dropoffText2;
33 |
34 | public static SupportMapFragment newInstance() {
35 | SupportMapFragment fragment = new RiderMapFragment();
36 | return fragment;
37 | }
38 |
39 | @Override
40 | public View onCreateView(@NonNull LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
41 | presenter = new RiderMapPresenter(getActivity(), this);
42 | return super.onCreateView(layoutInflater, viewGroup, bundle);
43 | }
44 |
45 | @Override
46 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
47 | super.onViewCreated(view, savedInstanceState);
48 | ((TextView)stateSnackbar.getView().findViewById(R.id.text)).setText(R.string.finding_drivers);
49 | stateSnackbar.setAction(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View view) {
52 | showOrderCancelDialog();
53 | }
54 | });
55 |
56 | chooseDestSnackbar = Snackbar.make(view, R.layout.snackbar_choose_dest, Snackbar.LENGTH_INDEFINITE)
57 | .setAction(R.id.dropoff, new View.OnClickListener() {
58 | @Override
59 | public void onClick(View view) {
60 | presenter.chooseDropoff();
61 | }
62 | });
63 |
64 | bookRideSnackbar = Snackbar.make(view, R.layout.snackbar_book_ride, Snackbar.LENGTH_INDEFINITE)
65 | .setAction(R.id.pickup, new View.OnClickListener() {
66 | @Override
67 | public void onClick(View view) {
68 | presenter.choosePickup();
69 | }
70 | })
71 | .setAction(R.id.dropoff, new View.OnClickListener() {
72 | @Override
73 | public void onClick(View view) {
74 | presenter.chooseDropoff();
75 | }
76 | })
77 | .setAction(R.id.my_location, new View.OnClickListener() {
78 | @Override
79 | public void onClick(View view) {
80 | presenter.setMyLocationAsPickup();
81 | }
82 | })
83 | .setAction(new View.OnClickListener() {
84 | @Override
85 | public void onClick(View view) {
86 | presenter.orderTaxi();
87 | }
88 | });
89 | dropoffText = chooseDestSnackbar.getView().findViewById(R.id.dropoff);
90 | dropoffText2 = bookRideSnackbar.getView().findViewById(R.id.dropoff_text);
91 | pickupText = bookRideSnackbar.getView().findViewById(R.id.pickup_text);
92 | }
93 |
94 | @Override
95 | public void showChooseDest() {
96 | presenter.addSnackbar(chooseDestSnackbar);
97 | }
98 |
99 | @Override
100 | public void dismissChooseDest() {
101 | presenter.removeSnackbar(chooseDestSnackbar);
102 | }
103 |
104 | @Override
105 | public void showBookRide() {
106 | presenter.addSnackbar(bookRideSnackbar);
107 | }
108 |
109 | @Override
110 | public void dismissBookRide() {
111 | presenter.removeSnackbar(bookRideSnackbar);
112 | }
113 |
114 | @Override
115 | public Marker addMarker(User driver) {
116 | MarkerOptions options = new MarkerOptions()
117 | .anchor(0.5f, 0.5f)
118 | .icon(BitmapDescriptorFactory.fromResource(R.drawable.car_marker_dark))
119 | .rotation(driver.location.getBearing())
120 | .position(new LatLng(driver.location.getLatitude(), driver.location.getLongitude()));
121 | return mGoogleMap.addMarker(options);
122 | }
123 |
124 | @Override
125 | public Marker addMarker(Place place, int iconResId) {
126 | MarkerOptions options = new MarkerOptions()
127 | .icon(BitmapDescriptorFactory.fromResource(iconResId))
128 | .draggable(true)
129 | .anchor(0.5f, 0.5f)
130 | .position(new LatLng(place.latitude, place.longitude));
131 | return mGoogleMap.addMarker(options);
132 | }
133 |
134 | @Override
135 | public void updatePickup(Place place) {
136 | if (place == null) {
137 | pickupText.setText("");
138 | } else {
139 | pickupText.setText(TextUtils.isEmpty(place.preview) ? place.address : place.preview);
140 | }
141 | }
142 |
143 | @Override
144 | public void updateDropoff(Place place) {
145 | if (place == null) {
146 | dropoffText.setText("");
147 | dropoffText2.setText("");
148 | } else {
149 | dropoffText.setText(place.address);
150 | dropoffText2.setText(place.address);
151 | }
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/components/driver/DriverMapFragment.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.components.driver;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import androidx.annotation.NonNull;
10 | import androidx.annotation.Nullable;
11 | import androidx.recyclerview.widget.RecyclerView;
12 |
13 | import com.google.android.gms.maps.SupportMapFragment;
14 | import com.google.android.gms.maps.model.BitmapDescriptorFactory;
15 | import com.google.android.gms.maps.model.LatLng;
16 | import com.google.android.gms.maps.model.Marker;
17 | import com.google.android.gms.maps.model.MarkerOptions;
18 | import com.hypertrack.sdk.TrackingError;
19 | import com.hypertrack.ridesharing.R;
20 | import com.hypertrack.ridesharing.adapters.OrdersAdapter;
21 | import com.hypertrack.ridesharing.components.MapFragment;
22 | import com.hypertrack.ridesharing.models.Order;
23 | import com.hypertrack.ridesharing.models.User;
24 | import com.hypertrack.ridesharing.views.Dialog;
25 | import com.hypertrack.ridesharing.views.Snackbar;
26 |
27 | import java.util.Collection;
28 |
29 | public class DriverMapFragment extends MapFragment implements DriverMapPresenter.DriverView {
30 | private static final String TAG = "DriverMapFragment";
31 |
32 | private Dialog acceptRideDialog;
33 | private Snackbar infoDriverSnackbar;
34 |
35 | public static SupportMapFragment newInstance() {
36 | SupportMapFragment fragment = new DriverMapFragment();
37 | return fragment;
38 | }
39 |
40 | @Override
41 | public View onCreateView(@NonNull LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
42 | presenter = new DriverMapPresenter(getActivity(), this);
43 | return super.onCreateView(layoutInflater, viewGroup, bundle);
44 | }
45 |
46 | @SuppressWarnings("ConstantConditions")
47 | @Override
48 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
49 | super.onViewCreated(view, savedInstanceState);
50 |
51 | infoOrderSnackbar.setAction(R.id.get_directions, new View.OnClickListener() {
52 | @Override
53 | public void onClick(View view) {
54 | presenter.getDirections();
55 | }
56 | });
57 | ordersAdapter.setOnItemClickListener(new OrdersAdapter.OnItemClickListener() {
58 | @Override
59 | public void onItemClick(RecyclerView.Adapter> adapter, View view, int position) {
60 | recyclerView.setVisibility(View.INVISIBLE);
61 | presenter.selectOrder(ordersAdapter.getOrder(position).id);
62 | }
63 | });
64 | acceptRideDialog = new Dialog(getActivity(), R.layout.dialog_accept_ride)
65 | .setAction(new View.OnClickListener() {
66 | @Override
67 | public void onClick(View view) {
68 | presenter.acceptRide();
69 | acceptRideDialog.dismiss();
70 | ordersAdapter.clear();
71 | ordersAdapter.notifyDataSetChanged();
72 | recyclerView.setVisibility(View.VISIBLE);
73 | }
74 | })
75 | .setAction(R.id.cancel, new View.OnClickListener() {
76 | @Override
77 | public void onClick(View view) {
78 | acceptRideDialog.dismiss();
79 | recyclerView.setVisibility(View.VISIBLE);
80 | }
81 | });
82 | infoDriverSnackbar = Snackbar.make(view, R.layout.snackbar_driver_info, Snackbar.LENGTH_INDEFINITE);
83 | }
84 |
85 | @Override
86 | public Marker addMarker(Order order) {
87 | MarkerOptions options = new MarkerOptions()
88 | .icon(BitmapDescriptorFactory.fromResource(R.drawable.iconmap_marker_filled))
89 | .position(new LatLng(order.pickup.latitude, order.pickup.longitude));
90 | return mGoogleMap.addMarker(options);
91 | }
92 |
93 | @Override
94 | public void updateNotifications(Collection orders) {
95 | ordersAdapter.addAll(orders);
96 | ordersAdapter.notifyDataSetChanged();
97 | }
98 |
99 | @Override
100 | public void showAcceptRide(Order order) {
101 | if (order != null) {
102 | recyclerView.setVisibility(View.INVISIBLE);
103 | TextView pickupAddress = acceptRideDialog.findViewById(R.id.pickup_address);
104 | TextView riderName = acceptRideDialog.findViewById(R.id.rider_name);
105 | pickupAddress.setText(order.pickup.address);
106 | riderName.setText(order.rider.name);
107 | acceptRideDialog.show();
108 | }
109 | }
110 |
111 | @Override
112 | public void showDriverInfo(User user) {
113 | if (user != null) {
114 | TextView name = infoDriverSnackbar.getView().findViewById(R.id.name);
115 | name.setText(user.name);
116 | presenter.addSnackbar(infoDriverSnackbar);
117 | }
118 | }
119 |
120 | @Override
121 | public void dismissDriverInfo() {
122 | presenter.removeSnackbar(infoDriverSnackbar);
123 | }
124 |
125 | @Override
126 | public void showInfoUserStartTripButton() {
127 | infoOrderSnackbar.setAction(R.id.start_trip, new View.OnClickListener() {
128 | @Override
129 | public void onClick(View view) {
130 | presenter.startRide();
131 | }
132 | });
133 | }
134 |
135 | @Override
136 | public void hideInfoUserStartTripButton() {
137 | infoOrderSnackbar.setAction(R.id.start_trip, null);
138 | }
139 |
140 | @Override
141 | public void showInfoUserEndTripButton() {
142 | infoOrderSnackbar.setAction(R.id.end_trip, new View.OnClickListener() {
143 | @Override
144 | public void onClick(View view) {
145 | presenter.endRide();
146 | }
147 | });
148 | }
149 |
150 | @Override
151 | public void hideInfoUserEndTripButton() {
152 | infoOrderSnackbar.setAction(R.id.end_trip, null);
153 |
154 | }
155 |
156 | @Override
157 | public void onError(TrackingError trackingError) {
158 |
159 | }
160 |
161 | @Override
162 | public void onTrackingStart() {
163 |
164 | }
165 |
166 | @Override
167 | public void onTrackingStop() {
168 |
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
23 |
32 |
33 |
37 |
38 |
45 |
46 |
49 |
50 |
53 |
54 |
63 |
64 |
68 |
69 |
70 |
71 |
72 |
80 |
81 |
84 |
85 |
88 |
89 |
94 |
95 |
105 |
106 |
116 |
117 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/app/src/main/java/com/hypertrack/ridesharing/adapters/MapInfoWindowAdapter.java:
--------------------------------------------------------------------------------
1 | package com.hypertrack.ridesharing.adapters;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.text.TextUtils;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.widget.TextView;
9 |
10 | import com.google.android.gms.maps.GoogleMap;
11 | import com.google.android.gms.maps.model.LatLng;
12 | import com.google.android.gms.maps.model.Marker;
13 | import com.hypertrack.maps.google.widget.GoogleMapAdapter;
14 | import com.hypertrack.sdk.views.maps.HyperTrackMap;
15 | import com.hypertrack.sdk.views.maps.models.MapLocation;
16 | import com.hypertrack.sdk.views.maps.models.MapObject;
17 | import com.hypertrack.sdk.views.maps.models.MapTrip;
18 | import com.hypertrack.sdk.views.dao.DeviceStatus;
19 | import com.hypertrack.sdk.views.dao.Location;
20 | import com.hypertrack.sdk.views.dao.Trip;
21 | import com.hypertrack.ridesharing.R;
22 | import com.hypertrack.ridesharing.utils.MapUtils;
23 | import com.hypertrack.ridesharing.utils.TextFormatUtils;
24 |
25 | import java.util.concurrent.TimeUnit;
26 |
27 | import io.reactivex.Single;
28 | import io.reactivex.functions.Consumer;
29 | import io.reactivex.functions.Function;
30 |
31 | public class MapInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
32 |
33 | private final LayoutInflater layoutInflater;
34 | private final GoogleMapAdapter mapAdapter;
35 |
36 | public MapInfoWindowAdapter(Context context, GoogleMapAdapter mapAdapter) {
37 | layoutInflater = LayoutInflater.from(context);
38 | this.mapAdapter = mapAdapter;
39 | }
40 |
41 | @SuppressLint("CheckResult")
42 | @Override
43 | public View getInfoWindow(final Marker marker) {
44 | MapObject mapObject = mapAdapter.findMapObjectByMarker(marker);
45 | if (mapObject != null) {
46 | Single single;
47 | ViewHolder viewHolder = (ViewHolder) marker.getTag();
48 | if (mapObject.getType() == HyperTrackMap.TRIP_MAP_OBJECT_TYPE) {
49 |
50 | marker.setInfoWindowAnchor(4.2f, 1.6f);
51 | GoogleMapAdapter.GMapTrip mapTrip = (GoogleMapAdapter.GMapTrip) mapObject;
52 | if (mapTrip.getDestinationMarker().getId().equals(marker.getId())) {
53 | if (viewHolder == null) {
54 | View view = layoutInflater.inflate(R.layout.info_window_to, null);
55 | viewHolder = new ViewHolder(view);
56 | marker.setTag(viewHolder);
57 | }
58 | single = viewHolder.updateTripDestination(mapTrip);
59 | } else {
60 | if (!mapTrip.trip.getStatus().equals("completed")) {
61 | return null;
62 | }
63 | if (viewHolder == null) {
64 | View view = layoutInflater.inflate(R.layout.info_window_from, null);
65 | viewHolder = new ViewHolder(view);
66 | marker.setTag(viewHolder);
67 | }
68 | single = viewHolder.updateTripOrigin(mapTrip);
69 | }
70 | } else {
71 |
72 | marker.setInfoWindowAnchor(3.4f, 1.3f);
73 | MapLocation mapLocation = (MapLocation) mapObject;
74 | if (viewHolder == null) {
75 | View view = layoutInflater.inflate(R.layout.info_window_from, null);
76 | viewHolder = new ViewHolder(view);
77 | marker.setTag(viewHolder);
78 | }
79 | single = viewHolder.updateLocation(mapLocation);
80 | }
81 | single.subscribe(new Consumer() {
82 | @Override
83 | public void accept(String s) throws Exception {
84 | if (!TextUtils.isEmpty(s)) {
85 | marker.showInfoWindow();
86 | }
87 | }
88 | });
89 | return viewHolder.view;
90 | }
91 | return null;
92 | }
93 |
94 | @Override
95 | public View getInfoContents(Marker marker) {
96 | return null;
97 | }
98 |
99 | @SuppressLint("CheckResult")
100 | static class ViewHolder {
101 | View view;
102 | TextView title;
103 | TextView text;
104 |
105 | ViewHolder(View view) {
106 | this.view = view;
107 | title = view.findViewById(R.id.title);
108 | text = view.findViewById(R.id.text);
109 | }
110 |
111 | Single updateLocation(MapLocation mapLocation) {
112 | String status = view.getContext().getString(R.string.my_location);
113 | if (mapLocation.deviceStatus != -1) {
114 | if (DeviceStatus.STOP == mapLocation.deviceStatus) {
115 | status = view.getContext().getString(R.string.stopped);
116 | } else {
117 | status = view.getContext().getString(R.string.driver);
118 | }
119 | }
120 | title.setText(status);
121 | LatLng latLng = new LatLng(mapLocation.location.getLatitude(), mapLocation.location.getLongitude());
122 | return MapUtils.getAddress(view.getContext(), latLng).map(new Function() {
123 | @Override
124 | public String apply(String s) throws Exception {
125 | if (!s.equals(text.getText().toString())) {
126 | text.setText(s);
127 | return s;
128 | }
129 | return "";
130 | }
131 | });
132 | }
133 |
134 | Single updateTripDestination(MapTrip mapTrip) {
135 | Trip.Destination destination = mapTrip.trip.getDestination();
136 | if (mapTrip.trip.getStatus().equals("completed")) {
137 | if (destination != null) {
138 | return MapUtils.getAddress(view.getContext(),
139 | new LatLng(destination.getLatitude(), destination.getLongitude()))
140 | .map(new Function() {
141 | @Override
142 | public String apply(String s) throws Exception {
143 | if (!s.equals(title.getText().toString())) {
144 | title.setText(s);
145 | return s;
146 | }
147 | return "";
148 | }
149 | });
150 | }
151 | if (mapTrip.trip.getEndDate() != null) {
152 | String date = TextFormatUtils.getRelativeDateTimeString(view.getContext(), mapTrip.trip.getEndDate().getTime());
153 | String text = view.getContext().getString(R.string.dropoff) + " | " + date;
154 | this.text.setText(text);
155 | }
156 | } else {
157 | if (mapTrip.trip.getEstimate() != null
158 | && mapTrip.trip.getEstimate().getRoute() != null
159 | && mapTrip.trip.getEstimate().getRoute().getDuration() != null) {
160 | long estimate = TimeUnit.SECONDS.toMinutes(
161 | mapTrip.trip.getEstimate().getRoute().getDuration()
162 | );
163 | title.setText(String.format(view.getContext().getString(R.string.mins), estimate));
164 | }
165 | if (destination != null) {
166 | LatLng latLng = new LatLng(destination.getLatitude(), destination.getLongitude());
167 | return MapUtils.getAddress(view.getContext(), latLng).map(new Function() {
168 | @Override
169 | public String apply(String s) throws Exception {
170 | if (!s.equals(text.getText().toString())) {
171 | text.setText(s);
172 | return s;
173 | }
174 | return "";
175 | }
176 | });
177 | }
178 | }
179 | return null;
180 | }
181 |
182 | Single updateTripOrigin(MapTrip mapTrip) {
183 | if (mapTrip.trip.getStatus().equals("completed")) {
184 | if (mapTrip.trip.getSummary() != null && !mapTrip.trip.getSummary().getLocations().isEmpty()) {
185 | Location location = mapTrip.trip.getSummary().getLocations().get(0);
186 | return MapUtils.getAddress(view.getContext(),
187 | new LatLng(location.getLatitude(), location.getLongitude()))
188 | .map(new Function() {
189 | @Override
190 | public String apply(String s) throws Exception {
191 | if (!s.equals(title.getText().toString())) {
192 | title.setText(s);
193 | return s;
194 | }
195 | return "";
196 | }
197 | });
198 | }
199 | if (mapTrip.trip.getStartDate() != null) {
200 | String date = TextFormatUtils.getRelativeDateTimeString(view.getContext(), mapTrip.trip.getStartDate().getTime());
201 | String text = view.getContext().getString(R.string.dropoff) + " | " + date;
202 | this.text.setText(text);
203 | }
204 | }
205 | return null;
206 | }
207 | }
208 | }
209 |
--------------------------------------------------------------------------------