Awful / Awful.app

Something Awful Forums browser for iOS
https://forums.somethingawful.com/showthread.php?threadid=3837546&perpage=40&noseen=1
137 stars 44 forks source link

Fix for copying GIFs to paste into other apps #1077

Closed dfsm closed 3 years ago

dfsm commented 3 years ago

Hed: "https://forums.somethingawful.com/showthread.php?threadid=3762868&perpage=40&noseen=1&pagenumber=323#post512491619

Both the image and the quoted one, if I long press and copy, then paste into iMessage, only the first frame will send over iMessage.

I feel like sometimes I can get it to transfer the full thing? Obviously copying the URL will cause the other communicant to fetch the image but I used to be able to paste in."

Some notes on this:

  1. I'm working on a version of ImageViewController that uses Nuke (in addition to FLAnimatedImage) because it feels like it's downloading the image every time an image is viewed. Pretty close with that, but posting this fix as its own thing for now.
  2. I've never seen "Preview Image" while using the app and I couldn't find any references to it using code search. So I deleted that block from ImageViewController. I can put it back if need be
  3. My CopyImageActivity has an empty init. Didn't seem worth initialising variables that I'm guaranteed to have by that point. I tried to limit the passing of imageURL and data into multiple functions. Now they're only passed once. Seems good to me but maybe it's bad. I added a guard to be doubly sure, but that may be redundant
  4. I'm not sure if CopyURLActivity is required at all? The default Copy option copies the URL anyway? We do in fact need it
  5. I went down a rabbit hole of using LinkPresentation and LPLinkMetadata, because I liked the way (I thought) it showed file types and sizes. I spent ages on it, because it doesn't do it for the Mr Freeze GIF in the issue description. Turns out that the file size and type show up even without LinkPresentation - passing a URL in the activity items is enough. It works for every image except the one I was constantly checking. Bah!

Edit: Ah, I see that I've changed the behaviour of "Copy" for static images.

Will update so that there are only two options: Copy and Copy URL. Copy will copy the image data

Edit 2: All done 🎉

nolanw commented 3 years ago

@dfsm thank you! This looks great. Don't mind my tidying up, just noticed some Swift 3-era bits while I was in the area.

I went ahead and implemented your todo about proper file types, and changed it to look at the data itself to determine type instead of looking at the URL extension (which can lie). If you're curious about file type stuff on iOS, this video is a good intro: https://developer.apple.com/videos/play/tech-talks/10696/ but if it's completely uninteresting, I understand :)