-
Notifications
You must be signed in to change notification settings - Fork 731
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
[Location sharing] Invisible text on map symbol #6688
Conversation
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
it would be handy to have screenshots for this fix 🙏 |
@@ -162,7 +163,7 @@ class MapTilerMapView @JvmOverloads constructor( | |||
pinDrawable?.let { drawable -> | |||
if (!safeMapRefs.style.isFullyLoaded || | |||
safeMapRefs.style.getImage(state.pinId) == null) { | |||
safeMapRefs.style.addImage(state.pinId, drawable) | |||
safeMapRefs.style.addImage(state.pinId, drawable.toBitmap()) |
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.
do we know why this behaviour is different?
addImage(drawable)
chains into BitmapUtils.getBitmapFromDrawable(drawable)
which in turn calls Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888)
whereas drawable.toBitmap()
calls Bitmap.createBitmap(width, height, config ?: Config.ARGB_8888)
I would have thought them to be equivalent? 🤔
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 wasn't curious enough to understand... Let me look at it to answer this question.
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.
After some investigation it seems the only difference I see is that in BitmapUtils.getBitmapFromDrawable()
they are creating a new drawable with Drawable drawable = constantState.newDrawable().mutate();
and then the bitmap is created from this new drawable. I suspect the Text part disappears due to this call. In the doc, it says density dependent properties may not be scaled well (https://developer.android.com/reference/android/graphics/drawable/Drawable.ConstantState#newDrawable()). Testing with following code leads to the same issue:
val bitmap = drawable.constantState?.newDrawable()?.toBitmap()
bitmap?.let { safeMapRefs.style.addImage(state.pinId, 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.
great to know, thanks for looking into it! 💯
I agree. I updated the description with captures. |
Type of change
Content
Convert the map symbol drawable to bitmap to be able to see text on it.
Motivation and context
Closes #6687
Screenshots / GIFs
Tests
Tested devices
Checklist