Merge pull request #5483 from nextcloud/issue-5075-png-files-for-activity-emails

Use PNGs for icons in activity emails
This commit is contained in:
Morris Jobke 2017-07-07 11:05:00 +02:00 committed by GitHub
commit b4deba2078
34 changed files with 313 additions and 82 deletions

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="32" width="32" viewBox="0 0 32 32"><path fill="#000" d="M16 3C7.163 3 0 7.925 0 14s7.163 11 16 11c.5 0 .98-.032 1.47-.063L26 32v-9.406c3.658-2.017 6-5.12 6-8.595 0-6.076-7.164-11-16-11z"/></svg>

After

Width:  |  Height:  |  Size: 243 B

View File

@ -87,7 +87,11 @@ class Provider implements IProvider {
if ($event->getSubject() === 'add_comment_subject') {
$this->parseMessage($event);
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg')));
}
if ($this->activityManager->isFormattingFilteredObject()) {
try {

View File

@ -84,7 +84,11 @@ class Calendar extends Base {
$this->l = $this->languageFactory->get('dav', $language);
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
}
if ($event->getSubject() === self::SUBJECT_ADD) {
$subject = $this->l->t('{actor} created calendar {calendar}');

View File

@ -80,7 +80,11 @@ class Event extends Base {
$this->l = $this->languageFactory->get('dav', $language);
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
}
if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_event') {
$subject = $this->l->t('{actor} created event {event} in calendar {calendar}');

View File

@ -40,7 +40,11 @@ class Todo extends Event {
$this->l = $this->languageFactory->get('dav', $language);
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.svg')));
}
if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_todo') {
$subject = $this->l->t('{actor} created todo {todo} in list {calendar}');

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
apps/files/img/change.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -97,11 +97,19 @@ class FavoriteProvider implements IProvider {
public function parseShortVersion(IEvent $event) {
if ($event->getSubject() === self::SUBJECT_ADDED) {
$event->setParsedSubject($this->l->t('Added to favorites'))
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg')));
$event->setParsedSubject($this->l->t('Added to favorites'));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg')));
}
} else if ($event->getSubject() === self::SUBJECT_REMOVED) {
$event->setParsedSubject($this->l->t('Removed from favorites'))
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg')));
$event->setParsedSubject($this->l->t('Removed from favorites'));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg')));
}
} else {
throw new \InvalidArgumentException();
}
@ -120,10 +128,18 @@ class FavoriteProvider implements IProvider {
if ($event->getSubject() === self::SUBJECT_ADDED) {
$subject = $this->l->t('You added {file} to your favorites');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg')));
}
} else if ($event->getSubject() === self::SUBJECT_REMOVED) {
$subject = $this->l->t('You removed {file} from your favorites');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star.svg')));
}
} else {
throw new \InvalidArgumentException();
}

View File

@ -110,21 +110,41 @@ class Provider implements IProvider {
if ($event->getSubject() === 'created_by') {
$subject = $this->l->t('Created by {user}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
}
} else if ($event->getSubject() === 'changed_by') {
$subject = $this->l->t('Changed by {user}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
}
} else if ($event->getSubject() === 'deleted_by') {
$subject = $this->l->t('Deleted by {user}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
}
} else if ($event->getSubject() === 'restored_by') {
$subject = $this->l->t('Restored by {user}');
} else if ($event->getSubject() === 'renamed_by') {
$subject = $this->l->t('Renamed by {user}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
}
} else if ($event->getSubject() === 'moved_by') {
$subject = $this->l->t('Moved by {user}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
}
} else {
throw new \InvalidArgumentException();
}
@ -151,41 +171,85 @@ class Provider implements IProvider {
if ($event->getSubject() === 'created_self') {
$subject = $this->l->t('You created {file}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
}
} else if ($event->getSubject() === 'created_by') {
$subject = $this->l->t('{user} created {file}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
}
} else if ($event->getSubject() === 'created_public') {
$subject = $this->l->t('{file} was created in a public folder');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg')));
}
} else if ($event->getSubject() === 'changed_self') {
$subject = $this->l->t('You changed {file}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
}
} else if ($event->getSubject() === 'changed_by') {
$subject = $this->l->t('{user} changed {file}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
}
} else if ($event->getSubject() === 'deleted_self') {
$subject = $this->l->t('You deleted {file}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
}
} else if ($event->getSubject() === 'deleted_by') {
$subject = $this->l->t('{user} deleted {file}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg')));
}
} else if ($event->getSubject() === 'restored_self') {
$subject = $this->l->t('You restored {file}');
} else if ($event->getSubject() === 'restored_by') {
$subject = $this->l->t('{user} restored {file}');
} else if ($event->getSubject() === 'renamed_self') {
$subject = $this->l->t('You renamed {oldfile} to {newfile}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
}
} else if ($event->getSubject() === 'renamed_by') {
$subject = $this->l->t('{user} renamed {oldfile} to {newfile}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
}
} else if ($event->getSubject() === 'moved_self') {
$subject = $this->l->t('You moved {oldfile} to {newfile}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
}
} else if ($event->getSubject() === 'moved_by') {
$subject = $this->l->t('{user} moved {oldfile} to {newfile}');
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg')));
}
} else {
throw new \InvalidArgumentException();
}

View File

@ -51,7 +51,11 @@ class Downloads extends Base {
throw new \InvalidArgumentException();
}
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
@ -76,7 +80,11 @@ class Downloads extends Base {
throw new \InvalidArgumentException();
}
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/download.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;

View File

@ -51,7 +51,11 @@ class Groups extends Base {
throw new \InvalidArgumentException();
}
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
@ -78,7 +82,11 @@ class Groups extends Base {
throw new \InvalidArgumentException();
}
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;

View File

@ -58,7 +58,11 @@ class PublicLinks extends Base {
throw new \InvalidArgumentException();
}
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
@ -90,7 +94,11 @@ class PublicLinks extends Base {
throw new \InvalidArgumentException();
}
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;

View File

@ -73,7 +73,11 @@ class RemoteShares extends Base {
throw new \InvalidArgumentException();
}
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
@ -100,7 +104,11 @@ class RemoteShares extends Base {
throw new \InvalidArgumentException();
}
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;

View File

@ -60,7 +60,11 @@ class Users extends Base {
throw new \InvalidArgumentException();
}
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;
@ -92,7 +96,11 @@ class Users extends Base {
throw new \InvalidArgumentException();
}
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
$this->setSubjects($event, $subject, $parsedParameters);
return $event;

View File

@ -117,8 +117,12 @@ class Activity implements IProvider {
]))
->setRichSubject($this->l->t('Shared with {email}'), [
'email' => $parsedParameters['email'],
])
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
]);
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
} else if ($event->getSubject() === self::SUBJECT_SHARED_EMAIL_BY) {
$event->setParsedSubject($this->l->t('Shared with %1$s by %2$s', [
$parsedParameters['email']['name'],
@ -127,20 +131,32 @@ class Activity implements IProvider {
->setRichSubject($this->l->t('Shared with {email} by {actor}'), [
'email' => $parsedParameters['email'],
'actor' => $parsedParameters['actor'],
])
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
]);
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
} else if ($event->getSubject() === self::SUBJECT_SHARED_EMAIL_PASSWORD_SEND) {
$event->setParsedSubject($this->l->t('Password for mail share sent to %1$s', [
$parsedParameters['email']['name']
]))
->setRichSubject($this->l->t('Password for mail share sent to {email}'), [
'email' => $parsedParameters['email']
])
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
]);
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
} else if ($event->getSubject() === self::SUBJECT_SHARED_EMAIL_PASSWORD_SEND_SELF) {
$event->setParsedSubject($this->l->t('Password for mail share sent to you'))
->setRichSubject($this->l->t('Password for mail share sent to you'))
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
->setRichSubject($this->l->t('Password for mail share sent to you'));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
} else {
throw new \InvalidArgumentException();
}
@ -162,29 +178,45 @@ class Activity implements IProvider {
$parsedParameters['file']['path'],
$parsedParameters['email']['name'],
]))
->setRichSubject($this->l->t('You shared {file} with {email} by mail'), $parsedParameters)
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
->setRichSubject($this->l->t('You shared {file} with {email} by mail'), $parsedParameters);
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
} else if ($event->getSubject() === self::SUBJECT_SHARED_EMAIL_BY) {
$event->setParsedSubject($this->l->t('%3$s shared %1$s with %2$s by mail', [
$parsedParameters['file']['path'],
$parsedParameters['email']['name'],
$parsedParameters['actor']['name'],
]))
->setRichSubject($this->l->t('{actor} shared {file} with {email} by mail'), $parsedParameters)
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
->setRichSubject($this->l->t('{actor} shared {file} with {email} by mail'), $parsedParameters);
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
} else if ($event->getSubject() === self::SUBJECT_SHARED_EMAIL_PASSWORD_SEND) {
$event->setParsedSubject($this->l->t('Password to access %1$s was sent to %2s', [
$parsedParameters['file']['path'],
$parsedParameters['email']['name']
]))
->setRichSubject($this->l->t('Password to access {file} was sent to {email}'), $parsedParameters)
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
->setRichSubject($this->l->t('Password to access {file} was sent to {email}'), $parsedParameters);
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
} else if ($event->getSubject() === self::SUBJECT_SHARED_EMAIL_PASSWORD_SEND_SELF) {
$event->setParsedSubject(
$this->l->t('Password to access %1$s was sent to you',
[$parsedParameters['file']['path']]))
->setRichSubject($this->l->t('Password to access {file} was sent to you'), $parsedParameters)
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
->setRichSubject($this->l->t('Password to access {file} was sent to you'), $parsedParameters);
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg')));
}
} else {
throw new \InvalidArgumentException();

View File

@ -104,7 +104,12 @@ class Provider implements IProvider {
*/
public function parseShortVersion(IEvent $event) {
$parsedParameters = $this->getParameters($event);
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.svg')));
}
if ($event->getSubject() === self::ASSIGN_TAG) {
if ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) {
@ -157,7 +162,12 @@ class Provider implements IProvider {
*/
public function parseLongVersion(IEvent $event) {
$parsedParameters = $this->getParameters($event);
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/tag.svg')));
}
if ($event->getSubject() === self::CREATE_TAG) {
if ($parsedParameters['actor']['id'] === $this->activityManager->getCurrentUserId()) {

View File

@ -24,8 +24,8 @@ namespace OCA\TwoFactorBackupCodes\Activity;
use InvalidArgumentException;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\L10N\IFactory as L10nFactory;
@ -37,17 +37,17 @@ class Provider implements IProvider {
/** @var IURLGenerator */
private $urlGenerator;
/** @var ILogger */
private $logger;
/** @var IManager */
private $activityManager;
/**
* @param L10nFactory $l10n
* @param IURLGenerator $urlGenerator
* @param ILogger $logger
* @param IManager $activityManager
*/
public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, ILogger $logger) {
$this->logger = $logger;
public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, IManager $activityManager) {
$this->urlGenerator = $urlGenerator;
$this->activityManager = $activityManager;
$this->l10n = $l10n;
}
@ -61,7 +61,12 @@ class Provider implements IProvider {
switch ($event->getSubject()) {
case 'codes_generated':
$event->setParsedSubject($l->t('You created two-factor backup codes for your account'));
$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.png')));
} else {
$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
}
break;
default:
throw new InvalidArgumentException();

View File

@ -25,8 +25,8 @@ namespace OCA\TwoFactorBackupCodes\Test\Unit\Activity;
use InvalidArgumentException;
use OCA\TwoFactorBackupCodes\Activity\Provider;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use PHPUnit_Framework_MockObject_MockObject;
@ -34,14 +34,14 @@ use Test\TestCase;
class ProviderTest extends TestCase {
/** @var IL10N|PHPUnit_Framework_MockObject_MockObject */
/** @var IFactory|PHPUnit_Framework_MockObject_MockObject */
private $l10n;
/** @var IURLGenerator|PHPUnit_Framework_MockObject_MockObject */
private $urlGenerator;
/** @var ILogger|PHPUnit_Framework_MockObject_MockObject */
private $logger;
/** @var IManager|PHPUnit_Framework_MockObject_MockObject */
private $activityManager;
/** @var Provider */
private $provider;
@ -51,9 +51,9 @@ class ProviderTest extends TestCase {
$this->l10n = $this->createMock(IFactory::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->logger = $this->createMock(ILogger::class);
$this->activityManager = $this->createMock(IManager::class);
$this->provider = new Provider($this->l10n, $this->urlGenerator, $this->logger);
$this->provider = new Provider($this->l10n, $this->urlGenerator, $this->activityManager);
}
public function testParseUnrelated() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
core/img/actions/share.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
core/img/actions/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
core/img/actions/tag.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -57,6 +57,9 @@ class Manager implements IManager {
/** @var int */
protected $formattingObjectId;
/** @var bool */
protected $requirePNG;
/** @var string */
protected $currentUserId;
@ -465,6 +468,20 @@ class Manager implements IManager {
&& $this->formattingObjectId === $this->request->getParam('object_id');
}
/**
* @param bool $status Set to true, when parsing events should not use SVG icons
*/
public function setRequirePNG($status) {
$this->requirePNG = $status;
}
/**
* @return bool
*/
public function getRequirePNG() {
return $this->requirePNG;
}
/**
* @param string $app
* @param string $text

View File

@ -206,6 +206,18 @@ interface IManager {
*/
public function isFormattingFilteredObject();
/**
* @param bool $status Set to true, when parsing events should not use SVG icons
* @since 12.0.1
*/
public function setRequirePNG($status);
/**
* @return bool
* @since 12.0.1
*/
public function getRequirePNG();
/**
* @param string $app
* @param string $text

View File

@ -22,6 +22,7 @@
namespace OC\Settings\Activity;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
use OCP\IL10N;
use OCP\IURLGenerator;
@ -50,6 +51,9 @@ class Provider implements IProvider {
/** @var IUserManager */
protected $userManager;
/** @var IManager */
private $activityManager;
/** @var string[] cached displayNames - key is the UID and value the displayname */
protected $displayNames = [];
@ -57,11 +61,13 @@ class Provider implements IProvider {
* @param IFactory $languageFactory
* @param IURLGenerator $url
* @param IUserManager $userManager
* @param IManager $activityManager
*/
public function __construct(IFactory $languageFactory, IURLGenerator $url, IUserManager $userManager) {
public function __construct(IFactory $languageFactory, IURLGenerator $url, IUserManager $userManager, IManager $activityManager) {
$this->languageFactory = $languageFactory;
$this->url = $url;
$this->userManager = $userManager;
$this->activityManager = $activityManager;
}
/**
@ -79,7 +85,11 @@ class Provider implements IProvider {
$this->l = $this->languageFactory->get('settings', $language);
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('settings', 'personal.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('settings', 'personal.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('settings', 'personal.svg')));
}
if ($event->getSubject() === self::PASSWORD_CHANGED_BY) {
$subject = $this->l->t('{actor} changed your password');

View File

@ -24,8 +24,8 @@ namespace OC\Settings\Activity;
use InvalidArgumentException;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\L10N\IFactory as L10nFactory;
@ -37,13 +37,13 @@ class SecurityProvider implements IProvider {
/** @var IURLGenerator */
private $urlGenerator;
/** @var ILogger */
private $logger;
/** @var IManager */
private $activityManager;
public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, ILogger $logger) {
$this->logger = $logger;
public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, IManager $activityManager) {
$this->urlGenerator = $urlGenerator;
$this->l10n = $l10n;
$this->activityManager = $activityManager;
}
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
@ -59,14 +59,22 @@ class SecurityProvider implements IProvider {
$event->setParsedSubject($l->t('You successfully logged in using two-factor authentication (%1$s)', [
$params['provider'],
]));
$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.png')));
} else {
$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
}
break;
case 'twofactor_failed':
$params = $event->getSubjectParameters();
$event->setParsedSubject($l->t('A login attempt using two-factor authentication failed (%1$s)', [
$params['provider'],
]));
$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.png')));
} else {
$event->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/password.svg')));
}
break;
default:
throw new InvalidArgumentException();

BIN
settings/img/personal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -25,8 +25,8 @@ namespace Tests\Settings\Activity;
use InvalidArgumentException;
use OC\Settings\Activity\SecurityProvider;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
use PHPUnit_Framework_MockObject_MockObject;
@ -34,14 +34,14 @@ use Test\TestCase;
class SecurityProviderTest extends TestCase {
/** @var IL10N|PHPUnit_Framework_MockObject_MockObject */
/** @var IFactory|PHPUnit_Framework_MockObject_MockObject */
private $l10n;
/** @var IURLGenerator|PHPUnit_Framework_MockObject_MockObject */
private $urlGenerator;
/** @var ILogger|PHPUnit_Framework_MockObject_MockObject */
private $logger;
/** @var IManager|PHPUnit_Framework_MockObject_MockObject */
private $activityManager;
/** @var SecurityProvider */
private $provider;
@ -51,9 +51,9 @@ class SecurityProviderTest extends TestCase {
$this->l10n = $this->createMock(IFactory::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->logger = $this->createMock(ILogger::class);
$this->activityManager = $this->createMock(IManager::class);
$this->provider = new SecurityProvider($this->l10n, $this->urlGenerator, $this->logger);
$this->provider = new SecurityProvider($this->l10n, $this->urlGenerator, $this->activityManager);
}
public function testParseUnrelated() {