diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-08-30 13:58:51 +0200 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-09-09 13:37:51 +0200 |
commit | 76d01653309f1535bfe8d364a5aae50e83a348e3 (patch) | |
tree | 1e5b15504a1251b3810a478fc8cbca9dd69477e3 /lib | |
parent | f98ae2b5b0567f28a875106724c0475d6395f3c5 (diff) | |
download | nextcloud-server-76d01653309f1535bfe8d364a5aae50e83a348e3.tar.gz nextcloud-server-76d01653309f1535bfe8d364a5aae50e83a348e3.zip |
Dark theme for guest avatar
And better caching policy
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Avatar/Avatar.php | 2 | ||||
-rw-r--r-- | lib/private/Avatar/GuestAvatar.php | 4 | ||||
-rw-r--r-- | lib/private/Avatar/PlaceholderAvatar.php | 10 |
3 files changed, 8 insertions, 8 deletions
diff --git a/lib/private/Avatar/Avatar.php b/lib/private/Avatar/Avatar.php index aec0f6e10f4..1e6ebd7c61b 100644 --- a/lib/private/Avatar/Avatar.php +++ b/lib/private/Avatar/Avatar.php @@ -150,7 +150,7 @@ abstract class Avatar implements IAvatar { protected function generateAvatar(string $userDisplayName, int $size, bool $dark): string { $text = $this->getAvatarText(); $textColor = $this->avatarBackgroundColor($userDisplayName); - $backgroundColor = $textColor->alphaBlending(0.1, $dark ? new Color() : new Color(255, 255, 255)); + $backgroundColor = $textColor->alphaBlending(0.1, $dark ? new Color(0, 0, 0) : new Color(255, 255, 255)); $im = imagecreatetruecolor($size, $size); $background = imagecolorallocate( diff --git a/lib/private/Avatar/GuestAvatar.php b/lib/private/Avatar/GuestAvatar.php index 79d7e6ee094..083deb4108f 100644 --- a/lib/private/Avatar/GuestAvatar.php +++ b/lib/private/Avatar/GuestAvatar.php @@ -84,8 +84,8 @@ class GuestAvatar extends Avatar { /** * Generates an avatar for the guest. */ - public function getFile(int $size): ISimpleFile { - $avatar = $this->generateAvatar($this->userDisplayName, $size); + public function getFile(int $size, bool $darkTheme = false): ISimpleFile { + $avatar = $this->generateAvatar($this->userDisplayName, $size, $darkTheme); return new InMemoryFile('avatar.png', $avatar); } diff --git a/lib/private/Avatar/PlaceholderAvatar.php b/lib/private/Avatar/PlaceholderAvatar.php index 504e5c1457d..e7ca89f4d30 100644 --- a/lib/private/Avatar/PlaceholderAvatar.php +++ b/lib/private/Avatar/PlaceholderAvatar.php @@ -108,13 +108,13 @@ class PlaceholderAvatar extends Avatar { * @throws \OCP\Files\NotPermittedException * @throws \OCP\PreConditionNotMetException */ - public function getFile(int $size): ISimpleFile { + public function getFile(int $size, bool $darkTheme = false): ISimpleFile { $ext = 'png'; if ($size === -1) { - $path = 'avatar-placeholder.' . $ext; + $path = 'avatar-placeholder' . ($darkTheme ? '-dark' : '') . '.' . $ext; } else { - $path = 'avatar-placeholder.' . $size . '.' . $ext; + $path = 'avatar-placeholder' . ($darkTheme ? '-dark' : '') . '.' . $size . '.' . $ext; } try { @@ -124,8 +124,8 @@ class PlaceholderAvatar extends Avatar { throw new NotFoundException; } - if (!$data = $this->generateAvatarFromSvg($size)) { - $data = $this->generateAvatar($this->getDisplayName(), $size); + if (!$data = $this->generateAvatarFromSvg($size, $darkTheme)) { + $data = $this->generateAvatar($this->getDisplayName(), $size, $darkTheme); } try { |