diff options
18 files changed, 278 insertions, 53 deletions
diff --git a/res/menu/select_album.xml b/res/menu/select_album.xml index 4b79d251..fa887c28 100644 --- a/res/menu/select_album.xml +++ b/res/menu/select_album.xml @@ -14,6 +14,22 @@ compat:showAsAction="ifRoom|withText"/> <item + android:id="@+id/menu_top_tracks" + android:title="@string/menu.top_tracks"/> + + <item android:id="@+id/menu_show_all" android:title="@string/menu.show_all"/> + + <item + android:id="@+id/menu_download" + android:title="@string/common.download"/> + + <item + android:id="@+id/menu_cache" + android:title="@string/common.pin"/> + + <item + android:id="@+id/menu_delete" + android:title="@string/menu.delete_cache"/> </menu> diff --git a/res/values/arrays.xml b/res/values/arrays.xml index deb8fdf5..3e85c982 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -225,4 +225,14 @@ <item>@string/settings.sync_interval_1440</item> </string-array> + <string-array name="replayGainTypeValues"> + <item>1</item> + <item>2</item> + <item>3</item> + </string-array> + <string-array name="replayGainTypeNames"> + <item>@string/settings.replay_gain_type.smart</item> + <item>@string/settings.replay_gain_type.album</item> + <item>@string/settings.replay_gain_type.track</item> + </string-array> </resources> diff --git a/res/values/strings.xml b/res/values/strings.xml index 857ebe71..0fdb2361 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -103,6 +103,7 @@ <string name="menu.add_user">Add User</string>
<string name="menu.rescan">Rescan Server</string>
<string name="menu.rate">Set Rating</string>
+ <string name="menu.top_tracks">Last.FM Top Tracks</string>
<string name="playlist.label">Playlists</string>
<string name="playlist.update_info">Update Information</string>
@@ -173,7 +174,7 @@ <string name="download.playerstate_downloading">Downloading - %s</string>
<string name="download.playerstate_buffering">Buffering</string>
<string name="download.playerstate_playing_shuffle">Playing shuffle</string>
- <string name="download.menu_show_album">Show album</string>
+ <string name="download.menu_show_album">Show Album</string>
<string name="download.menu_lyrics">Lyrics</string>
<string name="download.menu_remove">Remove from queue</string>
<string name="download.menu_remove_all">Remove all</string>
@@ -430,6 +431,10 @@ <string name="settings.admin_enabled_summary">Whether or not to display the admin listing in the pull out drawer</string>
<string name="settings.replay_gain">Replay Gain</string>
<string name="settings.replay_gain_summary">Whether or not to scale playback volume by track and album replay gain tags</string>
+ <string name="settings.replay_gain_type">Read from tags</string>
+ <string name="settings.replay_gain_type.smart">Smart detection</string>
+ <string name="settings.replay_gain_type.album">Album tags</string>
+ <string name="settings.replay_gain_type.track">Track tags</string>
<string name="settings.replay_gain_bump">Replay Gain Pre-amp</string>
<string name="settings.replay_gain_untagged">Songs without Replay Gain</string>
diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 394c268f..af782ac1 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -369,6 +369,13 @@ android:key="replayGain" android:defaultValue="false"/> + <ListPreference + android:title="@string/settings.replay_gain_type" + android:key="replayGainType" + android:defaultValue="1" + android:entryValues="@array/replayGainTypeValues" + android:entries="@array/replayGainTypeNames"/> + <github.daneren2005.dsub.view.SeekBarPreference android:key="replayGainBump2" android:dialogLayout="@layout/seekbar_preference" diff --git a/src/github/daneren2005/dsub/activity/SettingsActivity.java b/src/github/daneren2005/dsub/activity/SettingsActivity.java index c1618b7d..0dd68fcb 100644 --- a/src/github/daneren2005/dsub/activity/SettingsActivity.java +++ b/src/github/daneren2005/dsub/activity/SettingsActivity.java @@ -39,6 +39,10 @@ import android.preference.PreferenceScreen; import android.text.InputType; import android.util.Log; import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; import github.daneren2005.dsub.R; import github.daneren2005.dsub.service.DownloadService; @@ -55,6 +59,7 @@ import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.URL; +import java.security.acl.Group; import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; @@ -84,9 +89,11 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer private CheckBoxPreference syncStarred; private CheckBoxPreference syncMostRecent; private CheckBoxPreference replayGain; + private ListPreference replayGainType; private Preference replayGainBump; private Preference replayGainUntagged; private String internalSSID; + private String internalSSIDDisplay; private int serverCount = 3; private SharedPreferences settings; @@ -102,7 +109,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer if(internalSSID == null) { internalSSID = ""; } - internalSSID = this.getResources().getString(R.string.settings_server_local_network_ssid_hint, internalSSID); + internalSSIDDisplay = this.getResources().getString(R.string.settings_server_local_network_ssid_hint, internalSSID); theme = (ListPreference) findPreference(Constants.PREFERENCES_KEY_THEME); maxBitrateWifi = (ListPreference) findPreference(Constants.PREFERENCES_KEY_MAX_BITRATE_WIFI); @@ -125,6 +132,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer syncStarred = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SYNC_STARRED); syncMostRecent = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_SYNC_MOST_RECENT); replayGain = (CheckBoxPreference) findPreference(Constants.PREFERENCES_KEY_REPLAY_GAIN); + replayGainType = (ListPreference) findPreference(Constants.PREFERENCES_KEY_REPLAY_GAIN_TYPE); replayGainBump = (Preference) findPreference(Constants.PREFERENCES_KEY_REPLAY_GAIN_BUMP); replayGainUntagged = (Preference) findPreference(Constants.PREFERENCES_KEY_REPLAY_GAIN_UNTAGGED); @@ -329,12 +337,15 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer } } if(replayGain.isChecked()) { + replayGainType.setEnabled(true); replayGainBump.setEnabled(true); replayGainUntagged.setEnabled(true); } else { + replayGainType.setEnabled(false); replayGainBump.setEnabled(false); replayGainUntagged.setEnabled(false); } + replayGainType.setSummary(replayGainType.getEntry()); for (ServerSettings ss : serverSettings.values()) { ss.update(); @@ -372,11 +383,26 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer serverUrlPreference.setSummary(serverUrlPreference.getText()); screen.setSummary(serverUrlPreference.getText()); - final EditTextPreference serverLocalNetworkSSIDPreference = new EditTextPreference(this); + final EditTextPreference serverLocalNetworkSSIDPreference = new EditTextPreference(this) { + @Override + protected void onAddEditTextToDialogView(View dialogView, final EditText editText) { + super.onAddEditTextToDialogView(dialogView, editText); + ViewGroup root = (ViewGroup) ((ViewGroup) dialogView).getChildAt(0); + + Button defaultButton = new Button(getContext()); + defaultButton.setText(internalSSIDDisplay); + defaultButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + editText.setText(internalSSID); + } + }); + root.addView(defaultButton); + } + }; serverLocalNetworkSSIDPreference.setKey(Constants.PREFERENCES_KEY_SERVER_LOCAL_NETWORK_SSID + instance); serverLocalNetworkSSIDPreference.setTitle(R.string.settings_server_local_network_ssid); serverLocalNetworkSSIDPreference.setDialogTitle(R.string.settings_server_local_network_ssid); - serverLocalNetworkSSIDPreference.setDialogMessage(internalSSID); final EditTextPreference serverInternalUrlPreference = new EditTextPreference(this); serverInternalUrlPreference.setKey(Constants.PREFERENCES_KEY_SERVER_INTERNAL_URL + instance); diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 16f731d3..6d1a9330 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -498,7 +498,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte }
protected void exit() {
- if(this.getClass() != SubsonicFragmentActivity.class) {
+ if(((Object) this).getClass() != SubsonicFragmentActivity.class) {
Intent intent = new Intent(this, SubsonicFragmentActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(Constants.INTENT_EXTRA_NAME_EXIT, true);
@@ -674,7 +674,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte }
protected void restart() {
- Intent intent = new Intent(this, this.getClass());
+ Intent intent = new Intent(this, ((Object) this).getClass());
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtras(getIntent());
Util.startActivityWithoutTransition(this, intent);
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 4b845753..7b1276b9 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -87,6 +87,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter boolean restoredInstance = false;
boolean lookupParent = false;
boolean largeAlbums = false;
+ boolean topTracks = false;
String lookupEntry;
public SelectDirectoryFragment() {
@@ -131,6 +132,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter refreshListing = args.getBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS);
artist = args.getBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, false);
lookupEntry = args.getString(Constants.INTENT_EXTRA_SEARCH_SONG);
+ topTracks = args.getBoolean(Constants.INTENT_EXTRA_TOP_TRACKS);
+ showAll = args.getBoolean(Constants.INTENT_EXTRA_SHOW_ALL);
String childId = args.getString(Constants.INTENT_EXTRA_NAME_CHILD_ID);
if(childId != null) {
@@ -203,6 +206,10 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter menuInflater.inflate(R.menu.empty, menu);
} else {
menuInflater.inflate(R.menu.select_album, menu);
+
+ if(!ServerInfo.isMadsonic(context)) {
+ menu.removeItem(R.id.menu_top_tracks);
+ }
}
} else {
if(podcastId == null) {
@@ -283,12 +290,14 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter downloadAllPodcastEpisodes();
return true;
case R.id.menu_show_all:
- showAll = true;
- refresh(true);
+ setShowAll();
return true;
case R.id.menu_unstar:
unstarSelected();
return true;
+ case R.id.menu_top_tracks:
+ showTopTracks();
+ return true;
}
return super.onOptionsItemSelected(item);
@@ -452,6 +461,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter } else {
if(showAll) {
getRecursiveMusicDirectory(id, name, refresh);
+ } else if(topTracks) {
+ getTopTracks(id, name, refresh);
} else {
getMusicDirectory(id, name, refresh);
}
@@ -557,6 +568,17 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }.execute();
}
+ private void getTopTracks(final String id, final String name, final boolean refresh) {
+ setTitle(name);
+
+ new LoadTask() {
+ @Override
+ protected MusicDirectory load(MusicService service) throws Exception {
+ return service.getTopTrackSongs(name, 20, context, this);
+ }
+ }.execute();
+ }
+
private void getAlbumList(final String albumListType, final int size) {
showHeader = false;
@@ -872,10 +894,11 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter private void downloadBackground(final boolean save) {
List<Entry> songs = getSelectedSongs();
if(songs.isEmpty()) {
- selectAll(true, false);
- songs = getSelectedSongs();
+ // Get both songs and albums
+ downloadRecursively(id, save, false, false, false, true);
+ } else {
+ downloadBackground(save, songs);
}
- downloadBackground(save, songs);
}
private void downloadBackground(final boolean save, final List<Entry> songs) {
if (getDownloadService() == null) {
@@ -904,6 +927,11 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter if(songs.isEmpty()) {
selectAll(true, false);
songs = getSelectedSongs();
+
+ // Also delete all directories
+ for(Entry album: albums) {
+ deleteRecursively(album);
+ }
}
if (getDownloadService() != null) {
getDownloadService().delete(songs);
@@ -1146,6 +1174,24 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter builder.create().show();
}
+ private void showTopTracks() {
+ SubsonicFragment fragment = new SelectDirectoryFragment();
+ Bundle args = new Bundle(getArguments());
+ args.putBoolean(Constants.INTENT_EXTRA_TOP_TRACKS, true);
+ fragment.setArguments(args);
+
+ replaceFragment(fragment, true);
+ }
+
+ private void setShowAll() {
+ SubsonicFragment fragment = new SelectDirectoryFragment();
+ Bundle args = new Bundle(getArguments());
+ args.putBoolean(Constants.INTENT_EXTRA_SHOW_ALL, true);
+ fragment.setArguments(args);
+
+ replaceFragment(fragment, true);
+ }
+
private View createHeader(List<Entry> entries) {
View header = entryList.findViewById(R.id.select_album_header);
boolean add = false;
@@ -1239,6 +1285,12 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter }
}
});
+ } else if(topTracks) {
+ artistView.setText(R.string.menu_top_tracks);
+ artistView.setVisibility(View.VISIBLE);
+ } else if(showAll) {
+ artistView.setText(R.string.menu_show_all);
+ artistView.setVisibility(View.VISIBLE);
} else if (artists.size() == 1) {
String artistText = artists.iterator().next();
if(years.size() == 1) {
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index f2f81073..70a3b027 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -74,6 +74,10 @@ import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.util.LoadingTask;
import github.daneren2005.dsub.util.UserUtil;
import github.daneren2005.dsub.util.Util;
+import github.daneren2005.dsub.view.AlbumCell;
+import github.daneren2005.dsub.view.AlbumView;
+import github.daneren2005.dsub.view.ArtistEntryView;
+import github.daneren2005.dsub.view.ArtistView;
import github.daneren2005.dsub.view.PlaylistSongView;
import github.daneren2005.dsub.view.SongView;
import github.daneren2005.dsub.view.UpdateView;
@@ -267,28 +271,57 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR menu.setGroupVisible(R.id.hide_rating, false);
}
- // If we are looking at a standard song view, get downloadFile to cache what options to show
- if(info.targetView instanceof SongView) {
- SongView songView = (SongView) info.targetView;
- DownloadFile downloadFile = songView.getDownloadFile();
-
- try {
- if(downloadFile != null) {
- if(downloadFile.isWorkDone()) {
- // Remove permanent cache menu if already perma cached
- if(downloadFile.isSaved()) {
- menu.removeItem(R.id.song_menu_pin);
+ if(!Util.isOffline(context)) {
+ // If we are looking at a standard song view, get downloadFile to cache what options to show
+ if(info.targetView instanceof SongView) {
+ SongView songView = (SongView) info.targetView;
+ DownloadFile downloadFile = songView.getDownloadFile();
+
+ try {
+ if(downloadFile != null) {
+ if(downloadFile.isWorkDone()) {
+ // Remove permanent cache menu if already perma cached
+ if(downloadFile.isSaved()) {
+ menu.removeItem(R.id.song_menu_pin);
+ }
+
+ // Remove cache option no matter what if already downloaded
+ menu.removeItem(R.id.song_menu_download);
+ } else {
+ // Remove delete option if nothing to delete
+ menu.removeItem(R.id.song_menu_delete);
}
-
- // Remove cache option no matter what if already downloaded
- menu.removeItem(R.id.song_menu_download);
- } else {
- // Remove delete option if nothing to delete
- menu.removeItem(R.id.song_menu_delete);
}
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to lookup downloadFile info", e);
+ }
+ }
+ // Apply similar logic to album views
+ else if(info.targetView instanceof AlbumCell || info.targetView instanceof AlbumView
+ || info.targetView instanceof ArtistView || info.targetView instanceof ArtistEntryView) {
+ File folder = null;
+ int id = 0;
+ if(info.targetView instanceof AlbumCell) {
+ folder = ((AlbumCell) info.targetView).getFile();
+ id = R.id.album_menu_delete;
+ } else if(info.targetView instanceof AlbumView) {
+ folder = ((AlbumView) info.targetView).getFile();
+ id = R.id.album_menu_delete;
+ } else if(info.targetView instanceof ArtistView) {
+ folder = ((ArtistView) info.targetView).getFile();
+ id = R.id.artist_menu_delete;
+ } else if(info.targetView instanceof ArtistEntryView) {
+ folder = ((ArtistEntryView) info.targetView).getFile();
+ id = R.id.artist_menu_delete;
+ }
+
+ try {
+ if(folder != null && !folder.exists()) {
+ menu.removeItem(id);
+ }
+ } catch(Exception e) {
+ Log.w(TAG, "Failed to lookup album directory info", e);
}
- } catch(Exception e) {
- Log.w(TAG, "Failed to lookup downloadFile info", e);
}
}
}
@@ -497,7 +530,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR }
protected void exit() {
- if(context.getClass() != SubsonicFragmentActivity.class) {
+ if(((Object) context).getClass() != SubsonicFragmentActivity.class) {
Intent intent = new Intent(context, SubsonicFragmentActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(Constants.INTENT_EXTRA_NAME_EXIT, true);
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java index 59ed550c..17c9e722 100644 --- a/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -626,7 +626,12 @@ public class CachedMusicService implements MusicService { public MusicDirectory getSongsByGenre(String genre, int count, int offset, Context context, ProgressListener progressListener) throws Exception { return musicService.getSongsByGenre(genre, count, offset, context, progressListener); } - + + @Override + public MusicDirectory getTopTrackSongs(String artist, int size, Context context, ProgressListener progressListener) throws Exception { + return musicService.getTopTrackSongs(artist, size, context, progressListener); + } + @Override public List<PodcastChannel> getPodcastChannels(boolean refresh, Context context, ProgressListener progressListener) throws Exception { checkSettingsChanged(context); diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 588df901..071159b2 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -98,6 +98,7 @@ public class DownloadService extends Service { public static final int FAST_FORWARD = 30000; public static final int REWIND = 10000; private static final double DELETE_CUTOFF = 0.84; + private static final int REQUIRED_ALBUM_MATCHES = 4; private RemoteControlClientHelper mRemoteControl; @@ -138,8 +139,6 @@ public class DownloadService extends Service { private int cachedPosition = 0; private boolean downloadOngoing = false; private float volume = 1.0f; - private boolean singleAlbum = false; - private String singleAlbumName; private AudioEffectsController effectsController; private RemoteControlState remoteState = RemoteControlState.LOCAL; @@ -362,20 +361,6 @@ public class DownloadService extends Service { } else { downloadList.add(offset, file); } - - // Check if we are still dealing with a single album - // Don't bother with check if it is already false - if(singleAlbum) { - // If first download, set album to it - if(singleAlbumName == null) { - singleAlbumName = file.getSong().getAlbum(); - } else { - // Otherwise, check again previous album name - if(!singleAlbumName.equals(file.getSong().getAlbum())) { - singleAlbum = false; - } - } - } } public synchronized void downloadBackground(List<MusicDirectory.Entry> songs, boolean save) { for (MusicDirectory.Entry song : songs) { @@ -639,8 +624,6 @@ public class DownloadService extends Service { suggestedPlaylistName = null; suggestedPlaylistId = null; - singleAlbum = true; - singleAlbumName = null; } public synchronized void remove(int which) { @@ -1821,7 +1804,6 @@ public class DownloadService extends Service { } } currentPlayingIndex = downloadList.indexOf(currentPlaying); - singleAlbum = false; if (revisionBefore != revision) { updateJukeboxPlaylist(); @@ -1972,6 +1954,51 @@ public class DownloadService extends Service { float[] rg = BastpUtil.getReplayGainValues(downloadFile.getFile().getCanonicalPath()); /* track, album */ float adjust = 0f; if (prefs.getBoolean(Constants.PREFERENCES_KEY_REPLAY_GAIN, false)) { + boolean singleAlbum = false; + + String replayGainType = prefs.getString(Constants.PREFERENCES_KEY_REPLAY_GAIN_TYPE, "1"); + // 1 => Smart replay gain + if("1".equals(replayGainType)) { + // Check if part of at least <REQUIRED_ALBUM_MATCHES> consequetive songs of the same album + + int index = downloadList.indexOf(downloadFile); + if(index != -1) { + String albumName = downloadFile.getSong().getAlbum(); + int matched = 0; + + // Check forwards + for(int i = index + 1; i < downloadList.size() && matched < REQUIRED_ALBUM_MATCHES; i++) { + if(albumName.equals(downloadList.get(i).getSong().getAlbum())) { + matched++; + } else { + break; + } + } + + // Check backwards + for(int i = index - 1; i >= 0 && matched < REQUIRED_ALBUM_MATCHES; i--) { + if(albumName.equals(downloadList.get(i).getSong().getAlbum())) { + matched++; + } else { + break; + } + } + + if(matched >= REQUIRED_ALBUM_MATCHES) { + singleAlbum = true; + } + + Log.d(TAG, "Single album: " + singleAlbum); + } + } + // 2 => Use album tags + else if("2".equals(replayGainType)) { + singleAlbum = true; + } + // 3 => Use track tags + // Already false, no need to do anything here + + // If playing a single album or no track gain, use album gain if((singleAlbum || rg[0] == 0) && rg[1] != 0) { adjust = rg[1]; diff --git a/src/github/daneren2005/dsub/service/MusicService.java b/src/github/daneren2005/dsub/service/MusicService.java index 3f07e9f5..765f498a 100644 --- a/src/github/daneren2005/dsub/service/MusicService.java +++ b/src/github/daneren2005/dsub/service/MusicService.java @@ -137,6 +137,8 @@ public interface MusicService { List<Genre> getGenres(boolean refresh, Context context, ProgressListener progressListener) throws Exception; MusicDirectory getSongsByGenre(String genre, int count, int offset, Context context, ProgressListener progressListener) throws Exception; + + MusicDirectory getTopTrackSongs(String artist, int size, Context context, ProgressListener progressListener) throws Exception; List<PodcastChannel> getPodcastChannels(boolean refresh, Context context, ProgressListener progressListener) throws Exception; diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java index 7dd2631f..22b12cde 100644 --- a/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -628,7 +628,12 @@ public class OfflineMusicService implements MusicService { throw new OfflineException(ERRORMSG); } - @Override + @Override + public MusicDirectory getTopTrackSongs(String artist, int size, Context context, ProgressListener progressListener) throws Exception { + throw new OfflineException(ERRORMSG); + } + + @Override public MusicDirectory getRandomSongs(int size, String folder, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) throws Exception { File root = FileUtil.getMusicDirectory(context); List<File> children = new LinkedList<File>(); diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java index 1733009d..ca937bcc 100644 --- a/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -1040,7 +1040,25 @@ public class RESTMusicService implements MusicService { Util.close(reader); } } - + + @Override + public MusicDirectory getTopTrackSongs(String artist, int size, Context context, ProgressListener progressListener) throws Exception { + List<String> parameterNames = new ArrayList<String>(); + List<Object> parameterValues = new ArrayList<Object>(); + + parameterNames.add("artist"); + parameterValues.add(artist); + parameterNames.add("size"); + parameterValues.add(size); + + Reader reader = getReader(context, progressListener, "getTopTrackSongs", null, parameterNames, parameterValues); + try { + return new RandomSongsParser(context, getInstance(context)).parse(reader, progressListener); + } finally { + Util.close(reader); + } + } + @Override public List<PodcastChannel> getPodcastChannels(boolean refresh, Context context, ProgressListener progressListener) throws Exception { checkServerVersion(context, "1.6", "Podcasts not supported."); diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index 30dc33b4..50651a80 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -63,6 +63,8 @@ public final class Constants { public static final String INTENT_EXTRA_FRAGMENT_TYPE = "fragmentType"; public static final String INTENT_EXTRA_REFRESH_LISTINGS = "refreshListings"; public static final String INTENT_EXTRA_SEARCH_SONG = "searchSong"; + public static final String INTENT_EXTRA_TOP_TRACKS = "topTracks"; + public static final String INTENT_EXTRA_SHOW_ALL = "showAll"; // Preferences keys. public static final String PREFERENCES_KEY_SERVER_KEY = "server"; @@ -147,6 +149,7 @@ public final class Constants { public static final String PREFERENCES_KEY_REPLAY_GAIN = "replayGain"; public static final String PREFERENCES_KEY_REPLAY_GAIN_BUMP = "replayGainBump2"; public static final String PREFERENCES_KEY_REPLAY_GAIN_UNTAGGED = "replayGainUntagged2"; + public static final String PREFERENCES_KEY_REPLAY_GAIN_TYPE= "replayGainType"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; diff --git a/src/github/daneren2005/dsub/view/AlbumCell.java b/src/github/daneren2005/dsub/view/AlbumCell.java index d6a18205..110456e7 100644 --- a/src/github/daneren2005/dsub/view/AlbumCell.java +++ b/src/github/daneren2005/dsub/view/AlbumCell.java @@ -101,4 +101,8 @@ public class AlbumCell extends UpdateView { public MusicDirectory.Entry getEntry() {
return album;
}
+
+ public File getFile() {
+ return file;
+ }
}
diff --git a/src/github/daneren2005/dsub/view/AlbumView.java b/src/github/daneren2005/dsub/view/AlbumView.java index 7785a8af..70c1e049 100644 --- a/src/github/daneren2005/dsub/view/AlbumView.java +++ b/src/github/daneren2005/dsub/view/AlbumView.java @@ -100,4 +100,8 @@ public class AlbumView extends UpdateView { public MusicDirectory.Entry getEntry() {
return album;
}
+
+ public File getFile() {
+ return file;
+ }
}
diff --git a/src/github/daneren2005/dsub/view/ArtistEntryView.java b/src/github/daneren2005/dsub/view/ArtistEntryView.java index 86fe7b1f..157b25a9 100644 --- a/src/github/daneren2005/dsub/view/ArtistEntryView.java +++ b/src/github/daneren2005/dsub/view/ArtistEntryView.java @@ -72,4 +72,8 @@ public class ArtistEntryView extends UpdateView { exists = file.exists();
isStarred = artist.isStarred();
}
+
+ public File getFile() {
+ return file;
+ }
}
diff --git a/src/github/daneren2005/dsub/view/ArtistView.java b/src/github/daneren2005/dsub/view/ArtistView.java index 23ce4f9d..b8a87c20 100644 --- a/src/github/daneren2005/dsub/view/ArtistView.java +++ b/src/github/daneren2005/dsub/view/ArtistView.java @@ -71,4 +71,8 @@ public class ArtistView extends UpdateView { exists = file.exists();
isStarred = artist.isStarred();
}
+
+ public File getFile() {
+ return file;
+ }
}
|