Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LocationOfInterest display name #2047

Merged
merged 7 commits into from
Nov 7, 2023

Conversation

rachaprince
Copy link

Fixes #1559

Update the way LOI customId and properties fields are used to display the LOI

Screenshot 2023-11-06 at 1 25 14 PM Screenshot 2023-11-06 at 12 51 53 PM Screenshot 2023-11-06 at 1 26 49 PM @gino-m PTAL?

* Include properties field in Android Loi dataclasses.
* Propogate customId field to local database.
* Remove caption field.
Copy link
Collaborator

@gino-m gino-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So excited to finally see this working! A few nits, overall LGTM!

val isOpportunistic: Boolean = false
val isOpportunistic: Boolean = false,
/** Custom map of properties for this LOI. Corresponds to the properties field in GeoJSON */
val properties: Map<String, Any>? = null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, to avoid dual nil states (empty vs null), can we make this non-null and default to empty map in the local and remote Converters if not set in persistent storage?

var map = mutableMapOf<String, Any>()
try {
val type = object: TypeToken<Map<String, Any>>(){}.type
map = Gson().fromJson(
Copy link
Collaborator

@gino-m gino-m Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JSunde introduced proto (de)serialization for local storage. Can we use that instead of packing/unpacking Json ourselves?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this referring to JsonObjectTypeConverter?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's being done in GeometryWrapperTypeConverter usingProtoBuf.encodeToByteArray(). Can we use the same here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm so using ProtoBuf.encodeToByteArray() throws a Serialization Exception because kotlin doesn't have a serializer for the Any class http://screen/H4ovCcLxGR3MvZA

This medium article suggests either creating a custom serializer, or defining a stricter type, or using Gson. https://medium.com/@kerem_balic/serializer-for-class-any-not-found-how-do-we-fix-it-in-kotlin-cc196d92b7b3

What are your thoughts?

Copy link
Collaborator

@gino-m gino-m Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, sorry I hadn't thought of that. Since we're adding properties to the model, perhaps now would be a good time to add stricter typing? Afaik there are only two possible types for properties values: String and Number.

Assuming the proto serializer can handle generics, can we define an interface PropertyValue<T> with one member T value, which is implemented by NumberValue: PropertyValue<Number> and StringValue: PropertyValue<String>?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We chatted. We can make this change in a follow-up PR!

Copy link
Collaborator

@gino-m gino-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, thanks for the fix!

@gino-m gino-m changed the title Fix LocationOfInterest display name. Fix LocationOfInterest display name Nov 7, 2023
@gino-m
Copy link
Collaborator

gino-m commented Nov 7, 2023

@rachaprince Looks like unit tests are failing. Relevant build log lines:

com.google.android.ground.ui.home.mapcontainer.LoiCardUtilTest > testArea_whenCustomIdIsNotAvailable_usesPropertiesId FAILED
    com.google.common.truth.ComparisonFailureWithFacts at LoiCardUtilTest.kt:66

383 tests completed, 1 failed

> Task :ground:testDevDebugUnitTest FAILED

@codecov-commenter
Copy link

Codecov Report

Merging #2047 (e9f1baf) into master (172107e) will increase coverage by 0.18%.
The diff coverage is 81.81%.

@@             Coverage Diff              @@
##             master    #2047      +/-   ##
============================================
+ Coverage     48.29%   48.47%   +0.18%     
- Complexity     1191     1201      +10     
============================================
  Files           317      318       +1     
  Lines          6508     6531      +23     
  Branches        644      648       +4     
============================================
+ Hits           3143     3166      +23     
+ Misses         3032     3029       -3     
- Partials        333      336       +3     
Files Coverage Δ
.../src/main/java/com/google/android/ground/Config.kt 0.00% <ø> (ø)
...und/model/locationofinterest/LocationOfInterest.kt 100.00% <100.00%> (ø)
...round/model/mutation/LocationOfInterestMutation.kt 100.00% <100.00%> (ø)
...oid/ground/persistence/local/room/LocalDatabase.kt 100.00% <ø> (ø)
...d/persistence/local/room/converter/ConverterExt.kt 77.60% <100.00%> (+0.44%) ⬆️
...ence/local/room/entity/LocationOfInterestEntity.kt 100.00% <100.00%> (ø)
...al/room/entity/LocationOfInterestMutationEntity.kt 93.75% <100.00%> (+0.41%) ⬆️
.../persistence/remote/firebase/schema/LoiDocument.kt 100.00% <100.00%> (ø)
...droid/ground/ui/common/LocationOfInterestHelper.kt 62.50% <0.00%> (-6.25%) ⬇️
...d/ground/ui/home/mapcontainer/cards/LoiCardUtil.kt 72.41% <77.77%> (+18.84%) ⬆️
... and 2 more

@gino-m gino-m merged commit be8105f into master Nov 7, 2023
@gino-m gino-m deleted the rachaprince/fix-loi-customid-consistency branch November 7, 2023 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

LocationOfInterest caption and customId inconsistently implemented
3 participants