Skip to content

Commit aef9e16

Browse files
author
sds100
committed
Merge branch 'release/1.1.0' into main
2 parents f36f967 + c6cfe3f commit aef9e16

16 files changed

Lines changed: 637 additions & 197 deletions

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## [1.1.0](https://github.com/mapcode-foundation/mapcode-android-app/releases/tag/v1.1.0)
2+
3+
#### 9 August 2022
4+
5+
- [#39](https://github.com/mapcode-foundation/mapcode-android-app/issues/39) Call REST API when querying mapcodes.
6+
- [#20](https://github.com/mapcode-foundation/mapcode-android-app/issues/20) Show a dropdown that suggests addresses
7+
when typing.
8+
- [#44](https://github.com/mapcode-foundation/mapcode-android-app/issues/44) Don't show a snackbar confirmation when
9+
copying to the clipboard on Android 13+ to not conflict with the system's popup.
10+
- [#43](https://github.com/mapcode-foundation/mapcode-android-app/issues/43) Color the directions button grey.
11+
- [#40](https://github.com/mapcode-foundation/mapcode-android-app/issues/40) Never show, copy or share the international
12+
territory (AAA) for mapcodes.
13+
- [#41](https://github.com/mapcode-foundation/mapcode-android-app/issues/41) Select all text when tapping latitude and
14+
longitude.
15+
- [#42](https://github.com/mapcode-foundation/mapcode-android-app/issues/42) Copy location coordinates to the clipboard
16+
when tapping the latitude and longitude header.
17+
118
## [1.0.1](https://github.com/mapcode-foundation/mapcode-android-app/releases/tag/v1.0.1)
219

320
#### 5 August 2022

app/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ android {
1515
minSdk 21
1616
//noinspection OldTargetApi wait for sources to be released before upgrading
1717
targetSdk 32
18-
versionCode 2
19-
versionName "1.0.1"
18+
versionCode 3
19+
versionName "1.1.0"
2020

2121
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2222
vectorDrawables {
@@ -91,6 +91,7 @@ dependencies {
9191
implementation 'com.jakewharton.timber:timber:5.0.1'
9292
//noinspection GradleDependency. Issue with R8 on Android 8.0 or lower
9393
implementation 'com.mapcode:mapcode:2.4.14'
94+
implementation "com.squareup.okhttp3:okhttp:4.10.0"
9495

9596
//debug
9697
debugImplementation "androidx.compose.ui:ui-tooling:1.2.0"

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import kotlin.Result.Companion.success
1414
*/
1515
class FakeShowMapcodeUseCase : ShowMapcodeUseCase {
1616
var clipboard: String? = null
17+
private set
18+
1719
var hasInternetConnection: Boolean = true
1820
var currentLocation: Location? = null
1921
var isMapsAppInstalled: Boolean = true
@@ -22,6 +24,7 @@ class FakeShowMapcodeUseCase : ShowMapcodeUseCase {
2224
private set
2325

2426
val knownLocations: MutableList<FakeLocation> = mutableListOf()
27+
val matchingAddresses: MutableMap<String, List<String>> = mutableMapOf()
2528

2629
override fun getMapcodes(lat: Double, long: Double): List<Mapcode> {
2730
return knownLocations
@@ -77,11 +80,15 @@ class FakeShowMapcodeUseCase : ShowMapcodeUseCase {
7780
return currentLocation
7881
}
7982

83+
override fun shareText(text: String, description: String) {
84+
sharedText = text
85+
}
86+
8087
override fun launchDirectionsToLocation(location: Location, zoom: Float): Boolean {
8188
return isMapsAppInstalled
8289
}
8390

84-
override fun shareText(text: String, description: String) {
85-
sharedText = text
91+
override suspend fun getMatchingAddresses(query: String): Result<List<String>> {
92+
return success(matchingAddresses[query] ?: emptyList())
8693
}
8794
}

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

Lines changed: 139 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.mapcode.map
22

33
import android.Manifest
4+
import androidx.compose.ui.semantics.SemanticsProperties
45
import androidx.compose.ui.semantics.SemanticsPropertyKey
56
import androidx.compose.ui.test.*
67
import androidx.compose.ui.test.junit4.createComposeRule
8+
import androidx.compose.ui.text.TextRange
79
import androidx.test.rule.GrantPermissionRule
810
import assertk.assertThat
911
import assertk.assertions.isEqualTo
@@ -50,7 +52,7 @@ class MapScreenTest {
5052

5153
composeTestRule.onNodeWithText("Mapcode").performClick()
5254

53-
assertThat(useCase.clipboard).isEqualTo("AAA AB.XY")
55+
assertThat(useCase.clipboard).isEqualTo("AB.XY")
5456
}
5557

5658
@Test
@@ -64,13 +66,13 @@ class MapScreenTest {
6466
setMapScreenAsContent()
6567
viewModel.onCameraMoved(0.0, 0.0, 0f)
6668

67-
composeTestRule.onNodeWithText("AAA AB.XY").performClick()
69+
composeTestRule.onNodeWithText("AB.XY").performClick()
6870

69-
assertThat(useCase.clipboard).isEqualTo("AAA AB.XY")
71+
assertThat(useCase.clipboard).isEqualTo("AB.XY")
7072
}
7173

7274
@Test
73-
fun show_snack_bar_when_copying_mapcode() {
75+
fun show_snackbar_when_copying_mapcode() {
7476
useCase.knownLocations.add(
7577
FakeLocation(
7678
0.0, 0.0, addresses = emptyList(), mapcodes = listOf(Mapcode("AB.XY", Territory.AAA))
@@ -81,7 +83,7 @@ class MapScreenTest {
8183

8284
setMapScreenAsContent()
8385

84-
composeTestRule.onNodeWithText("AAA AB.XY").performClick()
86+
composeTestRule.onNodeWithText("AB.XY").performClick()
8587

8688
composeTestRule.waitForIdle()
8789

@@ -356,7 +358,7 @@ class MapScreenTest {
356358
}
357359

358360
@Test
359-
fun show_snack_bar_if_fail_to_get_current_location() {
361+
fun show_snackbar_if_fail_to_get_current_location() {
360362
useCase.currentLocation = null
361363
setMapScreenAsContent()
362364

@@ -388,7 +390,7 @@ class MapScreenTest {
388390

389391
composeTestRule.onNodeWithContentDescription("Share mapcode").performClick()
390392

391-
assertThat(useCase.sharedText).isEqualTo("AAA AB.XY")
393+
assertThat(useCase.sharedText).isEqualTo("AB.XY")
392394
}
393395

394396
@Test
@@ -491,6 +493,136 @@ class MapScreenTest {
491493
composeTestRule.onNodeWithText("Must be a number!").assertDoesNotExist()
492494
}
493495

496+
@Test
497+
fun hide_dropdown_if_no_matching_addresses() {
498+
useCase.matchingAddresses["address"] = emptyList()
499+
500+
setMapScreenAsContent()
501+
composeTestRule.onNodeWithText("Enter address or mapcode").apply {
502+
performTextClearance()
503+
performTextInput("address")
504+
}
505+
506+
composeTestRule.waitForIdle()
507+
composeTestRule.onNodeWithTag("address_dropdown").assertDoesNotExist()
508+
}
509+
510+
@Test
511+
fun show_matching_addresses_in_dropdown_when_typing() {
512+
useCase.matchingAddresses["address"] = listOf("Street 1", "Street 2")
513+
514+
setMapScreenAsContent()
515+
composeTestRule.onNodeWithText("Enter address or mapcode").apply {
516+
performTextClearance()
517+
performTextInput("address")
518+
}
519+
520+
composeTestRule.waitForIdle()
521+
composeTestRule.onNodeWithTag("address_dropdown").assertIsDisplayed()
522+
composeTestRule.onNodeWithText("Street 1").assertIsDisplayed()
523+
composeTestRule.onNodeWithText("Street 2").assertIsDisplayed()
524+
}
525+
526+
@Test
527+
fun hide_dropdown_if_not_typing_address() {
528+
setMapScreenAsContent()
529+
530+
composeTestRule.onNodeWithText("Enter address or mapcode")
531+
532+
composeTestRule.waitForIdle()
533+
composeTestRule.onNodeWithTag("address_dropdown").assertDoesNotExist()
534+
}
535+
536+
@Test
537+
fun clear_address_focus_when_submitting_address_query() {
538+
useCase.knownLocations.add(FakeLocation(1.0, 1.0, addresses = listOf("address"), mapcodes = emptyList()))
539+
setMapScreenAsContent()
540+
541+
composeTestRule.onNodeWithText("Enter address or mapcode").apply {
542+
performTextClearance()
543+
performTextInput("address")
544+
performImeAction()
545+
}
546+
547+
composeTestRule.waitForIdle()
548+
composeTestRule.onNodeWithText("Enter address or mapcode").assertIsNotFocused()
549+
}
550+
551+
@Test
552+
fun clear_address_focus_when_choosing_address_in_dropdown() {
553+
useCase.matchingAddresses["address"] = listOf("Street 1")
554+
555+
setMapScreenAsContent()
556+
557+
composeTestRule.onNodeWithText("Enter address or mapcode").apply {
558+
performTextClearance()
559+
performTextInput("address")
560+
}
561+
562+
composeTestRule.waitForIdle()
563+
composeTestRule.onNodeWithText("Street 1").performClick()
564+
composeTestRule.onNodeWithText("Enter address or mapcode").assertIsNotFocused()
565+
}
566+
567+
@Test
568+
fun do_not_focus_address_when_opening_app() {
569+
setMapScreenAsContent()
570+
composeTestRule.waitForIdle()
571+
composeTestRule.onNodeWithText("Enter address or mapcode").assertIsNotFocused()
572+
}
573+
574+
@Test
575+
fun select_latitude_text_when_focussing() {
576+
useCase.knownLocations.add(
577+
FakeLocation(0.0, 0.0, emptyList(), mapcodes = emptyList())
578+
)
579+
setMapScreenAsContent()
580+
viewModel.onCameraMoved(0.0, 0.0, 1f)
581+
582+
composeTestRule.onNodeWithText("Latitude (Y)").apply {
583+
performClick()
584+
assert(SemanticsMatcher.expectValue(SemanticsProperties.TextSelectionRange, TextRange(0, 9)))
585+
}
586+
}
587+
588+
@Test
589+
fun select_longitude_text_when_focussing() {
590+
useCase.knownLocations.add(
591+
FakeLocation(0.0, 0.0, emptyList(), mapcodes = emptyList())
592+
)
593+
setMapScreenAsContent()
594+
viewModel.onCameraMoved(0.0, 0.0, 1f)
595+
596+
composeTestRule.onNodeWithText("Longitude (X)").apply {
597+
performClick()
598+
assert(SemanticsMatcher.expectValue(SemanticsProperties.TextSelectionRange, TextRange(0, 9)))
599+
}
600+
}
601+
602+
@Test
603+
fun copy_location_to_clipboard_when_tapping_latitude_header() {
604+
setMapScreenAsContent()
605+
viewModel.onCameraMoved(1.0, 2.0, 1f)
606+
607+
composeTestRule.onNode(
608+
hasText("Latitude (Y)").and(hasTestTag("latlngtextfield")),
609+
useUnmergedTree = true
610+
).performClick()
611+
assertThat(useCase.clipboard).isEqualTo("1.0,2.0")
612+
}
613+
614+
@Test
615+
fun copy_location_to_clipboard_when_tapping_longitude_header() {
616+
setMapScreenAsContent()
617+
viewModel.onCameraMoved(1.0, 2.0, 1f)
618+
619+
composeTestRule.onNode(
620+
hasText("Longitude (X)").and(hasTestTag("latlngtextfield")),
621+
useUnmergedTree = true
622+
).performClick()
623+
assertThat(useCase.clipboard).isEqualTo("1.0,2.0")
624+
}
625+
494626
private fun setMapScreenAsContent() {
495627
composeTestRule.setContent {
496628
MapScreen(viewModel = viewModel, renderGoogleMaps = false)

0 commit comments

Comments
 (0)