Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>pull/42977/head
@@ -95,10 +95,6 @@ class Capabilities implements IPublicCapability { | |||
*/ | |||
public function getCapabilities() { | |||
$color = $this->theming->getDefaultColorPrimary(); | |||
// Same as in DefaultTheme | |||
if ($color === BackgroundService::DEFAULT_COLOR) { | |||
$color = BackgroundService::DEFAULT_ACCESSIBLE_COLOR; | |||
} | |||
$colorText = $this->util->invertTextColor($color) ? '#000000' : '#ffffff'; | |||
$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', ''); |
@@ -45,7 +45,6 @@ use OCP\PreConditionNotMetException; | |||
class BackgroundService { | |||
public const DEFAULT_COLOR = '#0082c9'; | |||
public const DEFAULT_BACKGROUND_COLOR = '#00679e'; | |||
public const DEFAULT_ACCESSIBLE_COLOR = '#00679e'; | |||
/** | |||
* One of our shipped background images is used | |||
@@ -291,8 +290,9 @@ class BackgroundService { | |||
* Called when a new global background (backgroundMime) is uploaded (admin setting) | |||
* This sets all necessary app config values | |||
* @param resource|string $path | |||
* @return string|null The fallback background color - if any | |||
*/ | |||
public function setGlobalBackground($path): void { | |||
public function setGlobalBackground($path): string|null { | |||
$image = new \OCP\Image(); | |||
$handle = is_resource($path) ? $path : fopen($path, 'rb'); | |||
@@ -301,6 +301,7 @@ class BackgroundService { | |||
if ($meanColor !== false) { | |||
$this->config->setAppValue(Application::APP_ID, 'background_color', $meanColor); | |||
} | |||
return $meanColor; | |||
} | |||
} | |||
@@ -44,17 +44,23 @@ class JSDataService implements \JsonSerializable { | |||
public function jsonSerialize(): array { | |||
return [ | |||
'name' => $this->themingDefaults->getName(), | |||
'url' => $this->themingDefaults->getBaseUrl(), | |||
'slogan' => $this->themingDefaults->getSlogan(), | |||
'color' => $this->themingDefaults->getColorPrimary(), // deprecated use primaryColor | |||
'primaryColor' => $this->themingDefaults->getColorPrimary(), | |||
'backgroundColor' => $this->themingDefaults->getColorBackground(), | |||
'defaultColor' => $this->themingDefaults->getDefaultColorPrimary(), | |||
'url' => $this->themingDefaults->getBaseUrl(), | |||
'imprintUrl' => $this->themingDefaults->getImprintUrl(), | |||
'privacyUrl' => $this->themingDefaults->getPrivacyUrl(), | |||
'primaryColor' => $this->themingDefaults->getColorPrimary(), | |||
'backgroundColor' => $this->themingDefaults->getColorBackground(), | |||
'defaultPrimaryColor' => $this->themingDefaults->getDefaultColorPrimary(), | |||
'defaultBackgroundColor' => $this->themingDefaults->getDefaultColorBackground(), | |||
'inverted' => $this->util->invertTextColor($this->themingDefaults->getColorPrimary()), | |||
'cacheBuster' => $this->util->getCacheBuster(), | |||
'enabledThemes' => $this->themesService->getEnabledThemes(), | |||
// deprecated use primaryColor | |||
'color' => $this->themingDefaults->getColorPrimary(), | |||
'' => 'color is deprecated since Nextcloud 29, use primaryColor instead' | |||
]; | |||
} |
@@ -27,7 +27,6 @@ namespace OCA\Theming\Themes; | |||
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; | |||
@@ -70,11 +69,6 @@ class DefaultTheme implements ITheme { | |||
$this->defaultPrimaryColor = $this->themingDefaults->getDefaultColorPrimary(); | |||
$this->primaryColor = $this->themingDefaults->getColorPrimary(); | |||
// Override primary colors (if set) to improve accessibility | |||
if ($this->primaryColor === BackgroundService::DEFAULT_COLOR) { | |||
$this->primaryColor = BackgroundService::DEFAULT_ACCESSIBLE_COLOR; | |||
} | |||
} | |||
public function getId(): string { |
@@ -61,7 +61,8 @@ class ThemingDefaults extends \OC_Defaults { | |||
private string $entity; | |||
private string $productName; | |||
private string $url; | |||
private string $color; | |||
private string $backgroundColor; | |||
private string $primaryColor; | |||
private string $docBaseUrl; | |||
private string $iTunesAppId; | |||
@@ -91,7 +92,8 @@ class ThemingDefaults extends \OC_Defaults { | |||
$this->entity = parent::getEntity(); | |||
$this->productName = parent::getProductName(); | |||
$this->url = parent::getBaseUrl(); | |||
$this->color = parent::getColorPrimary(); | |||
$this->primaryColor = parent::getColorPrimary(); | |||
$this->backgroundColor = parent::getColorBackground(); | |||
$this->iTunesAppId = parent::getiTunesAppId(); | |||
$this->iOSClientUrl = parent::getiOSClientUrl(); | |||
$this->AndroidClientUrl = parent::getAndroidClientUrl(); | |||
@@ -260,14 +262,8 @@ class ThemingDefaults extends \OC_Defaults { | |||
return $defaultColor; | |||
} | |||
// Fall back to background color | |||
$defaultColor = $this->config->getAppValue(Application::APP_ID, 'background_color', ''); | |||
if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) { | |||
return $defaultColor; | |||
} | |||
// worst case fall back to default primary color | |||
return BackgroundService::DEFAULT_COLOR; | |||
// fall back to default primary color | |||
return $this->primaryColor; | |||
} | |||
/** | |||
@@ -275,10 +271,11 @@ class ThemingDefaults extends \OC_Defaults { | |||
*/ | |||
public function getDefaultColorBackground(): string { | |||
$defaultColor = $this->config->getAppValue(Application::APP_ID, 'background_color', ''); | |||
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) { | |||
$defaultColor = BackgroundService::DEFAULT_BACKGROUND_COLOR; | |||
if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) { | |||
return $defaultColor; | |||
} | |||
return $defaultColor; | |||
return $this->backgroundColor; | |||
} | |||
/** |
@@ -52,6 +52,7 @@ class OC_Defaults { | |||
private $defaultDocBaseUrl; | |||
private $defaultDocVersion; | |||
private $defaultSlogan; | |||
private $defaultColorBackground; | |||
private $defaultColorPrimary; | |||
private $defaultTextColorPrimary; | |||
private $defaultProductName; | |||
@@ -70,6 +71,7 @@ class OC_Defaults { | |||
$this->defaultFDroidClientUrl = $config->getSystemValue('customclient_fdroid', 'https://f-droid.org/packages/com.nextcloud.client/'); | |||
$this->defaultDocBaseUrl = 'https://docs.nextcloud.com'; | |||
$this->defaultDocVersion = \OC_Util::getVersion()[0]; // used to generate doc links | |||
$this->defaultColorBackground = '#0069c3'; | |||
$this->defaultColorPrimary = '#0082c9'; | |||
$this->defaultTextColorPrimary = '#ffffff'; | |||
$this->defaultProductName = 'Nextcloud'; | |||
@@ -299,6 +301,17 @@ class OC_Defaults { | |||
return $this->defaultColorPrimary; | |||
} | |||
/** | |||
* Returns primary color | |||
* @return string | |||
*/ | |||
public function getColorBackground() { | |||
if ($this->themeExist('getColorBackground')) { | |||
return $this->theme->getColorBackground(); | |||
} | |||
return $this->defaultColorBackground; | |||
} | |||
/** | |||
* @return array scss variables to overwrite | |||
*/ |
@@ -110,6 +110,14 @@ class OC_Theme { | |||
return '#745bca'; | |||
} | |||
/** | |||
* Returns background color to be used | |||
* @return string | |||
*/ | |||
public function getColorBackground(): string { | |||
return '#3d85c6'; | |||
} | |||
/** | |||
* Returns variables to overload defaults from core/css/variables.scss | |||
* @return array |