Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme file update #87

Merged
merged 9 commits into from
Oct 12, 2023
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,29 @@ Below are the requirements for development, running and testing.
2. Java 11 or above.

#### Pre-requisites

1. Sign in to [Amazon AWS account](https://aws.amazon.com/)
2. Run the [CF template](https://us-west-2.console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks/create?stackName=amazon-location-resources-setup&templateURL=https://amazon-location-resources-setup.s3.amazonaws.com/location-services.yaml) using your own AWS account and get `IdentityPoolId` and `region` from stack output
2. Run the [CF template](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create?stackName=amazon-location-default-unauth-resources&templateURL=https://amazon-location-demo-resources.s3.us-west-2.amazonaws.com/default-unauth-resources-template.yaml) or use the template from `/extra/default-unauth-resources-template.yaml` to create a cloudformation stack on AWS in `us-east-1` region and get `IdentityPoolId`, `PinPointAppId`, `WebSocketUrl` from stack output's tab.
- `IdentityPoolId` value will be added to `custom.properties` file against `DEFAULT_IDENTITY_POOL_ID`.
- `PinPointAppId` value will be added to `custom.properties` file against `ANALYTICS_APP_ID`.
- `WebSocketUrl` value will be added to `custom.properties` file against `SIMULATION_WEB_SOCKET_URL`.
- Take region from IdentityPoolId (Character before ':') that value will be added to `custom.properties` file against `DEFAULT_REGION`.
3. Run the [CF template](https://ap-southeast-1.console.aws.amazon.com/cloudformation/home?region=ap-southeast-1#/stacks/create?stackName=amazon-location-default-unauth-resources&templateURL=https://amazon-location-demo-resources.s3.us-west-2.amazonaws.com/default-unauth-resources-template.yaml) or use the template from `/extra/default-unauth-resources-template.yaml` to create a cloudformation stack on AWS in `ap-southeast-1` region and get `IdentityPoolId`, `WebSocketUrl` from stack output's tab.
- `IdentityPoolId` value will be added to `custom.properties` file against `DEFAULT_IDENTITY_POOL_ID_AP`.
- `WebSocketUrl` value will be added to `custom.properties` file against `SIMULATION_WEB_SOCKET_URL_AP`.
4. Run the [CF template](https://eu-west-1.console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stacks/create?stackName=amazon-location-default-unauth-resources&templateURL=https://amazon-location-demo-resources.s3.us-west-2.amazonaws.com/default-unauth-resources-template.yaml) or use the template from `/extra/default-unauth-resources-template.yaml` to create a cloudformation stack on AWS in `eu-west-1` region and get `IdentityPoolId`, `WebSocketUrl` from stack output's tab.
- `IdentityPoolId` value will be added to `custom.properties` file against `DEFAULT_IDENTITY_POOL_ID_EU`.
- `WebSocketUrl` value will be added to `custom.properties` file against `SIMULATION_WEB_SOCKET_URL_EU`.
5. After adding all above details in `custom.properties` file in Android studio then open `Build -> Clean project` after this run project.
6. Run the [CF template](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create?stackName=amazon-location-resources-setup&templateURL=https://amazon-location-resources-setup.s3.amazonaws.com/dev/main-cf-template.yaml) or use the template from `/extra/main-cf-template.yaml` using your own AWS account and get below data.
- `IdentityPoolId` value will be added to `custom.properties` file against `IDENTITY_POOL_ID`.
- `UserDomain` value will be added to `custom.properties` file against `USER_DOMAIN`.
- `UserPoolClientId` value will be added to `custom.properties` file against `USER_POOL_CLIENT_ID`.
- `UserPoolId` value will be added to `custom.properties` file against `USER_POOL_ID`.
- `WebSocketUrl` value will be added to `custom.properties` file against `WEB_SOCKET_URL`.

Follow this [Document](https://location.aws.com/demo/help) for detailed info to create & configure a new Cloud formation.

The required values can be found from the `Outputs` tab on your stack page created in step 2 above.
The required values can be found from the `Outputs` tab on your stack page created in step 2, 3, 4 and 5 above.
## Configure

Create *`custom.properties`* file inside the project root folder and add the details as below.
Expand Down Expand Up @@ -48,6 +64,10 @@ DEFAULT_IDENTITY_POOL_ID=xx-xxxx-x:xxxx-xxxx-xxxx-xxxx
DEFAULT_REGION=xx-xxxx-x
DEFAULT_IDENTITY_POOL_ID_EU=xx-xxxx-x:xxxx-xxxx-xxxx-xxxx
DEFAULT_IDENTITY_POOL_ID_AP=xx-xxxx-x:xxxx-xxxx-xxxx-xxxx
SIMULATION_WEB_SOCKET_URL=xxxxxxxxxxxx-xxx.xxx.xx-xxxx-x.xxxxxxxxxx.com
SIMULATION_WEB_SOCKET_URL_EU=xxxxxxxxxxxx-xxx.xxx.xx-xxxx-x.xxxxxxxxxx.com
SIMULATION_WEB_SOCKET_URL_AP=xxxxxxxxxxxx-xxx.xxx.xx-xxxx-x.xxxxxxxxxx.com
ANALYTICS_APP_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

#### optional values to add after above if you want to run tests locally. (This can be a different stack only for testing)
Expand Down Expand Up @@ -122,6 +142,7 @@ Note:
./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.main.SettingSignInTest
./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.main.SettingAWSDisconnectingTest
./gradlew app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aws.amazonlocation.ui.main.ConnectToAWSTest

## Resources
> Maps (Name - Style)
- location.aws.com.demo.maps.Esri.DarkGrayCanvas - VectorEsriDarkGrayCanvas
Expand All @@ -137,6 +158,10 @@ Note:
- location.aws.com.demo.maps.HERE.Imagery - RasterHereExploreSatellite
- location.aws.com.demo.maps.Grab.StandardLight - VectorGrabStandardLight
- location.aws.com.demo.maps.Grab.StandardDark - VectorGrabStandardDark
- location.aws.com.demo.maps.OpenData.StandardLight - VectorOpenDataStandardLight
- location.aws.com.demo.maps.OpenData.StandardDark - VectorOpenDataStandardDark
- location.aws.com.demo.maps.OpenData.VisualizationLight - VectorOpenDataVisualizationLight
- location.aws.com.demo.maps.OpenData.VisualizationDark - VectorOpenDataVisualizationDark

> Place indexes (Name)
- location.aws.com.demo.places.Esri.PlaceIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.aws.amazonlocation.ui.main.web_view.WebViewActivity
import com.aws.amazonlocation.utils.KEY_MAP_NAME
import com.aws.amazonlocation.utils.KEY_URL
import com.aws.amazonlocation.utils.MAP_STYLE_ATTRIBUTION
import com.aws.amazonlocation.utils.attributionPattern

class AttributionFragment : BaseFragment() {

Expand Down Expand Up @@ -46,10 +47,12 @@ class AttributionFragment : BaseFragment() {

private fun init() {
mBinding.apply {
tvAttribution.text = mPreferenceManager.getValue(MAP_STYLE_ATTRIBUTION, getString(R.string.esri))
tvAttribution.text =
mPreferenceManager.getValue(MAP_STYLE_ATTRIBUTION, getString(R.string.esri))
?.replace(Regex(attributionPattern), "") ?: ""

}
}

private fun initClick() {
mBinding.apply {
btnLearnMoreSa.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,7 @@ class ExploreFragment :
R.color.btn_go_disable
)
)
showCalculateRouteAPIError(TravelMode.Walking.value)
mViewModel.mWalkingData = null
isCalculateWalkApiError = true
mBinding.bottomSheetDirectionSearch.clWalkLoader.hide()
Expand All @@ -1504,6 +1505,7 @@ class ExploreFragment :
R.color.btn_go_disable
)
)
showCalculateRouteAPIError(TravelMode.Car.value)
isCalculateDriveApiError = true
mViewModel.mCarData = null
mBinding.bottomSheetDirectionSearch.clDriveLoader.hide()
Expand All @@ -1516,6 +1518,7 @@ class ExploreFragment :
R.color.btn_go_disable
)
)
showCalculateRouteAPIError(TravelMode.Truck.value)
mViewModel.mTruckData = null
isCalculateTruckApiError = true
mBinding.bottomSheetDirectionSearch.clTruckLoader.hide()
Expand All @@ -1528,6 +1531,7 @@ class ExploreFragment :
R.color.btn_go_disable
)
)
showCalculateRouteAPIError(TRAVEL_MODE_BICYCLE)
mViewModel.mBicycleData = null
isCalculateBicycleApiError = true
mBinding.bottomSheetDirectionSearch.clBicycleLoader.hide()
Expand All @@ -1540,6 +1544,7 @@ class ExploreFragment :
R.color.btn_go_disable
)
)
showCalculateRouteAPIError(TRAVEL_MODE_MOTORCYCLE)
mViewModel.mMotorcycleData = null
isCalculateMotorcycleApiError = true
mBinding.bottomSheetDirectionSearch.clMotorcycleLoader.hide()
Expand Down Expand Up @@ -1828,6 +1833,12 @@ class ExploreFragment :
}
}

private fun showCalculateRouteAPIError(value: String) {
if (mTravelMode == value) {
showError(getString(R.string.no_route_found))
}
}

private fun checkAllApiCallFailed() {
mBinding.apply {
bottomSheetDirectionSearch.apply {
Expand Down Expand Up @@ -2317,27 +2328,22 @@ class ExploreFragment :
}

bottomSheetDirectionSearch.apply {
if (checkInternetConnection()) {
clDrive.setOnClickListener {
mTravelMode = TravelMode.Car.value
mViewModel.mCarData?.let {
tvDriveSelected.show()
showViews(cardRoutingOption)
hideViews(tvTruckSelected, tvWalkSelected, tvBicycleSelected, tvMotorcycleSelected)
adjustMapBound()
drawPolyLineOnMapCardClick(
it.legs,
isLineUpdate = false,
isWalk = false,
isLocationIcon = false
)
clDrive.setOnClickListener {
if (checkInternetConnection()) {
if (mViewModel.mCarData == null) {
showError(getString(R.string.no_route_found))
return@setOnClickListener
}
recordTravelModeChange()
setCarClickData()
}
}

clWalk.setOnClickListener {
if (checkInternetConnection()) {
if (mViewModel.mWalkingData == null) {
showError(getString(R.string.no_route_found))
return@setOnClickListener
}
mTravelMode = TravelMode.Walking.value
mViewModel.mWalkingData?.let {
tvWalkSelected.show()
Expand All @@ -2361,6 +2367,10 @@ class ExploreFragment :

clTruck.setOnClickListener {
if (checkInternetConnection()) {
if (mViewModel.mTruckData == null) {
showError(getString(R.string.no_route_found))
return@setOnClickListener
}
mTravelMode = TravelMode.Truck.value
mViewModel.mTruckData?.let {
tvTruckSelected.show()
Expand All @@ -2380,6 +2390,10 @@ class ExploreFragment :

clBicycle.setOnClickListener {
if (checkInternetConnection()) {
if (mViewModel.mBicycleData == null) {
showError(getString(R.string.no_route_found))
return@setOnClickListener
}
mTravelMode = TRAVEL_MODE_BICYCLE
mViewModel.mBicycleData?.let {
tvBicycleSelected.show()
Expand All @@ -2403,6 +2417,10 @@ class ExploreFragment :

clMotorcycle.setOnClickListener {
if (checkInternetConnection()) {
if (mViewModel.mMotorcycleData == null) {
showError(getString(R.string.no_route_found))
return@setOnClickListener
}
mTravelMode = TRAVEL_MODE_MOTORCYCLE
mViewModel.mMotorcycleData?.let {
tvMotorcycleSelected.show()
Expand Down Expand Up @@ -3158,6 +3176,23 @@ class ExploreFragment :
}
}

private fun BottomSheetDirectionSearchBinding.setCarClickData() {
mTravelMode = TravelMode.Car.value
mViewModel.mCarData?.let {
tvDriveSelected.show()
showViews(cardRoutingOption)
hideViews(tvTruckSelected, tvWalkSelected, tvBicycleSelected, tvMotorcycleSelected)
adjustMapBound()
drawPolyLineOnMapCardClick(
it.legs,
isLineUpdate = false,
isWalk = false,
isLocationIcon = false
)
}
recordTravelModeChange()
}

private fun recordTravelModeChange() {
if (mBottomSheetHelper.isDirectionSearchSheetVisible()) {
val isMetric = isMetric(mPreferenceManager.getValue(KEY_UNIT_SYSTEM, ""))
Expand Down Expand Up @@ -3367,6 +3402,7 @@ class ExploreFragment :
mBinding.apply {
bottomSheetAttribution.apply {
tvAttribution.text = mPreferenceManager.getValue(MAP_STYLE_ATTRIBUTION, getString(R.string.esri))
?.replace(Regex(attributionPattern), "") ?: ""
}
}
}
Expand Down Expand Up @@ -3736,6 +3772,8 @@ class ExploreFragment :
)
clTruck.invisible()
clWalk.invisible()
clBicycle.hide()
clMotorcycle.hide()
}
layoutCardError.groupCardErrorNoSearchFound.hide()
layoutCardError.root.hide()
Expand Down Expand Up @@ -4069,7 +4107,9 @@ class ExploreFragment :
mMapHelper.addLiveLocationMarker(false)
mBinding.tvDistance.text = ""
mBinding.tvNavigationName.text = ""
mBinding.bottomSheetDirectionSearch.clDrive.performClick()
mBinding.bottomSheetDirectionSearch.apply {
setCarClickData()
}
mRouteFinish = true
mNavigationList.clear()
mMapHelper.removeLocationListener()
Expand Down Expand Up @@ -4330,8 +4370,6 @@ class ExploreFragment :

private fun BottomSheetDirectionSearchBinding.routeOptionClose() {
mIsRouteOptionsOpened = false
mIsAvoidTolls = mPreferenceManager.getValue(KEY_AVOID_TOLLS, false)
mIsAvoidFerries = mPreferenceManager.getValue(KEY_AVOID_FERRIES, false)
ivDown.show()
cardRoutingOption.setCardBackgroundColor(
ContextCompat.getColor(
Expand Down Expand Up @@ -4878,7 +4916,10 @@ class ExploreFragment :

private fun BottomSheetDirectionSearchBinding.cardRouteOptionShow() {
hideViews(rvSearchPlacesDirection, rvSearchPlacesSuggestionDirection, clMyLocation.root)
showViews(cardRoutingOption, cardMapOption)
if (mTravelMode == TravelMode.Car.value || mTravelMode == TravelMode.Truck.value) {
cardRoutingOption.show()
}
showViews(cardMapOption)
}

private fun BottomSheetDirectionSearchBinding.cardRouteOptionHide() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ val regionDisplayName = arrayListOf("Automatic", "Europe (Ireland) eu-west-1", "
* eg 2> "49.281174, -123.116823" > Check LAT_LNG_REG_EXP > return true
*/
const val LAT_LNG_REG_EXP = "([+-]?\\d+\\.?\\d+)\\s*,\\s*([+-]?\\d+\\.?\\d+)"
const val attributionPattern = "<a[^>]*>|</a>"

const val GEOFENCE_NAME_REG_EXP = "^[-._\\p{L}\\p{N}]+\$"
const val userPoolIdPattern = "[\\w-]+_[0-9a-zA-Z]+"
Expand Down
Loading
Loading