diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ffcb66..52ec0d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog All notable changes to the Audio Player SONOS project will be documented in this file. +## 1.3.0 - 2021-09-21 +### Changed +- more NC compatibility +- updated event listener +- new notifications + ## 1.2.0 - 2020-10-04 ### Added - NC 20 diff --git a/appinfo/app.php b/appinfo/app.php deleted file mode 100644 index 5ace303..0000000 --- a/appinfo/app.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @copyright 2019 Marcel Scherello - */ - -namespace OCA\audioplayer_sonos\AppInfo; - -use OCP\Util; - -\OC::$server->getEventDispatcher()->addListener('OCA\audioplayer::loadAdditionalScripts', function () { - Util::addScript('audioplayer_sonos', 'sonos'); - Util::addStyle('audioplayer_sonos', 'sonos'); -} -); \ No newline at end of file diff --git a/appinfo/info.xml b/appinfo/info.xml index 83def89..51d172f 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -3,12 +3,11 @@ audioplayer_sonos Audio Player - SONOS (add-on) SONOS Playback - - 1.2.1 + 1.3.0 agpl Marcel Scherello audioplayer_sonos @@ -22,8 +21,8 @@ https://help.nextcloud.com/c/apps/audioplayer https://raw.githubusercontent.com/rello/audioplayer_sonos/master/screenshots/audioplayer_sonos_logo.png - - + + diff --git a/appinfo/routes.php b/appinfo/routes.php index 9e53c56..9c44ac2 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -9,11 +9,8 @@ * @copyright 2019 Marcel Scherello */ -namespace OCA\audioplayer_sonos\AppInfo; - -$application = new Application(); - -$application->registerRoutes($this, ['routes' => [ +return [ + 'routes' => [ ['name' => 'setting#setValue', 'url' => '/setvalue', 'verb' => 'POST'], ['name' => 'setting#getValue', 'url' => '/getvalue', 'verb' => 'POST'], ['name' => 'setting#admin', 'url' => '/admin', 'verb' => 'POST'], @@ -22,4 +19,5 @@ ['name' => 'sonos#setAction', 'url' => '/sonosaction', 'verb' => 'POST'], ['name' => 'sonos#getDebugInfo', 'url' => '/sonosdebug', 'verb' => 'GET'], ['name' => 'sonos#getDeviceList', 'url' => '/sonosdevices', 'verb' => 'POST'], -]]); + ] +]; diff --git a/js/settings/admin.js b/js/settings/admin.js index a1c34a6..e06eb01 100644 --- a/js/settings/admin.js +++ b/js/settings/admin.js @@ -28,7 +28,7 @@ document.addEventListener('DOMContentLoaded', function () { 'value': user_value }, success: function () { - OC.Notification.showTemporary(t('audioplayer_sonos', 'saved')); + OCP.Toast.success(t('audioplayer_sonos', 'saved')) } }); }); diff --git a/js/settings/personal.js b/js/settings/personal.js index dc87676..05b38b8 100644 --- a/js/settings/personal.js +++ b/js/settings/personal.js @@ -28,7 +28,7 @@ document.addEventListener('DOMContentLoaded', function () { 'value': user_value }, success: function () { - OC.Notification.showTemporary(t('audioplayer_sonos', 'saved')); + OCP.Toast.success(t('audioplayer_sonos', 'saved')) } }); }); @@ -43,7 +43,7 @@ document.addEventListener('DOMContentLoaded', function () { 'value': user_value }, success: function () { - OC.Notification.showTemporary(t('audioplayer_sonos', 'saved')); + OCP.Toast.success(t('audioplayer_sonos', 'saved')) } }); }); @@ -58,7 +58,7 @@ document.addEventListener('DOMContentLoaded', function () { 'value': user_value }, success: function () { - OC.Notification.showTemporary(t('audioplayer_sonos', 'saved')); + OCP.Toast.success(t('audioplayer_sonos', 'saved')) } }); }); diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 95f40d4..ce811fe 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -11,13 +11,28 @@ namespace OCA\audioplayer_sonos\AppInfo; +use OCA\audioplayer\Event\LoadAdditionalScriptsEvent; +use OCA\audioplayer_sonos\Listener\LoadAdditionalScripts; use OCP\AppFramework\App; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; -class Application extends App { +class Application extends App implements IBootstrap +{ + public const APP_ID = 'audioplayer_sonos'; - public function __construct(array $urlParams = array()) { + public function __construct(array $urlParams = []) + { + parent::__construct(self::APP_ID, $urlParams); + } - parent::__construct('audioplayer_sonos', $urlParams); + public function register(IRegistrationContext $context): void + { + $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class); + } - } -} + public function boot(IBootContext $context): void + { + } +} \ No newline at end of file diff --git a/lib/Controller/DbController.php b/lib/Controller/DbController.php index a6210ba..8c8672a 100644 --- a/lib/Controller/DbController.php +++ b/lib/Controller/DbController.php @@ -14,11 +14,8 @@ use OCP\AppFramework\Controller; use OCP\IRequest; use OCP\IL10N; -use OCP\IDbConnection; -use OCP\Share\IManager; -use OCP\ILogger; -use OCP\ITagManager; - +use OCP\IDBConnection; +use Psr\Log\LoggerInterface; /** * Controller class for main page. */ @@ -26,29 +23,20 @@ class DbController extends Controller { private $userId; - private $l10n; private $db; - private $shareManager; - private $tagManager; private $logger; public function __construct( $appName, IRequest $request, $userId, - IL10N $l10n, IDbConnection $db, - ITagManager $tagManager, - IManager $shareManager, - ILogger $logger + LoggerInterface $logger ) { parent::__construct($appName, $request); $this->userId = $userId; - $this->l10n = $l10n; $this->db = $db; - $this->shareManager = $shareManager; - $this->tagManager = $tagManager; $this->logger = $logger; } diff --git a/lib/Controller/SettingController.php b/lib/Controller/SettingController.php index f0bfacb..4310091 100644 --- a/lib/Controller/SettingController.php +++ b/lib/Controller/SettingController.php @@ -15,11 +15,6 @@ use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\IConfig; -use OCP\Files\IRootFolder; -use OCP\ITagManager; -use OCP\IDbConnection; -use OCP\ISession; - /** * Controller class for main page. @@ -28,35 +23,18 @@ class SettingController extends Controller { private $userId; private $config; - private $rootFolder; - private $tagger; - private $tagManager; - private $db; - private $session; - private $DBController; public function __construct( $appName, IRequest $request, $userId, - IConfig $config, - IDBConnection $db, - ITagManager $tagManager, - IRootFolder $rootFolder, - ISession $session, - DbController $DBController + IConfig $config ) { parent::__construct($appName, $request); $this->appName = $appName; $this->userId = $userId; $this->config = $config; - $this->db = $db; - $this->tagManager = $tagManager; - $this->tagger = null; - $this->rootFolder = $rootFolder; - $this->session = $session; - $this->DBController = $DBController; } /** diff --git a/lib/Controller/SonosController.php b/lib/Controller/SonosController.php index 201d684..242a5b2 100644 --- a/lib/Controller/SonosController.php +++ b/lib/Controller/SonosController.php @@ -16,7 +16,7 @@ use OCP\AppFramework\Http\JSONResponse; use OCP\Files\IRootFolder; use OCP\IConfig; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use OCP\IRequest; /** @@ -41,7 +41,7 @@ public function __construct( IRequest $request, $userId, IConfig $configManager, - ILogger $logger, + LoggerInterface $logger, IRootFolder $rootFolder, DbController $DBController ) diff --git a/lib/Listener/LoadAdditionalScripts.php b/lib/Listener/LoadAdditionalScripts.php new file mode 100644 index 0000000..037af8b --- /dev/null +++ b/lib/Listener/LoadAdditionalScripts.php @@ -0,0 +1,31 @@ + + * @copyright 2019 Marcel Scherello + */ + +namespace OCA\audioplayer_sonos\Listener; + +use OCA\audioplayer\Event\LoadAdditionalScriptsEvent; +use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventListener; +use OCP\Util; + +class LoadAdditionalScripts implements IEventListener +{ + public function handle(Event $event): void + { + if ($event instanceof LoadAdditionalScriptsEvent) { + Util::addScript('audioplayer_sonos', 'sonos'); + Util::addStyle('audioplayer_sonos', 'sonos'); + } + } +} \ No newline at end of file