-
-
Notifications
You must be signed in to change notification settings - Fork 28
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 support for a custom Map marker for the Case List #2935
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
@ctsims Can you advise on this ? |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
app/src/org/commcare/gis/EntityMapActivity.java (2)
134-142
: Add error handling and make icon size configurable.While the implementation is correct, consider these improvements:
- Add error handling for image loading failures
- Make the icon size configurable
+ private static final int DEFAULT_MARKER_SIZE = 120; private BitmapDescriptor getEntityIcon(Entity<TreeReference> entity) { if (imageFieldIndex != -1) { String jrUri = String.valueOf(entity.getData()[imageFieldIndex]); + if (jrUri == null || jrUri.isEmpty()) { + return null; + } try { - Bitmap bitmap = MediaUtil.inflateDisplayImage(this, jrUri, 120, 120, true); + Bitmap bitmap = MediaUtil.inflateDisplayImage(this, jrUri, + DEFAULT_MARKER_SIZE, DEFAULT_MARKER_SIZE, true); if (bitmap != null) { return BitmapDescriptorFactory.fromBitmap(bitmap); } + } catch (Exception e) { + Log.e(TAG, "Error loading marker icon: " + jrUri, e); } } return null; }
55-57
: Consider making custom markers configurable.As discussed in the PR description, consider adding a custom setting to control this feature. This would prevent unexpected changes for existing projects that use icons in their case list.
Suggested approaches:
- Add a feature flag in the app settings
- Add a configuration in the suite's detail definition
- Add a global configuration through CommCare's app settings
Would you like me to provide a detailed implementation for any of these approaches?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/src/org/commcare/gis/EntityMapActivity.java
(6 hunks)
🔇 Additional comments (5)
app/src/org/commcare/gis/EntityMapActivity.java (5)
3-4
: LGTM! Clean imports and field declaration.The new imports and field declaration are well-organized and properly initialized.
Also applies to: 8-8, 16-17, 29-29, 31-31, 55-57
97-105
: LGTM! Clean implementation of image field detection.The method efficiently finds the image field index with early termination.
118-119
: LGTM! Clean marker setup with custom icon.The marker creation properly includes both title and custom icon.
157-164
: Add null check for map instance.The location permission handling is correct, but there's a potential NPE if
mMap
is null. Please refer to the previous review comment for the suggested fix.
84-84
: Consider handling dynamic field changes.The
imageFieldIndex
should be re-evaluated if the detail fields change during runtime.Run this script to check if detail fields can change during runtime:
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.
The code changes look correct to me, although I'm not sure how to test this functionality as I'm not familiar with the mapping activity. Is there a test app that I could use to test the functionality?
I used this app to do the same, you can navigate as |
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.
Found one little issue but otherwise the code looks good.
mMap.setMyLocationEnabled(false); | ||
} | ||
private void setMapLocationEnabled(boolean enabled) { | ||
if (mMap != null && ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) |
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 think the or-clause needs to be put in parentheses so it calculates before the and-clause, i.e.
if (mMap != null && (FINE || COARSE))
I hit a crash when testing where mMap was null but the if-block executed anyway
Summary
Applies a custom map marker on the "Map" Case list view when a detail field with template
image
is defined for the case list when the propertycc-enable-custom-map-marker
is set toyes
in app settings.Product Description
Image with default icon:
Image with a custom icon applied:
PR Checklist
Automated test coverage
None
Safety story
Tested locally for scenarios when an icon is defined for the case list and when it's not.
QA Note: View on Map case list view now supports a custom map marker and an appropriate test case should be added to verify it.
Release Note: Custom map marker support for Case list's "View on Map" feature.
Best reviewed commit by commit.