App icon indicating copy to clipboard operation
App copied to clipboard

[$2000] Add support for copy/pasting images on iOS

Open roryabraham opened this issue 1 year ago • 80 comments

slack proposal: https://expensify.slack.com/archives/C01GTK53T8Q/p1714239125412939

Feature Request: Add support for pasting images on iOS.

Problem

One of the most common flows for sharing images on iOS is to copy the image somewhere and paste it somewhere else, and NewDot does not support that flow. For example, I wanted to share an image I found on Google in New Expensify. The first thing I did was copy the image to my clipboard, but when I long-pressed on the composer to try and paste that image, the only option available was AutoFill. This left me with two more less desirable options:

  • copy the URL to the image, then write that URL in a markdown comment with inline image syntax (this was the next thing I tried, and it actually didn't work for the URL I had)
  • save the image to my photos, then upload it to New Expensify. This is less ideal because it pollutes my photos gallery with something I don't want to keep there.

This was a very basic flow that did not work very well at all, and it was a frustrating experience. It's table-stakes for any chat app.

Solution

Implement support for pasting images on iOS.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0195bbb40518505764
  • Upwork Job ID: 1790820991593271296
  • Last Price Increase: 2024-07-09
Issue OwnerCurrent Issue Owner: @

roryabraham avatar Apr 29 '24 17:04 roryabraham

Triggered auto assignment to Contributor-plus team member for initial proposal review - @ahmedGaber93 (External)

melvin-bot[bot] avatar Apr 29 '24 17:04 melvin-bot[bot]

Triggered auto assignment to @sonialiap (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

melvin-bot[bot] avatar Apr 29 '24 17:04 melvin-bot[bot]

:warning: It looks like this issue is labelled as a New Feature but not tied to any GitHub Project. Keep in mind that all new features should be tied to GitHub Projects in order to properly track external CAP software time :warning:

melvin-bot[bot] avatar Apr 29 '24 17:04 melvin-bot[bot]

Triggered auto assignment to Design team member for new feature review - @dubielzyk-expensify (NewFeature)

melvin-bot[bot] avatar Apr 29 '24 17:04 melvin-bot[bot]

I don't think we need any design review here

roryabraham avatar Apr 29 '24 19:04 roryabraham

Proposal

Please re-state the problem that we are trying to solve in this issue.

Add images copy/paste in iOS.

What is the root cause of that problem?

New feature.

What changes do you think we should make in order to solve the problem?

Add a new option "Paste image" in the + menu of chats, which will show only when there's an image copied in the clipboard.

Clicking on this option will open the attachment modal with the image.

const [imageToBePasted, setImageToBePasted] = useState('')

useEffect(() => {
    Clipboard.getString().then((data) => {
        if (/\.(jpg|png|jpeg|svg)(\?.*)?$/.test(data)) {
            setImageToBePasted(data);
        }
    });
})

Like we have displayFileInModal, we'll add displayFileInModalUsingUrl which will have url of the copied image as input.

New option in attachment picker:

if (imageToBePasted) {
    menuItems.push({
        icon: Expensicons.Paperclip,
        text: 'Paste image',
        onSelected: () => {
            if (Browser.isSafari()) {
                return;
            }
            displayFileInModalUsingUrl(imageToBePasted)
    }})
}

https://github.com/Expensify/App/assets/35566748/c89ba805-db4e-4aba-8b85-45c0a2347eb6

Note that the above code is not extensive, I had to do more changes locally to make it work.

ShridharGoel avatar Apr 30 '24 07:04 ShridharGoel

Love this ticket. As for the solution, I kinda find it weird to trigger the "paste" permission on (+) click. Does this only work when you have copied a picture? What happens if you copy text?

In other apps, and even for Expensify Web and MacOS, you can paste a picture into the actual compose bar text input which to me feels more natural than to click the (+) button. Thoughts? cc @Expensify/design

dubielzyk-expensify avatar Apr 30 '24 07:04 dubielzyk-expensify

Does this only work when you have copied a picture? What happens if you copy text?

This option would only show when we have an image URL in the clipboard.

"paste" permission

That is needed because we want to get the clipboard content.

ShridharGoel avatar Apr 30 '24 09:04 ShridharGoel

you can paste a picture into the actual compose bar text input

That might not be feasible in iOS. Maybe we can modify the above shown flow instead?

ShridharGoel avatar Apr 30 '24 09:04 ShridharGoel

🤔 Also, what about Android to maintain cross-platform consistency given @Beamanator's recent discovery here on Rory's OG issue for this:

I did figure out that on an android device, you can go to chrome, search for an image, press & hold, and copy to the clipboard -> so shouldn't we make sure this is possible on our android app too? 👍

trjExpensify avatar Apr 30 '24 09:04 trjExpensify

100% agree, I find it super bizarre to override the default + behavior here. We should definitely not do that.

Why can't you just paste into the compose box as if you were pasting text, and then that triggers the paste dialog?

shawnborton avatar Apr 30 '24 12:04 shawnborton

When someone adds an image link in the input box, we can open the attachment modal with the image. But what if the user just wants to send the link itself? Should we show a modal with the option to add the image as an attachment or just keep it as a link?

ShridharGoel avatar Apr 30 '24 12:04 ShridharGoel

Well if a link was on your clipboard, I would think you would just paste the link. But if an image was on your clipboard, then it makes sense to trigger the modal window.

shawnborton avatar Apr 30 '24 12:04 shawnborton

When I check the clipboard content after copying an image on iOS, it just shows the link.

ShridharGoel avatar Apr 30 '24 13:04 ShridharGoel

@ShridharGoel Thanks for the proposal.

I think pasting the image from the URL in the clipboard seem a workaround, because when we copied the image, we click "copy image" not "copy image address", so we may need to handle the image as fileObject or base64 string.

Also, your proposal doesn't have how we will detect onPasteFile on the normal case by long click on the input then click paste.

ahmedGaber93 avatar Apr 30 '24 22:04 ahmedGaber93

The paste to compose bar is how most apps on iOS works. It works like this on Messages, Telegram, and Signal. So I suggest we do that. Like Shawn said, let's trigger the modal window like we do on web/mac os.

dubielzyk-expensify avatar Apr 30 '24 23:04 dubielzyk-expensify

The paste to compose bar is how most apps on iOS works. It works like this on Messages, Telegram, and Signal. So I suggest we do that. Like Shawn said, let's trigger the modal window like we do on web/mac os.

Totally agree.

dannymcclain avatar May 02 '24 14:05 dannymcclain

Yes, paste should appear on the native context menu that appears when you double-tap on the composer input.

roryabraham avatar May 06 '24 21:05 roryabraham

@sonialiap, @ahmedGaber93, @roryabraham Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] avatar May 10 '24 18:05 melvin-bot[bot]

@sonialiap, @ahmedGaber93, @roryabraham Still overdue 6 days?! Let's take care of this!

melvin-bot[bot] avatar May 14 '24 18:05 melvin-bot[bot]

@roryabraham should this issue be external or internal? Are we looking for contributors to build this or is thing something you're working on?

sonialiap avatar May 14 '24 22:05 sonialiap

It should be external - not sure why it appears no upwork job has been created...

roryabraham avatar May 15 '24 19:05 roryabraham

Job added to Upwork: https://www.upwork.com/jobs/~0195bbb40518505764

melvin-bot[bot] avatar May 15 '24 19:05 melvin-bot[bot]

Current assignee @ahmedGaber93 is eligible for the External assigner, not assigning anyone new.

melvin-bot[bot] avatar May 15 '24 19:05 melvin-bot[bot]

Upwork job price has been updated to $500

melvin-bot[bot] avatar May 15 '24 19:05 melvin-bot[bot]

bumping to $500 to try and get some fresh proposals

roryabraham avatar May 15 '24 19:05 roryabraham

Waiting on proposals

ahmedGaber93 avatar May 18 '24 19:05 ahmedGaber93

Waiting on proposals

ahmedGaber93 avatar May 21 '24 04:05 ahmedGaber93

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

melvin-bot[bot] avatar May 22 '24 16:05 melvin-bot[bot]

With our high focus on reliability over new features, this is kind of taking a back-seat. However, I'd say this is reasonably high priority still because it has a high impact on UX, particularly on iOS for P2P / chat uses.

So I'm going to bump the bounty.

roryabraham avatar May 23 '24 20:05 roryabraham