Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-08-30 14:58:51 +0300
committerCarl Schwan <carl@carlschwan.eu>2022-09-09 14:37:51 +0300
commit76d01653309f1535bfe8d364a5aae50e83a348e3 (patch)
tree1e5b15504a1251b3810a478fc8cbca9dd69477e3 /lib
parentf98ae2b5b0567f28a875106724c0475d6395f3c5 (diff)
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.php2
-rw-r--r--lib/private/Avatar/GuestAvatar.php4
-rw-r--r--lib/private/Avatar/PlaceholderAvatar.php10
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 {