Add download option
This commit is contained in:
parent
7a9e96b071
commit
ecb660f766
|
@ -2,8 +2,8 @@
|
|||
<manifest xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
package="com.thejoshwa.ultrasonic.androidapp"
|
||||
a:installLocation="auto"
|
||||
a:versionCode="23"
|
||||
a:versionName="1.1.0.19" >
|
||||
a:versionCode="24"
|
||||
a:versionName="1.1.0.20" >
|
||||
|
||||
<uses-permission a:name="android.permission.INTERNET" />
|
||||
<uses-permission a:name="android.permission.READ_PHONE_STATE" />
|
||||
|
|
|
@ -51,7 +51,7 @@ public final class R {
|
|||
public static final class id {
|
||||
public static final int both = 0x7f060003;
|
||||
public static final int disabled = 0x7f060000;
|
||||
public static final int fl_inner = 0x7f060089;
|
||||
public static final int fl_inner = 0x7f06008a;
|
||||
public static final int flip = 0x7f060008;
|
||||
public static final int gridview = 0x7f060009;
|
||||
public static final int manualOnly = 0x7f060004;
|
||||
|
@ -59,10 +59,10 @@ public final class R {
|
|||
public static final int pullFromEnd = 0x7f060002;
|
||||
public static final int pullFromStart = 0x7f060001;
|
||||
public static final int pullUpFromBottom = 0x7f060006;
|
||||
public static final int pull_to_refresh_image = 0x7f06008a;
|
||||
public static final int pull_to_refresh_progress = 0x7f06008b;
|
||||
public static final int pull_to_refresh_sub_text = 0x7f06008d;
|
||||
public static final int pull_to_refresh_text = 0x7f06008c;
|
||||
public static final int pull_to_refresh_image = 0x7f06008b;
|
||||
public static final int pull_to_refresh_progress = 0x7f06008c;
|
||||
public static final int pull_to_refresh_sub_text = 0x7f06008e;
|
||||
public static final int pull_to_refresh_text = 0x7f06008d;
|
||||
public static final int rotate = 0x7f060007;
|
||||
public static final int scrollview = 0x7f06000b;
|
||||
public static final int webview = 0x7f06000a;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -54,6 +54,14 @@
|
|||
android:src="?attr/unpin"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/select_album_download"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:src="?attr/downloaded"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/select_album_delete"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
|
||||
<item
|
||||
a:id="@+id/main_shuffle"
|
||||
a:showAsAction="ifRoom|withText"
|
||||
a:icon="?attr/media_shuffle"
|
||||
a:title="@string/main.shuffle"
|
||||
/>
|
||||
a:showAsAction="ifRoom|withText"
|
||||
a:title="@string/main.shuffle"/>
|
||||
|
||||
</menu>
|
|
@ -4,36 +4,26 @@
|
|||
<item
|
||||
a:id="@+id/download_equalizer"
|
||||
a:showAsAction="ifRoom|withText"
|
||||
a:title="@string/download.menu_equalizer"
|
||||
/>
|
||||
|
||||
a:title="@string/download.menu_equalizer"/>
|
||||
<item
|
||||
a:id="@+id/download_visualizer"
|
||||
a:showAsAction="ifRoom|withText"
|
||||
a:title="@string/download.menu_visualizer"
|
||||
/>
|
||||
|
||||
a:title="@string/download.menu_visualizer"/>
|
||||
<item
|
||||
a:id="@+id/download_jukebox"
|
||||
a:showAsAction="ifRoom|withText"
|
||||
a:title="@string/download.menu_jukebox"
|
||||
/>
|
||||
|
||||
a:title="@string/download.menu_jukebox"/>
|
||||
<item
|
||||
a:id="@+id/menu_save_playlist"
|
||||
a:icon="?attr/save"
|
||||
a:title="@string/download.menu_save"
|
||||
/>
|
||||
|
||||
a:title="@string/download.menu_save"/>
|
||||
<item
|
||||
a:id="@+id/menu_remove_all"
|
||||
a:icon="?attr/remove_all"
|
||||
a:title="@string/download.menu_remove_all"
|
||||
/>
|
||||
|
||||
a:title="@string/download.menu_remove_all"/>
|
||||
<item
|
||||
a:id="@+id/menu_screen_on_off"
|
||||
a:icon="?attr/screen_on_off"
|
||||
a:title="@string/download.menu_screen_on"
|
||||
/>
|
||||
a:title="@string/download.menu_screen_on"/>
|
||||
|
||||
</menu>
|
|
@ -3,32 +3,21 @@
|
|||
|
||||
<item
|
||||
a:id="@+id/menu_show_album"
|
||||
a:title="@string/download.menu_show_album"
|
||||
/>
|
||||
|
||||
a:title="@string/download.menu_show_album"/>
|
||||
<item
|
||||
a:id="@+id/menu_lyrics"
|
||||
a:title="@string/download.menu_lyrics"
|
||||
/>
|
||||
|
||||
a:title="@string/download.menu_lyrics"/>
|
||||
<item
|
||||
a:id="@+id/menu_remove"
|
||||
a:title="@string/download.menu_remove"
|
||||
/>
|
||||
|
||||
a:title="@string/download.menu_remove"/>
|
||||
<item
|
||||
a:id="@+id/menu_remove_all"
|
||||
a:title="@string/download.menu_remove_all"
|
||||
/>
|
||||
|
||||
a:title="@string/download.menu_remove_all"/>
|
||||
<item
|
||||
a:id="@+id/menu_shuffle"
|
||||
a:title="@string/download.menu_shuffle"
|
||||
/>
|
||||
|
||||
a:title="@string/download.menu_shuffle"/>
|
||||
<item
|
||||
a:id="@+id/menu_save_playlist"
|
||||
a:title="@string/download.menu_save"
|
||||
/>
|
||||
a:title="@string/download.menu_save"/>
|
||||
|
||||
</menu>
|
|
@ -3,12 +3,8 @@
|
|||
|
||||
<item
|
||||
a:id="@+id/select_album_play_all"
|
||||
a:showAsAction="ifRoom|withText"
|
||||
a:icon="?attr/media_play"
|
||||
a:title="@string/select_album.play_all"
|
||||
/>
|
||||
|
||||
a:showAsAction="ifRoom|withText"
|
||||
a:title="@string/select_album.play_all"/>
|
||||
|
||||
</menu>
|
||||
|
||||
|
||||
|
|
|
@ -3,27 +3,21 @@
|
|||
|
||||
<item
|
||||
a:id="@+id/album_menu_play_now"
|
||||
a:title="@string/common.play_now"
|
||||
/>
|
||||
|
||||
a:title="@string/common.play_now"/>
|
||||
<item
|
||||
a:id="@+id/album_menu_play_next"
|
||||
a:title="@string/common.play_next"
|
||||
/>
|
||||
|
||||
a:title="@string/common.play_next"/>
|
||||
<item
|
||||
a:id="@+id/album_menu_play_last"
|
||||
a:title="@string/common.play_last"
|
||||
/>
|
||||
|
||||
a:title="@string/common.play_last"/>
|
||||
<item
|
||||
a:id="@+id/album_menu_pin"
|
||||
a:title="@string/common.pin"
|
||||
/>
|
||||
|
||||
a:title="@string/common.pin"/>
|
||||
<item
|
||||
a:id="@+id/album_menu_unpin"
|
||||
a:title="@string/common.unpin"
|
||||
/>
|
||||
a:title="@string/common.unpin"/>
|
||||
<item
|
||||
a:id="@+id/album_menu_download"
|
||||
a:title="@string/common.download"/>
|
||||
|
||||
</menu>
|
|
@ -3,28 +3,21 @@
|
|||
|
||||
<item
|
||||
a:id="@+id/artist_menu_play_now"
|
||||
a:title="@string/common.play_now"
|
||||
/>
|
||||
|
||||
a:title="@string/common.play_now"/>
|
||||
<item
|
||||
a:id="@+id/artist_menu_play_next"
|
||||
a:title="@string/common.play_next"
|
||||
/>
|
||||
|
||||
a:title="@string/common.play_next"/>
|
||||
<item
|
||||
a:id="@+id/artist_menu_play_last"
|
||||
a:title="@string/common.play_last"
|
||||
/>
|
||||
|
||||
a:title="@string/common.play_last"/>
|
||||
<item
|
||||
a:id="@+id/artist_menu_pin"
|
||||
a:title="@string/common.pin"
|
||||
/>
|
||||
|
||||
a:title="@string/common.pin"/>
|
||||
<item
|
||||
a:id="@+id/artist_menu_unpin"
|
||||
a:title="@string/common.unpin"
|
||||
/>
|
||||
|
||||
a:title="@string/common.unpin"/>
|
||||
<item
|
||||
a:id="@+id/artist_menu_download"
|
||||
a:title="@string/common.download"/>
|
||||
|
||||
</menu>
|
|
@ -16,6 +16,9 @@
|
|||
<item
|
||||
android:id="@+id/playlist_menu_unpin"
|
||||
android:title="@string/common.unpin"/>
|
||||
<item
|
||||
android:id="@+id/playlist_menu_download"
|
||||
android:title="@string/common.download"/>
|
||||
<item
|
||||
android:id="@+id/playlist_update_info"
|
||||
android:title="@string/playlist.update_info"/>
|
||||
|
|
|
@ -3,27 +3,21 @@
|
|||
|
||||
<item
|
||||
a:id="@+id/song_menu_play_now"
|
||||
a:title="@string/common.play_now"
|
||||
/>
|
||||
|
||||
a:title="@string/common.play_now"/>
|
||||
<item
|
||||
a:id="@+id/song_menu_play_next"
|
||||
a:title="@string/common.play_next"
|
||||
/>
|
||||
|
||||
a:title="@string/common.play_next"/>
|
||||
<item
|
||||
a:id="@+id/song_menu_play_last"
|
||||
a:title="@string/common.play_last"
|
||||
/>
|
||||
|
||||
a:title="@string/common.play_last"/>
|
||||
<item
|
||||
a:id="@+id/song_menu_pin"
|
||||
a:title="@string/common.pin"
|
||||
/>
|
||||
|
||||
a:title="@string/common.pin"/>
|
||||
<item
|
||||
a:id="@+id/song_menu_unpin"
|
||||
a:title="@string/common.unpin"
|
||||
/>
|
||||
a:title="@string/common.unpin"/>
|
||||
<item
|
||||
a:id="@+id/song_menu_download"
|
||||
a:title="@string/common.download"/>
|
||||
|
||||
</menu>
|
|
@ -290,7 +290,7 @@
|
|||
<item quantity="one">Un titre</item>
|
||||
<item quantity="other">%d titres</item>
|
||||
</plurals>
|
||||
<plurals name="select_album_n_songs_downloading">
|
||||
<plurals name="select_album_n_songs_pinned">
|
||||
<item quantity="one">Un titre sélectionnée pour être épinglé.</item>
|
||||
<item quantity="other">%d titres sélectionnée pour être épinglé.</item>
|
||||
</plurals>
|
||||
|
|
|
@ -323,7 +323,7 @@
|
|||
<item quantity="one">1 dal</item>
|
||||
<item quantity="other">%d dal</item>
|
||||
</plurals>
|
||||
<plurals name="select_album_n_songs_downloading">
|
||||
<plurals name="select_album_n_songs_pinned">
|
||||
<item quantity="one">1 dal kijelölve tárolásra.</item>
|
||||
<item quantity="other">%d dal kijelölve tárolásra.</item>
|
||||
</plurals>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<string name="common.play_last">Play Last</string>
|
||||
<string name="common.pin">Pin</string>
|
||||
<string name="common.unpin">Unpin</string>
|
||||
<string name="common.download">Download</string>
|
||||
<string name="common.delete">Delete</string>
|
||||
<string name="common.various_artists">Various Artists</string>
|
||||
<string name="common.multiple_genres">Multiple Genres</string>
|
||||
|
@ -343,10 +344,14 @@
|
|||
<item quantity="one">1 song</item>
|
||||
<item quantity="other">%d songs</item>
|
||||
</plurals>
|
||||
<plurals name="select_album_n_songs_downloading">
|
||||
<plurals name="select_album_n_songs_pinned">
|
||||
<item quantity="one">1 song selected to be pinned.</item>
|
||||
<item quantity="other">%d songs selected to be pinned.</item>
|
||||
</plurals>
|
||||
<plurals name="select_album_n_songs_downloaded">
|
||||
<item quantity="one">1 song selected to be downloaded.</item>
|
||||
<item quantity="other">%d songs selected to be downloaded.</item>
|
||||
</plurals>
|
||||
<plurals name="select_album_n_songs_unpinned">
|
||||
<item quantity="one">1 song selected to be unpinned.</item>
|
||||
<item quantity="other">%d songs selected to be unpinned.</item>
|
||||
|
|
|
@ -206,6 +206,9 @@ public class SearchActivity extends SubsonicTabActivity {
|
|||
case R.id.album_menu_unpin:
|
||||
downloadRecursively(id, false, false, false, false, false, false, true);
|
||||
break;
|
||||
case R.id.album_menu_download:
|
||||
downloadRecursively(id, false, false, false, false, true, false, false);
|
||||
break;
|
||||
case R.id.song_menu_play_now:
|
||||
if (entry != null) {
|
||||
songs = new ArrayList<MusicDirectory.Entry>(1);
|
||||
|
@ -230,10 +233,17 @@ public class SearchActivity extends SubsonicTabActivity {
|
|||
case R.id.song_menu_pin:
|
||||
if (entry != null) {
|
||||
songs.add(entry);
|
||||
Util.toast(SearchActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_downloading, songs.size(), songs.size()));
|
||||
Util.toast(SearchActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_pinned, songs.size(), songs.size()));
|
||||
downloadBackground(true, songs);
|
||||
}
|
||||
break;
|
||||
case R.id.song_menu_download:
|
||||
if (entry != null) {
|
||||
songs.add(entry);
|
||||
Util.toast(SearchActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_downloaded, songs.size(), songs.size()));
|
||||
downloadBackground(false, songs);
|
||||
}
|
||||
break;
|
||||
case R.id.song_menu_unpin:
|
||||
if (entry != null) {
|
||||
songs.add(entry);
|
||||
|
@ -258,8 +268,6 @@ public class SearchActivity extends SubsonicTabActivity {
|
|||
public void run() {
|
||||
warnIfNetworkOrStorageUnavailable();
|
||||
getDownloadService().downloadBackground(songs, save);
|
||||
|
||||
Util.toast(SearchActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_downloading, songs.size(), songs.size()));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
|||
private ImageView playLastButton;
|
||||
private ImageView pinButton;
|
||||
private ImageView unpinButton;
|
||||
private ImageView downloadButton;
|
||||
private ImageView deleteButton;
|
||||
private ImageView moreButton;
|
||||
private boolean playAllButtonVisible;
|
||||
|
@ -126,6 +127,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
|||
playLastButton = (ImageView) findViewById(R.id.select_album_play_last);
|
||||
pinButton = (ImageView) findViewById(R.id.select_album_pin);
|
||||
unpinButton = (ImageView) findViewById(R.id.select_album_unpin);
|
||||
downloadButton = (ImageView) findViewById(R.id.select_album_download);
|
||||
deleteButton = (ImageView) findViewById(R.id.select_album_delete);
|
||||
moreButton = (ImageView) findViewById(R.id.select_album_more);
|
||||
emptyView = findViewById(R.id.select_album_empty);
|
||||
|
@ -169,6 +171,13 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
|||
selectAll(false, false);
|
||||
}
|
||||
});
|
||||
downloadButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
downloadBackground(false);
|
||||
selectAll(false, false);
|
||||
}
|
||||
});
|
||||
deleteButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -330,6 +339,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
|||
case R.id.album_menu_unpin:
|
||||
downloadRecursively(entry.getId(), false, false, false, false, false, false, true);
|
||||
break;
|
||||
case R.id.album_menu_download:
|
||||
downloadRecursively(entry.getId(), false, false, false, false, true, false, false);
|
||||
break;
|
||||
case R.id.select_album_play_all:
|
||||
playAll();
|
||||
break;
|
||||
|
@ -489,6 +501,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
|||
if (!result.getFirst().getChildren().isEmpty()) {
|
||||
pinButton.setVisibility(View.GONE);
|
||||
unpinButton.setVisibility(View.GONE);
|
||||
downloadButton.setVisibility(View.GONE);
|
||||
deleteButton.setVisibility(View.GONE);
|
||||
|
||||
// Hide more button when results are less than album list size
|
||||
|
@ -566,11 +579,13 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
|||
boolean deleteEnabled = false;
|
||||
|
||||
int pinnedCount = 0;
|
||||
|
||||
for (MusicDirectory.Entry song : selection) {
|
||||
DownloadFile downloadFile = getDownloadService().forSong(song);
|
||||
if (downloadFile.isCompleteFileAvailable()) {
|
||||
deleteEnabled = true;
|
||||
}
|
||||
|
||||
if (downloadFile.isSaved()) {
|
||||
pinnedCount++;
|
||||
unpinEnabled = true;
|
||||
|
@ -581,8 +596,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
|||
playNextButton.setVisibility(enabled ? View.VISIBLE : View.GONE);
|
||||
playLastButton.setVisibility(enabled ? View.VISIBLE : View.GONE);
|
||||
pinButton.setVisibility((enabled && !Util.isOffline(this) && selection.size() > pinnedCount) ? View.VISIBLE : View.GONE);
|
||||
unpinButton.setVisibility(unpinEnabled ? View.VISIBLE : View.GONE);
|
||||
deleteButton.setVisibility(deleteEnabled ? View.VISIBLE : View.GONE);
|
||||
unpinButton.setVisibility(enabled && unpinEnabled ? View.VISIBLE : View.GONE);
|
||||
downloadButton.setVisibility(enabled && !deleteEnabled && !Util.isOffline(this) ? View.VISIBLE : View.GONE);
|
||||
deleteButton.setVisibility(enabled && deleteEnabled ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
private void downloadBackground(final boolean save) {
|
||||
|
@ -605,8 +621,11 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
|||
warnIfNetworkOrStorageUnavailable();
|
||||
getDownloadService().downloadBackground(songs, save);
|
||||
|
||||
Util.toast(SelectAlbumActivity.this,
|
||||
getResources().getQuantityString(R.plurals.select_album_n_songs_downloading, songs.size(), songs.size()));
|
||||
if (save) {
|
||||
Util.toast(SelectAlbumActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_pinned, songs.size(), songs.size()));
|
||||
} else {
|
||||
Util.toast(SelectAlbumActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_downloaded, songs.size(), songs.size()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -687,6 +706,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
|||
|
||||
pinButton.setVisibility(View.VISIBLE);
|
||||
unpinButton.setVisibility(View.VISIBLE);
|
||||
downloadButton.setVisibility(View.VISIBLE);
|
||||
deleteButton.setVisibility(View.VISIBLE);
|
||||
selectButton.setVisibility(View.VISIBLE);
|
||||
playNowButton.setVisibility(View.VISIBLE);
|
||||
|
@ -716,6 +736,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
|
|||
} else {
|
||||
pinButton.setVisibility(View.GONE);
|
||||
unpinButton.setVisibility(View.GONE);
|
||||
downloadButton.setVisibility(View.GONE);
|
||||
deleteButton.setVisibility(View.GONE);
|
||||
selectButton.setVisibility(View.GONE);
|
||||
playNowButton.setVisibility(View.GONE);
|
||||
|
|
|
@ -237,6 +237,9 @@ public class SelectArtistActivity extends SubsonicTabActivity implements Adapter
|
|||
case R.id.artist_menu_unpin:
|
||||
downloadRecursively(artist.getId(), false, false, false, false, false, false, true);
|
||||
break;
|
||||
case R.id.artist_menu_download:
|
||||
downloadRecursively(artist.getId(), false, false, false, false, true, false, false);
|
||||
break;
|
||||
default:
|
||||
return super.onContextItemSelected(menuItem);
|
||||
}
|
||||
|
|
|
@ -147,6 +147,9 @@ public class SelectPlaylistActivity extends SubsonicTabActivity implements Adapt
|
|||
case R.id.playlist_menu_unpin:
|
||||
downloadPlaylist(playlist.getId(), playlist.getName(), false, false, false, false, true, false, true);
|
||||
break;
|
||||
case R.id.playlist_menu_download:
|
||||
downloadPlaylist(playlist.getId(), playlist.getName(), false, false, false, false, true, false, false);
|
||||
break;
|
||||
case R.id.playlist_menu_play_now:
|
||||
intent = new Intent(SelectPlaylistActivity.this, SelectAlbumActivity.class);
|
||||
intent.putExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, playlist.getId());
|
||||
|
|
|
@ -668,7 +668,7 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
|
|||
Util.startActivityWithoutTransition(SubsonicTabActivity.this, DownloadActivity.class);
|
||||
}
|
||||
} else if (save) {
|
||||
Util.toast(SubsonicTabActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_downloading, songs.size(), songs.size()));
|
||||
Util.toast(SubsonicTabActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_pinned, songs.size(), songs.size()));
|
||||
} else if (playNext) {
|
||||
Util.toast(SubsonicTabActivity.this, getResources().getQuantityString(R.plurals.select_album_n_songs_play_next, songs.size(), songs.size()));
|
||||
} else if (append) {
|
||||
|
@ -740,7 +740,7 @@ public class SubsonicTabActivity extends Activity implements OnClickListener{
|
|||
protected void done(List<MusicDirectory.Entry> songs) {
|
||||
DownloadService downloadService = getDownloadService();
|
||||
if (!songs.isEmpty() && downloadService != null) {
|
||||
if (!append && !playNext && !unpin) {
|
||||
if (!append && !playNext && !unpin && !background) {
|
||||
downloadService.clear();
|
||||
}
|
||||
warnIfNetworkOrStorageUnavailable();
|
||||
|
|
Loading…
Reference in New Issue