Skip to content

Saving attachments - #352

Merged
tomholub merged 11 commits into
masterfrom
feature/issue-194-ability-to-download-plain-attachment
Jun 24, 2021
Merged

Saving attachments #352
tomholub merged 11 commits into
masterfrom
feature/issue-194-ability-to-download-plain-attachment

Conversation

@ekievsky

@ekievskyekievsky commented Jun 16, 2021

Copy link
Copy Markdown
Contributor

This PR adds Files Manager that allows app to save attachments to user's phone

close#194

Tests:

  • Added test for FilesManager to make sure that file was saved

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities
  • is documented clearly and usefully, or doesn't need documentation

@tomholub

Copy link
Copy Markdown
Collaborator
Does not need tests

It 100% needs tests but we don't have a good mechanism for writing tests yet, blocked on #307 in part

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume this is still a draft? If so, you can mark it as a draft:

image

@Kharchevskyi

Copy link
Copy Markdown
Contributor
Does not need tests

It 100% needs tests but we don't have a good mechanism for writing tests yet, blocked on #307 in part

#307 will unblock only possibility to write UI tests

@tomholub

Copy link
Copy Markdown
Collaborator
Does not need tests

It 100% needs tests but we don't have a good mechanism for writing tests yet, blocked on #307 in part

#307 will unblock only possibility to write UI tests

Yup - that's the type of tests that's the most valuable to me especially initially.

@tomholub

Copy link
Copy Markdown
Collaborator

Alternatively, how could this functionality be tested? (rendering a message with an attachment, then downloading the attachment)

@ekievsky

Copy link
Copy Markdown
ContributorAuthor

I presume this is still a draft? If so, you can mark it as a draft:

image

as I understood from issue description, on scope of a task I need to add downloading attachments to user's phone. Since the attachments come along with message I just implemented saving attachment to device.

@tomholub

Copy link
Copy Markdown
Collaborator

From looking at the code, it's not clear where does it integrate with the UI and how do I download an attachment to my device as a user. Where is the handling of the tap on the attachment to download it?

@ekievsky

Copy link
Copy Markdown
ContributorAuthor

so the UI handling is also in this scope, I'll add. Do I need to implement the details of attachment? I mean if it's PDF should I show in separate view that PDF file?

@tomholub

tomholub commented Jun 17, 2021

Copy link
Copy Markdown
Collaborator

Do I need to implement the details of attachment? I mean if it's PDF should I show in separate view that PDF file?

No, I'd just like to tap the attachment name to download the file, whatever the file is. No need a separate view.

@ekievsky

ekievsky commented Jun 17, 2021

Copy link
Copy Markdown
ContributorAuthor

should I show a toast that notifies user that the file was saved?

@tomholub

Copy link
Copy Markdown
Collaborator

should I show a toast that notifies user that the file was saved?

I think yes - for a user, visual feedback is good to have.

Added tests for files manager;

}

public override func layoutDidFinish() {

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kharchevskyi here is the fix that I was talking about

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check next commit with better approach for this. Please confirm this one is works for you

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good, will test the app now

@tomholub

Copy link
Copy Markdown
Collaborator

I'm having trouble building this, please merge changes from master into here and resolve conflicts. Thanks!

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After I save the attachment, where can I find it?

I have tried to save an image, but can't find it anywhere on my phone. I would expect it to be in Downloads.

Best would be if after I download the attachment, it would pop up a modal that says

Attachment downloaded
[open now]
[close]

Where I could click open and iOS would figure out which app to open it with (like on a desktop).

But that's not strictly necessary, it would be for now enough to at least tell the user where to find their attachment so that they can open it themselves.

"message_compose_secure" = "Compose Secure Message";
"message_unknown_sender" = "(unknown sender)";
"message_missed_subject" = "No subject";
"message_attachment_saved_successfully" = "Attachemt was saved";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here

@tomholub
tomholub marked this pull request as draft June 21, 2021 13:33
@ekievsky

Copy link
Copy Markdown
ContributorAuthor

For now files store in Documents folder which iOS creates for every app. In order to save file to Downloads(you may access it using Files native app) we need to use UIDocumentInteractionController, that's the separate view that allows user to save file to Downloads and can be opened using Files native app in future.

@tomholub

Copy link
Copy Markdown
Collaborator

For now files store in Documents folder which iOS creates for every app

As a user, how can I open the file after it downloads?

@ekievsky

Copy link
Copy Markdown
ContributorAuthor

For now there is no way, I though we will add files reading inside of app in future.

@tomholub

tomholub commented Jun 23, 2021 via email

Copy link
Copy Markdown
Collaborator

@ekievsky

Copy link
Copy Markdown
ContributorAuthor

Other email clients have theirs own readers. But I got your point I'll add this documents reader. Thanks

@tomholub

tomholub commented Jun 24, 2021 via email

Copy link
Copy Markdown
Collaborator

@ekievsky

Copy link
Copy Markdown
ContributorAuthor

It won't take a lot of time, around an hour, it comes from native SDK.

@tomholub

tomholub commented Jun 24, 2021 via email

Copy link
Copy Markdown
Collaborator

@ekievsky

Copy link
Copy Markdown
ContributorAuthor

Had some merging side effects.

So, I added UIDocumentInteractionController. The flow is following:

  1. User taps on download button
  2. App opens native files browser inside of application.
  • success: user gets the alert asking him if he want to open Files app to open a file or dismiss alert
  • failure: user gets the toast saying that there was an error while saving a file

@ekievsky
ekievsky marked this pull request as ready for review June 24, 2021 17:27

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better! There is a bug though:

  1. click download icon on a small text file
  2. when choosing location, I only saw various app folders, but not Downloads folder. So I made a new folder called test folder
  3. click done
  4. get prompted to open the file, said yes
  5. the app took me to Downloads folder. But I saved it elsewhere

I'll merge this, and then you can fix this in a followup PR. Thanks!

@tomholub
tomholub merged commit a352197 into masterJun 24, 2021
@tomholub
tomholub deleted the feature/issue-194-ability-to-download-plain-attachment branch June 24, 2021 19:51
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ability to download plain attachments

3 participants

@ekievsky@tomholub@Kharchevskyi