Skip to content

Commit

Permalink
Merge branch 'main' into V2_bug_fixes_main_forked
Browse files Browse the repository at this point in the history
  • Loading branch information
shah272728 committed Oct 20, 2023
2 parents 21eea4f + b2d774a commit 30f2c76
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 63 deletions.
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@

# Amazon Location Services

Android application for using Location Services of Amazon.
This repository contains code for an Android application that demonstrates how to use [Amazon Location Services](https://aws.amazon.com/location/). The app showcases features like [displaying maps](https://aws.amazon.com/location/features/#Maps), searching for [points of interest](https://aws.amazon.com/location/features/#Places), calculating [routes](https://aws.amazon.com/location/features/#Routes), [geocoding](https://aws.amazon.com/location/features/#Places), [device tracking](https://aws.amazon.com/location/features/#Trackers), and creating [geofences](https://aws.amazon.com/location/features/#Geofences).

To use this code, you'll need an [AWS account](https://aws.amazon.com/) and resources to be deployed within your account. This is automated using [AWS CloudFormation](https://aws.amazon.com/cloudformation/), and this readme explains the full setup process.

Once configured, you can build and run the app locally or execute automated tests. The project includes unit and end-to-end UI tests.

The app supports multiple map styles and providers like [Esri](https://docs.aws.amazon.com/location/latest/developerguide/esri.html), [HERE Technologies](https://docs.aws.amazon.com/location/latest/developerguide/HERE.html), [GrabMaps](https://docs.aws.amazon.com/location/latest/developerguide/grab.html), and [Open Data](https://docs.aws.amazon.com/location/latest/developerguide/open-data.html).

Overall, this repo will help you get started with location-based features on Android using Amazon Location Services.

Please refer to the [AWS Geospatial repository](https://github.com/aws-geospatial/) for other demo apps, including [iOS](https://github.com/aws-geospatial/amazon-location-features-demo-ios), [React](https://github.com/aws-geospatial/amazon-location-samples-react), and [web](https://github.com/aws-geospatial/amazon-location-features-demo-web), as well as additional resources.

Features like map, searching points of interest, calculating routes, geocode, tracking devices, and triggering geofences using Amazon Location Service.
## Requirements

Below are the requirements for development, running and testing.

#### Development Tools

1. Android Studio
1. [Android Studio](https://developer.android.com/studio)
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-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.
1. [Create your AWS Account](https://repost.aws/knowledge-center/create-and-activate-aws-account) if needed, or sign in to your existing [AWS account](https://aws.amazon.com/)
2. Run the [AWS CloudFormation 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 the `us-east-1` region and get `IdentityPoolId`, `PinPointAppId`, `WebSocketUrl` from the stack's "outputs" 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.
3. Run the [AWS CloudFormation 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.
4. Run the [AWS CloudFormation 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.
6. Run the [AWS CloudFormation 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.
Follow this [Document](https://location.aws.com/demo/help) for detailed info to create & configure a new AWS CloudFormation template.

The required values can be found from the `Outputs` tab on your stack page created in step 2, 3, 4 and 5 above.
## Configure
Expand Down Expand Up @@ -70,7 +79,7 @@ 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)
#### Optional values to add after above if you want to run tests locally. (This can be a different stack only for testing)

```
IDENTITY_POOL_ID=xx-xxxx-x:xxxx-xxxx-xxxx-xxxx
Expand All @@ -84,27 +93,26 @@ USER_LOGIN_PASSWORD=<aws password>

## Run Locally

To run the application locally either an emulator needs to be running or a physical device connected with usb debugging enable.
To run the application locally, use either an [Android Emulator](https://developer.android.com/studio/run/emulator) or a physical device connected with [USB debugging enabled](https://developer.android.com/studio/debug/dev-options#Enable-debugging).

1. Clone the project.
2. Open the project in android studio.
2. Open the project in Android Studio.
3. Select 'Run Configuration' as 'app' if not already selected.
4. Click on run button.


## Running Tests

To run tests locally remember to add the values in `secrets.properties` mentioned above in configure section.

### Unit Tests

UnitTests are configured to run with jacoco and can be executed using various commands having different uses as below:
UnitTests are configured to run with [JaCoCo](https://www.jacoco.org/jacoco/) and can be executed using various commands having different uses as below:

| Command | Use |
|-------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
| ./gradlew testDebugUnitTest | Runs unit tests without jacoco coverage report. |
| ./gradlew testDebugUnitTestCoverage | Runs unit tests with jacoco coverage report. |
| ./gradlew testDebugUnitTestCoverageVerification | Runs unit tests with jacoco code coverage report and verifies if minimum code coverage constraint is satisfied. |
| ./gradlew testDebugUnitTest | Runs unit tests without JaCoCo coverage report. |
| ./gradlew testDebugUnitTestCoverage | Runs unit tests with JaCoCo coverage report. |
| ./gradlew testDebugUnitTestCoverageVerification | Runs unit tests with JaCoCo code coverage report and verifies if minimum code coverage constraint is satisfied. |

The code coverage report can be found at the following path:

Expand Down
93 changes: 47 additions & 46 deletions scripts/translation-script/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 30f2c76

Please sign in to comment.