From 030939fc215cc28755d8e335e355dafe8a76637c Mon Sep 17 00:00:00 2001 From: David Green Date: Thu, 19 Oct 2023 11:34:25 +0900 Subject: [PATCH 1/4] Update README.md --- README.md | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9afa36f3..8af30e8d 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -84,27 +93,26 @@ USER_LOGIN_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: From ce54ccf8fb2350216209588ce38b18fa8b923a25 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:33:37 +0000 Subject: [PATCH 2/4] Bump @babel/traverse in /scripts/translation-script Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.22.8 to 7.23.2. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse) --- updated-dependencies: - dependency-name: "@babel/traverse" dependency-type: indirect ... Signed-off-by: dependabot[bot] --- scripts/translation-script/package-lock.json | 93 ++++++++++---------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/scripts/translation-script/package-lock.json b/scripts/translation-script/package-lock.json index fb8c3d9a..dd16a1f7 100644 --- a/scripts/translation-script/package-lock.json +++ b/scripts/translation-script/package-lock.json @@ -7556,12 +7556,13 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" }, "node_modules/@babel/code-frame": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.5.tgz", - "integrity": "sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==", + "version": "7.22.13", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.22.13.tgz", + "integrity": "sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==", "peer": true, "dependencies": { - "@babel/highlight": "^7.22.5" + "@babel/highlight": "^7.22.13", + "chalk": "^2.4.2" }, "engines": { "node": ">=6.9.0" @@ -7607,12 +7608,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.9.tgz", - "integrity": "sha512-KtLMbmicyuK2Ak/FTCJVbDnkN1SlT8/kceFTiuDiiRUUSMnHMidxSCdG4ndkTOHHpoomWe/4xkvHkEOncwjYIw==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "peer": true, "dependencies": { - "@babel/types": "^7.22.5", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -7721,22 +7722,22 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "peer": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", - "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "peer": true, "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -7898,9 +7899,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", - "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "peer": true, "engines": { "node": ">=6.9.0" @@ -7944,13 +7945,13 @@ } }, "node_modules/@babel/highlight": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.5.tgz", - "integrity": "sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", + "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", "peer": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.22.5", - "chalk": "^2.0.0", + "@babel/helper-validator-identifier": "^7.22.20", + "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, "engines": { @@ -7958,9 +7959,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.7", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.7.tgz", - "integrity": "sha512-7NF8pOkHP5o2vpmGgNGcfAeCvOYhGLyA3Z4eBQkT1RJlWu47n63bCs93QfJ2hIAFCil7L5P2IWhs1oToVgrL0Q==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "peer": true, "bin": { "parser": "bin/babel-parser.js" @@ -9532,33 +9533,33 @@ } }, "node_modules/@babel/template": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", - "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "peer": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.22.8", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.8.tgz", - "integrity": "sha512-y6LPR+wpM2I3qJrsheCTwhIinzkETbplIgPBbwvqPKc+uljeA5gP+3nP8irdYt1mjQaDnlIcG+dw8OjAco4GXw==", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", "peer": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/generator": "^7.22.7", - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-function-name": "^7.22.5", + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/parser": "^7.22.7", - "@babel/types": "^7.22.5", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -9567,13 +9568,13 @@ } }, "node_modules/@babel/types": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.5.tgz", - "integrity": "sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "peer": true, "dependencies": { "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { From 3737987977d97fecb6785092da12d9054738be7f Mon Sep 17 00:00:00 2001 From: shah Date: Fri, 20 Oct 2023 14:04:01 +0530 Subject: [PATCH 3/4] Search direction swap click improvement --- .../ui/main/explore/ExploreFragment.kt | 13 ++++++++----- .../ui/main/explore/ExploreViewModel.kt | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/aws/amazonlocation/ui/main/explore/ExploreFragment.kt b/app/src/main/java/com/aws/amazonlocation/ui/main/explore/ExploreFragment.kt index b355aca0..46ad5c28 100644 --- a/app/src/main/java/com/aws/amazonlocation/ui/main/explore/ExploreFragment.kt +++ b/app/src/main/java/com/aws/amazonlocation/ui/main/explore/ExploreFragment.kt @@ -2528,9 +2528,11 @@ class ExploreFragment : ivSwapLocation.setOnClickListener { if (checkInternetConnection() && !mIsSwapClicked && !checkDirectionLoaderVisible()) { + mViewModel.searchDebounce = DELAY_300 mIsSwapClicked = true - mLastClickTime = SystemClock.elapsedRealtime() - showDirectionSearchShimmer() + if (!edtSearchDest.text.isNullOrEmpty() && !edtSearchDirection.text.isNullOrEmpty()) { + showDirectionSearchShimmer() + } if (edtSearchDirection.text.toString() == resources.getString(R.string.label_my_location)) { mMapHelper.removeMarkerAndLine() clearDirectionData() @@ -2582,8 +2584,9 @@ class ExploreFragment : } activity?.hideKeyboard() lifecycleScope.launch { - delay(CLICK_DEBOUNCE) + delay(DELAY_300) mIsSwapClicked = false + mViewModel.searchDebounce = CLICK_DEBOUNCE } } } @@ -2630,7 +2633,7 @@ class ExploreFragment : isDataSearchForDestination = false } } - edtSearchDest.textChanges().debounce(CLICK_DEBOUNCE).onEach { text -> + edtSearchDest.textChanges().debounce(mViewModel.searchDebounce).onEach { text -> updateDirectionSearchUI(text.isNullOrEmpty()) if (text?.trim().toString().lowercase() == getString(R.string.label_my_location).trim().lowercase()) { return@onEach @@ -2656,7 +2659,7 @@ class ExploreFragment : checkMyLocationUI(text, edtSearchDirection) }.launchIn(lifecycleScope) - edtSearchDirection.textChanges().debounce(CLICK_DEBOUNCE).onEach { text -> + edtSearchDirection.textChanges().debounce(mViewModel.searchDebounce).onEach { text -> updateDirectionSearchUI(text.isNullOrEmpty()) if (text?.trim().toString().lowercase() == getString(R.string.label_my_location).trim().lowercase()) { return@onEach diff --git a/app/src/main/java/com/aws/amazonlocation/ui/main/explore/ExploreViewModel.kt b/app/src/main/java/com/aws/amazonlocation/ui/main/explore/ExploreViewModel.kt index ec1e084f..b780646f 100644 --- a/app/src/main/java/com/aws/amazonlocation/ui/main/explore/ExploreViewModel.kt +++ b/app/src/main/java/com/aws/amazonlocation/ui/main/explore/ExploreViewModel.kt @@ -28,6 +28,7 @@ import com.aws.amazonlocation.utils.ATTRIBUTE_DARK import com.aws.amazonlocation.utils.ATTRIBUTE_LIGHT import com.aws.amazonlocation.utils.ATTRIBUTE_SATELLITE import com.aws.amazonlocation.utils.ATTRIBUTE_TRUCK +import com.aws.amazonlocation.utils.CLICK_DEBOUNCE import com.aws.amazonlocation.utils.MapNames import com.aws.amazonlocation.utils.MapStyles import com.aws.amazonlocation.utils.TRAVEL_MODE_BICYCLE @@ -73,6 +74,7 @@ class ExploreViewModel @Inject constructor( var providerOptions = ArrayList() var attributeOptions = ArrayList() var typeOptions = ArrayList() + var searchDebounce = CLICK_DEBOUNCE private val _searchForSuggestionsResultList = Channel>(Channel.BUFFERED) From 21eea4f014a8bb1be3c19ac8e567ab378f15ff40 Mon Sep 17 00:00:00 2001 From: shah Date: Fri, 20 Oct 2023 14:56:53 +0530 Subject: [PATCH 4/4] White screen shows while no internet fix --- .../amazonlocation/ui/base/BaseActivity.kt | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/aws/amazonlocation/ui/base/BaseActivity.kt b/app/src/main/java/com/aws/amazonlocation/ui/base/BaseActivity.kt index 10081260..713c66ac 100644 --- a/app/src/main/java/com/aws/amazonlocation/ui/base/BaseActivity.kt +++ b/app/src/main/java/com/aws/amazonlocation/ui/base/BaseActivity.kt @@ -6,7 +6,6 @@ import android.os.Bundle import android.os.StrictMode import android.os.StrictMode.ThreadPolicy import android.provider.Settings -import android.util.Log import android.widget.TextView import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity @@ -82,19 +81,23 @@ open class BaseActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) if (mPreferenceManager.getValue(KEY_NEAREST_REGION, "") == "") { - val latencyChecker = LatencyChecker() - val urls = arrayListOf() - regionList.forEach { - urls.add(String.format(BuildConfig.AWS_NEAREST_REGION_CHECK_URL, it)) - } + if (Units.checkInternetConnection(applicationContext)) { + val latencyChecker = LatencyChecker() + val urls = arrayListOf() + regionList.forEach { + urls.add(String.format(BuildConfig.AWS_NEAREST_REGION_CHECK_URL, it)) + } - val (fastestUrl, _) = runBlocking { latencyChecker.checkLatencyForUrls(urls) } - regionList.forEach { - if (fastestUrl != null) { - if (fastestUrl.contains(it)) { - mPreferenceManager.setValue(KEY_NEAREST_REGION, it) + val (fastestUrl, _) = runBlocking { latencyChecker.checkLatencyForUrls(urls) } + regionList.forEach { + if (fastestUrl != null) { + if (fastestUrl.contains(it)) { + mPreferenceManager.setValue(KEY_NEAREST_REGION, it) + } } } + } else { + mPreferenceManager.setValue(KEY_NEAREST_REGION, regionList[0]) } } try {