View Javadoc

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 java.util.ArrayList;
21  import java.util.List;
22  
23  import sk.baka.ambient.commons.Bind;
24  import android.content.Context;
25  import android.view.Gravity;
26  import android.widget.Toast;
27  
28  /***
29   * Contains current ambient configuration.
30   * 
31   * @author Martin Vysny
32   */
33  public final class ConfigurationBean {
34  	/***
35  	 * A notification to show when the current playing track is changed.
36  	 * 
37  	 * @author Martin Vysny
38  	 */
39  	public static enum TrackChangeNotifEnum {
40  		/***
41  		 * No notification.
42  		 */
43  		None(R.string.configNotifNone, 0),
44  		/***
45  		 * A quick info.
46  		 */
47  		Short(R.string.configNotifShort, Toast.LENGTH_SHORT),
48  		/***
49  		 * Detailed info.
50  		 */
51  		Long(R.string.configNotifLong, Toast.LENGTH_LONG);
52  		/***
53  		 * Caption text.
54  		 */
55  		public final int caption;
56  
57  		/***
58  		 * View duration, intended for the {@link Toast#setDuration(int)}
59  		 * method.
60  		 */
61  		public final int viewDuration;
62  
63  		private TrackChangeNotifEnum(final int caption, final int viewDuration) {
64  			this.caption = caption;
65  			this.viewDuration = viewDuration;
66  		}
67  
68  		/***
69  		 * Returns captions list.
70  		 * 
71  		 * @param context
72  		 *            string resolver
73  		 * @return list of strings - captions
74  		 */
75  		public static List<CharSequence> getCaptions(final Context context) {
76  			final List<CharSequence> captions = new ArrayList<CharSequence>();
77  			for (final TrackChangeNotifEnum notif : values()) {
78  				captions.add(context.getString(notif.caption));
79  			}
80  			return captions;
81  		}
82  	}
83  
84  	/***
85  	 * A notification to show when the current playing track is changed.
86  	 * 
87  	 * @author Martin Vysny
88  	 */
89  	public static enum TrackChangeNotifLocationEnum {
90  		/***
91  		 * Location: top
92  		 */
93  		Top(R.string.configNotifLocationTop, Gravity.TOP),
94  		/***
95  		 * Center the notification
96  		 */
97  		Center(R.string.configNotifLocationCenter, Gravity.CENTER),
98  		/***
99  		 * Show the notification in the bottom of the screen.
100 		 */
101 		Bottom(R.string.configNotifLocationBottom, Gravity.BOTTOM);
102 		/***
103 		 * Caption text.
104 		 */
105 		public final int caption;
106 
107 		/***
108 		 * The gravity, intended for the {@link Toast#setGravity(int, int, int)}
109 		 * method.
110 		 */
111 		public final int gravity;
112 
113 		private TrackChangeNotifLocationEnum(final int caption,
114 				final int gravity) {
115 			this.caption = caption;
116 			this.gravity = gravity;
117 		}
118 
119 		/***
120 		 * Returns captions list.
121 		 * 
122 		 * @param context
123 		 *            string resolver
124 		 * @return list of strings - captions
125 		 */
126 		public static List<CharSequence> getCaptions(final Context context) {
127 			final List<CharSequence> captions = new ArrayList<CharSequence>();
128 			for (final TrackChangeNotifLocationEnum notif : values()) {
129 				captions.add(context.getString(notif.caption));
130 			}
131 			return captions;
132 		}
133 	}
134 
135 	/***
136 	 * A notification to show when the current playing track is changed.
137 	 */
138 	@Bind(captionId = R.string.configNotifCaption, viewId = R.id.configNotificationType)
139 	public TrackChangeNotifEnum notificationType = TrackChangeNotifEnum.Short;
140 
141 	/***
142 	 * Where to show the notification on screen.
143 	 */
144 	@Bind(captionId = R.string.configNotifLocationCaption, viewId = R.id.configNotificationLocation)
145 	public TrackChangeNotifLocationEnum notificationLocation = TrackChangeNotifLocationEnum.Top;
146 
147 	/***
148 	 * The "short" notification format.
149 	 */
150 	@Bind(captionId = R.string.configNotificationShortFormat, viewId = R.id.configNotificationShortFormat, escape = true, tagFormat = true)
151 	public String shortNotificationFormat = "{%artist - }%title{\n%album{, %year}}";
152 
153 	/***
154 	 * The "long" notification format.
155 	 */
156 	@Bind(captionId = R.string.configNotificationLongFormat, viewId = R.id.configNotificationLongFormat, escape = true, tagFormat = true)
157 	public String longNotificationFormat = "{%track: }%title{ (%length)}{\nArtist: %artist}{\nAlbum: %album{, %year}}{\nGenre: %genre}{\nBitrate: %bitratekbps}";
158 
159 	/***
160 	 * Scan these directories for sound files. Directory names are separated by
161 	 * ':'
162 	 */
163 	@Bind(captionId = R.string.configScanDirsShort, viewId = R.id.configScanDirs)
164 	public String scanDirs = "/sdcard";
165 
166 	/***
167 	 * Dynamic playlist: History length.
168 	 */
169 	@Bind(captionId = R.string.configDynamicHistory, viewId = R.id.configDynamicHistory, min = 0, max = 99)
170 	public int dynamicHistorySize = 10;
171 
172 	/***
173 	 * Dynamic playlist: upcoming track count.
174 	 */
175 	@Bind(captionId = R.string.configDynamicUpcoming, viewId = R.id.configDynamicUpcoming, min = 1, max = 99)
176 	public int dynamicUpcomingSize = 5;
177 
178 	/***
179 	 * Notify only when minimized.
180 	 */
181 	@Bind(captionId = -1, viewId = R.id.configPlayerNotifHiddenOnly)
182 	public boolean notifyWhenMinimizedOnly = true;
183 
184 	/***
185 	 * Formatting string for the player ticker.
186 	 */
187 	@Bind(captionId = R.string.configPlayerTickerFormat, viewId = R.id.configPlayerTickerFormat, escape = true, tagFormat = true)
188 	public String playerTickerFormat = "{%track: }{%artist - }%title{ (%album{, %year})}";
189 
190 	/***
191 	 * The gap between tracks, in millis.
192 	 */
193 	@Bind(captionId = R.string.configPlayerGap, viewId = R.id.configPlayerGap, min = 0, max = 9999)
194 	public long playerGap = 1000;
195 
196 	/***
197 	 * Formatting string for the playlist items.
198 	 */
199 	@Bind(captionId = R.string.configPlaylistFormat, viewId = R.id.configPlaylistFormat, escape = true, tagFormat = true)
200 	public String playlistFormat = "{{%artist{, }%album{, }%year}\n}   {%track }%title{ (%length)}";
201 
202 	/***
203 	 * Show tag as <code>null</code> if previous track's tag was the same.
204 	 */
205 	@Bind(captionId = -1, viewId = R.id.configPlaylistRepeatIsNull)
206 	public boolean dontRepeatSameTag = true;
207 
208 	/***
209 	 * Remember playlist on player quit.
210 	 */
211 	@Bind(captionId = -1, viewId = R.id.configPlaylistRemember)
212 	public boolean rememberPlaylist = true;
213 
214 	/***
215 	 * Cache size in kb.
216 	 */
217 	@Bind(captionId = R.string.configCoverCache, viewId = R.id.configCoverCache)
218 	public int coverCache = 256;
219 
220 	/***
221 	 * If <code>true</code> then new covers will not be downloaded. If
222 	 * <code>false</code> then old covers will be purged.
223 	 */
224 	@Bind(captionId = -1, viewId = R.id.configCoverCacheFull)
225 	public boolean dontDownloadOnCacheFull = true;
226 
227 	/***
228 	 * If <code>true</code> then new covers will not be downloaded. If
229 	 * <code>false</code> then old covers will be purged.
230 	 */
231 	@Bind(captionId = -1, viewId = R.id.configAmpacheServerPassword)
232 	public String ampacheEmbeddedPassword = null;
233 }