Skip to content

Commit a0abe8b

Browse files
wadhawhshah272728
andauthored
ALS-1885 Update place popup to show new information (#96)
* fix: reverse geocode and direction button should not work if only data is pulled bug fixes fix: Two bottom sheet opening fixes with code optimization refactor: Auth SDK version update with related code changes ALS-1882 * fix: App should work without no data inside custom.properties file ALS-1884 * feat: Places popup updated with new information ALS-1885 * feat: code optimize ALS-1885 --------- Co-authored-by: shah <[email protected]>
1 parent d7b035c commit a0abe8b

File tree

54 files changed

+1863
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1863
-416
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ dependencies {
145145

146146
implementation "org.maplibre.gl:android-sdk:11.0.0"
147147
implementation "org.maplibre.gl:android-plugin-annotation-v9:3.0.0"
148-
implementation("software.amazon.location:auth:0.2.5")
148+
implementation("software.amazon.location:auth:1.1.0")
149149
implementation("com.google.android.gms:play-services-location:21.3.0")
150150

151151
implementation "androidx.navigation:navigation-fragment-ktx:2.7.7"

app/src/androidTest/java/com/aws/amazonlocation/ConstantTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const val TEST_WORD_RIO_TINTO = "Rio Tinto"
3232
const val TEST_WORD_SHYAMAL = "Shyamal Cross"
3333
const val TEST_WORD_SCHOOL = "School"
3434
const val TEST_WORD_SHYAMAL_CROSS_ROAD = "Shyamal Cross Road"
35+
const val TEST_WORD_DOMINO_PIZZA_VEJALPUR = "dominos Jivraj Park Cross Road, Vejalpur Police Chowky, Vejalpur"
36+
const val TEST_WORD_DOMINO_PIZZA = "Domino's"
3537
const val TEST_WORD_AUBURN_SYDNEY = "auburn sydney"
3638
const val TEST_WORD_MANLY_BEACH_SYDNEY = "manly beach sydney"
3739
const val TEST_WORD_CLOVERDALE_PERTH = "cloverdale perth"
@@ -86,6 +88,7 @@ const val TEST_FAILED_COUNT_NOT_GREATER_THEN_TWO = "Test failed due to count not
8688
const val TEST_FAILED_DRIVE_OR_WALK_OR_TRUCK_OPTION_NOT_VISIBLE = "Test failed due to drive or walk or truck option not visible"
8789
const val TEST_FAILED_INVALID_ORIGIN_OR_DESTINATION_TEXT = "Test failed due to invalid origin or destination text"
8890
const val TEST_FAILED_DIRECTION_TIME_NOT_VISIBLE = "Test failed due to direction time not visible"
91+
const val TEST_FAILED_PLACE_LINK_NOT_VISIBLE = "Test failed due to place link not visible"
8992
const val TEST_FAILED_IMAGE_NULL = "Test failed due to image null"
9093
const val TEST_FAILED_NOT_EQUAL = "Test failed due to not equal"
9194
const val TEST_FAILED_POOL_ID_NOT_BLANK = "Test failed due to pool id not blank"

app/src/androidTest/java/com/aws/amazonlocation/ui/MapLoadAndPlaceSearchFlowSuite.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.aws.amazonlocation.ui.main.ExploreFragmentSearchByCategoriesTest
1313
import com.aws.amazonlocation.ui.main.ExploreFragmentSearchCollapseTest
1414
import com.aws.amazonlocation.ui.main.ExploreFragmentSearchExistsTest
1515
import com.aws.amazonlocation.ui.main.ExploreFragmentSearchGeocodeReversedTest
16+
import com.aws.amazonlocation.ui.main.SearchContactInfoPOICardTest
1617
import org.junit.runner.RunWith
1718
import org.junit.runners.Suite
1819

@@ -31,5 +32,6 @@ import org.junit.runners.Suite
3132
ExploreFragmentSearchCollapseTest::class,
3233
ExploreFragmentSearchExistsTest::class,
3334
ExploreFragmentSearchGeocodeReversedTest::class,
35+
SearchContactInfoPOICardTest::class
3436
)
3537
class MapLoadAndPlaceSearchFlowSuite
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package com.aws.amazonlocation.ui.main
2+
3+
import android.view.View
4+
import androidx.appcompat.widget.AppCompatTextView
5+
import androidx.recyclerview.widget.RecyclerView
6+
import androidx.recyclerview.widget.RecyclerView.ViewHolder
7+
import androidx.test.core.app.ApplicationProvider
8+
import androidx.test.espresso.Espresso.onView
9+
import androidx.test.espresso.action.ViewActions.click
10+
import androidx.test.espresso.action.ViewActions.replaceText
11+
import androidx.test.espresso.assertion.ViewAssertions.matches
12+
import androidx.test.espresso.contrib.RecyclerViewActions
13+
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
14+
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
15+
import androidx.test.espresso.matcher.ViewMatchers.withId
16+
import androidx.test.espresso.matcher.ViewMatchers.withText
17+
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
18+
import androidx.test.uiautomator.By
19+
import androidx.test.uiautomator.UiDevice
20+
import androidx.test.uiautomator.UiSelector
21+
import androidx.test.uiautomator.Until
22+
import com.aws.amazonlocation.ALLOW
23+
import com.aws.amazonlocation.AMAZON_MAP_READY
24+
import com.aws.amazonlocation.BaseTestMainActivity
25+
import com.aws.amazonlocation.BuildConfig
26+
import com.aws.amazonlocation.DELAY_15000
27+
import com.aws.amazonlocation.DELAY_2000
28+
import com.aws.amazonlocation.DELAY_20000
29+
import com.aws.amazonlocation.R
30+
import com.aws.amazonlocation.TEST_FAILED
31+
import com.aws.amazonlocation.TEST_FAILED_NO_SEARCH_RESULT
32+
import com.aws.amazonlocation.TEST_FAILED_PLACE_LINK_NOT_VISIBLE
33+
import com.aws.amazonlocation.TEST_WORD_DOMINO_PIZZA
34+
import com.aws.amazonlocation.TEST_WORD_DOMINO_PIZZA_VEJALPUR
35+
import com.aws.amazonlocation.WHILE_USING_THE_APP
36+
import com.aws.amazonlocation.WHILE_USING_THE_APP_ALLOW
37+
import com.aws.amazonlocation.WHILE_USING_THE_APP_CAPS
38+
import com.aws.amazonlocation.di.AppModule
39+
import com.aws.amazonlocation.enableGPS
40+
import com.aws.amazonlocation.failTest
41+
import com.google.android.material.card.MaterialCardView
42+
import dagger.hilt.android.testing.HiltAndroidTest
43+
import dagger.hilt.android.testing.UninstallModules
44+
import org.junit.Assert
45+
import org.junit.Test
46+
47+
@UninstallModules(AppModule::class)
48+
@HiltAndroidTest
49+
class SearchContactInfoPOICardTest : BaseTestMainActivity() {
50+
51+
private val uiDevice = UiDevice.getInstance(getInstrumentation())
52+
53+
@Test
54+
fun searchContactInfoPOICardTest() {
55+
try {
56+
val btnContinueToApp = uiDevice.findObject(UiSelector().resourceId("${BuildConfig.APPLICATION_ID}:id/btn_continue_to_app"))
57+
if (btnContinueToApp.exists()) {
58+
btnContinueToApp.click()
59+
Thread.sleep(DELAY_2000)
60+
}
61+
uiDevice.findObject(By.text(WHILE_USING_THE_APP))?.click()
62+
uiDevice.findObject(By.text(WHILE_USING_THE_APP_CAPS))?.click()
63+
uiDevice.findObject(By.text(WHILE_USING_THE_APP_ALLOW))?.click()
64+
uiDevice.findObject(By.text(ALLOW))?.click()
65+
Thread.sleep(DELAY_2000)
66+
enableGPS(ApplicationProvider.getApplicationContext())
67+
uiDevice.wait(Until.hasObject(By.desc(AMAZON_MAP_READY)), DELAY_15000)
68+
Thread.sleep(DELAY_2000)
69+
70+
val edtSearch =
71+
onView(withId(R.id.edt_search_places)).check(matches(isDisplayed()))
72+
edtSearch.perform(click())
73+
onView(withId(R.id.edt_search_places)).perform(replaceText(TEST_WORD_DOMINO_PIZZA_VEJALPUR))
74+
uiDevice.wait(
75+
Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/rv_search_places_suggestion")),
76+
DELAY_20000
77+
)
78+
getInstrumentation().waitForIdleSync()
79+
val rvSearchPlaceSuggestion =
80+
mActivityRule.activity.findViewById<RecyclerView>(R.id.rv_search_places_suggestion)
81+
if (rvSearchPlaceSuggestion.adapter?.itemCount != null) {
82+
rvSearchPlaceSuggestion.adapter?.itemCount?.let {
83+
if (it >= 0) {
84+
Thread.sleep(DELAY_2000)
85+
onView(withId(R.id.rv_search_places_suggestion))
86+
.check(matches(hasDescendant(withText(TEST_WORD_DOMINO_PIZZA))))
87+
Thread.sleep(DELAY_2000)
88+
onView(withId(R.id.rv_search_places_suggestion))
89+
.perform(RecyclerViewActions.actionOnItem<ViewHolder>(hasDescendant(withText(TEST_WORD_DOMINO_PIZZA)), click()))
90+
Thread.sleep(DELAY_2000)
91+
val btnDirection =
92+
mActivityRule.activity.findViewById<MaterialCardView>(R.id.btn_direction)
93+
if (btnDirection.visibility == View.VISIBLE) {
94+
uiDevice.wait(
95+
Until.hasObject(By.res("${BuildConfig.APPLICATION_ID}:id/tv_direction_distance")),
96+
DELAY_20000,
97+
)
98+
val tvPlaceLink =
99+
mActivityRule.activity.findViewById<AppCompatTextView>(R.id.tv_place_link)
100+
Thread.sleep(DELAY_2000)
101+
Assert.assertTrue(TEST_FAILED_PLACE_LINK_NOT_VISIBLE, tvPlaceLink.visibility == View.VISIBLE)
102+
} else {
103+
Assert.fail()
104+
}
105+
} else {
106+
Assert.fail(TEST_FAILED_NO_SEARCH_RESULT)
107+
}
108+
}
109+
} else {
110+
Assert.fail(TEST_FAILED_NO_SEARCH_RESULT)
111+
}
112+
} catch (e: Exception) {
113+
failTest(107, e)
114+
Assert.fail(TEST_FAILED)
115+
}
116+
}
117+
}

app/src/main/java/com/aws/amazonlocation/data/datasource/RemoteDataSource.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package com.aws.amazonlocation.data.datasource
22

3-
import aws.sdk.kotlin.services.georoutes.model.CalculateRoutesResponse
43
import aws.sdk.kotlin.services.location.model.ListGeofenceResponseEntry
5-
import aws.sdk.kotlin.services.location.model.Step
64
import com.aws.amazonlocation.domain.`interface`.BatchLocationUpdateInterface
75
import com.aws.amazonlocation.domain.`interface`.DistanceInterface
86
import com.aws.amazonlocation.domain.`interface`.GeofenceAPIInterface
97
import com.aws.amazonlocation.domain.`interface`.LocationDeleteHistoryInterface
108
import com.aws.amazonlocation.domain.`interface`.LocationHistoryInterface
11-
import com.aws.amazonlocation.domain.`interface`.NavigationDataInterface
9+
import com.aws.amazonlocation.domain.`interface`.PlaceInterface
1210
import com.aws.amazonlocation.domain.`interface`.SearchDataInterface
1311
import com.aws.amazonlocation.domain.`interface`.SearchPlaceInterface
1412
import com.aws.amazonlocation.domain.`interface`.SignInInterface
@@ -102,4 +100,9 @@ interface RemoteDataSource {
102100
suspend fun refreshTokensWithOkHttp(
103101
signInInterface: SignInInterface
104102
)
103+
104+
suspend fun getPlace(
105+
placeId: String,
106+
placeInterface: PlaceInterface
107+
)
105108
}

app/src/main/java/com/aws/amazonlocation/data/datasource/RemoteDataSourceImpl.kt

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.aws.amazonlocation.domain.`interface`.DistanceInterface
99
import com.aws.amazonlocation.domain.`interface`.GeofenceAPIInterface
1010
import com.aws.amazonlocation.domain.`interface`.LocationDeleteHistoryInterface
1111
import com.aws.amazonlocation.domain.`interface`.LocationHistoryInterface
12+
import com.aws.amazonlocation.domain.`interface`.PlaceInterface
1213
import com.aws.amazonlocation.domain.`interface`.SearchDataInterface
1314
import com.aws.amazonlocation.domain.`interface`.SearchPlaceInterface
1415
import com.aws.amazonlocation.domain.`interface`.SignInInterface
@@ -48,8 +49,8 @@ class RemoteDataSourceImpl(
4849
if (mContext.isInternetAvailable()) {
4950
val mSearchSuggestionResponse =
5051
mPlacesProvider.searchPlaceSuggestion(lat, lng, searchText, mLocationProvider.getBaseActivity(), mLocationProvider.getGeoPlacesClient())
51-
if (validateLatLng(searchText) != null) {
52-
val mLatLng = validateLatLng(searchText)
52+
if (validateLatLng(searchText.trim()) != null) {
53+
val mLatLng = validateLatLng(searchText.trim())
5354
if (mSearchSuggestionResponse.text == (mLatLng?.latitude.toString() + "," + mLatLng?.longitude.toString())) {
5455
searchPlace.getSearchPlaceSuggestionResponse(mSearchSuggestionResponse)
5556
} else {
@@ -267,4 +268,25 @@ class RemoteDataSourceImpl(
267268
signInInterface.refreshTokensWithOkHttpFailed("failed")
268269
}
269270
}
271+
272+
override suspend fun getPlace(placeId: String, placeInterface: PlaceInterface) {
273+
if (mContext.isInternetAvailable()) {
274+
val placeResponse = mPlacesProvider.getPlace(placeId, mLocationProvider.getBaseActivity(), mLocationProvider.getGeoPlacesClient())
275+
if (placeResponse != null) {
276+
placeInterface.placeSuccess(placeResponse)
277+
} else {
278+
placeInterface.placeFailed(DataSourceException.Error(""))
279+
}
280+
} else {
281+
placeInterface.internetConnectionError(
282+
if (isRunningRemoteDataSourceImplTest) {
283+
""
284+
} else {
285+
mContext.resources.getString(
286+
R.string.check_your_internet_connection_and_try_again,
287+
)
288+
},
289+
)
290+
}
291+
}
270292
}

app/src/main/java/com/aws/amazonlocation/data/repository/LocationSearchImp.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.aws.amazonlocation.data.repository
22

3+
import aws.sdk.kotlin.services.geoplaces.GeoPlacesClient
34
import com.aws.amazonlocation.data.datasource.RemoteDataSourceImpl
45
import com.aws.amazonlocation.domain.`interface`.DistanceInterface
6+
import com.aws.amazonlocation.domain.`interface`.PlaceInterface
57
import com.aws.amazonlocation.domain.`interface`.SearchDataInterface
68
import com.aws.amazonlocation.domain.`interface`.SearchPlaceInterface
79
import com.aws.amazonlocation.domain.repository.LocationSearchRepository
10+
import com.aws.amazonlocation.ui.base.BaseActivity
811

912
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
1013

@@ -64,4 +67,8 @@ class LocationSearchImp(private val mRemoteDataSource: RemoteDataSourceImpl) :
6467
searchPlace
6568
)
6669
}
70+
71+
override suspend fun getPlace(placeId: String, placeInterface: PlaceInterface) {
72+
mRemoteDataSource.getPlace(placeId, placeInterface)
73+
}
6774
}

app/src/main/java/com/aws/amazonlocation/data/response/SearchSuggestionResponse.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.aws.amazonlocation.data.response
22

33
import aws.sdk.kotlin.services.geoplaces.model.Address
4+
import aws.sdk.kotlin.services.geoplaces.model.Contacts
5+
import aws.sdk.kotlin.services.geoplaces.model.OpeningHours
46

57

68
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -23,5 +25,7 @@ data class SearchSuggestionData(
2325
var isPlaceIndexForPosition: Boolean = false,
2426
var amazonLocationAddress: Address? = null,
2527
var position: List<Double> ? = null,
26-
var queryId: String ? = null
28+
var queryId: String ? = null,
29+
var contacts: Contacts? = null,
30+
var openingHours: List<OpeningHours>? = null
2731
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.aws.amazonlocation.domain.`interface`
2+
3+
import aws.sdk.kotlin.services.geoplaces.model.GetPlaceResponse
4+
import com.aws.amazonlocation.data.common.DataSourceException
5+
6+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7+
8+
// SPDX-License-Identifier: MIT-0
9+
interface PlaceInterface {
10+
11+
fun placeSuccess(success: GetPlaceResponse) {}
12+
13+
fun placeFailed(exception: DataSourceException) {}
14+
15+
fun internetConnectionError(exception: String) {}
16+
}

app/src/main/java/com/aws/amazonlocation/domain/repository/LocationSearchRepository.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import aws.sdk.kotlin.services.georoutes.model.CalculateRoutesResponse
44
import aws.sdk.kotlin.services.location.model.Step
55
import com.aws.amazonlocation.domain.`interface`.DistanceInterface
66
import com.aws.amazonlocation.domain.`interface`.NavigationDataInterface
7+
import com.aws.amazonlocation.domain.`interface`.PlaceInterface
78
import com.aws.amazonlocation.domain.`interface`.SearchDataInterface
89
import com.aws.amazonlocation.domain.`interface`.SearchPlaceInterface
910

@@ -43,4 +44,6 @@ interface LocationSearchRepository {
4344
lng: Double?,
4445
searchPlace: SearchDataInterface
4546
)
47+
48+
suspend fun getPlace(placeId: String, placeInterface: PlaceInterface)
4649
}

app/src/main/java/com/aws/amazonlocation/domain/usecase/LocationSearchUseCase.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import aws.sdk.kotlin.services.georoutes.model.CalculateRoutesResponse
44
import aws.sdk.kotlin.services.location.model.Step
55
import com.aws.amazonlocation.domain.`interface`.DistanceInterface
66
import com.aws.amazonlocation.domain.`interface`.NavigationDataInterface
7+
import com.aws.amazonlocation.domain.`interface`.PlaceInterface
78
import com.aws.amazonlocation.domain.`interface`.SearchDataInterface
89
import com.aws.amazonlocation.domain.`interface`.SearchPlaceInterface
910
import com.aws.amazonlocation.domain.repository.LocationSearchRepository
@@ -55,4 +56,6 @@ class LocationSearchUseCase @Inject constructor(private val mLocationSearchRepos
5556
lng: Double?,
5657
searchPlace: SearchDataInterface
5758
) = mLocationSearchRepository.searPlaceIndexForPosition(lat, lng, searchPlace)
59+
60+
suspend fun getPlace(placeId: String, placeInterface: PlaceInterface) = mLocationSearchRepository.getPlace(placeId, placeInterface)
5861
}

app/src/main/java/com/aws/amazonlocation/ui/base/BaseActivity.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import dagger.hilt.android.AndroidEntryPoint
4444
import kotlinx.coroutines.delay
4545
import kotlinx.coroutines.launch
4646
import kotlinx.coroutines.runBlocking
47-
import software.amazon.location.auth.AuthHelper
4847
import javax.inject.Inject
4948

5049
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -73,7 +72,6 @@ open class BaseActivity : AppCompatActivity() {
7372
lateinit var mLocationProvider: LocationProvider
7473

7574
private var subTitle = ""
76-
lateinit var authHelper: AuthHelper
7775
val mSignInViewModel: SignInViewModel by viewModels()
7876

7977
override fun onCreate(savedInstanceState: Bundle?) {
@@ -105,7 +103,6 @@ open class BaseActivity : AppCompatActivity() {
105103
mGeofenceBottomSheetHelper = GeofenceBottomSheetHelper(this@BaseActivity)
106104
mGeofenceUtils = GeofenceUtils()
107105

108-
authHelper = AuthHelper(applicationContext)
109106
val preference = PreferenceManager(applicationContext)
110107
mTrackingUtils = TrackingUtils(preference, this@BaseActivity, mLocationProvider)
111108
mSimulationUtils = SimulationUtils(preference, this@BaseActivity, mLocationProvider)
@@ -127,8 +124,8 @@ open class BaseActivity : AppCompatActivity() {
127124
}
128125

129126
suspend fun initMobileClient() {
130-
mLocationProvider.initializeLocationCredentialsProvider(authHelper, this)
131-
mLocationProvider.initPlaceRoutesClients()
127+
mLocationProvider.initializeLocationCredentialsProvider(this)
128+
mLocationProvider.initPlaceRoutesClients(this)
132129
}
133130

134131
private fun locationPermissionDialog() {
@@ -253,10 +250,10 @@ open class BaseActivity : AppCompatActivity() {
253250

254251
fun restartAppWithClearData() {
255252
lifecycleScope.launch {
256-
mLocationProvider.locationCredentialsProvider?.clear()
253+
mLocationProvider.clearCredentials()
257254
mPreferenceManager.setDefaultConfig()
258255
delay(RESTART_DELAY)
259256
restartApplication()
260257
}
261258
}
262-
}
259+
}

0 commit comments

Comments
 (0)