Merge pull request #31582 from nextcloud/refactor/carl/accesibility-app

Modernize accessibility app
This commit is contained in:
Côme Chilliet 2022-03-22 10:57:37 +01:00 committed by GitHub
commit c43d015fe5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 94 deletions

View file

@ -33,22 +33,10 @@ use OCP\IURLGenerator;
class AccessibilityProvider {
/** @var string */
protected $appName;
protected string $appName;
private IURLGenerator $urlGenerator;
private IL10N $l;
/** @var IURLGenerator */
private $urlGenerator;
/** @var IL10N */
private $l;
/**
* Account constructor.
*
* @param string $appName
* @param IURLGenerator $urlGenerator
* @param IL10N $l
*/
public function __construct(string $appName,
IURLGenerator $urlGenerator,
IL10N $l) {
@ -57,7 +45,10 @@ class AccessibilityProvider {
$this->l = $l;
}
public function getThemes() {
/**
* @psalm-return array<array-key, array{id: string, img: string, title: string, enableLabel: string, text: string}>
*/
public function getThemes(): array {
return [
[
'id' => 'dark',
@ -69,7 +60,10 @@ class AccessibilityProvider {
];
}
public function getHighContrast() {
/**
* @psalm-return array{id: string, img: string, title: string, enableLabel: string, text: string}
*/
public function getHighContrast(): array {
return [
'id' => 'highcontrast',
'img' => $this->urlGenerator->imagePath($this->appName, 'mode-highcontrast.jpg'),
@ -79,7 +73,10 @@ class AccessibilityProvider {
];
}
public function getFonts() {
/**
* @psalm-return array<array-key, array{id: string, img: string, title: string, enableLabel: string, text: string}>
*/
public function getFonts(): array {
return [
[
'id' => 'fontdyslexic',

View file

@ -48,35 +48,15 @@ use ScssPhp\ScssPhp\OutputStyle;
class AccessibilityController extends Controller {
/** @var string */
protected $appName;
/** @var string */
protected $serverRoot;
/** @var IConfig */
private $config;
/** @var LoggerInterface */
private $logger;
/** @var ITimeFactory */
protected $timeFactory;
/** @var IUserSession */
private $userSession;
/** @var IconsCacher */
protected $iconsCacher;
/** @var \OC_Defaults */
private $defaults;
/** @var null|string */
private $injectedVariables;
/** @var string */
private $appRoot;
protected string $serverRoot;
private IConfig $config;
private LoggerInterface $logger;
protected ITimeFactory $timeFactory;
private IUserSession $userSession;
protected IconsCacher $iconsCacher;
private \OC_Defaults $defaults;
private ?string $injectedVariables = null;
private string $appRoot;
public function __construct(string $appName,
IRequest $request,
@ -104,8 +84,6 @@ class AccessibilityController extends Controller {
* @PublicPage
* @NoCSRFRequired
* @NoSameSiteCookieRequired
*
* @return DataDisplayResponse
*/
public function getCss(): DataDisplayResponse {
$css = '';
@ -186,8 +164,6 @@ class AccessibilityController extends Controller {
/**
* Return an array with the user theme & font settings
*
* @return array
*/
private function getUserValues(): array {
$userTheme = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false);
@ -210,10 +186,6 @@ class AccessibilityController extends Controller {
/**
* Add the correct uri prefix to make uri valid again
*
* @param string $css
* @param string $webDir
* @return string
*/
private function rebaseUrls(string $css, string $webDir): string {
$re = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x';
@ -226,9 +198,8 @@ class AccessibilityController extends Controller {
* Remove all matches from the $rule regex
*
* @param string $css string to parse
* @return string
*/
private function invertSvgIconsColor(string $css) {
private function invertSvgIconsColor(string $css): string {
return str_replace(
['color=000&', 'color=fff&', 'color=***&'],
['color=***&', 'color=000&', 'color=fff&'],

View file

@ -41,32 +41,13 @@ use OCP\PreConditionNotMetException;
class ConfigController extends OCSController {
/** @var string */
protected $appName;
/** @var string */
protected $userId;
/** @var string */
protected $serverRoot;
/** @var IConfig */
private $config;
/** @var IUserSession */
private $userSession;
/** @var AccessibilityProvider */
private $accessibilityProvider;
protected string $userId;
private IConfig $config;
private IUserSession $userSession;
private AccessibilityProvider $accessibilityProvider;
/**
* Config constructor.
*
* @param string $appName
* @param IRequest $request
* @param IConfig $config
* @param IUserSession $userSession
* @param AccessibilityProvider $accessibilityProvider
*/
public function __construct(string $appName,
IRequest $request,
@ -74,7 +55,6 @@ class ConfigController extends OCSController {
IUserSession $userSession,
AccessibilityProvider $accessibilityProvider) {
parent::__construct($appName, $request);
$this->appName = $appName;
$this->config = $config;
$this->userSession = $userSession;
$this->accessibilityProvider = $accessibilityProvider;
@ -102,7 +82,8 @@ class ConfigController extends OCSController {
*
* Set theme or font config
*
* @param string $key theme or font
* @param string $key the theme or font
* @param string|false $value the value
* @return DataResponse
* @throws OCSBadRequestException|PreConditionNotMetException
*/

View file

@ -35,17 +35,11 @@ use OCP\Migration\IRepairStep;
class RepairUserConfig implements IRepairStep {
/** @var IUserManager */
protected $userManager;
/** @var IConfig */
protected $config;
protected IUserManager $userManager;
protected IConfig $config;
/**
* MigrateUserConfig constructor.
*
* @param IConfig $config
* @param IUserManager $userManager
*/
public function __construct(IConfig $config,
IUserManager $userManager) {

View file

@ -31,10 +31,8 @@ use OCP\IConfig;
use OCP\IUserSession;
class JSDataService extends InitialStateProvider {
/** @var IUserSession */
private $userSession;
/** @var IConfig */
private $config;
private IUserSession $userSession;
private IConfig $config;
public function __construct(
IUserSession $userSession,