Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'apps/theming/lib/Themes/DefaultTheme.php')
-rw-r--r--apps/theming/lib/Themes/DefaultTheme.php19
1 files changed, 11 insertions, 8 deletions
diff --git a/apps/theming/lib/Themes/DefaultTheme.php b/apps/theming/lib/Themes/DefaultTheme.php
index 203e03757c8..413902d7813 100644
--- a/apps/theming/lib/Themes/DefaultTheme.php
+++ b/apps/theming/lib/Themes/DefaultTheme.php
@@ -27,6 +27,7 @@ namespace OCA\Theming\Themes;
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;
@@ -41,6 +42,7 @@ class DefaultTheme implements ITheme {
public Util $util;
public ThemingDefaults $themingDefaults;
+ public IUserSession $userSession;
public IURLGenerator $urlGenerator;
public ImageManager $imageManager;
public IConfig $config;
@@ -50,18 +52,22 @@ class DefaultTheme implements ITheme {
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;
$this->l = $l;
- $this->primaryColor = $this->themingDefaults->getColorPrimary();
+ $initialPrimaryColor = $this->themingDefaults->getColorPrimary();
+ // Override default color if set to improve accessibility
+ $this->primaryColor = $initialPrimaryColor === BackgroundService::DEFAULT_COLOR ? BackgroundService::DEFAULT_ACCESSIBLE_COLOR : $initialPrimaryColor;
}
public function getId(): string {
@@ -101,6 +107,7 @@ class DefaultTheme implements ITheme {
$variables = [
'--color-main-background' => $colorMainBackground,
+ '--color-main-background-not-plain' => $this->themingDefaults->getColorPrimary(),
'--color-main-background-rgb' => $colorMainBackgroundRGB,
'--color-main-background-translucent' => 'rgba(var(--color-main-background-rgb), .97)',
'--color-main-background-blur' => 'rgba(var(--color-main-background-rgb), .8)',
@@ -221,21 +228,17 @@ class DefaultTheme implements ITheme {
}
$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;
+ $variables['--color-main-background-plain'] = $this->themingDefaults->getColorPrimary();
}
}