Add the primary font color to the capabilities as well

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-08-15 13:33:14 +02:00
parent 95b7fa306e
commit b7b4cfd6a1
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
2 changed files with 22 additions and 9 deletions

View File

@ -37,6 +37,9 @@ class Capabilities implements IPublicCapability {
/** @var ThemingDefaults */ /** @var ThemingDefaults */
protected $theming; protected $theming;
/** @var Util */
protected $util;
/** @var IURLGenerator */ /** @var IURLGenerator */
protected $url; protected $url;
@ -45,11 +48,13 @@ class Capabilities implements IPublicCapability {
/** /**
* @param ThemingDefaults $theming * @param ThemingDefaults $theming
* @param Util $util
* @param IURLGenerator $url * @param IURLGenerator $url
* @param IConfig $config * @param IConfig $config
*/ */
public function __construct(ThemingDefaults $theming, IURLGenerator $url, IConfig $config) { public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator $url, IConfig $config) {
$this->theming = $theming; $this->theming = $theming;
$this->util = $util;
$this->url = $url; $this->url = $url;
$this->config = $config; $this->config = $config;
} }
@ -68,6 +73,7 @@ class Capabilities implements IPublicCapability {
'url' => $this->theming->getBaseUrl(), 'url' => $this->theming->getBaseUrl(),
'slogan' => $this->theming->getSlogan(), 'slogan' => $this->theming->getSlogan(),
'color' => $this->theming->getColorPrimary(), 'color' => $this->theming->getColorPrimary(),
'color-text' => $this->util->invertTextColor($this->theming->getColorPrimary()) ? '#000000' : '#FFFFFF',
'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()), 'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
'background' => $backgroundLogo === 'backgroundColor' ? 'background' => $backgroundLogo === 'backgroundColor' ?
$this->theming->getColorPrimary() : $this->theming->getColorPrimary() :

View File

@ -23,6 +23,9 @@ namespace OCA\Theming\Tests;
use OCA\Theming\Capabilities; use OCA\Theming\Capabilities;
use OCA\Theming\ThemingDefaults; use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
use OCP\App\IAppManager;
use OCP\Files\IAppData;
use OCP\IConfig; use OCP\IConfig;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use Test\TestCase; use Test\TestCase;
@ -52,34 +55,38 @@ class CapabilitiesTest extends TestCase {
$this->theming = $this->createMock(ThemingDefaults::class); $this->theming = $this->createMock(ThemingDefaults::class);
$this->url = $this->getMockBuilder(IURLGenerator::class)->getMock(); $this->url = $this->getMockBuilder(IURLGenerator::class)->getMock();
$this->config = $this->createMock(IConfig::class); $this->config = $this->createMock(IConfig::class);
$this->capabilities = new Capabilities($this->theming, $this->url, $this->config); $util = new Util($this->config, $this->createMock(IAppManager::class), $this->createMock(IAppData::class));
$this->capabilities = new Capabilities($this->theming, $util, $this->url, $this->config);
} }
public function dataGetCapabilities() { public function dataGetCapabilities() {
return [ return [
['name', 'url', 'slogan', 'color', 'logo', 'background', 'http://absolute/', [ ['name', 'url', 'slogan', '#FFFFFF', 'logo', 'background', 'http://absolute/', [
'name' => 'name', 'name' => 'name',
'url' => 'url', 'url' => 'url',
'slogan' => 'slogan', 'slogan' => 'slogan',
'color' => 'color', 'color' => '#FFFFFF',
'color-text' => '#000000',
'logo' => 'http://absolute/logo', 'logo' => 'http://absolute/logo',
'background' => 'http://absolute/background', 'background' => 'http://absolute/background',
]], ]],
['name1', 'url2', 'slogan3', 'color4', 'logo5', 'background6', 'http://localhost/', [ ['name1', 'url2', 'slogan3', '#01e4a0', 'logo5', 'background6', 'http://localhost/', [
'name' => 'name1', 'name' => 'name1',
'url' => 'url2', 'url' => 'url2',
'slogan' => 'slogan3', 'slogan' => 'slogan3',
'color' => 'color4', 'color' => '#01e4a0',
'color-text' => '#FFFFFF',
'logo' => 'http://localhost/logo5', 'logo' => 'http://localhost/logo5',
'background' => 'http://localhost/background6', 'background' => 'http://localhost/background6',
]], ]],
['name1', 'url2', 'slogan3', 'color4', 'logo5', 'backgroundColor', 'http://localhost/', [ ['name1', 'url2', 'slogan3', '#000000', 'logo5', 'backgroundColor', 'http://localhost/', [
'name' => 'name1', 'name' => 'name1',
'url' => 'url2', 'url' => 'url2',
'slogan' => 'slogan3', 'slogan' => 'slogan3',
'color' => 'color4', 'color' => '#000000',
'color-text' => '#FFFFFF',
'logo' => 'http://localhost/logo5', 'logo' => 'http://localhost/logo5',
'background' => 'color4', 'background' => '#000000',
]], ]],
]; ];
} }