Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sds100 committed Nov 11, 2022
2 parents 314c36f + eee7e80 commit cd50839
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 206 deletions.
20 changes: 14 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## [1.2.1](https://github.com/mapcode-foundation/mapcode-android-app/releases/tag/v1.2.1)

#### 2022-11-11

- [#51](https://github.com/mapcode-foundation/mapcode-android-app/issues/51) Put the buttons to save
and view locations next to each other so that they are easier to find.
- [#50](https://github.com/mapcode-foundation/mapcode-android-app/issues/50) Add a button to go to
see the tutorial again.
- [#49](https://github.com/mapcode-foundation/mapcode-android-app/issues/49) Make the backgrounds of
the tutorial lighter so the text is easier to read.

## [1.2.0](https://github.com/mapcode-foundation/mapcode-android-app/releases/tag/v1.2.0)

#### 2022-10-21
Expand All @@ -12,14 +23,11 @@
#### 2022-08-21

- [#47](https://github.com/mapcode-foundation/mapcode-android-app/issues/47) Improve address
autocompletion results by
using Google Places API.
autocompletion results by using Google Places API.
- [#48](https://github.com/mapcode-foundation/mapcode-android-app/issues/48) Allow comma decimal in
latitude and
longitude.
latitude and longitude.
- [#46](https://github.com/mapcode-foundation/mapcode-android-app/issues/46) Latitude and longitude
text are invisible
in dark mode.
text are invisible in dark mode.
- Button to clear latitude and longitude text is now a copy button.

## [1.1.0](https://github.com/mapcode-foundation/mapcode-android-app/releases/tag/v1.1.0)
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ android {
minSdk 21
//noinspection OldTargetApi wait for sources to be released before upgrading
targetSdk 33
versionCode 5
versionName "1.2.0"
versionCode 6
versionName "1.2.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
9 changes: 9 additions & 0 deletions app/src/androidTest/java/com/mapcode/map/MapScreenTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import assertk.assertions.prop
import com.mapcode.Mapcode
import com.mapcode.Territory
import com.mapcode.destinations.FavouritesScreenDestination
import com.mapcode.destinations.OnboardingScreenDestination
import com.mapcode.favourites.Favourite
import com.mapcode.util.Location
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
Expand Down Expand Up @@ -785,6 +786,14 @@ class MapScreenTest {
composeTestRule.onNodeWithText("Save a location first!").assertIsDisplayed()
}

@Test
fun navigate_to_onboarding_screen_when_click_view_tutorial() {
setMapScreenAsContent()
composeTestRule.onNodeWithContentDescription("More").performClick()
composeTestRule.onNodeWithText("Tutorial").performClick()
verify(mockDestinationsNavigator).navigate(OnboardingScreenDestination.route)
}

private fun setMapScreenAsContent() {
composeTestRule.setContent {
MapScreen(
Expand Down
161 changes: 52 additions & 109 deletions app/src/main/java/com/mapcode/map/AddressScreenPart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Bookmark
import androidx.compose.material.icons.outlined.BookmarkAdd
import androidx.compose.material.icons.outlined.Clear
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
Expand All @@ -38,7 +35,6 @@ import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.mapcode.R
import com.mapcode.theme.MapcodeColor
import com.mapcode.theme.MapcodeTheme

@OptIn(ExperimentalMaterialApi::class)
Expand All @@ -51,88 +47,72 @@ fun AddressArea(
onSubmit: () -> Unit = {},
helper: AddressHelper,
error: AddressError,
onAddFavouriteClick: () -> Unit = {},
onDeleteFavouriteClick: () -> Unit = {},
isFavouriteLocation: Boolean
) {
Column(modifier) {

var menuExpanded by remember { mutableStateOf(false) }
val focusRequester = FocusRequester()
val focusManager = LocalFocusManager.current

Row {
ExposedDropdownMenuBox(
modifier = Modifier.weight(1f),
expanded = menuExpanded,
onExpandedChange = { menuExpanded = it }) {
OutlinedTextField(
modifier = Modifier
.fillMaxWidth()
.focusRequester(focusRequester),
value = address,
onValueChange = {
onChange(it)
if (!menuExpanded) {
menuExpanded = true
}
},
singleLine = true,
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Search,
keyboardType = KeyboardType.Text
),
keyboardActions = KeyboardActions(onSearch = {
menuExpanded = false
focusManager.clearFocus()
onSubmit()
}),
label = { Text(stringResource(R.string.address_bar_label), maxLines = 1) },
placeholder = { Text(address, maxLines = 1) },
trailingIcon = {
if (address.isNotEmpty()) {
IconButton(
onClick = {
focusRequester.requestFocus()
onChange("")
}) {
Icon(
Icons.Outlined.Clear,
contentDescription = stringResource(R.string.clear_address_content_description)
)
}
ExposedDropdownMenuBox(
modifier = Modifier.fillMaxWidth(),
expanded = menuExpanded,
onExpandedChange = { menuExpanded = it }) {
OutlinedTextField(
modifier = Modifier
.fillMaxWidth()
.focusRequester(focusRequester),
value = address,
onValueChange = {
onChange(it)
if (!menuExpanded) {
menuExpanded = true
}
},
singleLine = true,
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Search,
keyboardType = KeyboardType.Text
),
keyboardActions = KeyboardActions(onSearch = {
menuExpanded = false
focusManager.clearFocus()
onSubmit()
}),
label = { Text(stringResource(R.string.address_bar_label), maxLines = 1) },
placeholder = { Text(address, maxLines = 1) },
trailingIcon = {
if (address.isNotEmpty()) {
IconButton(
onClick = {
focusRequester.requestFocus()
onChange("")
}) {
Icon(
Icons.Outlined.Clear,
contentDescription = stringResource(R.string.clear_address_content_description)
)
}
}
)
}
)

if (matchingAddresses.isNotEmpty()) {
ExposedDropdownMenu(
modifier = Modifier.testTag("address_dropdown"),
expanded = menuExpanded, onDismissRequest = { menuExpanded = false }) {
matchingAddresses.forEach { address ->
DropdownMenuItem(onClick = {
menuExpanded = false
focusManager.clearFocus()
onChange(address)
onSubmit()
}) {
Text(address)
}
if (matchingAddresses.isNotEmpty()) {
ExposedDropdownMenu(
modifier = Modifier.testTag("address_dropdown"),
expanded = menuExpanded, onDismissRequest = { menuExpanded = false }) {
matchingAddresses.forEach { address ->
DropdownMenuItem(onClick = {
menuExpanded = false
focusManager.clearFocus()
onChange(address)
onSubmit()
}) {
Text(address)
}
}
}
}

Spacer(Modifier.width(8.dp))

FavouriteButton(
modifier = Modifier
.align(Alignment.CenterVertically)
.padding(top = 8.dp),
isFavouriteLocation = isFavouriteLocation,
addFavourite = onAddFavouriteClick,
deleteFavourite = onDeleteFavouriteClick
)
}

val extraTextHeight = 20.dp
Expand Down Expand Up @@ -165,7 +145,6 @@ private fun AddressAreaPreview() {
helper = AddressHelper.None,
error = AddressError.None,
matchingAddresses = listOf("Address 1", "VERY VERY VERY VERY VERY LONG ADDRESS"),
isFavouriteLocation = true
)
}
}
Expand Down Expand Up @@ -231,40 +210,4 @@ private fun HelperText(modifier: Modifier = Modifier, message: String) {
style = MaterialTheme.typography.body1,
fontWeight = FontWeight.Bold
)
}

@Composable
private fun FavouriteButton(
modifier: Modifier = Modifier,
isFavouriteLocation: Boolean,
deleteFavourite: () -> Unit,
addFavourite: () -> Unit
) {
IconButton(
modifier = modifier,
onClick = {
if (isFavouriteLocation) {
deleteFavourite()
} else {
addFavourite()
}
}
) {
if (isFavouriteLocation) {
Icon(
modifier = Modifier.size(32.dp),
imageVector = Icons.Outlined.Bookmark,
contentDescription = stringResource(R.string.delete_favourite_button_content_description),
tint = MapcodeColor.addFavouritesButton()
)
} else {
Icon(
modifier = Modifier.size(32.dp),
imageVector = Icons.Outlined.BookmarkAdd,
contentDescription = stringResource(R.string.add_favourite_button_content_description),
tint = MapcodeColor.addFavouritesButton()
)
}
}

}
Loading

0 comments on commit cd50839

Please sign in to comment.