aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2024-01-23 10:12:09 +0100
committerGitHub <noreply@github.com>2024-01-23 10:12:09 +0100
commit667b0bc3fff4e9f463a47ba64da2d1b8b384cda6 (patch)
tree7d32cae789ee4214a07725fc8ea52b358bd6cf99 /apps/theming
parentc6c9ec9c14f8ea0a2c871f8b6c8ba41b54af58da (diff)
parentafa56bb8a4cd7e5cad22a0490259a84008500f30 (diff)
downloadnextcloud-server-667b0bc3fff4e9f463a47ba64da2d1b8b384cda6.tar.gz
nextcloud-server-667b0bc3fff4e9f463a47ba64da2d1b8b384cda6.zip
Merge pull request #43032 from nextcloud/fix/stable28-capabilities
[stable28] fix(theming): Apply same logic on capabilities for primary color as done on themes
Diffstat (limited to 'apps/theming')
-rw-r--r--apps/theming/lib/Capabilities.php11
-rw-r--r--apps/theming/tests/CapabilitiesTest.php6
2 files changed, 12 insertions, 5 deletions
diff --git a/apps/theming/lib/Capabilities.php b/apps/theming/lib/Capabilities.php
index e19665ffb31..b0c6a71731b 100644
--- a/apps/theming/lib/Capabilities.php
+++ b/apps/theming/lib/Capabilities.php
@@ -94,7 +94,11 @@ class Capabilities implements IPublicCapability {
*/
public function getCapabilities() {
$color = $this->theming->getDefaultColorPrimary();
- $colorText = $this->theming->getDefaultTextColorPrimary();
+ // Same as in DefaultTheme
+ if ($color === BackgroundService::DEFAULT_COLOR) {
+ $color = BackgroundService::DEFAULT_ACCESSIBLE_COLOR;
+ }
+ $colorText = $this->util->invertTextColor($color) ? '#000000' : '#ffffff';
$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', '');
$backgroundPlain = $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $color !== '#0082c9');
@@ -108,7 +112,10 @@ class Capabilities implements IPublicCapability {
* @see \OCA\Theming\Themes\CommonThemeTrait::generateUserBackgroundVariables()
*/
$color = $this->theming->getColorPrimary();
- $colorText = $this->theming->getTextColorPrimary();
+ if ($color === BackgroundService::DEFAULT_COLOR) {
+ $color = BackgroundService::DEFAULT_ACCESSIBLE_COLOR;
+ }
+ $colorText = $this->util->invertTextColor($color) ? '#000000' : '#ffffff';
$backgroundImage = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background_image', BackgroundService::BACKGROUND_DEFAULT);
if ($backgroundImage === BackgroundService::BACKGROUND_CUSTOM) {
diff --git a/apps/theming/tests/CapabilitiesTest.php b/apps/theming/tests/CapabilitiesTest.php
index 932cbe4a111..566380b3237 100644
--- a/apps/theming/tests/CapabilitiesTest.php
+++ b/apps/theming/tests/CapabilitiesTest.php
@@ -174,9 +174,6 @@ class CapabilitiesTest extends TestCase {
$this->theming->expects($this->exactly(3))
->method('getLogo')
->willReturn($logo);
- $this->theming->expects($this->once())
- ->method('getDefaultTextColorPrimary')
- ->willReturn($textColor);
$util = new Util($this->config, $this->createMock(IAppManager::class), $this->createMock(IAppData::class), $this->createMock(ImageManager::class));
$this->util->expects($this->exactly(3))
@@ -186,6 +183,9 @@ class CapabilitiesTest extends TestCase {
return $util->elementColor($color, $brightBackground);
});
+ $this->util->expects($this->any())
+ ->method('invertTextColor')
+ ->willReturnCallback(fn () => $textColor === '#000000');
$this->util->expects($this->once())
->method('isBackgroundThemed')
->willReturn($backgroundThemed);