summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-01-25 10:41:19 +0100
committerJoas Schilling <coding@schilljs.com>2023-01-30 09:12:49 +0100
commita192641808fb5943d1524d18986cc4167b27a24b (patch)
tree23ae4c61e4290ca443e33c0af47a54b05d23c5dd
parent97e6fe4b4682f0dfe0d96851494a792ec1934d89 (diff)
downloadnextcloud-server-a192641808fb5943d1524d18986cc4167b27a24b.tar.gz
nextcloud-server-a192641808fb5943d1524d18986cc4167b27a24b.zip
Use the default color and matching text color for the federation invite
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--apps/federatedfilesharing/lib/Settings/Personal.php36
-rw-r--r--apps/theming/lib/ThemingDefaults.php9
-rw-r--r--lib/public/Defaults.php24
3 files changed, 46 insertions, 23 deletions
diff --git a/apps/federatedfilesharing/lib/Settings/Personal.php b/apps/federatedfilesharing/lib/Settings/Personal.php
index bd44e3d970b..18189f4cde7 100644
--- a/apps/federatedfilesharing/lib/Settings/Personal.php
+++ b/apps/federatedfilesharing/lib/Settings/Personal.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
@@ -29,7 +32,7 @@ namespace OCA\FederatedFileSharing\Settings;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
-use OCP\IL10N;
+use OCP\Defaults;
use OCP\IUserSession;
use OCP\IURLGenerator;
use OCP\Settings\ISettings;
@@ -37,22 +40,19 @@ use OCP\Settings\ISettings;
class Personal implements ISettings {
private FederatedShareProvider $federatedShareProvider;
private IUserSession $userSession;
- private IL10N $l;
- private \OC_Defaults $defaults;
+ private Defaults $defaults;
private IInitialState $initialState;
private IURLGenerator $urlGenerator;
public function __construct(
- FederatedShareProvider $federatedShareProvider, #
+ FederatedShareProvider $federatedShareProvider,
IUserSession $userSession,
- IL10N $l,
- \OC_Defaults $defaults,
+ Defaults $defaults,
IInitialState $initialState,
IURLGenerator $urlGenerator
) {
$this->federatedShareProvider = $federatedShareProvider;
$this->userSession = $userSession;
- $this->l = $l;
$this->defaults = $defaults;
$this->initialState = $initialState;
$this->urlGenerator = $urlGenerator;
@@ -62,35 +62,25 @@ class Personal implements ISettings {
* @return TemplateResponse returns the instance with all parameters set, ready to be rendered
* @since 9.1
*/
- public function getForm() {
+ public function getForm(): TemplateResponse {
$cloudID = $this->userSession->getUser()->getCloudId();
$url = 'https://nextcloud.com/sharing#' . $cloudID;
- $parameters = [
- 'message_with_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID, see %s', [$url]),
- 'message_without_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID', [$cloudID]),
- 'logoPath' => $this->defaults->getLogo(),
- 'reference' => $url,
- 'cloudId' => $cloudID,
- 'color' => $this->defaults->getColorPrimary(),
- 'textColor' => "#ffffff",
- ];
-
- $this->initialState->provideInitialState('color', $this->defaults->getColorPrimary());
- $this->initialState->provideInitialState('textColor', '#fffff');
+ $this->initialState->provideInitialState('color', $this->defaults->getDefaultColorPrimary());
+ $this->initialState->provideInitialState('textColor', $this->defaults->getDefaultTextColorPrimary());
$this->initialState->provideInitialState('logoPath', $this->defaults->getLogo());
$this->initialState->provideInitialState('reference', $url);
$this->initialState->provideInitialState('cloudId', $cloudID);
$this->initialState->provideInitialState('docUrlFederated', $this->urlGenerator->linkToDocs('user-sharing-federated'));
- return new TemplateResponse('federatedfilesharing', 'settings-personal', $parameters, '');
+ return new TemplateResponse('federatedfilesharing', 'settings-personal', [], TemplateResponse::RENDER_AS_BLANK);
}
/**
* @return string the section ID, e.g. 'sharing'
* @since 9.1
*/
- public function getSection() {
+ public function getSection(): ?string {
if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() ||
$this->federatedShareProvider->isIncomingServer2serverGroupShareEnabled()) {
return 'sharing';
@@ -106,7 +96,7 @@ class Personal implements ISettings {
* E.g.: 70
* @since 9.1
*/
- public function getPriority() {
+ public function getPriority(): int {
return 40;
}
}
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index afec58dc3a3..6cb204d1b1b 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -497,6 +497,15 @@ class ThemingDefaults extends \OC_Defaults {
}
/**
+ * Color of text in the header and primary buttons
+ *
+ * @return string
+ */
+ public function getDefaultTextColorPrimary() {
+ return $this->util->invertTextColor($this->getDefaultColorPrimary()) ? '#000000' : '#ffffff';
+ }
+
+ /**
* Has the admin disabled user customization
*/
public function isUserThemingDisabled(): bool {
diff --git a/lib/public/Defaults.php b/lib/public/Defaults.php
index cb04d62df0d..a295db120ad 100644
--- a/lib/public/Defaults.php
+++ b/lib/public/Defaults.php
@@ -206,6 +206,18 @@ class Defaults {
}
/**
+ * Return the default color primary
+ * @return string
+ * @since 25.0.4
+ */
+ public function getDefaultColorPrimary(): string {
+ if (method_exists($this->defaults, 'getDefaultColorPrimary')) {
+ return $this->defaults->getDefaultColorPrimary();
+ }
+ return $this->defaults->getColorPrimary();
+ }
+
+ /**
* @param string $key
* @return string URL to doc with key
* @since 12.0.0
@@ -231,4 +243,16 @@ class Defaults {
public function getTextColorPrimary(): string {
return $this->defaults->getTextColorPrimary();
}
+
+ /**
+ * Returns primary color
+ * @return string
+ * @since 25.0.4
+ */
+ public function getDefaultTextColorPrimary(): string {
+ if (method_exists($this->defaults, 'getDefaultTextColorPrimary')) {
+ return $this->defaults->getDefaultTextColorPrimary();
+ }
+ return $this->defaults->getTextColorPrimary();
+ }
}