Skip to content

Commit

Permalink
fix(theming): Apply same logic on capabilities for primary color like…
Browse files Browse the repository at this point in the history
… on themes

Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Jan 22, 2024
1 parent 9398e90 commit f70a37b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 9 additions & 2 deletions apps/theming/lib/Capabilities.php
Original file line number Diff line number Diff line change
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
3 changes: 3 additions & 0 deletions apps/theming/tests/CapabilitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ public function testGetCapabilities($name, $url, $slogan, $color, $textColor, $l
return $util->elementColor($color, $brightBackground);
});

$this->util->expects($this->any())
->method('invertTextColor')
->willReturnCallback(fn (string $color) => $color === '#000000');
$this->util->expects($this->once())
->method('isBackgroundThemed')
->willReturn($backgroundThemed);
Expand Down

0 comments on commit f70a37b

Please sign in to comment.