aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/App/AppManager.php16
-rw-r--r--lib/private/NavigationManager.php12
-rw-r--r--lib/private/Server.php3
-rw-r--r--lib/public/App/IAppManager.php9
4 files changed, 34 insertions, 6 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php
index 5eeb7ef1fbd..5dec4e7ccde 100644
--- a/lib/private/App/AppManager.php
+++ b/lib/private/App/AppManager.php
@@ -56,6 +56,7 @@ use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
+use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Settings\IManager as ISettingsManager;
@@ -104,9 +105,24 @@ class AppManager implements IAppManager {
private ICacheFactory $memCacheFactory,
private IEventDispatcher $dispatcher,
private LoggerInterface $logger,
+ private IURLGenerator $urlGenerator,
) {
}
+ public function getAppIcon(string $appId): ?string {
+ $possibleIcons = [$appId . '.svg', 'app.svg', $appId . '-dark.svg', 'app-dark.svg'];
+ $icon = null;
+ foreach ($possibleIcons as $iconName) {
+ try {
+ $icon = $this->urlGenerator->imagePath($appId, $iconName);
+ break;
+ } catch (\RuntimeException $e) {
+ // ignore
+ }
+ }
+ return $icon;
+ }
+
/**
* @return string[] $appId => $enabled
*/
diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php
index 17573d9db86..cac52ab5c9f 100644
--- a/lib/private/NavigationManager.php
+++ b/lib/private/NavigationManager.php
@@ -372,16 +372,18 @@ class NavigationManager implements INavigationManager {
$order = $nav['order'] ?? 100;
$type = $nav['type'];
$route = !empty($nav['route']) ? $this->urlGenerator->linkToRoute($nav['route']) : '';
- $icon = $nav['icon'] ?? 'app.svg';
- foreach ([$icon, "$app.svg"] as $i) {
+ $icon = $nav['icon'] ?? null;
+ if ($icon !== null) {
try {
- $icon = $this->urlGenerator->imagePath($app, $i);
- break;
+ $icon = $this->urlGenerator->imagePath($app, $icon);
} catch (\RuntimeException $ex) {
- // no icon? - ignore it then
+ // ignore
}
}
if ($icon === null) {
+ $icon = $this->appManager->getAppIcon($app);
+ }
+ if ($icon === null) {
$icon = $this->urlGenerator->imagePath('core', 'default-app-icon');
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 385d654b951..2732b6486f2 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -893,7 +893,8 @@ class Server extends ServerContainer implements IServerContainer {
$c->get(IGroupManager::class),
$c->get(ICacheFactory::class),
$c->get(IEventDispatcher::class),
- $c->get(LoggerInterface::class)
+ $c->get(LoggerInterface::class),
+ $c->get(IURLGenerator::class),
);
});
/** @deprecated 19.0.0 */
diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php
index d15cfdbea96..968771388dc 100644
--- a/lib/public/App/IAppManager.php
+++ b/lib/public/App/IAppManager.php
@@ -62,6 +62,15 @@ interface IAppManager {
public function getAppVersion(string $appId, bool $useCache = true): string;
/**
+ * Returns the app icon or null if none is found
+ *
+ * @param string $appId
+ * @return string|null
+ * @since 29.0.0
+ */
+ public function getAppIcon(string $appId): string|null;
+
+ /**
* Check if an app is enabled for user
*
* @param string $appId