--background-invert-if-dark: no;
--background-invert-if-bright: invert(100%);
--image-main-background: url('/core/img/app-background.jpg');
- --color-primary: #0082c9;
+ --color-primary: #00639a;
--color-primary-text: #ffffff;
- --color-primary-hover: #329bd3;
- --color-primary-light: #e5f2f9;
- --color-primary-light-text: #003450;
- --color-primary-light-hover: #dbe7ee;
+ --color-primary-hover: #3282ae;
+ --color-primary-light: #e5eff4;
+ --color-primary-light-text: #00273d;
+ --color-primary-light-hover: #dbe4e9;
--color-primary-text-dark: #ededed;
- --color-primary-element: #0082c9;
+ --color-primary-element: #00639a;
--color-primary-element-text: #ffffff;
- --color-primary-element-hover: #329bd3;
- --color-primary-element-light: #e5f2f9;
- --color-primary-element-light-text: #003450;
- --color-primary-element-light-hover: #dbe7ee;
+ --color-primary-element-hover: #3282ae;
+ --color-primary-element-light: #e5eff4;
+ --color-primary-element-light-text: #00273d;
+ --color-primary-element-light-hover: #dbe4e9;
--color-primary-element-text-dark: #ededed;
--gradient-primary-background: linear-gradient(40deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
}
use OCA\Theming\AppInfo\Application;
use OCA\Theming\ImageManager;
use OCA\Theming\ITheme;
+use OCA\Theming\Service\BackgroundService;
use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
use OCP\App\IAppManager;
public Util $util;
public ThemingDefaults $themingDefaults;
+ public IUserSession $userSession;
public IURLGenerator $urlGenerator;
public ImageManager $imageManager;
public IConfig $config;
public function __construct(Util $util,
ThemingDefaults $themingDefaults,
+ IUserSession $userSession,
IURLGenerator $urlGenerator,
ImageManager $imageManager,
IConfig $config,
IL10N $l) {
$this->util = $util;
$this->themingDefaults = $themingDefaults;
+ $this->userSession = $userSession;
$this->urlGenerator = $urlGenerator;
$this->imageManager = $imageManager;
$this->config = $config;
}
$appManager = Server::get(IAppManager::class);
- $userSession = Server::get(IUserSession::class);
- $user = $userSession->getUser();
+ $user = $this->userSession->getUser();
if ($appManager->isEnabledForUser(Application::APP_ID) && $user !== null) {
$themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', 'default');
if ($themingBackground === 'custom') {
- // Custom
$variables['--image-main-background'] = "url('" . $this->urlGenerator->linkToRouteAbsolute('theming.userTheme.getBackground') . "')";
- } elseif ($themingBackground !== 'default' && substr($themingBackground, 0, 1) !== '#') {
- // Shipped background
+ } elseif (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground])) {
$variables['--image-main-background'] = "url('" . $this->urlGenerator->linkTo(Application::APP_ID, "/img/background/$themingBackground") . "')";
} elseif (substr($themingBackground, 0, 1) === '#') {
- // Color
unset($variables['--image-main-background']);
$variables['--color-main-background-plain'] = $this->primaryColor;
}
*/
namespace OCA\Theming;
+use OCA\Theming\AppInfo\Application;
+use OCA\Theming\Service\BackgroundService;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\Files\NotFoundException;
use OCP\IL10N;
use OCP\INavigationManager;
use OCP\IURLGenerator;
+use OCP\IUserSession;
class ThemingDefaults extends \OC_Defaults {
- /** @var IConfig */
- private $config;
- /** @var IL10N */
- private $l;
- /** @var ImageManager */
- private $imageManager;
- /** @var IURLGenerator */
- private $urlGenerator;
- /** @var ICacheFactory */
- private $cacheFactory;
- /** @var Util */
- private $util;
- /** @var IAppManager */
- private $appManager;
- /** @var INavigationManager */
- private $navigationManager;
-
- /** @var string */
- private $name;
- /** @var string */
- private $title;
- /** @var string */
- private $entity;
- /** @var string */
- private $productName;
- /** @var string */
- private $url;
- /** @var string */
- private $color;
-
- /** @var string */
- private $iTunesAppId;
- /** @var string */
- private $iOSClientUrl;
- /** @var string */
- private $AndroidClientUrl;
- /** @var string */
- private $FDroidClientUrl;
+ private IConfig $config;
+ private IL10N $l;
+ private ImageManager $imageManager;
+ private IUserSession $userSession;
+ private IURLGenerator $urlGenerator;
+ private ICacheFactory $cacheFactory;
+ private Util $util;
+ private IAppManager $appManager;
+ private INavigationManager $navigationManager;
+
+ private string $name;
+ private string $title;
+ private string $entity;
+ private string $productName;
+ private string $url;
+ private string $color;
+
+ private string $iTunesAppId;
+ private string $iOSClientUrl;
+ private string $AndroidClientUrl;
+ private string $FDroidClientUrl;
/**
* ThemingDefaults constructor.
* @param IConfig $config
* @param IL10N $l
* @param ImageManager $imageManager
+ * @param IUserSession $userSession
* @param IURLGenerator $urlGenerator
* @param ICacheFactory $cacheFactory
* @param Util $util
*/
public function __construct(IConfig $config,
IL10N $l,
+ IUserSession $userSession,
IURLGenerator $urlGenerator,
ICacheFactory $cacheFactory,
Util $util,
$this->config = $config;
$this->l = $l;
$this->imageManager = $imageManager;
+ $this->userSession = $userSession;
$this->urlGenerator = $urlGenerator;
$this->cacheFactory = $cacheFactory;
$this->util = $util;
* @return string
*/
public function getColorPrimary() {
- $color = $this->config->getAppValue('theming', 'color', $this->color);
+ $user = $this->userSession->getUser();
+ $color = $this->config->getAppValue(Application::APP_ID, 'color', '');
+
+ if ($color === '' && !empty($user)) {
+ $themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', 'default');
+ if (isset(BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'])) {
+ $this->increaseCacheBuster();
+ return BackgroundService::SHIPPED_BACKGROUNDS[$themingBackground]['primary_color'];
+ } else if ($themingBackground === 'default') {
+ $this->increaseCacheBuster();
+ return BackgroundService::SHIPPED_BACKGROUNDS['kamil-porembinski-clouds.jpg']['primary_color'];
+ }
+ }
+
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
- $color = '#0082c9';
+ return BackgroundService::SHIPPED_BACKGROUNDS['kamil-porembinski-clouds.jpg']['primary_color'];
}
+
return $color;
}
->method('getUserValue')
->with('user', Application::APP_ID, 'enabled-themes', '[]')
->willReturn(json_encode($enabledThemes));
-
+
$this->assertEquals($expectedEnabled, $this->themesService->disableTheme($this->themes[$toDisable]));
}
->method('getUserValue')
->with('user', Application::APP_ID, 'enabled-themes', '[]')
->willReturn(json_encode($enabledThemes));
-
+
$this->assertEquals($expected, $this->themesService->isEnabled($this->themes[$themeId]));
}
'default' => new DefaultTheme(
$util,
$this->themingDefaults,
+ $this->userSession,
$urlGenerator,
$imageManager,
$this->config,
'light' => new LightTheme(
$util,
$this->themingDefaults,
+ $this->userSession,
$urlGenerator,
$imageManager,
$this->config,
'dark' => new DarkTheme(
$util,
$this->themingDefaults,
+ $this->userSession,
$urlGenerator,
$imageManager,
$this->config,
'light-highcontrast' => new HighContrastTheme(
$util,
$this->themingDefaults,
+ $this->userSession,
$urlGenerator,
$imageManager,
$this->config,
'dark-highcontrast' => new DarkHighContrastTheme(
$util,
$this->themingDefaults,
+ $this->userSession,
$urlGenerator,
$imageManager,
$this->config,
'opendyslexic' => new DyslexiaFont(
$util,
$this->themingDefaults,
+ $this->userSession,
$urlGenerator,
$imageManager,
$this->config,
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
+use OCP\IUserSession;
use Test\TestCase;
class PersonalTest extends TestCase {
private function initThemes() {
$util = $this->createMock(Util::class);
$themingDefaults = $this->createMock(ThemingDefaults::class);
+ $userSession = $this->createMock(IUserSession::class);
$urlGenerator = $this->createMock(IURLGenerator::class);
$imageManager = $this->createMock(ImageManager::class);
$config = $this->createMock(IConfig::class);
'default' => new DefaultTheme(
$util,
$themingDefaults,
+ $userSession,
$urlGenerator,
$imageManager,
$config,
'light' => new LightTheme(
$util,
$themingDefaults,
+ $userSession,
$urlGenerator,
$imageManager,
$config,
'dark' => new DarkTheme(
$util,
$themingDefaults,
+ $userSession,
$urlGenerator,
$imageManager,
$config,
'light-highcontrast' => new HighContrastTheme(
$util,
$themingDefaults,
+ $userSession,
$urlGenerator,
$imageManager,
$config,
'dark-highcontrast' => new DarkHighContrastTheme(
$util,
$themingDefaults,
+ $userSession,
$urlGenerator,
$imageManager,
$config,
'opendyslexic' => new DyslexiaFont(
$util,
$themingDefaults,
+ $userSession,
$urlGenerator,
$imageManager,
$config,
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
+use OCP\IUserSession;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
protected function setUp(): void {
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
+ $this->userSession = $this->createMock(IUserSession::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->imageManager = $this->createMock(ImageManager::class);
$this->config = $this->createMock(IConfig::class);
$this->defaultTheme = new DefaultTheme(
$util,
$this->themingDefaults,
+ $this->userSession,
$this->urlGenerator,
$this->imageManager,
$this->config,
protected function setUp(): void {
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
+ $this->userSession = $this->createMock(IUserSession::class);
$this->imageManager = $this->createMock(ImageManager::class);
$this->config = $this->createMock(IConfig::class);
$this->l10n = $this->createMock(IL10N::class);
$this->dyslexiaFont = new DyslexiaFont(
$util,
$this->themingDefaults,
+ $this->userSession,
$this->urlGenerator,
$this->imageManager,
$this->config,
/**
* @dataProvider dataTestGetCustomCss
- *
+ *
* Ensure the fonts are always loaded from the web root
* despite having url rewriting enabled or not
*
->method('getSystemValue')
->with('htaccess.IgnoreFrontController', false)
->willReturn($prettyUrlsEnabled);
-
+
$this->assertStringContainsString("'$webRoot/apps/theming/fonts/OpenDyslexic-Regular.woff'", $this->dyslexiaFont->getCustomCss());
$this->assertStringNotContainsString('index.php', $this->dyslexiaFont->getCustomCss());
}
use OCP\IL10N;
use OCP\INavigationManager;
use OCP\IURLGenerator;
+use OCP\IUserSession;
use Test\TestCase;
class ThemingDefaultsTest extends TestCase {
private $config;
/** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
private $l10n;
+ /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
+ private $userSession;
/** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
private $urlGenerator;
/** @var \OC_Defaults|\PHPUnit\Framework\MockObject\MockObject */
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->l10n = $this->createMock(IL10N::class);
+ $this->userSession = $this->createMock(IUserSession::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->cache = $this->createMock(ICache::class);
$this->template = new ThemingDefaults(
$this->config,
$this->l10n,
+ $this->userSession,
$this->urlGenerator,
$this->cacheFactory,
$this->util,
$this->config
->expects($this->once())
->method('getAppValue')
- ->with('theming', 'color', $this->defaults->getColorPrimary())
+ ->with('theming', 'color', null)
->willReturn($this->defaults->getColorPrimary());
$this->assertEquals($this->defaults->getColorPrimary(), $this->template->getColorPrimary());
$this->config
->expects($this->once())
->method('getAppValue')
- ->with('theming', 'color', $this->defaults->getColorPrimary())
+ ->with('theming', 'color', null)
->willReturn('#fff');
$this->assertEquals('#fff', $this->template->getColorPrimary());
->method('getAppValue')
->withConsecutive(
['theming', 'cachebuster', '0'],
- ['theming', 'color', $this->defaults->getColorPrimary()],
+ ['theming', 'color', null],
)->willReturnOnConsecutiveCalls(
'15',
$this->defaults->getColorPrimary(),
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')),