Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/theming/lib/Themes/CommonThemeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function generatePrimaryVariables(string $colorMainBackground, string
protected function generateGlobalBackgroundVariables(): array {
$user = $this->userSession->getUser();
$backgroundDeleted = $this->config->getAppValue(Application::APP_ID, 'backgroundMime', '') === 'backgroundColor';
$hasCustomLogoHeader = $this->imageManager->hasImage('logo') || $this->imageManager->hasImage('logoheader');
$hasCustomLogoHeader = $this->util->isLogoThemed();

$variables = [];

Expand Down
16 changes: 8 additions & 8 deletions apps/theming/lib/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,13 @@ class Util {
private IConfig $config;
private IAppManager $appManager;
private IAppData $appData;
private ImageManager $imageManager;

/**
* Util constructor.
*
* @param IConfig $config
* @param IAppManager $appManager
* @param IAppData $appData
*/
public function __construct(IConfig $config, IAppManager $appManager, IAppData $appData) {
public function __construct(IConfig $config, IAppManager $appManager, IAppData $appData, ImageManager $imageManager) {
$this->config = $config;
$this->appManager = $appManager;
$this->appData = $appData;
$this->imageManager = $imageManager;
}

/**
Expand Down Expand Up @@ -266,4 +261,9 @@ public function isBackgroundThemed() {
$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', '');
return $backgroundLogo !== '' && $backgroundLogo !== 'backgroundColor';
}

public function isLogoThemed() {
return $this->imageManager->hasImage('logo')
|| $this->imageManager->hasImage('logoheader');
}
}
3 changes: 2 additions & 1 deletion apps/theming/tests/CapabilitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
namespace OCA\Theming\Tests;

use OCA\Theming\Capabilities;
use OCA\Theming\ImageManager;
use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
use OCP\App\IAppManager;
Expand Down Expand Up @@ -173,7 +174,7 @@ public function testGetCapabilities($name, $url, $slogan, $color, $textColor, $l
->method('getTextColorPrimary')
->willReturn($textColor);

$util = new Util($this->config, $this->createMock(IAppManager::class), $this->createMock(IAppData::class));
$util = new Util($this->config, $this->createMock(IAppManager::class), $this->createMock(IAppData::class), $this->createMock(ImageManager::class));
$this->util->expects($this->exactly(3))
->method('elementColor')
->with($color)
Expand Down
2 changes: 1 addition & 1 deletion apps/theming/tests/IconBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function setUp(): void {
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->imageManager = $this->createMock(ImageManager::class);
$this->util = new Util($this->config, $this->appManager, $this->appData);
$this->util = new Util($this->config, $this->appManager, $this->appData, $this->imageManager);
$this->iconBuilder = new IconBuilder($this->themingDefaults, $this->util, $this->imageManager);
}

Expand Down
3 changes: 2 additions & 1 deletion apps/theming/tests/Themes/DefaultThemeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ protected function setUp(): void {
$util = new Util(
$this->config,
$this->appManager,
$this->createMock(IAppData::class)
$this->createMock(IAppData::class),
$this->imageManager
);

$this->themingDefaults
Expand Down
5 changes: 3 additions & 2 deletions apps/theming/tests/Themes/DyslexiaFontTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ protected function setUp(): void {

$util = new Util(
$this->config,
$this->createMock(AppManager::class),
$this->createMock(IAppData::class)
$this->appManager,
$this->createMock(IAppData::class),
$this->imageManager
);

$userSession = $this->createMock(IUserSession::class);
Expand Down
6 changes: 5 additions & 1 deletion apps/theming/tests/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
namespace OCA\Theming\Tests;

use OCA\Theming\ImageManager;
use OCA\Theming\Util;
use OCP\App\IAppManager;
use OCP\Files\IAppData;
Expand All @@ -46,13 +47,16 @@ class UtilTest extends TestCase {
protected $appData;
/** @var IAppManager */
protected $appManager;
/** @var ImageManager */
protected $imageManager;

protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->appData = $this->createMock(IAppData::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->util = new Util($this->config, $this->appManager, $this->appData);
$this->imageManager = $this->createMock(ImageManager::class);
$this->util = new Util($this->config, $this->appManager, $this->appData, $this->imageManager);
}

public function dataInvertTextColor() {
Expand Down
1 change: 1 addition & 0 deletions core/css/header.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/css/header.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions core/css/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@
left: 12px;
top: 1px;
bottom: 1px;
// Invert if not customized and background is bright
filter: var(--image-logoheader-custom, var(--background-image-invert-if-bright));
}

.header-appname-container {
Expand Down
1 change: 1 addition & 0 deletions core/css/server.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/css/server.css.map

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -1209,21 +1209,22 @@ public function __construct($webRoot, \OC\Config $config) {
}

if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
$imageManager = new ImageManager(
$c->get(\OCP\IConfig::class),
$c->getAppDataDir('theming'),
$c->get(IURLGenerator::class),
$this->get(ICacheFactory::class),
$this->get(ILogger::class),
$this->get(ITempManager::class)
);
return new ThemingDefaults(
$c->get(\OCP\IConfig::class),
$c->getL10N('theming'),
$c->get(IUserSession::class),
$c->get(IURLGenerator::class),
$c->get(ICacheFactory::class),
new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming')),
new ImageManager(
$c->get(\OCP\IConfig::class),
$c->getAppDataDir('theming'),
$c->get(IURLGenerator::class),
$this->get(ICacheFactory::class),
$this->get(ILogger::class),
$this->get(ITempManager::class)
),
new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
$imageManager,
$c->get(IAppManager::class),
$c->get(INavigationManager::class)
);
Expand Down