aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-01-20 07:42:27 +0100
committerFerdinand Thiessen <opensource@fthiessen.de>2024-05-21 20:36:21 +0200
commit282f1b1faba5c3d4a27fc6254badd9e75864e225 (patch)
treed20e267756d6d6e63e8e25ac3ebf4f3ebeb782e8 /apps
parent4d865fd33fcd309a241f9fd21144fe157ad4a3d2 (diff)
downloadnextcloud-server-282f1b1faba5c3d4a27fc6254badd9e75864e225.tar.gz
nextcloud-server-282f1b1faba5c3d4a27fc6254badd9e75864e225.zip
fix(theming): Also apply new background colors to guest view
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/theming/lib/Capabilities.php5
-rw-r--r--apps/theming/lib/Service/BackgroundService.php4
-rw-r--r--apps/theming/lib/Themes/CommonThemeTrait.php24
-rw-r--r--apps/theming/lib/ThemingDefaults.php10
4 files changed, 25 insertions, 18 deletions
diff --git a/apps/theming/lib/Capabilities.php b/apps/theming/lib/Capabilities.php
index eec2b5187ea..7131607e016 100644
--- a/apps/theming/lib/Capabilities.php
+++ b/apps/theming/lib/Capabilities.php
@@ -101,7 +101,8 @@ class Capabilities implements IPublicCapability {
$colorText = $this->util->invertTextColor($color) ? '#000000' : '#ffffff';
$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', '');
- $backgroundColor = $this->theming->getDefaultColorBackground();
+ $backgroundColor = $this->theming->getColorBackground();
+ $backgroundText = $this->theming->getTextColorBackground();
$backgroundPlain = $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $backgroundColor !== BackgroundService::DEFAULT_COLOR);
$background = $backgroundPlain ? $backgroundColor : $this->url->getAbsoluteURL($this->theming->getBackground());
@@ -114,8 +115,6 @@ class Capabilities implements IPublicCapability {
*/
$color = $this->theming->getColorPrimary();
$colorText = $this->theming->getTextColorPrimary();
- $backgroundColor = $this->theming->getColorBackground();
- $backgroundText = $this->theming->getTextColorBackground();
$backgroundImage = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background_image', BackgroundService::BACKGROUND_DEFAULT);
if ($backgroundImage === BackgroundService::BACKGROUND_CUSTOM) {
diff --git a/apps/theming/lib/Service/BackgroundService.php b/apps/theming/lib/Service/BackgroundService.php
index cc053baf39a..2b1dd635e44 100644
--- a/apps/theming/lib/Service/BackgroundService.php
+++ b/apps/theming/lib/Service/BackgroundService.php
@@ -44,6 +44,7 @@ use OCP\PreConditionNotMetException;
class BackgroundService {
public const DEFAULT_COLOR = '#0082c9';
+ public const DEFAULT_BACKGROUND_COLOR = '#00679e';
public const DEFAULT_ACCESSIBLE_COLOR = '#00679e';
/**
@@ -161,7 +162,7 @@ class BackgroundService {
'attribution' => 'Clouds (Kamil PorembiƄski, CC BY-SA)',
'description' => 'Background picture of white clouds on in front of a blue sky',
'attribution_url' => 'https://www.flickr.com/photos/paszczak000/8715851521/',
- 'background_color' => '#00679e',
+ 'background_color' => self::DEFAULT_BACKGROUND_COLOR,
'primary_color' => self::DEFAULT_COLOR,
],
'bernard-spragg-new-zealand-fern.jpg' => [
@@ -219,6 +220,7 @@ class BackgroundService {
public function setDefaultBackground(): void {
$this->config->deleteUserValue($this->userId, Application::APP_ID, 'background_image');
$this->config->deleteUserValue($this->userId, Application::APP_ID, 'background_color');
+ $this->config->deleteUserValue($this->userId, Application::APP_ID, 'primary_color');
}
/**
diff --git a/apps/theming/lib/Themes/CommonThemeTrait.php b/apps/theming/lib/Themes/CommonThemeTrait.php
index e15b127645e..05e8054a291 100644
--- a/apps/theming/lib/Themes/CommonThemeTrait.php
+++ b/apps/theming/lib/Themes/CommonThemeTrait.php
@@ -29,10 +29,12 @@ namespace OCA\Theming\Themes;
use OCA\Theming\AppInfo\Application;
use OCA\Theming\ImageManager;
use OCA\Theming\Service\BackgroundService;
+use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
trait CommonThemeTrait {
public Util $util;
+ public ThemingDefaults $themingDefaults;
/**
* Generate primary-related variables
@@ -89,13 +91,15 @@ trait CommonThemeTrait {
protected function generateGlobalBackgroundVariables(): array {
$backgroundDeleted = $this->config->getAppValue(Application::APP_ID, 'backgroundMime', '') === 'backgroundColor';
$hasCustomLogoHeader = $this->util->isLogoThemed();
- $isPrimaryBright = $this->util->invertTextColor($this->primaryColor);
-
- $variables = [];
+ $backgroundColor = $this->themingDefaults->getColorBackground();
// Default last fallback values
- $variables['--image-background-default'] = "url('" . $this->themingDefaults->getBackground() . "')";
- $variables['--color-background-plain'] = $this->primaryColor;
+ $variables = [
+ '--color-background-plain' => $backgroundColor,
+ '--color-background-plain-text' => $this->util->invertTextColor($backgroundColor) ? '#000000' : '#ffffff',
+ '--image-background-default' => "url('" . $this->themingDefaults->getBackground() . "')",
+ '--background-image-invert-if-bright' => $this->util->invertTextColor($backgroundColor) ? 'invert(100%)' : 'no',
+ ];
// Register image variables only if custom-defined
foreach (ImageManager::SUPPORTED_IMAGE_KEYS as $image) {
@@ -106,17 +110,13 @@ trait CommonThemeTrait {
}
}
- // If primary as background has been request or if we have a custom primary colour
- // let's not define the background image
+ // If a background has been requested let's not define the background image
if ($backgroundDeleted) {
- $variables['--color-background-plain'] = $this->primaryColor;
- $variables['--image-background-plain'] = 'yes';
- $variables['--image-background'] = 'no';
- // If no background image is set, we need to check against the shown primary colour
- $variables['--background-image-invert-if-bright'] = $isPrimaryBright ? 'invert(100%)' : 'no';
+ $variables['--image-background'] = 'none';
}
if ($hasCustomLogoHeader) {
+ // prevent inverting the logo on bright colors if customized
$variables['--image-logoheader-custom'] = 'true';
}
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index 04ec22fe700..39e7d88de0d 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -261,7 +261,13 @@ class ThemingDefaults extends \OC_Defaults {
}
// Fall back to background color
- return $this->getDefaultColorBackground();
+ $defaultColor = $this->config->getAppValue(Application::APP_ID, 'background_color', '');
+ if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) {
+ return $defaultColor;
+ }
+
+ // worst case fall back to default primary color
+ return BackgroundService::DEFAULT_COLOR;
}
/**
@@ -270,7 +276,7 @@ class ThemingDefaults extends \OC_Defaults {
public function getDefaultColorBackground(): string {
$defaultColor = $this->config->getAppValue(Application::APP_ID, 'background_color', '');
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) {
- $defaultColor = BackgroundService::DEFAULT_COLOR;
+ $defaultColor = BackgroundService::DEFAULT_BACKGROUND_COLOR;
}
return $defaultColor;
}