Skip to content

Change the mail subject when sharing a file to something more consise#51

Open
ducalex wants to merge 6 commits intogrote:masterfrom
ducalex:file-subject
Open

Change the mail subject when sharing a file to something more consise#51
ducalex wants to merge 6 commits intogrote:masterfrom
ducalex:file-subject

Conversation

@ducalex
Copy link
Copy Markdown
Contributor

@ducalex ducalex commented Aug 31, 2021

This is related to #28.

I went for the simplest possible, and while testing I found that a prefix was more intuitive than a suffix. We could even remove the prefix IMHO, the filename seems to be enough.

But I'd be happy to change the format to whatever is preferred, as were suggested before!

Examples of the new subjects:

Single file: File: MY_FILE.png
Two files: Files: MY_FILE.png and MY_FILE2.png
More files: Files: MY_FILE.png and 3 more

Examples of the new subjects:

Single file: `File: MY_FILE.png`
Two files:   `Files: MY_FILE.png and MY_FILE2.png`
More files:  `Files: MY_FILE.png and 3 more`
@ducalex
Copy link
Copy Markdown
Contributor Author

ducalex commented Aug 31, 2021

Thinking about it we could even ditch the two files format and only keep:
Single file: File: MY_FILE.png
2 or more files: Files: MY_FILE.png and 1 more

Comment thread res/values/strings.xml Outdated

<string name="files_shared_1">File: %s</string>
<string name="files_shared_2">Files: %s and %s</string>
<string name="files_shared_3">Files: %s and %d more</string>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

From my side, we can remove the File(s): prefix. However, the last string needs to be a quantity string, because different languages have different ways to say 1 more, 2 more, 3 more, etc.

Copy link
Copy Markdown
Contributor Author

@ducalex ducalex Sep 1, 2021

Choose a reason for hiding this comment

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

I tested having a suffix first, then tried prefix and realized it made it so much clearer that it's an attachment at first glance while browsing emails.

But can you let me know your preferred format for 1, 2, and 3+ files? I'll update this pull request to exactly match your choice.

Copy link
Copy Markdown
Owner

@grote grote Sep 1, 2021

Choose a reason for hiding this comment

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

If you think we need the prefix, I am fine with it. I just think that files_shared_3 needs to be a quantity string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've replaced files_shared_1/2/3 by a single plural string. It gives us a little less flexibility (we lose files_shared_2 because no quantity expresses 2 reliably) but it makes the code simpler and presumably easier to translate, I can see that now!

Comment thread res/values/plurals.xml Outdated
<plurals name="files_shared">
<item quantity="one">File: %3$s</item>
<item quantity="other">Files: %3$s and %2$d more</item>
</plurals>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think you can add this to strings.xml which makes it easier for translators and us to maintain.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Also, why %3$s and %2$d ? where's %1$s

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Also, why %3$s and %2$d ? where's %1$s

%1$s isn't used in English but according to the documentation, some languages like Korean, only have the "other" quantity which would require the total number of files. I've moved the translation to strings.xml and I've added a comment to describe the 3 arguments.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! I am just confused about %1$s. If it isn't used in English why would it be in other languages? I've never seen string placeholders not being used in the source language before.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've removed it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've separated the translations for single attachment and multiple attachment, which looking back is probably what you were suggesting initially.

That way it should work in all languages and only the subject with N more is puralized.

@ducalex ducalex force-pushed the file-subject branch 2 times, most recently from 73fae1d to 339b67e Compare September 3, 2021 02:00
String num = String.valueOf(jMail.getJSONArray("attachments").length());
jMail.put("subject", num + " " + getString(R.string.files_shared) + " " + getString(R.string.app_name));
JSONArray files = jMail.getJSONArray(MAIL_ATTACHMENTS);
String filename = files.getJSONObject(0).getString("filename");
Copy link
Copy Markdown
Owner

@grote grote Sep 7, 2021

Choose a reason for hiding this comment

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

Thanks for using the MAIL_ATTACHMENTS constant here. Do we also have one for filename and subject?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. There was one for MAIL_SUBJECT which I just updated but there isn't one for filename.

I'd be happy to define a scheme or constants for attachments but are you sure this should be done in this pull request?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can be in another one, just brought it up since you started to use constants.

}
if (files.length() == 1) {
jMail.put(MAIL_SUBJECT, getString(R.string.subject_single_file, filename));
} else {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Something I notice just now. Can it happen that files.length() == 0 for some reason?

Copy link
Copy Markdown
Contributor Author

@ducalex ducalex Sep 9, 2021

Choose a reason for hiding this comment

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

I couldn't find an easy way to get 0 because even if an attachment fails (eg IOException) it would still be put in attachments.
However I have made changes to hopefully cover any possibility of attachments being empty or null or missing from the jMail object.

(I've had some commit issues hopefully my changes went through.)

@ducalex ducalex force-pushed the file-subject branch 2 times, most recently from 221c251 to 92f5d98 Compare September 9, 2021 01:14
Sign up for free to 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.

2 participants