-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add ability to delete reference layers #6175
Conversation
c2047c9
to
b8128b7
Compare
9e298d9
to
8658d99
Compare
8658d99
to
0ef5e80
Compare
maps/src/main/java/org/odk/collect/maps/layers/OfflineMapLayersPickerViewModel.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f345b6a
to
620f902
Compare
620f902
to
bac2b71
Compare
maps/src/main/java/org/odk/collect/maps/layers/OfflineMapLayersPicker.kt
Outdated
Show resolved
Hide resolved
maps/src/main/java/org/odk/collect/maps/layers/OfflineMapLayersPicker.kt
Outdated
Show resolved
Hide resolved
maps/src/main/java/org/odk/collect/maps/layers/OfflineMapLayersPicker.kt
Outdated
Show resolved
Hide resolved
maps/src/main/java/org/odk/collect/maps/layers/OfflineMapLayersPicker.kt
Show resolved
Hide resolved
return oldItem == newItem | ||
} | ||
} | ||
private val asyncListDiffer = AsyncListDiffer(this, diffUtil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never seen AsyncListDiffer
before. Is this just a performance optimization, or does it not working with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would work without it. I've added it for performance optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks from the docs like we could just be using ListAdapter
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but the sample below in https://developer.android.com/reference/androidx/recyclerview/widget/ListAdapter shows that it doesn't work out of the box. There is a DiffUtil.ItemCallbac
similar to what I've implemented.
maps/src/main/java/org/odk/collect/maps/layers/OfflineMapLayersStateViewModel.kt
Outdated
Show resolved
Hide resolved
import org.odk.collect.androidshared.livedata.MutableNonNullLiveData | ||
import org.odk.collect.androidshared.livedata.NonNullLiveData | ||
|
||
class OfflineMapLayersStateViewModel(checkedLayerId: String?) : ViewModel() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to do have anything to do with layers now right? It could be named something generic and moved to lists
. I'm also wondering if we could reduce this to just the "checked"/select state and use MultiSelectViewModel
to track the expanded state. I think we'd just need to modify the latter to use String IDs instead of Long (which is probably better anyway).
What do you think? Better as a follow up PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better as a follow up PR?
Yes for now I've moved it to #6174 (comment)
maps/src/test/java/org/odk/collect/maps/layers/OfflineMapLayersPickerTest.kt
Outdated
Show resolved
Hide resolved
|
||
scheduler.flush() | ||
|
||
onView(withRecyclerView(R.id.layers).atPositionOnView(1, R.id.arrow)).perform(click()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these RecyclerView
Espresso assertions and actions make the tests pretty hard to read, and you'll see there are quite a lot of changes if you auto format the file due to the line lengths. Maybe you can pull out some helpers to try and make them a little cleaner. Remember that the result of an onView
call can be pulled out to a local variable which can save a bunch of repetition and line length. The chained called can also be stacked on new lines like:
onView(...
.atPositionOnView(...
.check(...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about that and I'm on it now... if it's the last missing thing please merge and I will add it along with other improvements #6174 (comment)
@grzesiek2010 really liking where this has ended up! Just a few more comments with some questions and suggested tweaks. |
e4aeeed
to
d92908c
Compare
d92908c
to
0248104
Compare
This looks great! I've left a couple of comments about some small tweaks, but nothing that really blocks this if you just want to follow up with them. |
Closes #5850
Closes #6183
Why is this the best possible solution? Were any other approaches considered?
The issue does not describe how the confirmation dialog (when deleting layers) should look like but the one I saw on Figma was pretty complex. I'm not sure if we want/should have the complex one so for now I've implemented something simple. If we want to change it we can do that in a separate pull request:
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?
Once this pr is merged it's time to test everything (adding/removing/setting offline layers). Please read the issues marked as mbtiles import and verify the new functionality.
Do we need any specific form for testing your changes? If so, please attach one.
No.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still passDateFormatsTest