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.R.string;
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 * {@link string#playlistMgmtTip}
32 */
33 PlaylistManagement(R.drawable.playlist48, R.string.playlist_mgmt,
34 R.string.playlistMgmtTip),
35 /***
36 * {@link string#ShowCollectionTip}
37 */
38 ShowCollection(R.drawable.collection48, R.string.collection,
39 R.string.ShowCollectionTip),
40 /***
41 * Opens or hides the file browser.
42 */
43 ShowFileBrowser(R.drawable.files48, R.string.fb, -1),
44 /***
45 * Opens or hides the player.
46 */
47 ShowPlayer(R.drawable.player48, R.string.player, -1),
48 /***
49 * {@link string#ShowContextTip}
50 */
51 ShowContext(R.drawable.lyrics, R.string.context, R.string.ShowContextTip),
52 /***
53 * Shows or hides karaoke for current track.
54 */
55 ShowKaraoke(R.drawable.karaoke48, R.string.karaoke, -1),
56 /***
57 * Deletes karaoke for current track.
58 */
59 RefreshKaraoke(R.drawable.refresh, R.string.refreshKaraoke, -1),
60 /***
61 * Opens or hides the Magnatune view.
62 */
63 ShowMagnatune(R.drawable.magnatune, R.string.magnatune,
64 R.string.ShowMagnatuneTip),
65 /***
66 * Navigates back.
67 */
68 Back(R.drawable.back48, R.string.back, -1),
69 /***
70 * {@link string#GoOfflineTip}
71 */
72 GoOffline(R.drawable.online, R.string.goOffline, R.string.GoOfflineTip),
73 /***
74 * Goes online.
75 */
76 GoOnline(R.drawable.offline, R.string.goOnline, R.string.GoOnlineTip),
77 /***
78 * Shows configuration window that configures Ambient.
79 */
80 Configure(R.drawable.config48, R.string.configure, -1),
81 /***
82 * Clears the playlist.
83 */
84 PlaylistClear(R.drawable.playlist_clear48, R.string.playlist_clear, -1),
85 /***
86 * Shuffles the playlist.
87 */
88 PlaylistShuffle(R.drawable.playlist_shuffle48, R.string.playlist_shuffle,
89 -1),
90 /***
91 * {@link string#PlaylistSortByAlbumsTip}
92 */
93 PlaylistSortByAlbums(R.drawable.playlist_sort, R.string.playlist_sort,
94 R.string.PlaylistSortByAlbumsTip),
95 /***
96 * Saves current playlist.
97 */
98 PlaylistSave(R.drawable.playlist_save, R.string.playlist_ls, -1),
99 /***
100 * {@link string#RandomNoTip}
101 */
102 RandomNo(R.drawable.random_no, R.string.normal_song_order,
103 R.string.RandomNoTip) {
104 @Override
105 public Random getRandom() {
106 return Random.NONE;
107 }
108 },
109 /***
110 * {@link string#RandomTracksTip}
111 */
112 RandomTracks(R.drawable.random_track, R.string.random_tracks,
113 R.string.RandomTracksTip) {
114 @Override
115 public Random getRandom() {
116 return Random.TRACK;
117 }
118 },
119 /***
120 * {@link string#RandomAlbumsTip}
121 */
122 RandomAlbums(R.drawable.random_album, R.string.random_albums,
123 R.string.RandomAlbumsTip) {
124 @Override
125 public Random getRandom() {
126 return Random.ALBUM;
127 }
128 },
129 /***
130 * {@link string#RandomAlbumsTracksTip}
131 */
132 RandomAlbumsTracks(R.drawable.random_album_track,
133 R.string.random_albums_tracks, R.string.RandomAlbumsTracksTip) {
134 @Override
135 public Random getRandom() {
136 return Random.ALBUM_TRACK;
137 }
138 },
139 /***
140 * {@link string#RandomAlbumsPlaylistTip}
141 */
142 RandomAlbumsPlaylist(R.drawable.random_album_playlist,
143 R.string.random_albums_playlist, R.string.RandomAlbumsPlaylistTip) {
144 @Override
145 public Random getRandom() {
146 return Random.ALBUM_PLAYLIST;
147 }
148 },
149 /***
150 * Does not repeat anything.
151 */
152 RepeatNothing(R.drawable.repeat_no, R.string.repeat_nothing, -1) {
153 @Override
154 public Repeat getRepeat() {
155 return Repeat.NO;
156 }
157 },
158 /***
159 * {@link string#RepeatTrackTip}
160 */
161 RepeatTrack(R.drawable.repeat_track, R.string.repeat_track,
162 R.string.RepeatTrackTip) {
163 @Override
164 public Repeat getRepeat() {
165 return Repeat.TRACK;
166 }
167 },
168 /***
169 * {@link string#RepeatAlbumTip}
170 */
171 RepeatAlbum(R.drawable.repeat_album, R.string.repeat_album,
172 R.string.RepeatAlbumTip) {
173 @Override
174 public Repeat getRepeat() {
175 return Repeat.ALBUM;
176 }
177 },
178 /***
179 * {@link string#RepeatPlaylistTip}
180 */
181 RepeatPlaylist(R.drawable.repeat_playlist, R.string.repeat_playlist,
182 R.string.RepeatPlaylistTip) {
183 @Override
184 public Repeat getRepeat() {
185 return Repeat.PLAYLIST;
186 }
187 },
188 /***
189 * Queues selected tracks.
190 */
191 QueueTracks(R.drawable.queue, R.string.queue_track, -1),
192 /***
193 * Clears the track queue.
194 */
195 QueueClear(R.drawable.dequeue, R.string.clear_queue, -1),
196 /***
197 * Moves to the next song in the playlist.
198 */
199 PlaybackNext(R.drawable.next48, R.string.next_song, -1),
200 /***
201 * Moves to the previous song in the playlist.
202 */
203 PlaybackPrevious(R.drawable.prev48, R.string.prev_song, -1),
204 /***
205 * Stops the playback.
206 */
207 PlaybackStop(R.drawable.stop48, R.string.stop, -1),
208 /***
209 * Starts the playback.
210 */
211 PlaybackPlay(R.drawable.play48, R.string.play, -1),
212 /***
213 * Pauses the playback.
214 */
215 PlaybackPause(R.drawable.pause48, R.string.pause, -1),
216 /***
217 * Shows the statistics.
218 */
219 ShowStatistics(R.drawable.statistics, R.string.show_statistics, -1),
220 /***
221 * Hides Ambient and minimizes it.
222 */
223 Minimize(R.drawable.back48, R.string.minimize, -1),
224 /***
225 * {@link string#PlaylistStaticTip}
226 */
227 PlaylistStatic(R.drawable.staticplaylist, R.string.static_playlist,
228 R.string.PlaylistStaticTip),
229 /***
230 * {@link string#PlaylistDynamicTip}
231 */
232 PlaylistDynamic(R.drawable.dynamicplaylist, R.string.dynamic_playlist,
233 R.string.PlaylistDynamicTip),
234 /***
235 * Quits (closes) the application.
236 */
237 Quit(R.drawable.quit, R.string.quit, -1),
238 /***
239 * Rescans the magnatune collection.
240 */
241 MagnatuneRescan(R.drawable.refresh, R.string.magnatune_rescan,
242 R.string.RescanMagnatuneTip),
243 /***
244 * Shows the track's license.
245 */
246 ShowLicense(R.drawable.magnatune, R.string.show_license, -1),
247 /***
248 * Opens the "buy" link.
249 */
250 BuyAlbum(R.drawable.magnatune, R.string.buyAlbum, -1),
251 /***
252 * Shows the artist page.
253 */
254 ShowArtistPage(R.drawable.magnatune, R.string.showArtistPage, -1),
255 /***
256 * {@link string#CollectionYearTip}
257 */
258 CollectionYear(R.drawable.year, R.string.coll_year,
259 R.string.CollectionYearTip),
260 /***
261 * Shows the track lyrics.
262 */
263 ShowLyrics(R.drawable.lyrics, R.string.show_lyrics, -1),
264 /***
265 * {@link string#ShowShoutcastTip}
266 */
267 ShowShoutcast(R.drawable.shoutcast48, R.string.showShoutcast,
268 R.string.ShowShoutcastTip),
269 /***
270 * {@link string#ShowAmpacheTip}
271 */
272 ShowAmpache(R.drawable.ampache, R.string.ampache, R.string.ShowAmpacheTip),
273 /***
274 * {@link string#AmpacheConfigureClientTip}
275 */
276 AmpacheConfigureClient(R.drawable.config48,
277 R.string.ampacheConfigureConnection,
278 R.string.AmpacheConfigureClientTip),
279 /***
280 * {@link string#AmpacheSynchronizeTip}
281 */
282 AmpacheSynchronize(R.drawable.synchronize, R.string.ampacheSynchronize,
283 R.string.AmpacheSynchronizeTip),
284 /***
285 * {@link string#ShoutcastNameTrackSwitchTip}
286 */
287 ShoutcastNameTrackSwitch(R.drawable.magnatune,
288 R.string.shoutcastNameTrackSwitch,
289 R.string.ShoutcastNameTrackSwitchTip),
290 /***
291 * Shows the About dialog.
292 */
293 About(R.drawable.button_i, R.string.aboutTitle, -1),
294 /***
295 * Shows a wiki page about selected artist.
296 */
297 ShowWiki(R.drawable.wikipedia, R.string.show_wiki, -1),
298 /***
299 * Starts the embedded Ampache server. Local action.
300 */
301 AmpacheStartServer(R.drawable.ampache_embedded_on,
302 R.string.ampacheServerStart, R.string.AmpacheStartServerTip),
303 /***
304 * Stops the embedded Ampache server. Local action.
305 */
306 AmpacheStopServer(R.drawable.ampache_embedded_on,
307 R.string.ampacheServerStop, -1),
308 /***
309 * Stops the embedded Ampache server. Local action.
310 */
311 RepopulatePlaylist(R.drawable.synchronize,
312 R.string.repopulate, -1),
313 /***
314 * Positions the file browser back to the root directory.
315 */
316 GoToRoot(R.drawable.root, R.string.goToRoot, -1),
317 /***
318 * Deletes selected files.
319 */
320 DeleteSelected(R.drawable.quit, R.string.deleteSelectedFiles, -1),
321 /***
322 * Download selected files from the ampache server.
323 */
324 AmpacheDownloadSelected(R.drawable.download,
325 R.string.ampacheDownloadSelected,
326 R.string.AmpacheDownloadSelectedTip),
327 /***
328 * Performs a refresh.
329 */
330 Refresh(R.drawable.refresh, R.string.refresh, -1),
331 /***
332 * Resizes the task windows.
333 */
334 ResizeKeypad(R.drawable.resize, R.string.resize, -1),
335 /***
336 * {@link string#dpadSearchDesc}
337 */
338 DpadSearch(R.drawable.quit, R.string.dpadSearch, R.string.dpadSearchDesc);
339 /***
340 * The icon resource of the action.
341 */
342 public final int icon;
343
344 /***
345 * The caption resource.
346 */
347 public final int caption;
348
349 /***
350 * The action description, displayed when the activity is activated for the
351 * first time. If <code>-1</code> then no description is available.
352 */
353 public final int description;
354
355 private ActionsEnum(final int icon, final int caption, final int description) {
356 this.icon = icon;
357 this.caption = caption;
358 this.description = description;
359 }
360
361 /***
362 * Returns action for given random constant.
363 *
364 * @param random
365 * the random constant, must not be <code>null</code>.
366 * @return non-null action
367 */
368 public static ActionsEnum getAction(final Random random) {
369 switch (random) {
370 case ALBUM:
371 return RandomAlbums;
372 case NONE:
373 return RandomNo;
374 case TRACK:
375 return RandomTracks;
376 case ALBUM_TRACK:
377 return RandomAlbumsTracks;
378 case ALBUM_PLAYLIST:
379 return RandomAlbumsPlaylist;
380 }
381 throw new Error();
382 }
383
384 /***
385 * Returns action for given random constant.
386 *
387 * @param repeat
388 * the random constant, must not be <code>null</code>.
389 * @return non-null action
390 */
391 public static ActionsEnum getAction(final Repeat repeat) {
392 switch (repeat) {
393 case ALBUM:
394 return RepeatAlbum;
395 case NO:
396 return RepeatNothing;
397 case TRACK:
398 return RepeatTrack;
399 case PLAYLIST:
400 return RepeatPlaylist;
401 }
402 throw new Error();
403 }
404
405 /***
406 * Returns the repeat value of this action or <code>null</code> if this
407 * action is not a set-repeat action.
408 *
409 * @return the repeat value or <code>null</code>.
410 */
411 public Repeat getRepeat() {
412 return null;
413 }
414
415 /***
416 * Returns the "Random" value of this action or <code>null</code> if this
417 * action is not a set-random action.
418 *
419 * @return the Random value or <code>null</code>.
420 */
421 public Random getRandom() {
422 return null;
423 }
424 }