Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${MAPS_API_KEY}" />
<!-- Google Maps' Play Services module still uses Apache HTTP, which Android 9+ no longer
loads by default: without this the map crashes with NoClassDefFoundError
org/apache/http/ProtocolVersion (seen on the CI emulator, #391). Not required, so
devices without the library can still install the app. -->
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import com.android.polybazaar.listing.model.ListingRules.MAX_TITLE_LENGTH
import com.android.polybazaar.listing.model.ListingType
import com.android.polybazaar.listing.viewmodel.ListingFormUiState
import com.android.polybazaar.listing.viewmodel.ListingFormViewModel
import com.android.polybazaar.map.model.Coordinates
import java.time.LocalDate
import kotlinx.coroutines.Dispatchers

Expand Down Expand Up @@ -147,6 +148,14 @@ class ListingFormActions(
/** Returns the URI the camera app writes the photo to, or null when none can be created. */
val startTakingPhoto: (retakeIndex: Int?) -> Uri? = { null },
val finishTakingPhoto: (saved: Boolean) -> Unit = {},
/** Sets the location to the point confirmed on the map. */
val onConfirmLocation: (Coordinates) -> Unit = {},
val onLocationNameChange: (String) -> Unit = {},
/** The location's name field lost focus: a missing name is flagged from then on. */
val onLocationNameFieldLeft: () -> Unit = {},
val onClearLocation: () -> Unit = {},
/** Asks for the lender's position, for the map picker to open there. */
val onLocateLender: () -> Unit = {},
val onSave: () -> Unit = {},
)

Expand All @@ -168,6 +177,11 @@ internal fun listingFormActions(viewModel: ListingFormViewModel) =
onStoredPhotoShown = viewModel::loadStoredPhoto,
startTakingPhoto = viewModel::startTakingPhoto,
finishTakingPhoto = viewModel::finishTakingPhoto,
onConfirmLocation = viewModel::setLocationPoint,
onLocationNameChange = viewModel::updateLocationName,
onLocationNameFieldLeft = viewModel::leaveLocationNameField,
onClearLocation = viewModel::clearLocation,
onLocateLender = viewModel::locateLender,
onSave = viewModel::save,
)

Expand Down Expand Up @@ -201,9 +215,14 @@ fun CreateListingScreen(
* [ListingType]: items get a daily price and a refund value, services an hourly price.
*
* @param actions called when the user edits the form, adds photos or creates the listing.
* @param locationMap the location picker's map, replaced in tests.
*/
@Composable
fun CreateListingContent(uiState: ListingFormUiState, actions: ListingFormActions) {
fun CreateListingContent(
uiState: ListingFormUiState,
actions: ListingFormActions,
locationMap: ListingLocationMap = DefaultListingLocationMap,
) {
Column(
modifier =
Modifier.fillMaxSize()
Expand All @@ -221,7 +240,7 @@ fun CreateListingContent(uiState: ListingFormUiState, actions: ListingFormAction
// The repository is still reading these photos, so none may be removed or replaced.
enabled = !uiState.isSaving,
)
ListingDetailsFields(uiState = uiState, actions = actions)
ListingDetailsFields(uiState = uiState, actions = actions, locationMap = locationMap)
}
CreateListingFooter(uiState = uiState, onCreate = actions.onSave)
}
Expand Down Expand Up @@ -296,7 +315,8 @@ internal fun ListingTypeSelector(
}

/**
* Title, description, price, category, for items the refund value, and the available days.
* Title, description, price, category, for items the refund value, the available days and the
* location.
*
* @param priceHint shown under the price, such as when a price change only applies to new bookings.
*/
Expand All @@ -305,6 +325,7 @@ internal fun ListingDetailsFields(
uiState: ListingFormUiState,
actions: ListingFormActions,
priceHint: String? = null,
locationMap: ListingLocationMap = DefaultListingLocationMap,
) {
val texts = formTextsFor(uiState.type)
FormField(
Expand Down Expand Up @@ -363,6 +384,7 @@ internal fun ListingDetailsFields(
// Not while saving: an edit form then shows the listing as saved, and would lose the change.
enabled = uiState.canEdit && !uiState.isSaving,
)
ListingLocationField(uiState = uiState, actions = actions, map = locationMap)
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Co-authored-by: Claude Code (Claude Fable 5.2)
// Co-authored-by: Claude Code (Claude Opus 5.5, Claude Fable 5.2)
package com.android.polybazaar.listing.ui

import androidx.activity.compose.BackHandler
Expand Down Expand Up @@ -110,6 +110,7 @@ fun EditListingScreen(
* @param onRetry loads the listing again after a failure.
* @param storedPhotoBytes the saved photos downloaded so far, by Storage path, for their
* thumbnails.
* @param locationMap the location picker's map, replaced in tests.
*/
@Composable
fun EditListingContent(
Expand All @@ -118,6 +119,7 @@ fun EditListingContent(
onBack: () -> Unit,
onRetry: () -> Unit,
storedPhotoBytes: Map<String, ByteArray> = emptyMap(),
locationMap: ListingLocationMap = DefaultListingLocationMap,
) {
Column(
modifier =
Expand Down Expand Up @@ -161,6 +163,7 @@ fun EditListingContent(
uiState = uiState,
actions = actions,
priceHint = stringResource(R.string.edit_listing_price_hint),
locationMap = locationMap,
)
}
EditListingFooter(uiState = uiState, onCancel = onBack, onSave = actions.onSave)
Expand Down
Loading
Loading