4040 */
4141namespace OCA \Theming ;
4242
43+ use OCA \Theming \AppInfo \Application ;
44+ use OCA \Theming \Service \BackgroundService ;
4345use OCP \App \AppPathNotFoundException ;
4446use OCP \App \IAppManager ;
4547use OCP \Files \NotFoundException ;
4951use OCP \IL10N ;
5052use OCP \INavigationManager ;
5153use OCP \IURLGenerator ;
54+ use OCP \IUserSession ;
5255
5356class ThemingDefaults extends \OC_Defaults {
5457
55- /** @var IConfig */
56- private $ config ;
57- /** @var IL10N */
58- private $ l ;
59- /** @var ImageManager */
60- private $ imageManager ;
61- /** @var IURLGenerator */
62- private $ urlGenerator ;
63- /** @var ICacheFactory */
64- private $ cacheFactory ;
65- /** @var Util */
66- private $ util ;
67- /** @var IAppManager */
68- private $ appManager ;
69- /** @var INavigationManager */
70- private $ navigationManager ;
71-
72- /** @var string */
73- private $ name ;
74- /** @var string */
75- private $ title ;
76- /** @var string */
77- private $ entity ;
78- /** @var string */
79- private $ productName ;
80- /** @var string */
81- private $ url ;
82- /** @var string */
83- private $ color ;
84-
85- /** @var string */
86- private $ iTunesAppId ;
87- /** @var string */
88- private $ iOSClientUrl ;
89- /** @var string */
90- private $ AndroidClientUrl ;
91- /** @var string */
92- private $ FDroidClientUrl ;
58+ private IConfig $ config ;
59+ private IL10N $ l ;
60+ private ImageManager $ imageManager ;
61+ private IUserSession $ userSession ;
62+ private IURLGenerator $ urlGenerator ;
63+ private ICacheFactory $ cacheFactory ;
64+ private Util $ util ;
65+ private IAppManager $ appManager ;
66+ private INavigationManager $ navigationManager ;
67+
68+ private string $ name ;
69+ private string $ title ;
70+ private string $ entity ;
71+ private string $ productName ;
72+ private string $ url ;
73+ private string $ color ;
74+
75+ private string $ iTunesAppId ;
76+ private string $ iOSClientUrl ;
77+ private string $ AndroidClientUrl ;
78+ private string $ FDroidClientUrl ;
9379
9480 /**
9581 * ThemingDefaults constructor.
9682 *
9783 * @param IConfig $config
9884 * @param IL10N $l
9985 * @param ImageManager $imageManager
86+ * @param IUserSession $userSession
10087 * @param IURLGenerator $urlGenerator
10188 * @param ICacheFactory $cacheFactory
10289 * @param Util $util
10390 * @param IAppManager $appManager
10491 */
10592 public function __construct (IConfig $ config ,
10693 IL10N $ l ,
94+ IUserSession $ userSession ,
10795 IURLGenerator $ urlGenerator ,
10896 ICacheFactory $ cacheFactory ,
10997 Util $ util ,
@@ -115,6 +103,7 @@ public function __construct(IConfig $config,
115103 $ this ->config = $ config ;
116104 $ this ->l = $ l ;
117105 $ this ->imageManager = $ imageManager ;
106+ $ this ->userSession = $ userSession ;
118107 $ this ->urlGenerator = $ urlGenerator ;
119108 $ this ->cacheFactory = $ cacheFactory ;
120109 $ this ->util = $ util ;
@@ -229,10 +218,24 @@ public function getShortFooter() {
229218 * @return string
230219 */
231220 public function getColorPrimary () {
232- $ color = $ this ->config ->getAppValue ('theming ' , 'color ' , $ this ->color );
221+ $ user = $ this ->userSession ->getUser ();
222+ $ color = $ this ->config ->getAppValue (Application::APP_ID , 'color ' , '' );
223+
224+ if ($ color === '' && !empty ($ user )) {
225+ $ themingBackground = $ this ->config ->getUserValue ($ user ->getUID (), Application::APP_ID , 'background ' , 'default ' );
226+ if ($ themingBackground === 'default ' ) {
227+ $ this ->increaseCacheBuster ();
228+ return BackgroundService::DEFAULT_COLOR ;
229+ } else if (isset (BackgroundService::SHIPPED_BACKGROUNDS [$ themingBackground ]['primary_color ' ])) {
230+ $ this ->increaseCacheBuster ();
231+ return BackgroundService::SHIPPED_BACKGROUNDS [$ themingBackground ]['primary_color ' ];
232+ }
233+ }
234+
233235 if (!preg_match ('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i ' , $ color )) {
234- $ color = ' #0082c9 ' ;
236+ return BackgroundService:: DEFAULT_COLOR ;
235237 }
238+
236239 return $ color ;
237240 }
238241
0 commit comments