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

Using StickerView for stickers and emojis #234

Open
msroid opened this issue Apr 13, 2020 · 4 comments
Open

Using StickerView for stickers and emojis #234

msroid opened this issue Apr 13, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@msroid
Copy link

msroid commented Apr 13, 2020

Please use something like this for stickers and emojis.
Right now it's hard to resize and rotate stickers and specially emojis and there is no option for flipping them.

@lucianocheng
Copy link
Collaborator

@msroid I'll check this out.

Looks like they use a cool trick to keep the "corner buttons" consistent size here, at the very least we could apply that.

@lucianocheng
Copy link
Collaborator

@burhanrashid52 could you assign this to me? Thanks.

@lucianocheng
Copy link
Collaborator

Specifically they use a function called convertDpToPixel to convert the handle to a fixed pixel size using the system screen's DPI measurement. Basically forcing the re-size of the handle to a fixed number of pixels for every redraw.

@lucianocheng
Copy link
Collaborator

Ok, I took a closer look at this.

android-StickerView (the repo linked in the first comment) uses a different method for scaling stickers than us:

  • PhotoEditor scales stickers by adjusting the scaleX / scaleY values of the frame view that wraps the ImageView or TextView (for text and emojis). You can see this in MultiTouchListener.kt
  • android-StickerView sets scaleType to be ImageView.ScaleType.FIT_XY on it's images [1], then "scales" the x and y values manually on the ImageView.

Since android-StickerView sets the x and y values directly, they don't have a view tree where the image, handles, graphic frame, etc are all scaled. Since it's just the inner image that is scaled, the handles have the same scale "transformation matrix" per se, which means they don't need adjusting.

We could use this technique for ImageView types (stickers), but unfortunately, TextViews can't have FIT_XY set as ScaleType. So it wouldn't work for Text or Emoji. android-StickerView gets around this by changing the font / dp size of the text when scaling.

The android-StickerView technique is probably a superior solution, but it would require significant refactoring to use. Using the library directly probably isn't a good idea since hooking it into our callback system for other functionality would be difficult. The library also hasn't been updated in 5 years so I worry about long term maintenance.

Bottom Line: This is still a good idea, but it's not easy to implement. Will probably require one or two large refactorings (zoom and text / emoji frame logic) to implement. It's much more than just handle sizes.

[1] https://github.com/tonguetech/Android-StickerView/blob/master/src/main/java/com/knef/stickerview/StickerImageView.java#L48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants