Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable28] fix(theming): Apply same logic on capabilities for primary color as done on themes #43032

Merged
merged 1 commit into from Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions apps/theming/lib/Capabilities.php
Expand Up @@ -94,7 +94,11 @@ public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator
*/
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');
Expand All @@ -108,7 +112,10 @@ public function getCapabilities() {
* @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) {
Expand Down
6 changes: 3 additions & 3 deletions apps/theming/tests/CapabilitiesTest.php
Expand Up @@ -174,9 +174,6 @@ public function testGetCapabilities($name, $url, $slogan, $color, $textColor, $l
$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))
Expand All @@ -186,6 +183,9 @@ public function testGetCapabilities($name, $url, $slogan, $color, $textColor, $l
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);
Expand Down