Skip to content

Commit

Permalink
Fix illegible text color in columns Size and Modified on dark theme: …
Browse files Browse the repository at this point in the history
…rework after review
  • Loading branch information
lex111 committed Oct 16, 2018
1 parent 6b83ec3 commit a0bcac1
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
3 changes: 2 additions & 1 deletion apps/accessibility/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@
// Separate from the constructor since the route are not initialized before that
// 1. create the app
// 2. generate css route and inject
$app->injectCss();
$app->injectCss();
$app->injectJavascript();
1 change: 1 addition & 0 deletions apps/accessibility/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
return [
'routes' => [
['name' => 'accessibility#getCss', 'url' => '/css/user-{md5}.css', 'verb' => 'GET'],
['name' => 'accessibility#getJavascript', 'url' => '/js/accessibility', 'verb' => 'GET'],
],
'ocs' => [
[
Expand Down
18 changes: 18 additions & 0 deletions apps/accessibility/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,22 @@ public function injectCss() {
}
}
}

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()
],
''
);
}
}
19 changes: 19 additions & 0 deletions apps/accessibility/lib/Controller/AccessibilityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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;
Expand Down Expand Up @@ -184,6 +185,24 @@ public function getCss(): DataDisplayResponse {
return $response;
}

/**
* @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
*
Expand Down
4 changes: 2 additions & 2 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@
// 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 (oc_defaults.themeName === 'themedark') {
if (OCA.Accessibility && OCA.Accessibility.theme === 'themedark') {
sizeColor = Math.abs(sizeColor);
}
} else {
Expand All @@ -1407,7 +1407,7 @@
if (modifiedColor >= '118') {
modifiedColor = 118;
}
if (oc_defaults.themeName === 'themedark') {
if (OCA.Accessibility && OCA.Accessibility.theme === 'themedark') {
modifiedColor = Math.abs(modifiedColor);

// ensure that the dimmest color is still readable
Expand Down
1 change: 0 additions & 1 deletion lib/private/Template/JSConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ public function getConfig() {
'shortFooter' => $this->defaults->getShortFooter(),
'longFooter' => $this->defaults->getLongFooter(),
'folder' => \OC_Util::getTheme(),
'themeName' => $this->config->getUserValue($uid, 'accessibility', 'theme', false),
]),
"oc_capabilities" => json_encode($capabilities),
];
Expand Down

0 comments on commit a0bcac1

Please sign in to comment.