summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-10-19 15:31:51 +0200
committerGitHub <noreply@github.com>2018-10-19 15:31:51 +0200
commit6a979a0ba0d59ceda2a117cc4fe5efee4b048b4b (patch)
tree7487ce3d0cf71258c95dce0bff5dc6f66f9bf475 /apps
parentd35b6513cdf799831c72022bee688230812201f8 (diff)
parent30cbd137e8c32c32920292e285c06466392e89f9 (diff)
downloadnextcloud-server-6a979a0ba0d59ceda2a117cc4fe5efee4b048b4b.tar.gz
nextcloud-server-6a979a0ba0d59ceda2a117cc4fe5efee4b048b4b.zip
Merge pull request #11823 from lex111/fix-illegible-text-color-in-size-and-modified-columns
Fix illegible text color in columns Size and Modified on dark theme
Diffstat (limited to 'apps')
-rw-r--r--apps/accessibility/appinfo/app.php3
-rw-r--r--apps/accessibility/appinfo/routes.php5
-rw-r--r--apps/accessibility/lib/AppInfo/Application.php18
-rw-r--r--apps/accessibility/lib/Controller/AccessibilityController.php19
-rw-r--r--apps/files/js/filelist.js14
5 files changed, 56 insertions, 3 deletions
diff --git a/apps/accessibility/appinfo/app.php b/apps/accessibility/appinfo/app.php
index 7f8e3c3262b..96621a16829 100644
--- a/apps/accessibility/appinfo/app.php
+++ b/apps/accessibility/appinfo/app.php
@@ -27,4 +27,5 @@ $app = new \OCA\Accessibility\AppInfo\Application();
// Separate from the constructor since the route are not initialized before that
// 1. create the app
// 2. generate css route and inject
-$app->injectCss(); \ No newline at end of file
+$app->injectCss();
+$app->injectJavascript(); \ No newline at end of file
diff --git a/apps/accessibility/appinfo/routes.php b/apps/accessibility/appinfo/routes.php
index ebb845e06a3..52e74918216 100644
--- a/apps/accessibility/appinfo/routes.php
+++ b/apps/accessibility/appinfo/routes.php
@@ -22,8 +22,9 @@
*/
return [
- 'routes' => [
- ['name' => 'accessibility#getCss', 'url' => '/css/user-{md5}.css', 'verb' => 'GET'],
+ 'routes' => [
+ ['name' => 'accessibility#getCss', 'url' => '/css/user-{md5}.css', 'verb' => 'GET'],
+ ['name' => 'accessibility#getJavascript', 'url' => '/js/accessibility', 'verb' => 'GET'],
],
'ocs' => [
[
diff --git a/apps/accessibility/lib/AppInfo/Application.php b/apps/accessibility/lib/AppInfo/Application.php
index 068fcc27b7a..6e3dc789d97 100644
--- a/apps/accessibility/lib/AppInfo/Application.php
+++ b/apps/accessibility/lib/AppInfo/Application.php
@@ -60,4 +60,22 @@ class Application extends App {
}
}
}
+
+ public function injectJavascript() {
+ $linkToJs = $this->urlGenerator->linkToRoute(
+ $this->appName . '.accessibility.getJavascript',
+ [
+ 'v' => \OC::$server->getConfig()->getAppValue('accessibility', 'cachebuster', '0'),
+ ]
+ );
+
+ \OCP\Util::addHeader(
+ 'script',
+ [
+ 'src' => $linkToJs,
+ 'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
+ ],
+ ''
+ );
+ }
}
diff --git a/apps/accessibility/lib/Controller/AccessibilityController.php b/apps/accessibility/lib/Controller/AccessibilityController.php
index 8f1ffa452af..cdc9e004404 100644
--- a/apps/accessibility/lib/Controller/AccessibilityController.php
+++ b/apps/accessibility/lib/Controller/AccessibilityController.php
@@ -28,6 +28,7 @@ use Leafo\ScssPhp\Formatter\Crunched;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDisplayResponse;
+use OCP\AppFramework\Http\DataDownloadResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\App\IAppManager;
use OCP\IConfig;
@@ -185,6 +186,24 @@ class AccessibilityController extends Controller {
}
/**
+ * @NoCSRFRequired
+ * @PublicPage
+ *
+ * @return DataDownloadResponse
+ */
+ public function getJavascript(): DataDownloadResponse {
+ $responseJS = '(function() {
+ OCA.Accessibility = {
+ theme: ' . json_encode($this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false)) . ',
+
+ };
+})();';
+ $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
+ $response->cacheFor(3600);
+ return $response;
+ }
+
+ /**
* Return an array with the user theme & font settings
*
* @return array
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 771ec495a2d..0a6620ab22c 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -1384,6 +1384,10 @@
// rgb(118, 118, 118) / #767676
// min. color contrast for normal text on white background according to WCAG AA
sizeColor = Math.round(118-Math.pow((fileData.size/(1024*1024)),2));
+
+ if (OCA.Accessibility && OCA.Accessibility.theme === 'themedark') {
+ sizeColor = Math.abs(sizeColor);
+ }
} else {
simpleSize = t('files', 'Pending');
}
@@ -1403,6 +1407,16 @@
if (modifiedColor >= '118') {
modifiedColor = 118;
}
+ if (OCA.Accessibility && OCA.Accessibility.theme === 'themedark') {
+ modifiedColor = Math.abs(modifiedColor);
+
+ // ensure that the dimmest color is still readable
+ // rgb(130, 130, 130) / #828282
+ // min. color contrast for normal text on black background according to WCAG AA
+ if (modifiedColor < 130) {
+ modifiedColor = 130;
+ }
+ }
var formatted;
var text;
if (mtime > 0) {