summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-08-15 21:27:28 +0200
committerGitHub <noreply@github.com>2017-08-15 21:27:28 +0200
commit8c97218b95ce43f393d7100b6df8c18aa5d4f1c4 (patch)
tree6799e5a9153adb641f84ea30f19865176178c18e
parent60a485b80db9290df089d35b3fe73ad128371d7d (diff)
parentb7b4cfd6a14775ba9f4c71d7f3bc787971acf70f (diff)
downloadnextcloud-server-8c97218b95ce43f393d7100b6df8c18aa5d4f1c4.tar.gz
nextcloud-server-8c97218b95ce43f393d7100b6df8c18aa5d4f1c4.zip
Merge pull request #6128 from nextcloud/primary-font-color-in-capabilities
Add the primary font color to the capabilities as well
-rw-r--r--apps/theming/lib/Capabilities.php8
-rw-r--r--apps/theming/tests/CapabilitiesTest.php23
2 files changed, 22 insertions, 9 deletions
diff --git a/apps/theming/lib/Capabilities.php b/apps/theming/lib/Capabilities.php
index 2552d15ea81..d94a65f21c1 100644
--- a/apps/theming/lib/Capabilities.php
+++ b/apps/theming/lib/Capabilities.php
@@ -37,6 +37,9 @@ class Capabilities implements IPublicCapability {
/** @var ThemingDefaults */
protected $theming;
+ /** @var Util */
+ protected $util;
+
/** @var IURLGenerator */
protected $url;
@@ -45,11 +48,13 @@ class Capabilities implements IPublicCapability {
/**
* @param ThemingDefaults $theming
+ * @param Util $util
* @param IURLGenerator $url
* @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->util = $util;
$this->url = $url;
$this->config = $config;
}
@@ -68,6 +73,7 @@ class Capabilities implements IPublicCapability {
'url' => $this->theming->getBaseUrl(),
'slogan' => $this->theming->getSlogan(),
'color' => $this->theming->getColorPrimary(),
+ 'color-text' => $this->util->invertTextColor($this->theming->getColorPrimary()) ? '#000000' : '#FFFFFF',
'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
'background' => $backgroundLogo === 'backgroundColor' ?
$this->theming->getColorPrimary() :
diff --git a/apps/theming/tests/CapabilitiesTest.php b/apps/theming/tests/CapabilitiesTest.php
index 55f40cb788a..8ab7f6e2c7f 100644
--- a/apps/theming/tests/CapabilitiesTest.php
+++ b/apps/theming/tests/CapabilitiesTest.php
@@ -23,6 +23,9 @@ namespace OCA\Theming\Tests;
use OCA\Theming\Capabilities;
use OCA\Theming\ThemingDefaults;
+use OCA\Theming\Util;
+use OCP\App\IAppManager;
+use OCP\Files\IAppData;
use OCP\IConfig;
use OCP\IURLGenerator;
use Test\TestCase;
@@ -52,34 +55,38 @@ class CapabilitiesTest extends TestCase {
$this->theming = $this->createMock(ThemingDefaults::class);
$this->url = $this->getMockBuilder(IURLGenerator::class)->getMock();
$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() {
return [
- ['name', 'url', 'slogan', 'color', 'logo', 'background', 'http://absolute/', [
+ ['name', 'url', 'slogan', '#FFFFFF', 'logo', 'background', 'http://absolute/', [
'name' => 'name',
'url' => 'url',
'slogan' => 'slogan',
- 'color' => 'color',
+ 'color' => '#FFFFFF',
+ 'color-text' => '#000000',
'logo' => 'http://absolute/logo',
'background' => 'http://absolute/background',
]],
- ['name1', 'url2', 'slogan3', 'color4', 'logo5', 'background6', 'http://localhost/', [
+ ['name1', 'url2', 'slogan3', '#01e4a0', 'logo5', 'background6', 'http://localhost/', [
'name' => 'name1',
'url' => 'url2',
'slogan' => 'slogan3',
- 'color' => 'color4',
+ 'color' => '#01e4a0',
+ 'color-text' => '#FFFFFF',
'logo' => 'http://localhost/logo5',
'background' => 'http://localhost/background6',
]],
- ['name1', 'url2', 'slogan3', 'color4', 'logo5', 'backgroundColor', 'http://localhost/', [
+ ['name1', 'url2', 'slogan3', '#000000', 'logo5', 'backgroundColor', 'http://localhost/', [
'name' => 'name1',
'url' => 'url2',
'slogan' => 'slogan3',
- 'color' => 'color4',
+ 'color' => '#000000',
+ 'color-text' => '#FFFFFF',
'logo' => 'http://localhost/logo5',
- 'background' => 'color4',
+ 'background' => '#000000',
]],
];
}