Skip to content

Commit 3c59064

Browse files
author
sds100
committed
Merge branch 'develop' into main
2 parents 6c26abb + 0ff2f97 commit 3c59064

13 files changed

Lines changed: 290 additions & 101 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## [1.1.1](https://github.com/mapcode-foundation/mapcode-android-app/releases/tag/v1.1.1)
2+
3+
#### 2022-08-21
4+
5+
- [#47](https://github.com/mapcode-foundation/mapcode-android-app/issues/47) Improve address autocompletion results by
6+
using Google Places API.
7+
- [#48](https://github.com/mapcode-foundation/mapcode-android-app/issues/48) Allow comma decimal in latitude and
8+
longitude.
9+
- [#46](https://github.com/mapcode-foundation/mapcode-android-app/issues/46) Latitude and longitude text are invisible
10+
in dark mode.
11+
- Button to clear latitude and longitude text is now a copy button.
12+
13+
#### 2022-08-09
14+
115
## [1.1.0](https://github.com/mapcode-foundation/mapcode-android-app/releases/tag/v1.1.0)
216

317
#### 2022-08-09

app/build.gradle

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ plugins {
88

99
android {
1010
namespace 'com.mapcode'
11-
compileSdk 32
11+
compileSdk 33
1212

1313
defaultConfig {
1414
applicationId "com.mapcode"
1515
minSdk 21
1616
//noinspection OldTargetApi wait for sources to be released before upgrading
17-
targetSdk 32
18-
versionCode 3
19-
versionName "1.1.0"
17+
targetSdk 33
18+
versionCode 4
19+
versionName "1.1.1"
2020

2121
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2222
vectorDrawables {
@@ -64,6 +64,8 @@ dependencies {
6464
//google
6565
implementation 'com.google.maps.android:maps-compose:2.2.0'
6666
implementation 'com.google.android.gms:play-services-maps:18.1.0'
67+
implementation 'com.google.android.libraries.places:places:2.6.0'
68+
implementation 'com.google.maps.android:places-ktx:2.0.0'
6769
implementation "com.google.dagger:hilt-android:2.42"
6870
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'
6971
implementation 'com.google.android.gms:play-services-location:20.0.0'
@@ -77,15 +79,15 @@ dependencies {
7779
implementation 'androidx.activity:activity-compose:1.5.1'
7880
//noinspection GradleDependency
7981
implementation "androidx.compose.ui:ui:1.2.0"
80-
implementation "androidx.compose.ui:ui-tooling-preview:1.2.0"
81-
implementation 'androidx.compose.material:material:1.2.0'
82+
implementation "androidx.compose.ui:ui-tooling-preview:1.2.1"
83+
implementation 'androidx.compose.material:material:1.2.1'
8284
implementation "androidx.navigation:navigation-compose:2.5.1"
83-
implementation "androidx.compose.foundation:foundation:1.3.0-alpha02"
85+
implementation "androidx.compose.foundation:foundation:1.3.0-alpha03"
8486
implementation 'com.google.accompanist:accompanist-permissions:0.24.10-beta'
8587
implementation "com.google.accompanist:accompanist-systemuicontroller:0.17.0"
8688
implementation "androidx.datastore:datastore-preferences:1.0.0"
8789
implementation "androidx.core:core-splashscreen:1.0.0"
88-
implementation "androidx.compose.material3:material3-window-size-class:1.0.0-alpha15"
90+
implementation "androidx.compose.material3:material3-window-size-class:1.0.0-alpha16"
8991

9092
//other
9193
implementation 'com.jakewharton.timber:timber:5.0.1'
@@ -94,8 +96,8 @@ dependencies {
9496
implementation "com.squareup.okhttp3:okhttp:4.10.0"
9597

9698
//debug
97-
debugImplementation "androidx.compose.ui:ui-tooling:1.2.0"
98-
debugImplementation "androidx.compose.ui:ui-test-manifest:1.2.0"
99+
debugImplementation "androidx.compose.ui:ui-tooling:1.2.1"
100+
debugImplementation "androidx.compose.ui:ui-test-manifest:1.2.1"
99101

100102
//testing
101103
testImplementation 'junit:junit:4.13.2'
@@ -110,7 +112,7 @@ dependencies {
110112
androidTestImplementation 'com.willowtreeapps.assertk:assertk-jvm:0.25'
111113
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
112114
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
113-
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.2.0"
115+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.2.1"
114116
androidTestImplementation 'org.mockito.kotlin:mockito-kotlin:4.0.0'
115117
androidTestImplementation 'org.mockito:mockito-android:4.6.1'
116118
androidTestImplementation 'androidx.test:rules:1.4.0'

app/src/androidTest/java/com/mapcode/map/FakeShowMapcodeUseCase.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,16 @@ class FakeShowMapcodeUseCase : ShowMapcodeUseCase {
9797
sharedText = text
9898
}
9999

100-
override fun launchDirectionsToLocation(location: Location, zoom: Float): Boolean {
101-
return isMapsAppInstalled
100+
override suspend fun getMatchingAddresses(
101+
query: String,
102+
maxResults: Int,
103+
southwest: Location,
104+
northeast: Location
105+
): Result<List<String>> {
106+
return success(matchingAddresses[query] ?: emptyList())
102107
}
103108

104-
override suspend fun getMatchingAddresses(query: String): Result<List<String>> {
105-
return success(matchingAddresses[query] ?: emptyList())
109+
override fun launchDirectionsToLocation(location: Location, zoom: Float): Boolean {
110+
return isMapsAppInstalled
106111
}
107112
}

app/src/androidTest/java/com/mapcode/map/MapScreenTest.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ class MapScreenTest {
183183
composeTestRule.waitForIdle()
184184

185185
composeTestRule.onNodeWithText("Street, City, Country").assertIsDisplayed()
186-
187186
composeTestRule.onNodeWithText("City, Country").assertIsDisplayed()
188187
}
189188

@@ -530,6 +529,10 @@ class MapScreenTest {
530529
performTextInput("address")
531530
}
532531

532+
composeTestRule.waitUntil(2000) {
533+
viewModel.uiState.value.addressUi.matchingAddresses.isNotEmpty()
534+
}
535+
533536
composeTestRule.waitForIdle()
534537
composeTestRule.onNodeWithTag("address_dropdown").assertIsDisplayed()
535538
composeTestRule.onNodeWithText("Street 1").assertIsDisplayed()
@@ -572,7 +575,10 @@ class MapScreenTest {
572575
performTextInput("address")
573576
}
574577

575-
composeTestRule.waitForIdle()
578+
composeTestRule.waitUntil(2000) {
579+
viewModel.uiState.value.addressUi.matchingAddresses.isNotEmpty()
580+
}
581+
576582
composeTestRule.onNodeWithText("Street 1").performClick()
577583
composeTestRule.onNodeWithText("Enter address or mapcode").assertIsNotFocused()
578584
}
@@ -613,27 +619,21 @@ class MapScreenTest {
613619
}
614620

615621
@Test
616-
fun copy_location_to_clipboard_when_tapping_latitude_header() {
622+
fun copy_location_to_clipboard_when_tapping_latitude_copy_button() {
617623
setMapScreenAsContent()
618624
viewModel.onCameraMoved(1.0, 2.0, 1f)
619625

620-
composeTestRule.onNode(
621-
hasText("Latitude (Y)").and(hasTestTag("latlngtextfield")),
622-
useUnmergedTree = true
623-
).performClick()
624-
assertThat(useCase.clipboard).isEqualTo("1.0,2.0")
626+
composeTestRule.onAllNodes(hasContentDescription("Copy location")).onFirst().performClick()
627+
assertThat(useCase.clipboard).isEqualTo("1,2")
625628
}
626629

627630
@Test
628-
fun copy_location_to_clipboard_when_tapping_longitude_header() {
631+
fun copy_location_to_clipboard_when_tapping_longitude_copy_button() {
629632
setMapScreenAsContent()
630633
viewModel.onCameraMoved(1.0, 2.0, 1f)
631634

632-
composeTestRule.onNode(
633-
hasText("Longitude (X)").and(hasTestTag("latlngtextfield")),
634-
useUnmergedTree = true
635-
).performClick()
636-
assertThat(useCase.clipboard).isEqualTo("1.0,2.0")
635+
composeTestRule.onAllNodes(hasContentDescription("Copy location")).onLast().performClick()
636+
assertThat(useCase.clipboard).isEqualTo("1,2")
637637
}
638638

639639
private fun setMapScreenAsContent() {

app/src/main/java/com/mapcode/MainActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
2828
import androidx.core.view.WindowCompat
2929
import androidx.navigation.compose.rememberNavController
3030
import com.google.android.gms.maps.MapsInitializer
31+
import com.google.android.libraries.places.api.Places
3132
import com.mapcode.map.MapViewModel
3233
import com.mapcode.theme.MapcodeTheme
3334
import dagger.hilt.android.AndroidEntryPoint
@@ -48,6 +49,7 @@ class MainActivity : ComponentActivity() {
4849
MapcodeApp(viewModel, windowSizeClass)
4950
}
5051

52+
Places.initialize(applicationContext, BuildConfig.MAPS_API_KEY)
5153
MapsInitializer.initialize(this)
5254
viewModel.isGoogleMapsSdkLoaded = true
5355
}

app/src/main/java/com/mapcode/map/InfoScreenPart.kt

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,15 @@ import androidx.annotation.DrawableRes
2424
import androidx.compose.foundation.ExperimentalFoundationApi
2525
import androidx.compose.foundation.clickable
2626
import androidx.compose.foundation.layout.*
27-
import androidx.compose.foundation.text.ClickableText
2827
import androidx.compose.foundation.text.KeyboardActions
2928
import androidx.compose.foundation.text.KeyboardOptions
3029
import androidx.compose.material.*
31-
import androidx.compose.material.icons.Icons
32-
import androidx.compose.material.icons.outlined.Clear
3330
import androidx.compose.runtime.*
3431
import androidx.compose.ui.Modifier
3532
import androidx.compose.ui.focus.FocusRequester
3633
import androidx.compose.ui.focus.focusRequester
3734
import androidx.compose.ui.focus.onFocusChanged
3835
import androidx.compose.ui.platform.LocalFocusManager
39-
import androidx.compose.ui.platform.testTag
4036
import androidx.compose.ui.res.painterResource
4137
import androidx.compose.ui.res.stringResource
4238
import androidx.compose.ui.text.SpanStyle
@@ -347,7 +343,6 @@ private fun LatitudeTextBox(
347343
placeholder = placeHolder,
348344
showInvalidError = showInvalidError,
349345
label = stringResource(R.string.latitude_text_field_label),
350-
clearButtonContentDescription = stringResource(R.string.clear_latitude_content_description),
351346
onSubmit = onSubmit,
352347
onChange = onChange,
353348
onCopy = onCopy
@@ -373,7 +368,6 @@ private fun LongitudeTextBox(
373368
placeholder = placeHolder,
374369
showInvalidError = showInvalidError,
375370
label = stringResource(R.string.longitude_text_field_label),
376-
clearButtonContentDescription = stringResource(R.string.clear_longitude_content_description),
377371
onSubmit = onSubmit,
378372
onChange = onChange,
379373
onCopy = onCopy
@@ -388,7 +382,6 @@ private fun LatLngTextField(
388382
placeholder: String,
389383
showInvalidError: Boolean,
390384
label: String,
391-
clearButtonContentDescription: String,
392385
onSubmit: () -> Unit,
393386
onChange: (String) -> Unit,
394387
onCopy: () -> Unit
@@ -421,11 +414,9 @@ private fun LatLngTextField(
421414
value = textValue,
422415
singleLine = true,
423416
label = {
424-
ClickableText(
425-
modifier = Modifier.testTag("latlngtextfield"),
426-
text = buildAnnotatedString { append(label) },
427-
maxLines = 1,
428-
onClick = { onCopy() }
417+
Text(
418+
text = label,
419+
maxLines = 1
429420
)
430421
},
431422
onValueChange = { value ->
@@ -444,16 +435,11 @@ private fun LatLngTextField(
444435
}),
445436
placeholder = { Text(placeholder, maxLines = 1) },
446437
trailingIcon = {
447-
if (text.isNotEmpty()) {
448-
IconButton(onClick = {
449-
focusRequester.requestFocus()
450-
onChange("")
451-
}) {
452-
Icon(
453-
Icons.Outlined.Clear,
454-
contentDescription = clearButtonContentDescription
455-
)
456-
}
438+
IconButton(onClick = onCopy) {
439+
Icon(
440+
painterResource(R.drawable.ic_outline_content_copy_24),
441+
contentDescription = stringResource(R.string.copy_location_content_description)
442+
)
457443
}
458444
})
459445

0 commit comments

Comments
 (0)