diff --git a/apps/theming/img/default-source.svg b/apps/theming/img/default-source.svg new file mode 100644 index 0000000000000..89711e2a0c8f5 --- /dev/null +++ b/apps/theming/img/default-source.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/apps/theming/img/default.jpg b/apps/theming/img/default.jpg index ad3fafd96f24b..bbea0e905b975 100644 Binary files a/apps/theming/img/default.jpg and b/apps/theming/img/default.jpg differ diff --git a/apps/theming/img/light.jpg b/apps/theming/img/light.jpg new file mode 100644 index 0000000000000..ad3fafd96f24b Binary files /dev/null and b/apps/theming/img/light.jpg differ diff --git a/apps/theming/lib/Service/ThemesService.php b/apps/theming/lib/Service/ThemesService.php index 01ebc3fb5040c..43977721e7632 100644 --- a/apps/theming/lib/Service/ThemesService.php +++ b/apps/theming/lib/Service/ThemesService.php @@ -29,6 +29,7 @@ use OCA\Theming\Themes\DefaultTheme; use OCA\Theming\Themes\DyslexiaFont; use OCA\Theming\Themes\HighContrastTheme; +use OCA\Theming\Themes\LightTheme; use OCP\IConfig; use OCP\IUser; use OCP\IUserSession; @@ -43,6 +44,7 @@ class ThemesService { public function __construct(IUserSession $userSession, IConfig $config, DefaultTheme $defaultTheme, + LightTheme $lightTheme, DarkTheme $darkTheme, HighContrastTheme $highContrastTheme, DarkHighContrastTheme $darkHighContrastTheme, @@ -53,6 +55,7 @@ public function __construct(IUserSession $userSession, // Register themes $this->themesProviders = [ $defaultTheme->getId() => $defaultTheme, + $lightTheme->getId() => $lightTheme, $darkTheme->getId() => $darkTheme, $highContrastTheme->getId() => $highContrastTheme, $darkHighContrastTheme->getId() => $darkHighContrastTheme, diff --git a/apps/theming/lib/Themes/DefaultTheme.php b/apps/theming/lib/Themes/DefaultTheme.php index 191cb5814af54..b13e481907a68 100644 --- a/apps/theming/lib/Themes/DefaultTheme.php +++ b/apps/theming/lib/Themes/DefaultTheme.php @@ -67,15 +67,15 @@ public function getType(): int { } public function getTitle(): string { - return $this->l->t('Light theme'); + return $this->l->t('System default theme'); } public function getEnableLabel(): string { - return $this->l->t('Enable the default light theme'); + return $this->l->t('Enable the system default'); } public function getDescription(): string { - return $this->l->t('The default light appearance.'); + return $this->l->t('Using the default system appearance.'); } public function getMediaQuery(): string { diff --git a/apps/theming/lib/Themes/LightTheme.php b/apps/theming/lib/Themes/LightTheme.php new file mode 100644 index 0000000000000..e988f612226a2 --- /dev/null +++ b/apps/theming/lib/Themes/LightTheme.php @@ -0,0 +1,61 @@ + + * + * @author Joas Schilling + * @author John Molakvoæ + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OCA\Theming\Themes; + +use OCA\Theming\ImageManager; +use OCA\Theming\ThemingDefaults; +use OCA\Theming\Util; +use OCA\Theming\ITheme; +use OCA\Theming\Themes\DefaultTheme; +use OCP\IConfig; +use OCP\IL10N; +use OCP\IURLGenerator; + +class LightTheme extends DefaultTheme implements ITheme { + + public function getId(): string { + return 'light'; + } + + public function getType(): int { + return ITheme::TYPE_THEME; + } + + public function getTitle(): string { + return $this->l->t('Light theme'); + } + + public function getEnableLabel(): string { + return $this->l->t('Enable the default light theme'); + } + + public function getDescription(): string { + return $this->l->t('The default light appearance.'); + } + + public function getMediaQuery(): string { + return '(prefers-color-scheme: light)'; + } +} diff --git a/apps/theming/tests/Controller/UserThemeControllerTest.php b/apps/theming/tests/Controller/UserThemeControllerTest.php index b925085bf41f6..952cd01221047 100644 --- a/apps/theming/tests/Controller/UserThemeControllerTest.php +++ b/apps/theming/tests/Controller/UserThemeControllerTest.php @@ -30,6 +30,7 @@ use OCA\Theming\Themes\DyslexiaFont; use OCA\Theming\Themes\HighContrastTheme; use OCA\Theming\Service\ThemesService; +use OCA\Theming\Themes\LightTheme; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSBadRequestException; use OCP\IConfig; @@ -63,6 +64,7 @@ protected function setUp(): void { $this->themes = [ 'default' => $this->createMock(DefaultTheme::class), + 'light' => $this->createMock(LightTheme::class), 'dark' => $this->createMock(DarkTheme::class), 'highcontrast' => $this->createMock(HighContrastTheme::class), 'dark-highcontrast' => $this->createMock(DarkHighContrastTheme::class), @@ -91,6 +93,7 @@ protected function setUp(): void { public function dataTestThemes() { return [ ['default'], + ['light'], ['dark'], ['highcontrast'], ['dark-highcontrast'], diff --git a/apps/theming/tests/Service/ThemesServiceTest.php b/apps/theming/tests/Service/ThemesServiceTest.php index 56f96d2963788..5865875cbb8f5 100644 --- a/apps/theming/tests/Service/ThemesServiceTest.php +++ b/apps/theming/tests/Service/ThemesServiceTest.php @@ -31,6 +31,7 @@ use OCA\Theming\Themes\DyslexiaFont; use OCA\Theming\Themes\HighContrastTheme; use OCA\Theming\Service\ThemesService; +use OCA\Theming\Themes\LightTheme; use OCA\Theming\ThemingDefaults; use OCA\Theming\Util; use OCP\AppFramework\Http\DataResponse; @@ -81,6 +82,7 @@ protected function setUp(): void { public function testGetThemes() { $expected = [ 'default', + 'light', 'dark', 'highcontrast', 'dark-highcontrast', @@ -92,6 +94,7 @@ public function testGetThemes() { public function dataTestEnableTheme() { return [ + ['default', [], ['default']], ['dark', [], ['dark']], ['dark', ['dark'], ['dark']], ['opendyslexic', ['dark'], ['dark', 'opendyslexic']], @@ -207,6 +210,14 @@ private function initThemes() { $this->config, $l10n, ), + 'light' => new LightTheme( + $util, + $this->themingDefaults, + $urlGenerator, + $imageManager, + $this->config, + $l10n, + ), 'dark' => new DarkTheme( $util, $this->themingDefaults, diff --git a/apps/theming/tests/Themes/DefaultThemeTest.php b/apps/theming/tests/Themes/DefaultThemeTest.php index b9302bb4c957a..160efdba1426e 100644 --- a/apps/theming/tests/Themes/DefaultThemeTest.php +++ b/apps/theming/tests/Themes/DefaultThemeTest.php @@ -97,15 +97,15 @@ public function testGetType() { } public function testGetTitle() { - $this->assertEquals('Light theme', $this->defaultTheme->getTitle()); + $this->assertEquals('System default theme', $this->defaultTheme->getTitle()); } public function testGetEnableLabel() { - $this->assertEquals('Enable the default light theme', $this->defaultTheme->getEnableLabel()); + $this->assertEquals('Enable the system default', $this->defaultTheme->getEnableLabel()); } public function testGetDescription() { - $this->assertEquals('The default light appearance.', $this->defaultTheme->getDescription()); + $this->assertEquals('Using the default system appearance.', $this->defaultTheme->getDescription()); } public function testGetMediaQuery() {