From fccf2a013d913de636f19d1d52c523a9e512f4bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Thomas?= Date: Sat, 18 Jun 2016 21:16:18 +0200 Subject: [PATCH] Add user option for keyboard shortcuts --- .../command/PersonalSettingsCommand.java | 9 +++++++++ .../player/controller/MultiController.java | 1 + .../PersonalSettingsController.java | 2 ++ .../org/libresonic/player/dao/UserDao.java | 5 +++-- .../player/dao/schema/hsql/Schema61.java | 6 ++++++ .../player/domain/UserSettings.java | 9 +++++++++ .../player/service/SettingsService.java | 1 + .../player/i18n/ResourceBundle_de.properties | 1 + .../player/i18n/ResourceBundle_en.properties | 1 + .../src/main/webapp/WEB-INF/jsp/head.jsp | 19 ++++++++++++++----- .../webapp/WEB-INF/jsp/personalSettings.jsp | 9 ++++++++- 11 files changed, 55 insertions(+), 8 deletions(-) diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/PersonalSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/PersonalSettingsCommand.java index bea8cd23..1f182583 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/PersonalSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/PersonalSettingsCommand.java @@ -52,6 +52,7 @@ public class PersonalSettingsCommand { private boolean showArtistInfoEnabled; private boolean nowPlayingAllowed; private boolean autoHidePlayQueue; + private boolean keyboardShortcutsEnabled; private boolean finalVersionNotificationEnabled; private boolean betaVersionNotificationEnabled; private boolean songNotificationEnabled; @@ -230,6 +231,14 @@ public class PersonalSettingsCommand { this.autoHidePlayQueue = autoHidePlayQueue; } + public boolean isKeyboardShortcutsEnabled() { + return keyboardShortcutsEnabled; + } + + public void setKeyboardShortcutsEnabled(boolean keyboardShortcutsEnabled) { + this.keyboardShortcutsEnabled = keyboardShortcutsEnabled; + } + public boolean isLastFmEnabled() { return lastFmEnabled; } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java index e37b736e..c332e2e4 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java @@ -238,6 +238,7 @@ public class MultiController extends MultiActionController { map.put("showRight", userSettings.isShowNowPlayingEnabled() || userSettings.isShowChatEnabled()); map.put("autoHidePlayQueue", userSettings.isAutoHidePlayQueue()); map.put("listReloadDelay", userSettings.getListReloadDelay()); + map.put("keyboardShortcutsEnabled", userSettings.isKeyboardShortcutsEnabled()); map.put("showSideBar", userSettings.isShowSideBar()); map.put("brand", settingsService.getBrand()); return new ModelAndView("index", "model", map); diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/PersonalSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/PersonalSettingsController.java index e772c224..3a0cb5f0 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/PersonalSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/PersonalSettingsController.java @@ -74,6 +74,7 @@ public class PersonalSettingsController extends SimpleFormController { command.setSongNotificationEnabled(userSettings.isSongNotificationEnabled()); command.setAutoHidePlayQueue(userSettings.isAutoHidePlayQueue()); command.setListReloadDelay(userSettings.getListReloadDelay()); + command.setKeyboardShortcutsEnabled(userSettings.isKeyboardShortcutsEnabled()); command.setLastFmEnabled(userSettings.isLastFmEnabled()); command.setLastFmUsername(userSettings.getLastFmUsername()); command.setLastFmPassword(userSettings.getLastFmPassword()); @@ -137,6 +138,7 @@ public class PersonalSettingsController extends SimpleFormController { settings.setSongNotificationEnabled(command.isSongNotificationEnabled()); settings.setAutoHidePlayQueue(command.isAutoHidePlayQueue()); settings.setListReloadDelay(command.getListReloadDelay()); + settings.setKeyboardShortcutsEnabled(command.isKeyboardShortcutsEnabled()); settings.setLastFmEnabled(command.isLastFmEnabled()); settings.setLastFmUsername(command.getLastFmUsername()); settings.setSystemAvatarId(getSystemAvatarId(command)); diff --git a/libresonic-main/src/main/java/org/libresonic/player/dao/UserDao.java b/libresonic-main/src/main/java/org/libresonic/player/dao/UserDao.java index 87c3d81a..b8aa5e45 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/dao/UserDao.java +++ b/libresonic-main/src/main/java/org/libresonic/player/dao/UserDao.java @@ -44,7 +44,7 @@ public class UserDao extends AbstractDao { "playlist_year, playlist_bit_rate, playlist_duration, playlist_format, playlist_file_size, " + "last_fm_enabled, last_fm_username, last_fm_password, transcode_scheme, show_now_playing, selected_music_folder_id, " + "party_mode_enabled, now_playing_allowed, avatar_scheme, system_avatar_id, changed, show_chat, show_artist_info, auto_hide_play_queue, " + - "view_as_list, default_album_list, queue_following_songs, show_side_bar, list_reload_delay"; + "view_as_list, default_album_list, queue_following_songs, show_side_bar, list_reload_delay, keyboard_shortcuts_enabled"; private static final Integer ROLE_ID_ADMIN = 1; private static final Integer ROLE_ID_DOWNLOAD = 2; @@ -188,7 +188,7 @@ public class UserDao extends AbstractDao { settings.getAvatarScheme().name(), settings.getSystemAvatarId(), settings.getChanged(), settings.isShowChatEnabled(), settings.isShowArtistInfoEnabled(), settings.isAutoHidePlayQueue(), settings.isViewAsList(), settings.getDefaultAlbumList().getId(), settings.isQueueFollowingSongs(), - settings.isShowSideBar(), settings.getListReloadDelay()}); + settings.isShowSideBar(), settings.getListReloadDelay(), settings.isKeyboardShortcutsEnabled()}); } private static String encrypt(String s) { @@ -350,6 +350,7 @@ public class UserDao extends AbstractDao { settings.setQueueFollowingSongs(rs.getBoolean(col++)); settings.setShowSideBar(rs.getBoolean(col++)); settings.setListReloadDelay((Integer) rs.getObject(col++)); + settings.setKeyboardShortcutsEnabled(rs.getBoolean(col++)); return settings; } diff --git a/libresonic-main/src/main/java/org/libresonic/player/dao/schema/hsql/Schema61.java b/libresonic-main/src/main/java/org/libresonic/player/dao/schema/hsql/Schema61.java index d2634efa..378d11c3 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/dao/schema/hsql/Schema61.java +++ b/libresonic-main/src/main/java/org/libresonic/player/dao/schema/hsql/Schema61.java @@ -44,5 +44,11 @@ public class Schema61 extends Schema { template.execute("alter table user_settings add list_reload_delay int default 60 not null"); LOG.info("Database column 'user_settings.list_reload_delay' was added successfully."); } + + if (!columnExists(template, "keyboard_shortcuts_enabled", "user_settings")) { + LOG.info("Database column 'user_settings.keyboard_shortcuts_enabled' not found. Creating it."); + template.execute("alter table user_settings add keyboard_shortcuts_enabled boolean default false not null"); + LOG.info("Database column 'user_settings.keyboard_shortcuts_enabled' was added successfully."); + } } } diff --git a/libresonic-main/src/main/java/org/libresonic/player/domain/UserSettings.java b/libresonic-main/src/main/java/org/libresonic/player/domain/UserSettings.java index 05a9139c..3d88454a 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/domain/UserSettings.java +++ b/libresonic-main/src/main/java/org/libresonic/player/domain/UserSettings.java @@ -38,6 +38,7 @@ public class UserSettings { private boolean finalVersionNotificationEnabled; private boolean betaVersionNotificationEnabled; private boolean songNotificationEnabled; + private boolean keyboardShortcutsEnabled; private boolean autoHidePlayQueue; private boolean showSideBar; private boolean viewAsList; @@ -221,6 +222,14 @@ public class UserSettings { this.autoHidePlayQueue = autoHidePlayQueue; } + public boolean isKeyboardShortcutsEnabled() { + return keyboardShortcutsEnabled; + } + + public void setKeyboardShortcutsEnabled(boolean keyboardShortcutsEnabled) { + this.keyboardShortcutsEnabled = keyboardShortcutsEnabled; + } + public boolean isShowSideBar() { return showSideBar; } diff --git a/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java b/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java index 2c579baf..4ca1eeef 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java +++ b/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java @@ -1264,6 +1264,7 @@ public class SettingsService { settings.setPartyModeEnabled(false); settings.setNowPlayingAllowed(true); settings.setAutoHidePlayQueue(true); + settings.setKeyboardShortcutsEnabled(false); settings.setShowSideBar(true); settings.setShowArtistInfoEnabled(true); settings.setViewAsList(false); diff --git a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_de.properties b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_de.properties index 5cf701c7..b7da1d8a 100644 --- a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_de.properties +++ b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_de.properties @@ -350,6 +350,7 @@ personalsettings.nowplayingallowed = Zeige anderen was ich h\u00F6re personalsettings.showchat = Zeige Chat Nachrichten personalsettings.showartistinfo = Zeige Artisten-Info personalsettings.autohideplayqueue = Playlist automatisch ausblenden +personalsettings.keyboardshortcutsenabled = Tastaturk\u00FCrzeln aktivieren personalsettings.finalversionnotification = Informiere mich \u00FCber neue Versionen personalsettings.betaversionnotification = Informiere mich \u00FCber neue Beta Versionen personalsettings.songnotification = Benachrichtigen Sie mich, wenn neue Songs gespielt werden (nicht von allen Browsern unterst\u00FCtzt) diff --git a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties index a71e11bb..510018ff 100644 --- a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties +++ b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties @@ -375,6 +375,7 @@ personalsettings.nowplayingallowed = Let others see what I am playing personalsettings.showchat = Show chat messages personalsettings.showartistinfo = Show artist info personalsettings.autohideplayqueue = Auto-hide play queue +personalsettings.keyboardshortcutsenabled = Enable keyboard shortcuts personalsettings.finalversionnotification = Notify me about new versions personalsettings.betaversionnotification = Notify me about new beta versions personalsettings.songnotification = Notify me when new songs are played (not supported by all browsers) diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/head.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/head.jsp index 5331458b..45dea935 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/head.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/head.jsp @@ -11,9 +11,21 @@ Libresonic + + + + diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/personalSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/personalSettings.jsp index 449e18f6..f57974d3 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/personalSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/personalSettings.jsp @@ -179,6 +179,13 @@ + + + + + +
+ @@ -253,4 +260,4 @@ - \ No newline at end of file +