Merge pull request #43033 from nextcloud/fix/color-capabilities

fix(theming): Apply same logic on capabilities for primary color as done on themes
pull/43069/head
Ferdinand Thiessen 2024-01-23 18:32:55 +07:00 committed by GitHub
commit 8ba7de87f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

@ -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) {

@ -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);