collect icon indicating copy to clipboard operation
collect copied to clipboard

Show recently created entities in Experimental Settings

Open seadowg opened this issue 1 year ago • 18 comments

Closes #5231 ~~Blocked by getodk/javarosa#691~~ Blocked by JavaRosa changes

This goes a bit further than the issue describes and adds an "entitiy browser" UI that can be accessed from Experimental settings. This will show entities created by forms. Entities are not "persisted" and you'll get a clean slate every time you restart the app.

One thing to note is that I decided to use the AndroidX Navigation library to implement the browser UI (you can see the switch in 73a15c83f3e8edf7034b1e37885b59b77aba9c3f). This was an experiment to see how it felt, and I ended up really liking it! Interested to know what others think.

What has been done to verify that this works as intended?

New tests and verified manually.

Why is this the best possible solution? Were any other approaches considered?

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Should just add the ability to view created entities. I think doing a quick check on form entry (filling, saving, editing forms etc) in general would be good, but we don't need to check entity forms themselves as this is still experimental and something we'll be playing with later.

Before submitting this PR, please make sure you have:

  • [x] run ./gradlew checkAll and confirmed all checks still pass OR confirm CircleCI build passes and run ./gradlew connectedDebugAndroidTest locally.
  • [x] verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • [x] verified that any new UI elements use theme colors. UI Components Style guidelines

seadowg avatar Sep 23 '22 15:09 seadowg

Couple of very small changes to consider. I think this is ready for a mini regression pass around form entry!

lognaturel avatar Oct 06 '22 23:10 lognaturel

I’d like to double-check the expected results -when new entities should appear in "experimental". I’m able to view created entities in "experimental" when the form is:

  • finalized and sent
  • finalized and not sent (flight mode on)

The entity is not created if the form is saved but not finalized. Are those results the expected results?

dbemke avatar Oct 11 '22 11:10 dbemke

Are those results the expected results?

Yup that looks correct to me! Entities are only created once the form is initialized.

seadowg avatar Oct 11 '22 13:10 seadowg

Entities are not "persisted" and you'll get a clean slate every time you restart the app.

@seadowg Entities that were saved and visible in experimental settings disappear after killing the app. If I just close the app by tapping device back button, the saved entities are still in experimental settings. By restarting the app you mean e.g. removing/downloading the app?

dbemke avatar Oct 11 '22 13:10 dbemke

By restarting the app you mean e.g. removing/downloading the app?

No I mean killing the app and starting it up again. I'd usually refer to "removing/downloading the app" as "reinstalling".

seadowg avatar Oct 11 '22 13:10 seadowg

Problem description

When a user finalizes and saves an empty one question enity form, the app crashes.

Steps to reproduce the problem

  1. Open one question entity form. one-question-entity.xml.txt
  2. Don’t fill anything.
  3. Tap next.
  4. Finalize and save the form.

dbemke avatar Oct 11 '22 14:10 dbemke

@dbemke good catch. I'll look at fixing that.

seadowg avatar Oct 12 '22 09:10 seadowg

From another conversation:

  • Currently empty values should save as blank strings for those entity properties.
  • Once we have entity updates there will be a difference between non-relevant form fields and blank relevant form fields. Non-relevant form fields will be no-ops (so the current entity property value will be used) and blank relevant form fields will result in updates to clear out the corresponding entity property.

The update behavior may not matter now but wanted to include it for completeness!

lognaturel avatar Oct 12 '22 20:10 lognaturel

I have forms that feed into two datasets, people and shovels. I see all of the entities when I navigate to people AND when I navigate to shovels.

lognaturel avatar Oct 12 '22 21:10 lognaturel

shovel_registration.xml.txt

I had a look at the shovel form @lognaturel mentioned and there are different results for the first entity created after downloading a project and following entities. In the shovel form I filled in:

  • blue 22cm (first submission after downloading a project)
  • purple 33cm
  • black 66cm In experimental settings for the first submission there is the color, but for the following submissions length is visible. There is also a difference on Central- the first submission after downloading a project has "meta-entity-label”. Is this the way submissions should be shown? entities shovelscentral

dbemke avatar Oct 13 '22 08:10 dbemke

When a user finalizes and saves an empty one question enity form, the app crashes.

I'll make changes to fix this in JavaRosa so blocking this PR on that.

I have forms that feed into two datasets, people and shovels. I see all of the entities when I navigate to people AND when I navigate to shovels.

I'm guessing it's two forms rather than one form right? Yeah, it looks I missed actually filtering entities by dataset! I knew this had felt too easy. Definitely a peril of switching back and forth between the two projects...

In experimental settings for the first submission there is the color, but for the following submissions length is visible.

We're only showing the "first" property right now for each entity. It could be that "first" ends up a bit random though in this case. In hindsight, this feels too confusing for multiple property entities (as it really looks like something is going wrong here). I'll have a look at doing the easiest thing for this PR to make it nicer - either making sure always show the same property, or showing all properties. I want to make sure I'm not spending too much time perfecting all this seeing as it's very much a debug tool. We can still do another pass on it before release.

There is also a difference on Central- the first submission after downloading a project has "meta-entity-label”. Is this the way submissions should be shown?

That's very strange. You should be able to see the value Central is using in the actual submission XML (in Collect's instances dir) in /data/meta/entities:entity/entities:label. Are the values missing there as well? Slack me if you have trouble reading the submissions.

seadowg avatar Oct 13 '22 09:10 seadowg

In xml entities:label is filled in only for the first submission. shovelsxml

dbemke avatar Oct 13 '22 09:10 dbemke

In xml entities:label is filled in only for the first submission.

Very strange. I'll see if I can reproduce this.

seadowg avatar Oct 13 '22 10:10 seadowg

Ok it looks like both the different ordering of properties and the missing label are to do with form def caching. @dbemke @srujner an interesting thing I always forget is that Collect will cache the parsed form definition after loading it the first time. This means that we sometimes see bugs that happen only on the first or not on the first time you load the form. I've fixed the properties (and we're now showing all of them to make it easier to see what's going on) and will look into what's happening with the label next.

seadowg avatar Oct 13 '22 12:10 seadowg

I haven't been able to immediately find a reason that entities:label isn't being populated for forms filled with a cached form def. As far as I understand though, that shouldn't be a special case. The form def just uses existing (non entity specific) features for all that to work and that if that's not working, it's due to an existing bug in JavaRosa. I'm going to try making a non-entity form that demonstrates this.

seadowg avatar Oct 13 '22 12:10 seadowg

@dbemke @srujner yeah the missing label is an existing problem (https://github.com/getodk/javarosa/issues/695). That shouldn't block this PR. It is something we'll want to fix before release however, as it really messed up entities.

seadowg avatar Oct 13 '22 13:10 seadowg

I checked different Android versions and in Android 8.1, 10, 11, 12, 13 the missing part in entities:label for following submissions in xml is present in all Android versions. In case of entities shown in experimental part:

  • Android 8.1, 10, 11, 12 show color (for the first submission), length (fot the following submissions)
  • Android 13 shows color for all the submissions android13entities

dbemke avatar Oct 13 '22 13:10 dbemke

@dbemke sorry I hadn't actually committed all my changes for showing the properties properly. Nice catch. That's fixed now.

seadowg avatar Oct 13 '22 14:10 seadowg

@dbemke rebuilding should now fix the crash when finalizing a form without answer entity questions. The label problem (https://github.com/getodk/javarosa/issues/695) still exists, but we'll be fixing that separately as it's not specific to entities.

seadowg avatar Oct 22 '22 11:10 seadowg

@seadowg Should /data/meta/entities:entity/entities:label be fixed now or it isn't included in the PR?

dbemke avatar Nov 03 '22 08:11 dbemke

@dbemke it's not included in this PR. That issue is tracked at #javarosa/695.

seadowg avatar Nov 03 '22 09:11 seadowg

I’ve added many entities and the entities screen is scrollable but I’m not able to scroll down to the bottom of list of entities. The last entity I can see is a half of the second entity from the button (both in horizontal and vertical view).

dbemke avatar Nov 04 '22 12:11 dbemke

At the moment, everything has been checked by us, but we're waiting for the fix for the issue with scrolling. Let us now @seadowg when this will be ready. For now, we will remove the "Needs testing" label.

srujner avatar Nov 08 '22 15:11 srujner

@srujner @dbemke I've fixed the problem with scrolling the list and fixed conflicts so please finish testing.

grzesiek2010 avatar Nov 08 '22 21:11 grzesiek2010

Tested with Success!

Verified on Android 10

Verified Cases:

  • the issues with an empty answer and scrolling down the list of entities are no longer reproducing
  • finalizing a new form and when form is edited
  • two different forms with the same name in a dataset
  • scrolling entities
  • finalizing a finalized form
  • finalizing a form without sending and afterwards deleting the form
  • killing the app
  • killing the app and sending again already sent forms
  • changing the dataset name in a new version of the form
  • hide old form versions disabled + finalizing different version of the same form with different dataset name
  • dark and light mode
  • don’t keep activities enabled/disabled
  • minimizing the app, rotating and locking the screen
  • different Form Management settings

dbemke avatar Nov 09 '22 14:11 dbemke

Tested with Success!

Verified on Android 13

srujner avatar Nov 09 '22 14:11 srujner