1 /*** 2 * Ambient - A music player for the Android platform 3 Copyright (C) 2007 Martin Vysny 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 package sk.baka.ambient; 19 20 import sk.baka.ambient.collection.CollectionUtils; 21 import sk.baka.ambient.playlist.Random; 22 import sk.baka.ambient.playlist.Repeat; 23 24 /*** 25 * Enumerates all actions that can be taken. 26 * 27 * @author Martin Vysny 28 */ 29 public enum ActionsEnum { 30 /*** 31 * Opens the playlist management menu - you can sort or shuffle the 32 * playlist, add or remove tracks, save and open playlists. 33 */ 34 PlaylistManagement(R.drawable.playlist48, R.string.playlist_mgmt), 35 /*** 36 * Opens or hides the collection browser. 37 */ 38 ShowCollection(R.drawable.collection48, R.string.collection), 39 /*** 40 * Opens or hides the file browser. 41 */ 42 ShowFileBrowser(R.drawable.files48, R.string.fb), 43 /*** 44 * Opens or hides the player. 45 */ 46 ShowPlayer(R.drawable.player48, R.string.player), 47 /*** 48 * Opens or hides the context view. 49 */ 50 ShowContext(R.drawable.lyrics, R.string.context), 51 /*** 52 * Shows or hides karaoke for current track. 53 */ 54 ShowKaraoke(R.drawable.karaoke48, R.string.karaoke), 55 /*** 56 * Deletes karaoke for current track. 57 */ 58 RefreshKaraoke(R.drawable.refresh, R.string.refreshKaraoke), 59 /*** 60 * Opens or hides the Magnatune view. 61 */ 62 ShowMagnatune(R.drawable.magnatune, R.string.magnatune), 63 /*** 64 * Navigates back. 65 */ 66 Back(R.drawable.back48, R.string.back), 67 /*** 68 * Goes offline. 69 */ 70 GoOffline(R.drawable.online, R.string.goOffline), 71 /*** 72 * Goes online. 73 */ 74 GoOnline(R.drawable.offline, R.string.goOnline), 75 /*** 76 * Shows configuration window that configures Ambient. 77 */ 78 Configure(R.drawable.config48, R.string.configure), 79 /*** 80 * Clears the playlist. 81 */ 82 PlaylistClear(R.drawable.playlist_clear48, R.string.playlist_clear), 83 /*** 84 * Shuffles the playlist. 85 */ 86 PlaylistShuffle(R.drawable.playlist_shuffle48, R.string.playlist_shuffle), 87 /*** 88 * Sorts the playlist by album ordering, see 89 * {@link CollectionUtils#ALBUM_ORDER_COMPARATOR} for details. 90 */ 91 PlaylistSortByAlbums(R.drawable.playlist_sort, R.string.playlist_sort), 92 /*** 93 * Saves current playlist. 94 */ 95 PlaylistSave(R.drawable.playlist_save, R.string.playlist_ls), 96 /*** 97 * Sets normal play order. 98 */ 99 RandomNo(R.drawable.random_no, R.string.normal_song_order), 100 /*** 101 * Play random tracks. 102 */ 103 RandomTracks(R.drawable.random_track, R.string.random_tracks), 104 /*** 105 * Play random albums. 106 */ 107 RandomAlbums(R.drawable.random_album, R.string.random_albums), 108 /*** 109 * Play random albums and tracks in the albums. 110 */ 111 RandomAlbumsTracks(R.drawable.random_album_track, 112 R.string.random_albums_tracks), 113 /*** 114 * Play random albums and tracks in the albums. 115 */ 116 RandomAlbumsPlaylist(R.drawable.random_album_playlist, 117 R.string.random_albums_playlist), 118 /*** 119 * Does not repeat anything. 120 */ 121 RepeatNothing(R.drawable.repeat_no, R.string.repeat_nothing), 122 /*** 123 * Repeat single track over and over. 124 */ 125 RepeatTrack(R.drawable.repeat_track, R.string.repeat_track), 126 /*** 127 * Repeats an album. 128 */ 129 RepeatAlbum(R.drawable.repeat_album, R.string.repeat_album), 130 /*** 131 * Repeats playlist. 132 */ 133 RepeatPlaylist(R.drawable.repeat_playlist, R.string.repeat_playlist), 134 /*** 135 * Queues selected tracks. 136 */ 137 QueueTracks(R.drawable.queue, R.string.queue_track), 138 /*** 139 * Clears the track queue. 140 */ 141 QueueClear(R.drawable.dequeue, R.string.clear_queue), 142 /*** 143 * Moves to the next song in the playlist. 144 */ 145 PlaybackNext(R.drawable.next48, R.string.next_song), 146 /*** 147 * Moves to the previous song in the playlist. 148 */ 149 PlaybackPrevious(R.drawable.prev48, R.string.prev_song), 150 /*** 151 * Stops the playback. 152 */ 153 PlaybackStop(R.drawable.stop48, R.string.stop), 154 /*** 155 * Starts the playback. 156 */ 157 PlaybackPlay(R.drawable.play48, R.string.play), 158 /*** 159 * Pauses the playback. 160 */ 161 PlaybackPause(R.drawable.pause48, R.string.pause), 162 /*** 163 * Shows the statistics. 164 */ 165 ShowStatistics(R.drawable.statistics, R.string.show_statistics), 166 /*** 167 * Hides Ambient and minimizes it. 168 */ 169 Minimize(R.drawable.back48, R.string.minimize), 170 /*** 171 * Activates static playlist. 172 */ 173 PlaylistStatic(R.drawable.staticplaylist, R.string.static_playlist), 174 /*** 175 * Activates dynamic playlist. 176 */ 177 PlaylistDynamic(R.drawable.dynamicplaylist, R.string.dynamic_playlist), 178 /*** 179 * Quits (closes) the application. 180 */ 181 Quit(R.drawable.quit, R.string.quit), 182 /*** 183 * Rescans the magnatune collection. 184 */ 185 MagnatuneRescan(R.drawable.refresh, R.string.magnatune_rescan), 186 /*** 187 * Shows the track's license. 188 */ 189 ShowLicense(R.drawable.magnatune, R.string.show_license), 190 /*** 191 * Opens the "buy" link. 192 */ 193 BuyAlbum(R.drawable.magnatune, R.string.buyAlbum), 194 /*** 195 * Shows the artist page. 196 */ 197 ShowArtistPage(R.drawable.magnatune, R.string.showArtistPage), 198 /*** 199 * Flips the visibility of "filtering by a year" in the collection. 200 */ 201 CollectionYear(R.drawable.year, R.string.coll_year), 202 /*** 203 * Shows the track lyrics. 204 */ 205 ShowLyrics(R.drawable.lyrics, R.string.show_lyrics), 206 /*** 207 * Shows the shoutcast view. 208 */ 209 ShowShoutcast(R.drawable.shoutcast48, R.string.showShoutcast), 210 /*** 211 * Shows the Ampache browser. 212 */ 213 ShowAmpache(R.drawable.ampache, R.string.ampache), 214 /*** 215 * Configure the Ampache connection. 216 */ 217 AmpacheConfigureClient(R.drawable.config48, 218 R.string.ampacheConfigureConnection), 219 /*** 220 * Synchronize tracks with the Ampache server. 221 */ 222 AmpacheSynchronize(R.drawable.synchronize, R.string.ampacheSynchronize), 223 /*** 224 * Switch between the radio name/current track display. 225 */ 226 ShoutcastNameTrackSwitch(R.drawable.magnatune, 227 R.string.shoutcastNameTrackSwitch), 228 /*** 229 * Shows the About dialog. 230 */ 231 About(R.drawable.button_i, R.string.aboutTitle), 232 /*** 233 * Shows a wiki page about selected artist. 234 */ 235 ShowWiki(R.drawable.wikipedia, R.string.show_wiki), 236 /*** 237 * Starts the embedded Ampache server. Local action. 238 */ 239 AmpacheStartServer(R.drawable.ampache_embedded_off, 240 R.string.ampacheServerStart), 241 /*** 242 * Stops the embedded Ampache server. Local action. 243 */ 244 AmpacheStopServer(R.drawable.ampache_embedded_on, 245 R.string.ampacheServerStop), 246 /*** 247 * Positions the file browser back to the root directory. 248 */ 249 GoToRoot(R.drawable.root, R.string.goToRoot), 250 /*** 251 * Deletes selected files. 252 */ 253 DeleteSelected(R.drawable.quit, R.string.deleteSelectedFiles); 254 /*** 255 * The icon resource of the action. 256 */ 257 public final int icon; 258 259 /*** 260 * The caption resource. 261 */ 262 public final int caption; 263 264 private ActionsEnum(final int icon, final int caption) { 265 this.icon = icon; 266 this.caption = caption; 267 } 268 269 /*** 270 * Returns action for given random constant. 271 * 272 * @param random 273 * the random constant, must not be <code>null</code>. 274 * @return non-null action 275 */ 276 public static ActionsEnum getAction(final Random random) { 277 switch (random) { 278 case ALBUM: 279 return RandomAlbums; 280 case NONE: 281 return RandomNo; 282 case TRACK: 283 return RandomTracks; 284 case ALBUM_TRACK: 285 return RandomAlbumsTracks; 286 case ALBUM_PLAYLIST: 287 return RandomAlbumsPlaylist; 288 } 289 throw new Error(); 290 } 291 292 /*** 293 * Returns action for given random constant. 294 * 295 * @param repeat 296 * the random constant, must not be <code>null</code>. 297 * @return non-null action 298 */ 299 public static ActionsEnum getAction(final Repeat repeat) { 300 switch (repeat) { 301 case ALBUM: 302 return RepeatAlbum; 303 case NO: 304 return RepeatNothing; 305 case TRACK: 306 return RepeatTrack; 307 case PLAYLIST: 308 return RepeatPlaylist; 309 } 310 throw new Error(); 311 } 312 }