Browse Source

Fix illegible text color in columns Size and Modified on dark theme: rework after review

Signed-off-by: Alexey Pyltsyn <lex61rus@gmail.com>
tags/v15.0.0beta1
Alexey Pyltsyn 5 years ago
parent
commit
30cbd137e8

+ 2
- 1
apps/accessibility/appinfo/app.php View File

@@ -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();
$app->injectCss();
$app->injectJavascript();

+ 3
- 2
apps/accessibility/appinfo/routes.php View File

@@ -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' => [
[

+ 18
- 0
apps/accessibility/lib/AppInfo/Application.php View File

@@ -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()
],
''
);
}
}

+ 19
- 0
apps/accessibility/lib/Controller/AccessibilityController.php View File

@@ -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;
@@ -184,6 +185,24 @@ class AccessibilityController extends Controller {
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
*

+ 2
- 2
apps/files/js/filelist.js View File

@@ -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 {
@@ -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

+ 0
- 1
lib/private/Template/JSConfigHelper.php View File

@@ -260,7 +260,6 @@ class JSConfigHelper {
'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),
];

Loading…
Cancel
Save